http://stackoverflow.com/comment/33622289
has text: @Jonathan. Yes that is correct. I bet on that you have session management enabled (probably bind to view or even better - to single request). If it is, you will not have even to close it nor flush. But that is pure cunfiguration issue.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22155498
type: Comment

http://stackoverflow.com/comment/33578449
score: 1
comment on: http://stackoverflow.com/q/22130856
type: Comment
type: QuestionComment
has text: http://stackoverflow.com/questions/4644415/java-how-to-get-input-from-system-console

http://stackoverflow.com/comment/33564950
has text: @AndrewThompson . Apologize I'm just set in my ways currently. I'm looking into trying a JDialog inlue of the JFrame but otherwise really don't wish to completely undo all the coding I had to go through to get my panel's components in the write layout. And don't really use stackoverflow that often, was unaware of the format.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22123431

http://stackoverflow.com/q/22055930
score: 1
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/22133877
has body: In Eclipse we add a formatting.xml files to check the Java code formatting. In Eclipse go to Window > Preferences > Java > Code Style > Formatter and we enter the formatting.xml Inside the formatting.xml file we have several Java code formatting rules: &lt;profiles version="10"&gt; &lt;profile name="JavaFormatter" version="10"&gt; &lt;setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/&gt; &lt;setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/&gt; &lt;setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/&gt; &lt;setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/&gt; &lt;setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/&gt; . . . . . Is there a way of adding these rules to SonarQube 4.1.1? I have already imported our checkstyle rules, I just need to add the code formatting rules.
tagged with: java
upvote count: 1
tagged with: formatting
tagged with: eclipse
answer count: 1
has title: Adding Java code formatting rules to Sonarqube
type: UnansweredQuestion
tagged with: sonarqube
downvote count: 0

http://stackoverflow.com/comment/33523116
comment on: http://stackoverflow.com/q/22100533
has text: Sorry, kind of newer to this site. Well, when I did my math, I just did each chunk separately. (Standard working hours 0-40 at minimum wage, then time and a half, then double.) And my teacher did the same, but it was a few days ago. I just remember it was about $813 or so. And I know my math in this program is just way off.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33464221
has text: but im using the double cast to make the object a primitive double
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22067874
score: 0

http://stackoverflow.com/a/22121399
score: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/33561042
has comment: http://stackoverflow.com/comment/33560854
type: Answer
has body: The servlet is mapped to the url pattern /Controller. The unique URL to reach this servlet is thus http://localhost:8080/apphome/Controller.
upvote count: 3
has comment: http://stackoverflow.com/comment/33560949
has comment: http://stackoverflow.com/comment/33560989
has comment: http://stackoverflow.com/comment/33561001
answers question: http://stackoverflow.com/q/22121374

http://stackoverflow.com/a/22139447
has comment: http://stackoverflow.com/comment/33593135
has comment: http://stackoverflow.com/comment/33593211
answers question: http://stackoverflow.com/q/22138665
score: 1
upvote count: 1
has body: You inserted list of column details in to an object it is not a good behaviour, change it as public class TestResponse { private String col1; private String col2; // getters and setters } use like List&lt;TestResponse&gt; responses = null; Use private static void insertIntoDatabase(List&lt;TestResponse&gt; resps) { // how to use resp so that I can generate below correct insert SQL query? // which I can use to execute it? **// Iterate the above list and update second table** String query = "INSERT into table-database-B .... "; } alter getFromDatabaseA like this List&lt;TestResponse&gt; testResponses = new ArrayList&lt;TestResponse&gt;(); // Iterate for values or execute query for multiple time to get all details from table 1 { TestResponse testResponse = new TestResponse(); testResponse.setsetCol1(/* ADD COL1 DATA */); testResponse.setsetCol2(/* ADD COL2 DATA */); testResponses.add(testResponse); } return testResponses;
accepted answer of: http://stackoverflow.com/q/22138665
has comment: http://stackoverflow.com/comment/33593256
downvote count: 0
has comment: http://stackoverflow.com/comment/33593826
has comment: http://stackoverflow.com/comment/33593671
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/q/22138549
has comment: http://stackoverflow.com/comment/34806848
upvote count: 5
tagged with: java
tagged with: memory
tagged with: eclipse
type: Question
has comment: http://stackoverflow.com/comment/34954678
score: 5
has title: How to use Eclipse Memory Analyser Tool (MAT) for analysing a hashmap
downvote count: 0
tagged with: android-memory
tagged with: android
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33591704
has answer: http://stackoverflow.com/a/22165983
accepted answer: http://stackoverflow.com/a/22165983
has body: I am facing a memory leak. So, I captured a heap dump for my application, and am trying to analyse it using Memory Analyser Tool (MAT). I clicked on Heap Dump Overview option in the menu of hprof file. Then , clicked on Class Histogram. It showed me a list of all objects, grouped by class, taking up the maximum meory. One of which is my cutom hashmap. Now, I want to analyse the entries of this hashmap. Any idea how I can do so ? If I click on the custom hashmap name, then click on List Objects-&gt;with incoming references, it just shows list of all objects in the hashmap &amp; the hierarchy by which these objects was created, &amp; not the actual key-value pairs for the hashmap entries. P.S. My custom Hashmap: private Hashmap&lt;Integer, TextCache&gt; mCache; class TextCache{ Bitmap bitmap; int left; int right; int keyCode; }
type: AnsweredQuestion

http://stackoverflow.com/q/22057252
tagged with: java
has body: when I was writing my program I came across a problem with arrays and can't find any explanations on how to fix it. The problem i ran into is how i should go about using an array from the main a method and passing it to a method, but only getting one value as a return rather than the whole array again. note: the way i have my program set up the array is filled with random numbers every time it is ran. im not too sure if you can do this or not, but The way i am currently calling a method is by doing as follows: "declared variable (not array)" = "name of method" ("the actual array name") totalSum = sumTotal (randomArray) // example The method I'm trying to call: public static int[] sumTotal (int[] totals) { int total = 0; for (int i = 0; i &lt; totals.lenght; i++) { total += totals[i]; } return total; } it keeps giving me a "cannot find symbol symbol : method sumTotals(int[]) location: class oneDimensionArraysNew" error when i try to compile, im not too sure how i would go about fixing this, I appreciate any and all help!!
tagged with: methods
downvote count: 1
type: Question
has title: Return one value from an array when calling a method
accepted answer: http://stackoverflow.com/a/22057293
answer count: 2
has answer: http://stackoverflow.com/a/22057291
tagged with: arrays
favorite count: 0
possible better answer: http://stackoverflow.com/a/22057291
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22057293
upvote count: 2
score: 1

spring-mvc
tags question: http://stackoverflow.com/q/22035553
tags question: http://stackoverflow.com/q/22056189
tags question: http://stackoverflow.com/q/22130432
tags question: http://stackoverflow.com/q/22121918
tags question: http://stackoverflow.com/q/22116451
tags question: http://stackoverflow.com/q/22079080
tags question: http://stackoverflow.com/q/22045181
tags question: http://stackoverflow.com/q/22093149
tags question: http://stackoverflow.com/q/22112653
tags question: http://stackoverflow.com/q/22087259
tags question: http://stackoverflow.com/q/22081093
tags question: http://stackoverflow.com/q/22043411
tags question: http://stackoverflow.com/q/22039173
tags question: http://stackoverflow.com/q/22020338
tags question: http://stackoverflow.com/q/22010793
tags question: http://stackoverflow.com/q/22059898
tags question: http://stackoverflow.com/q/22107033
tags question: http://stackoverflow.com/q/22097365
tags question: http://stackoverflow.com/q/22073597
tags question: http://stackoverflow.com/q/22051593
tags question: http://stackoverflow.com/q/22078568
tags question: http://stackoverflow.com/q/22133613
tags question: http://stackoverflow.com/q/22111146
tags question: http://stackoverflow.com/q/22135383
tags question: http://stackoverflow.com/q/22076276
tags question: http://stackoverflow.com/q/22167662
tag name: spring-mvc
tags question: http://stackoverflow.com/q/22148197
tags question: http://stackoverflow.com/q/22086373
tags question: http://stackoverflow.com/q/22168159
tags question: http://stackoverflow.com/q/22031083
tags question: http://stackoverflow.com/q/22125899
tags question: http://stackoverflow.com/q/22089501
tags question: http://stackoverflow.com/q/22046180
type: Tag
tags question: http://stackoverflow.com/q/22168156
tags question: http://stackoverflow.com/q/22089024
tags question: http://stackoverflow.com/q/22163397
tags question: http://stackoverflow.com/q/22097251
tags question: http://stackoverflow.com/q/22149945
tags question: http://stackoverflow.com/q/22060996
tags question: http://stackoverflow.com/q/22098959
tags question: http://stackoverflow.com/q/22142107
tags question: http://stackoverflow.com/q/22060474
tags question: http://stackoverflow.com/q/22064150
tags question: http://stackoverflow.com/q/22157525
tags question: http://stackoverflow.com/q/22167928
tags question: http://stackoverflow.com/q/22167177
tags question: http://stackoverflow.com/q/22120150
tags question: http://stackoverflow.com/q/22150176
tags question: http://stackoverflow.com/q/22160711
tags question: http://stackoverflow.com/q/22165821
tags question: http://stackoverflow.com/q/22094609
tags question: http://stackoverflow.com/q/22157505
tags question: http://stackoverflow.com/q/22013074
tags question: http://stackoverflow.com/q/22035048
tags question: http://stackoverflow.com/q/22015013
tags question: http://stackoverflow.com/q/22130564
tags question: http://stackoverflow.com/q/22060686
tags question: http://stackoverflow.com/q/22034158
tags question: http://stackoverflow.com/q/22152530
tags question: http://stackoverflow.com/q/22135002
tags question: http://stackoverflow.com/q/22039369
tags question: http://stackoverflow.com/q/22151491
tags question: http://stackoverflow.com/q/22034964
tags question: http://stackoverflow.com/q/22026512
tags question: http://stackoverflow.com/q/22156112
tags question: http://stackoverflow.com/q/22107384
tags question: http://stackoverflow.com/q/22053414

http://stackoverflow.com/a/22056620
has comment: http://stackoverflow.com/comment/33984216
has body: Java 7 - use the format code X import java.text.SimpleDateFormat; public class Test { public static void main(String[] args) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); String date1 = "2013-12-18T00:41:38-0500"; String date2 = "2013-10-25T15:00:00+08:00"; try { System.out.println(dateFormat.parse(date1)); System.out.println(dateFormat.parse(date2)); } catch (Exception e ) { System.out.println(e); } } } produces the output Wed Dec 18 05:41:38 GMT 2013 Fri Oct 25 08:00:00 BST 2013 When run in Ireland in winter.
score: 0
answers question: http://stackoverflow.com/q/22056204
type: Answer
has comment: http://stackoverflow.com/comment/33444814
has comment: http://stackoverflow.com/comment/33490459

http://stackoverflow.com/q/22054873
has title: Guava Function with generic types
has body: I am trying to code up a few Functions that I will be using quite often in the rest of my code. Some of these are things like, say, summing up all the numbers of an Iterable. Instead of implementing different functions for Double, Integer, etc. I want a single Function that sums up all the elements of a given Iterable as long as each element is a number. In order to do this, I attempted the following: &lt;T&gt; Function&lt;List&lt;T extends Number&gt;, T&gt; sum = new Function&lt;List&lt;T extends Number&gt;, T&gt;() { public T apply(List&lt;T&gt; tlist) { // the main code } }; But I get a compiler error saying "Unexpected token". I have coded my own Java methods with generics before, but I don't understand why the same thing isn't working here. Am I missing something ridiculously obvious, or is it that guava Functions don't allow generics?
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/22054933
upvote count: 1
has comment: http://stackoverflow.com/comment/33446389
tagged with: generics
favorite count: 0
has answer: http://stackoverflow.com/a/22055208
accepted answer: http://stackoverflow.com/a/22055208
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22054933
tagged with: guava
downvote count: 0
score: 1
tagged with: java

http://stackoverflow.com/comment/33862808
type: AnswerComment
comment on: http://stackoverflow.com/a/22090163
type: Comment
has text: would you give me an example of such listener?
score: 0

http://stackoverflow.com/comment/33517215
has text: Could you add your `persistence.xml` to your question?
comment on: http://stackoverflow.com/a/22096272
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/104548768
has text: One more year, another Android version and getFeaturename() still doesn't return anything useful.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22096011

http://stackoverflow.com/comment/33628603
type: Comment
type: QuestionComment
has text: @DonBranson I'm not saying they should, but that it is possible. The `Number` class is the parent class of all the general numeric types in Java, `Integer`, `Long`, `Double`, etc., but also `BigInteger` and `BigDecimal`. They must all therefore implement the `abstract intValue()` method. It is available. `Integer` _could_ have used it.
comment on: http://stackoverflow.com/q/22158295
score: 0

http://stackoverflow.com/comment/33495493
type: Comment
has text: Is it possible that the environment this came from is using [Flaka](https://code.google.com/p/flaka/)? That's the only Ant related thing I know of that uses this kind of syntax. If you really do have Flaka installed, see this for an explanation: http://workbench.haefelinger.it/flaka/download/manual/flaka-1.2.2.html#el
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/22075510

http://stackoverflow.com/comment/33625598
comment on: http://stackoverflow.com/a/22150794
type: Comment
has text: That translates to replacing the while loop to an `if` statement block within the `gtf` if statement - probably better to give `gtf` its own `ActionListener` at this stage....
score: 0
type: AnswerComment

http://stackoverflow.com/a/22133414
has comment: http://stackoverflow.com/comment/33627081
type: Answer
answers question: http://stackoverflow.com/q/22133112
has body: Here is an example: public class ProcessTest { private Process p; private BufferedReader reader; private BufferedWriter writer; public void start() throws IOException { ProcessBuilder pb = new ProcessBuilder("cmd", "/c", "dir"); pb.directory(new File("./")); this.p = pb.start(); this.reader = new BufferedReader(new InputStreamReader(this.p.getInputStream())); this.writer = new BufferedWriter(new OutputStreamWriter(this.p.getOutputStream())); new Read(this.reader).start(); } public boolean writeToConsole(String s) throws IOException { if (p == null) return false; this.writer.write(s + "\n"); this.writer.flush(); return true; } public class Read extends Thread { private BufferedReader reader; public Read(BufferedReader reader) { this.reader = reader; } public void run() { try { String line; while ((line = this.reader.readLine()) != null) { System.out.println(line); } } catch (IOException e) { e.printStackTrace(); } } } public static void main(String[] args) { try { new ProcessTest().start(); } catch (IOException e) { e.printStackTrace(); } } } With the writeToConsole method you can write any string to the programm that you executed.
has comment: http://stackoverflow.com/comment/33628493
accepted answer of: http://stackoverflow.com/q/22133112
score: 0
has comment: http://stackoverflow.com/comment/33833628
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33626882
has comment: http://stackoverflow.com/comment/33863996
has comment: http://stackoverflow.com/comment/33833516

http://stackoverflow.com/comment/33543950
has text: How complex are the page contents? I.e are there form xobjects which can in turn contain mixed text and image data and, therefore, also have to be treated?
comment on: http://stackoverflow.com/q/22067557
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33420858
has text: Well hex is something similar, but just using 0-9A-F ? Can you convert it to hex?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22043451

http://stackoverflow.com/q/22032462
has comment: http://stackoverflow.com/comment/33592774
has comment: http://stackoverflow.com/comment/33609040
has title: Optimising a Load Operation(To Fetch All Entities of a specific Kind) in Objectify 4
tagged with: java
has comment: http://stackoverflow.com/comment/33701399
has comment: http://stackoverflow.com/comment/33422197
type: Question
has comment: http://stackoverflow.com/comment/33549159
has comment: http://stackoverflow.com/comment/33699177
has comment: http://stackoverflow.com/comment/33530660
has comment: http://stackoverflow.com/comment/33693361
has comment: http://stackoverflow.com/comment/34553564
score: 0
has body: I am loading/fetching all entities of a specific kind using objectify 4 using this query: ofy.load().type(Thing.class) Thing is the entity, with autoGenerated Id (Long DataType), having 5-6 fields . However, when i run this operation(assuming 1 entity to be present in datastore), it takes some time to fetch the results(like 2-4 secs). is this the normal behaviour i should expect. Or is there a way to load all entities of a specific kind faster?? Thank You
has comment: http://stackoverflow.com/comment/33514074
has comment: http://stackoverflow.com/comment/33704135
answer count: 0
tagged with: objectify
type: UnansweredQuestion
tagged with: google-app-engine

http://stackoverflow.com/a/22168773
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22151098
answers question: http://stackoverflow.com/q/22151098
type: Answer
upvote count: 6
has body: Try use rotate(...)method instead of setRotation(...). With setOrigin(widthSprite\2, heightSprite\2) That action rotate sprite itself.
score: 6

http://stackoverflow.com/q/22113826
answer count: 2
accepted answer: http://stackoverflow.com/a/22113867
has answer: http://stackoverflow.com/a/22113945
has answer: http://stackoverflow.com/a/22113867
score: 0
has title: Target ID is not recognized during android create project action
tagged with: android
has body: I am trying to create android project using android create project action with options like below root@123-PC: android create project --name Sample --path .--target android-18 --package com.mobile.sample --activity Main Below error shows up! Error: Argument 'android-18' is not recognized. Usage: android [global options] create project [action options] Global options: -h --help : Help on a specific command. -v --verbose : Verbose mode, shows errors, warnings and all messages. --clear-cache: Clear the SDK Manager repository manifest cache. -s --silent : Silent mode, shows errors only. Action "create project": Creates a new Android project. Options: -n --name : Project name. -v --gradle-version: Gradle Android plugin version. -t --target : Target ID of the new project. [required] -p --path : The new project's directory. [required] -g --gradle : Use gradle template. -k --package : Android package name for the application. [required] -a --activity : Name of the default Activity that is created. [required] But, when I list the available targets, it shows it. android-18 is present. Can someone help me understand what's going in the behind scene? root@123-PC: android list targets Available Android targets: ---------- id: 1 or "android-15" Name: Android 4.0.3 Type: Platform API level: 15 Revision: 3 Skins: WXGA800, HVGA, WSVGA, WQVGA400, WVGA854, QVGA, WXGA720, WQVGA432, WVGA800 (default) ABIs : armeabi-v7a ---------- id: 2 or "Google Inc.:Google APIs:15" Name: Google APIs Type: Add-On Vendor: Google Inc. Revision: 2 Description: Android + Google APIs Based on Android 4.0.3 (API level 15) Libraries: * com.google.android.media.effects (effects.jar) Collection of video effects * com.android.future.usb.accessory (usb.jar) API for USB Accessories * com.google.android.maps (maps.jar) API for Google Maps Skins: WVGA854, WQVGA400, WSVGA, WXGA720, HVGA, WQVGA432, WVGA800 (default), QVGA, WXGA800 ABIs : armeabi-v7a ---------- id: 3 or "android-18" Name: Android 4.3 Type: Platform API…
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/22113945
type: Question

http://stackoverflow.com/comment/33605655
comment on: http://stackoverflow.com/a/22142810
score: 0
has text: @SK-logic Xabster said: *"To be a "virtual machine" you'd need to create ways of interacting with "everything" on the PC that it runs. Giving your users/developers a "print to screen" feature is not a virtual machine."*. So you disagree?
type: Comment
type: AnswerComment

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

http://stackoverflow.com/comment/33386471
type: Comment
type: QuestionComment
has text: Works fine for me. What do you mean by failure?
score: 0
comment on: http://stackoverflow.com/q/22023975

jfreechart
type: Tag
tags question: http://stackoverflow.com/q/22008763
tags question: http://stackoverflow.com/q/22111709
tags question: http://stackoverflow.com/q/22014381
tags question: http://stackoverflow.com/q/22026781
tags question: http://stackoverflow.com/q/22149909
tags question: http://stackoverflow.com/q/22061692
tags question: http://stackoverflow.com/q/22131324
tags question: http://stackoverflow.com/q/22071389
tags question: http://stackoverflow.com/q/22041440
tags question: http://stackoverflow.com/q/22023391
tags question: http://stackoverflow.com/q/22030630
tags question: http://stackoverflow.com/q/22048071
tags question: http://stackoverflow.com/q/22054594
tags question: http://stackoverflow.com/q/22144038
tag name: jfreechart
tags question: http://stackoverflow.com/q/22021178
tags question: http://stackoverflow.com/q/22046206

http://stackoverflow.com/a/22038715
type: Answer
upvote count: 7
score: 7
has comment: http://stackoverflow.com/comment/33448955
accepted answer of: http://stackoverflow.com/q/22038359
type: AcceptedAnswer
downvote count: 0
has body: Yes. While you can't get Java to run the assignments again, you can move the assignments into a method instead: public static String MSG1; public static void setLocale(Locale locale) { MSG1 = Translator.get(locale, "MSG1"); } static { setLocale( Locale.getDefault() ); } After that, you can use the method setLocale() to switch the locale. When the class is loaded for the first time, the locale is set using the static initializer block at the end. [EDIT] This of course doesn't work in a multi-threaded environment: Static variables are global (= shared between all threads). What's worse: Due to Java's memory model, a change of the variable in thread 1 might not be visible at any specific point in time to any other threads. If you need this in a web server, then you can't use static variables anymore. I suggest to create an instance of the class and convert all the static fields into methods. Then you can create this instance in a Filter and put it in the request and configure it correctly. public class I18nHelper { public static I18nHelper get( HttpServletRequest request ) { return (HttpServletRequest) request.getAttribute( "I18nHelper" ); } private Locale locale; public I18nHelper(Locale locale) { this.locale = locale; } public String msg1() { return Translator.get(locale, "MSG1"); } } This approach has another huge advantage: You can pass type-safe arguments! public String fileNotFoundMsg( File file ) { ... format message with parameter "file" and return it... }
answers question: http://stackoverflow.com/q/22038359

http://stackoverflow.com/q/22063667
tagged with: java
answer count: 1
accepted answer: http://stackoverflow.com/a/22100060
tagged with: runtime
tagged with: dao
type: AnsweredQuestion
tagged with: generics
has body: I am trying to create a class that is responsable for managing all the database access of my application, controlling the API of my DAO objects that have all protected methods. Some indentifiers are in portuguese since I'm a brazilian, anyways I think you will be able to understand whats going on there.. Following is the code: public class DatabaseManager { private ItemExpansivelDataSource itemExpansivelDataSource; private ConfiguracoesDashboardDataSource configuracoesDashboardDataSource; private PranchaDataSource pranchaDataSource; private PranchaRaizDataSource pranchaRaizDataSource; private HashMap&lt;Class&lt;?&gt;, DataSource&lt;?&gt;&gt; dataSourcesMap; public DatabaseManager() { super(); this.dataSourcesMap = new HashMap&lt;Class&lt;?&gt;, DataSource&lt;?&gt;&gt;(); dataSourcesMap.put(ItemExpansivel.class, itemExpansivelDataSource); dataSourcesMap.put(ConfiguracoesDashboard.class, itemExpansivelDataSource); dataSourcesMap.put(Prancha.class, itemExpansivelDataSource); dataSourcesMap.put(PranchaRaiz.class, itemExpansivelDataSource); } public void insert(Object objeto){ if(dataSourcesMap.containsKey(objeto.getClass())) { return dataSourcesMap.get(objeto.getClass()).insert(objeto); } else { throw new RuntimeException(ErrorMessages.NAO_EXISTE_DATA_SOURCE.toString()); } } and there is the declaration of my datasource public interface DataSource&lt;T&gt; { List&lt;T&gt; getAll(); T findById(Integer id); void openConection(); void closeConection(); void update(T valor); void update(List&lt;T&gt; valores); T insert(T valor); List&lt;T&gt; insert(List&lt;T&gt; valores); void delete(T valor); void delete(List&lt;T&gt; valores); Integer getLastInsertedRowId(); T converter(Cursor cursor); } My problem is that java dont know what kind of object it will receive as parameter so I cant call the insert method as I am trying to do, I need to find a work around but I cant think on nothing.. I wish someone can bring me some light, because I really think this is a good aproach to c…
type: Question
has answer: http://stackoverflow.com/a/22100060
has title: How to get object type in runtime?
tagged with: reflection
score: 0

http://stackoverflow.com/a/22011687
answers question: http://stackoverflow.com/q/22009969
score: 0
has body: I think you want to do the following: Check, if it is a multipart message AND consists of several parts 1.1 If so, it has attachments. You should then retrieve the first text/plain or text/html part, which should be the text itself. You leave the other parts alone. But along the text you store some id or reference to the message on the server, that the text is taken from. Consider the following code. Folder folderInbox = store.getFolder("INBOX"); Message[] arrayMessages = folderInbox.getMessages(); for (int i = 0; i &lt; arrayMessages.length; i++) { Message message = arrayMessages[i]; } Now the class javax.mail.Message has a method getMessageNumber()::int. If you store this message number and the folder name, in this case "INBOX", you have an identifier, that will allow you to find the message on the server again at a later time and do something with it, like downloading parts that have not been retrieved yet. So (pseudo code here) you basically have to do this. var message_text = message.getFirstTextBodyPart(); var message_ident = (message.getFolderName(), message.getMessageNumber()); var message = (message_ident, message_text); saveMessage(message); showMessage(message); 1.2 In other cases, you download the entire message right now, as there are no parts for later retrieval.
type: Answer

http://stackoverflow.com/comment/33498508
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22086350
has text: let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/48639/discussion-between-kedarnath-and-user3245658)

http://stackoverflow.com/comment/33520547
has text: Using a list you can't go no faster than that. If efficiency is what you are looking for then you are going to have to use a different data structure, probably a hash-based collection, or by saving some extra information than actually required.
type: Comment
comment on: http://stackoverflow.com/q/22099153
type: QuestionComment
score: 0

http://stackoverflow.com/a/22119635
score: 1
has comment: http://stackoverflow.com/comment/96782413
downvote count: 0
has body: Well, since this sounds like homework, it's for you to solve, but I would consider this very-English pseudo-code. It avoids the use of java.util.* (e.g. ArrayList or Arrays classes) and only uses primitive constructs. count = 0 for each item in the input if the rule matches increase count by 1 create output array of size count target index = 0 for each item in the input if the rule matches add the item to the output array at the target index, and increase the target index by 1 return the output array This code is O(n) in complexity, even though it loops through the input (n) twice because that's a constant factor, and O(2*n) is 2*O(n) is O(n). Now, the constant bounds could be slightly reduced by, instead of only counting on the first pass, also compacting the values on the first pass, and then only copying the compacted values, which would be less than or equal to n, to a new smaller array. It would still be O(n), but it may have a slightly lower wall-clock time .. or it might perform worse depending on subtle cache/JIT/data factors. Oh, the fun intricacies of modern computers! There is no trivial way to improve the O(n) "efficiency" bounds - and especially not for one run.
has comment: http://stackoverflow.com/comment/96813913
answers question: http://stackoverflow.com/q/22119454
type: Answer
upvote count: 1

http://stackoverflow.com/q/22133117
has comment: http://stackoverflow.com/comment/33583048
has answer: http://stackoverflow.com/a/22133421
answer count: 1
has title: Combinations method return issue
has comment: http://stackoverflow.com/comment/33582821
has comment: http://stackoverflow.com/comment/33582830
downvote count: 0
has comment: http://stackoverflow.com/comment/33582792
favorite count: 0
accepted answer: http://stackoverflow.com/a/22133421
has body: I have written a method to find all combinations n choose k. When I have it void and simply print out the solutions it works fine. However, I am trying to change it as to return a List&lt;List&lt;Integer&gt;&gt; of all the combinations. I tried returning the solution and returning the recursion call in the if-else respectively but I get an error for unreachable line of code. Below I am trying to carry the list of list through the recursion and return it in the end. public class Combos { public static void main(String[] args) { List&lt;Integer&gt; n = new ArrayList&lt;Integer&gt;(); for (int i = 0; i &lt; 9; i++) { n.add(i); } List&lt;Integer&gt; temp = new ArrayList&lt;Integer&gt;(); List&lt;List&lt;Integer&gt;&gt; combos = new ArrayList&lt;List&lt;Integer&gt;&gt;(); // findCombos(n, temp, 3, combos); System.out.println(findCombos(n, temp, 3, combos)); } public static List&lt;List&lt;Integer&gt;&gt; findCombos(List&lt;Integer&gt; n, List&lt;Integer&gt; temp, int k, List&lt;List&lt;Integer&gt;&gt; combos) { if (k == 0) { //System.out.print(temp); combos.add(temp); } else { for (int i = 0; i &lt; n.size(); i++) { temp.add(n.get(i)); List&lt;Integer&gt; subList = n.subList(i + 1, n.size()); findCombos(subList, temp, k - 1, combos); temp.remove(temp.size() - 1); } } return combos; } } The working void method is here: package client; import java.util.ArrayList; import java.util.List; public class Combos { public static void main(String[] args) { List&lt;Integer&gt; n = new ArrayList&lt;Integer&gt;(); for (int i = 0; i &lt; 5; i++) { n.add(i); } List&lt;Integer&gt; temp = new ArrayList&lt;Integer&gt;(); findCombos(n, temp, 3); } public static void findCombos(List&lt;Integer&gt; n, List&lt;Integer&gt; temp, int k) { if (k == 0) { System.out.print(temp); } else { for (int i = 0; i &lt; n.size(); i++) { temp.add(n.get(i)); List&lt;Integer&gt; subList = n.subList(i + 1, n.size()); findCombos(subList, temp, k - 1); temp.remove(temp.size() - 1); } } } }
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
type: Question

http://stackoverflow.com/comment/33520485
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22096963
has text: It can get easily solved using genetic algorithms, is it in your interest to I post an answer for you?
score: 0

http://stackoverflow.com/comment/34386591
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22031628
score: 0
has text: @Imma threads are by far the most convenient way to do it. It is possible to do *without* using threads. If you have hundreds of connections at a time, you'll run into performance issues with threads and have to do it the other way, but if you don't have many connections, just use threads.

http://stackoverflow.com/a/54088055
answers question: http://stackoverflow.com/q/22060889
has body: Try this: InputStream mockInputStream = IOUtils.toInputStream("fake string", StandardCharsets.UTF_8);
score: 0
type: Answer

http://stackoverflow.com/comment/33649321
score: 0
type: Comment
has text: What do you mean with "the threads never die" ? What should I call to kill the threads ?
type: AnswerComment
comment on: http://stackoverflow.com/a/22072163

http://stackoverflow.com/comment/33505980
type: AnswerComment
comment on: http://stackoverflow.com/a/22091154
has text: Ah of course good point. Thanks a lot :-) When I run the program I get the error: HTTP Status 405 - HTTP method GET is not supported by this URL type Status report message HTTP method GET is not supported by this URL description The specified HTTP method is not allowed for the requested resource. Do you know how this can be? Best Regards Mads
type: Comment
score: 0

http://stackoverflow.com/comment/33520244
has text: @user3365304: Perhaps there is *another* problem, but the question you asked *was* answered.
comment on: http://stackoverflow.com/a/22099024
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33555514
type: QuestionComment
has text: Why never? I think it is better to let people decide what count of ternaries could be allowed per one expression
comment on: http://stackoverflow.com/q/22117029
score: 0
type: Comment

http
tags question: http://stackoverflow.com/q/22022000
tags question: http://stackoverflow.com/q/22159682
tags question: http://stackoverflow.com/q/22090672
tags question: http://stackoverflow.com/q/22110726
tags question: http://stackoverflow.com/q/22099905
tags question: http://stackoverflow.com/q/22163325
tags question: http://stackoverflow.com/q/22099886
tags question: http://stackoverflow.com/q/22086113
tag name: http
tags question: http://stackoverflow.com/q/22052649
tags question: http://stackoverflow.com/q/22086295
type: Tag
tags question: http://stackoverflow.com/q/22165172
tags question: http://stackoverflow.com/q/22063435
tags question: http://stackoverflow.com/q/22010360
tags question: http://stackoverflow.com/q/22078592
tags question: http://stackoverflow.com/q/22011955
tags question: http://stackoverflow.com/q/22076896
tags question: http://stackoverflow.com/q/22053689
tags question: http://stackoverflow.com/q/22026684

http://stackoverflow.com/q/22109522
has comment: http://stackoverflow.com/comment/33539760
accepted answer: http://stackoverflow.com/a/22109566
has comment: http://stackoverflow.com/comment/33539775
has comment: http://stackoverflow.com/comment/33539769
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33539839
tagged with: java
linked to: http://stackoverflow.com/q/352780
has comment: http://stackoverflow.com/comment/33539759
has body: After one loop the program throws an exception at the new component line and quits. How do I loop until the user selects a file that works? while(!next){ NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), folderChooser()); try{ EmbeddedMediaPlayerComponent a = new EmbeddedMediaPlayerComponent(); a.release(); next = true; } catch(Exception e){ next = false; } } Error: Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class uk.co.caprica.vlcj.binding.LibVlc at uk.co.caprica.vlcj.binding.LibVlcFactory.create(LibVlcFactory.java:158) at uk.co.caprica.vlcj.player.MediaPlayerFactory.&lt;init&gt;(MediaPlayerFactory.java:236) at uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent.onGetMediaPlayerFactory(EmbeddedMediaPlayerComponent.java:278) at uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent.&lt;init&gt;(EmbeddedMediaPlayerComponent.java:168) at sv1.MainRun.try1(MainRun.java:107) at sv1.MainRun.&lt;init&gt;(MainRun.java:82) at sv1.Start.main(Start.java:7)
type: Question
tagged with: try-catch
has comment: http://stackoverflow.com/comment/33539800
has comment: http://stackoverflow.com/comment/33539887
has comment: http://stackoverflow.com/comment/33539787
has answer: http://stackoverflow.com/a/22109566
has title: Java try catch loop not catching after 1 loop
tagged with: vlcj
score: 0
has comment: http://stackoverflow.com/comment/33539833
answer count: 3
possible better answer: http://stackoverflow.com/a/22109779
has answer: http://stackoverflow.com/a/22109578
has answer: http://stackoverflow.com/a/22109779
has comment: http://stackoverflow.com/comment/33539814

http://stackoverflow.com/q/22022363
has title: Comparing list of automobile objects by plate number
has body: Okay so I'm doing an assignment that's fairly complex. Basically I have a class of automobile, then subclasses of it (passenger car, and nonpassenger) and then subclasses of them (subcompact car, small pickuptruck etc). I also have a sorting.java class with various methods of sorting. I am supposed to create an array of automobiles, and them sort them by plate number. Automobile class: public class Automobile{ public String Name; public String Colour; public String plateNum; public Automobile (String eName, String eColour, String eplateNum) { Name = eName; Colour = eColour; plateNum = eplateNum; } public String toString() { String result = "Name: " + Name +"\n"; result += "Colour: "+Colour+"\n"; result+= "Plate Number: "+ plateNum; return result; } }//end Automobile Passenger car class: abstract public class passengerCar extends Automobile{ public abstract double fee(); public passengerCar (String eName, String eColour, String eplateNum) { super (eName, eColour, eplateNum); } public String toString() { String result = super.toString(); result += "\n Fee: "+fee(); return result; } } subcompact class: (example of subclass) public class subCompact extends passengerCar{ public double litres; public subCompact (String eName, String eColour, String eplateNum, double eLitres) { super (eName, eColour, eplateNum); litres = eLitres; } public double fee(){ double cost = (litres / 10); return cost; } } Database class: public class CarDataBase{ private Automobile[] database; private int count; //creates initially empty database public CarDataBase() { database = new Automobile[100]; count =0; } public void addminiCompact(String eName, String eColour, String eplateNum, double eLitres) { if(count == database.length) increasesize(); database[count] = new miniCompact (eName, eColour, eplateNum, eLitres); count++; } public void addsubCompact(String eName, String eColour, String eplateNum, double eLitres) { if(count == database.length) increasesize(); database[count] = new subCompact (…
has comment: http://stackoverflow.com/comment/33383330
tagged with: object
tagged with: java
has answer: http://stackoverflow.com/a/22022522
type: Question
has comment: http://stackoverflow.com/comment/33383570
tagged with: arrays
tagged with: sorting
has comment: http://stackoverflow.com/comment/33383396
score: 0
answer count: 1
type: UnansweredQuestion
tagged with: subclass

http://stackoverflow.com/comment/33515403
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22096554
has text: @Jon Taylor Because it's homework
score: 0

http://stackoverflow.com/comment/33566832
type: Comment
type: QuestionComment
score: 0
has text: possible duplicate of [What does "Could not find or load main class" mean?](http://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean)
comment on: http://stackoverflow.com/q/22124527

http://stackoverflow.com/q/22006363
answer count: 0
has title: Decision tree construction using c4.5 algorithm?
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33363114
has body: For the implementation of a decision tree using c4.5 algorithm,I take a numerical dataset,but how to find the threshold value for the dataset.
duplicate of: http://stackoverflow.com/q/16097189
tagged with: java
has comment: http://stackoverflow.com/comment/33355765
type: Question
score: 0
has comment: http://stackoverflow.com/comment/33355542
upvote count: 1
downvote count: 1
linked to: http://stackoverflow.com/q/16097189
tagged with: decision-tree
linked to: http://stackoverflow.com/q/15629398
favorite count: 0

http://stackoverflow.com/q/22102103
answer count: 3
has comment: http://stackoverflow.com/comment/33525999
tagged with: unique
favorite count: 0
has comment: http://stackoverflow.com/comment/33525963
has comment: http://stackoverflow.com/comment/33525897
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33525989
has answer: http://stackoverflow.com/a/22102870
upvote count: 1
has comment: http://stackoverflow.com/comment/33527652
has answer: http://stackoverflow.com/a/22105427
tagged with: java
tagged with: set
has comment: http://stackoverflow.com/comment/33529714
has title: Trouble putting only unique values into an array
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/22103266
tagged with: arrays
has body: So I have a list of countries that I am reading from a text file and some of the countries are on there more than once. I need to put each country name into a string array without any doubles, or countries put on there twice. I tried using a for loop but could not wrap my head around the logic required for this. Thanks in advance.
score: 0

http://stackoverflow.com/comment/33390425
comment on: http://stackoverflow.com/q/22025948
has text: You are correct, trying to get a path of an item in WebSphere v7. I think that it's the correct method, but it's very hard to find any documentation or tutorials for it. I'm basing it off this: http://www-01.ibm.com/support/docview.wss?uid=swg1PK71825 - is there another (easier) way to call the path of the item? Thanks
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33413534
type: QuestionComment
comment on: http://stackoverflow.com/q/22039576
score: 0
has text: A string variable without a value assigned is `null`, so check if it is *not* that. `if(category[checking] != null)`.
type: Comment

http://stackoverflow.com/comment/33537253
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22107517
score: 1
has text: have you tried this http://stackoverflow.com/questions/5618652/publishing-failed-with-multiple-errors-eclipse

http://stackoverflow.com/comment/33441105
type: Comment
has text: @Prog You can check out this question for possible out-of-the-box solutions: http://stackoverflow.com/questions/7951290/resize-image-in-java-lose-quality?rq=1
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22054486

http://stackoverflow.com/comment/33458694
has text: This is clearly *not* a duplicate of the question that so far, 4 inattentive users have voted to close this question for... Reviewers, *please* pay attention when reviewing close votes.
score: 1
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22061361

http://stackoverflow.com/q/22125475
type: Question
tagged with: object
possible better answer: http://stackoverflow.com/a/22125519
has answer: http://stackoverflow.com/a/22125519
score: -1
has answer: http://stackoverflow.com/a/22125673
answer count: 3
has comment: http://stackoverflow.com/comment/33568625
upvote count: 0
has comment: http://stackoverflow.com/comment/33568580
tagged with: arrays
has comment: http://stackoverflow.com/comment/33568665
has answer: http://stackoverflow.com/a/22125607
favorite count: 0
tagged with: constructor
has comment: http://stackoverflow.com/comment/33568614
type: AnsweredQuestion
has title: How can I make array of bowlers?
tagged with: java
accepted answer: http://stackoverflow.com/a/22125607
has body: Following is the question which I am trying to solve- In a one day international, the bowling figures of all the bowlers have been provided. The objective is to create an array of Bowler and return it. Note that the objects should appear in the same order in the array as they appear in the input. The input is provided a string. The string has space demarcated details of each bowler provided as Name-Overs-Maiden-Runs-Wickets, like , “Zaheer-10-1-55-0 Harbhajan-8.4-0-44-2 Ishant-10-0-71-1″.Define a function that takes and prints the array of Bowler returned. There is some error in the code but I am unable to detect it. public class MakeArrayOfBowlers{ String name; double over; int maiden; int runs; int wickets; public MakeArrayOfBowlers(String input){ String[] str=input.split("-"); this.name=str[0]; this.over=Double.parseDouble(str[1]); this.maiden=Integer.parseInt(str[2]); this.runs=Integer.parseInt(str[3]); this.wickets=Integer.parseInt(str[4]); } public MakeArrayOfBowlers[] makeBowlers (String input){ MakeArrayOfBowlers str= (MakeArrayOfBowlers) new MakeArrayOfBowlers("Zaheer-10-1-55-0 Harbhajan-8.4-0-44-2 Ishant-10-0-71-1"); String[] str1 = input.split(" "); MakeArrayOfBowlers bowler[]= new MakeArrayOfBowlers[str1.length]; for(int i = 0; i &lt; str1.length; i++){ bowler = new MakeArrayOfBowlers[str1.length]; MakeArrayOfBowlers obj = new MakeArrayOfBowlers(str1[i]); bowler[i] = obj; } return bowler; } }
downvote count: 1

http://stackoverflow.com/a/22155462
score: 0
has comment: http://stackoverflow.com/comment/33622124
has comment: http://stackoverflow.com/comment/33622084
type: Answer
has comment: http://stackoverflow.com/comment/33621967
has comment: http://stackoverflow.com/comment/33625275
has body: SessionFactory is a Singleton. Therefore, you should get it from the ApplicationContext (i.e. using the @Autowired annotation). Passing it as a parameter will only complicate your API.
answers question: http://stackoverflow.com/q/22155328

http://stackoverflow.com/a/22095076
downvote count: 0
answers question: http://stackoverflow.com/q/22094644
has comment: http://stackoverflow.com/comment/33534210
has comment: http://stackoverflow.com/comment/33518995
has comment: http://stackoverflow.com/comment/33520104
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/33516059
score: 1
has comment: http://stackoverflow.com/comment/33517147
has comment: http://stackoverflow.com/comment/33513954
has body: You can use this to execute something before each test, i'm not sure you need this though. @Before public void method() This method is executed once before any tests are started. @BeforeClass public static void method() this also looks a bit buggy @Test public void testSetImageStoreLocation() { AA.setImageStoreLocation(directoryStore);; &lt;== } EDIT: Maybe you should switch to the JUnit dependency instead of the one you are using. I'm not sure all other libraries have the same annotations could be the reason you are getting null pointer exception if you are mixing different test frameworks. Be sure to check that you have the JUnit library in your build path and not just as an import statement.
has comment: http://stackoverflow.com/comment/33517955

security
tags question: http://stackoverflow.com/q/22063768
tags question: http://stackoverflow.com/q/22037968
tags question: http://stackoverflow.com/q/22016669
tags question: http://stackoverflow.com/q/22071427
tags question: http://stackoverflow.com/q/22064972
tags question: http://stackoverflow.com/q/22046252
tags question: http://stackoverflow.com/q/22011866
tags question: http://stackoverflow.com/q/22115493
tags question: http://stackoverflow.com/q/22085170
tags question: http://stackoverflow.com/q/22117317
tags question: http://stackoverflow.com/q/22065776
type: Tag
tag name: security

http://stackoverflow.com/comment/33392749
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22027289
has text: Can you comment on the command that I provided? It is not correct because it creates errors i.e. `file_name.jar: command not found`

junit-runner
tag name: junit-runner
tags question: http://stackoverflow.com/q/22051705
type: Tag

http://stackoverflow.com/q/22061727
tagged with: annotations
type: Question
tagged with: jpa
has title: How to implement custom annotation with parameters that returns on calling the function? Like @Query
score: 0
tagged with: spring-data-jpa
has comment: http://stackoverflow.com/comment/33454331
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33963227
tagged with: spring
answer count: 0
has body: How to implement some thing like @Query method of Spring-Data-JPA-Repository? Instead of using @Query, I want to use my own annotation, but it should work the exact same way as @Query does. For example, the method should get parameters and return some data. public interface UserRepository extends JpaRepository&lt;User, Long&gt; { @Query("select u from User u where u.emailAddress = ?1") User findByEmailAddress(String emailAddress); } Maybe I sound stupid, but I want to implement some thing similar to this.
tagged with: java

http://stackoverflow.com/a/22032305
downvote count: 0
answers question: http://stackoverflow.com/q/22032175
type: Answer
upvote count: 1
has body: use the file.exist() method to check, if that what you want to do is to make sure it exist then this is the codes: File sfile = new File(salesFile); if (sfile.exists()) { // ok, file exist do something. ... } On the other hand, when you say "invalid file" could be anything, if it is bad filename, then it is another animal (well, different exeception)... To use try/catch for a readonly file then: try { FileInputStream sfile = new FileInputStream(salesFile); ... } catch (FileNotFoundException e) { System.out.println(e.getMessage()); }
has comment: http://stackoverflow.com/comment/33401335
score: 1
has comment: http://stackoverflow.com/comment/33401202

http://stackoverflow.com/q/22046252
tagged with: shell
has comment: http://stackoverflow.com/comment/33425803
favorite count: 0
has title: Java to securely execute a shell command
has comment: http://stackoverflow.com/comment/33426033
upvote count: 1
has comment: http://stackoverflow.com/comment/33425908
has answer: http://stackoverflow.com/a/22046728
type: AnsweredQuestion
score: 1
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33425923
downvote count: 0
accepted answer: http://stackoverflow.com/a/22046728
tagged with: security
answer count: 1
has body: What would be a good solution to ensure information security and integrity in the following scenario: A Java application needs to do some initial work, then pass credentials (for example, a username and a password) to a shell command which will do some processing (possibly make requests over https, amongst other operations) and then return a private token to the Java application. Let's assume for this discussion that the functionality of the shell command cannot be replicated in Java without reasonable effort and most of it is closed-source. What would be a good manner to ensure neither the credentials nor the token can easily be hijacked by a third party? Assume, that the IO can be customized as necessary in both the Java application and the shell command. Icons from Saki &amp; Untergunter

http://stackoverflow.com/a/22028293
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22028253
has body: The culprit is : String selectListValue = selectionList.getSelectedValue().toString(); and also if(selectListData.size() &gt; 0) // Null pointer exception will be thrown is selctionData is Null In this you are not checking if selectionList is null. Ideally you should check if a object is null before performing any operation on it. Correct Way : if(selectionList != null) { String selectListValue = selectionList.getSelectedValue().toString(); // perform yoour operations } Also change : if(selectListData != null &amp;&amp; selectListData.size() &gt; 0)
upvote count: 3
type: AcceptedAnswer
type: Answer
score: 3
answers question: http://stackoverflow.com/q/22028253

http://stackoverflow.com/a/22082626
upvote count: 4
answers question: http://stackoverflow.com/q/22082449
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/22082449
has body: Junit does not include an HTML parser or validator by itself. So yes, use something like jsoup to parse and validate your html and then do asserts on the result.
score: 4

http://stackoverflow.com/q/22062311
has title: How to use @ExceptionHandler in Spring Interceptor？
tagged with: spring
has comment: http://stackoverflow.com/comment/104595723
has answer: http://stackoverflow.com/a/22064443
has answer: http://stackoverflow.com/a/57406410
has answer: http://stackoverflow.com/a/56410240
has comment: http://stackoverflow.com/comment/68532094
has body: I am using springmvc to create restful api for client， I have an interceptor for checking the accesstoken. public class AccessTokenInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (handler instanceof HandlerMethod) { HandlerMethod handlerMethod = (HandlerMethod) handler; Authorize authorizeRequired = handlerMethod.getMethodAnnotation(Authorize.class); if (authorizeRequired != null) { String token = request.getHeader("accesstoken"); ValidateToken(token); } } return true; } protected long ValidateToken(String token) { AccessToken accessToken = TokenImpl.GetAccessToken(token); if (accessToken != null) { if (accessToken.getExpirationDate().compareTo(new Date()) &gt; 0) { throw new TokenExpiredException(); } return accessToken.getUserId(); } else { throw new InvalidTokenException(); } } And in my controller, I use @ExceptionHandler to handle exceptions, the code to handle InvalidTokenException looks like @ExceptionHandler(InvalidTokenException.class) public @ResponseBody Response handleInvalidTokenException(InvalidTokenException e) { Log.p.debug(e.getMessage()); Response rs = new Response(); rs.setErrorCode(ErrorCode.INVALID_TOKEN); return rs; } But unfortunately the exception throwed in preHandle method is not caught by the exception handler defined in controller. Can any one give me an solution of handling the exception? PS: My controller method produce both json and xml using code below: @RequestMapping(value = "login", method = RequestMethod.POST, produces = { "application/xml", "application/json" })
has answer: http://stackoverflow.com/a/22089742
type: Question
has comment: http://stackoverflow.com/comment/33454113
tagged with: java
score: 15
has comment: http://stackoverflow.com/comment/33458564
has answer: http://stackoverflow.com/a/27823944
upvote count: 15
downvote count: 0
tagged with: interceptor
favorite count: 0
answer count: 5
tagged with: exception
type: UnansweredQuestion

http://stackoverflow.com/comment/33478414
comment on: http://stackoverflow.com/a/22074406
type: Comment
score: 0
has text: i didn't get u...can u explain
type: AnswerComment

http://stackoverflow.com/a/22018364
has body: I see one thing definitely wrong, and one thing potentially wrong here. First, When you're done adding to your first list, the list contains three references to the same Task instance. Essentially, you have three Task references in the list that all have id=3 and name="dinnu". I'm guessing you probably intended to do this instead: List&lt;Task&gt; mainList = new ArrayList&lt;&gt;(); Task e = new Task(); e.setId(1); e.setName("shiva"); mainList.add(e); e = new Task(); //Make a new instance e.setId(2); e.setName("Jyothi"); mainList.add(e); e = new Task(); //Make a new instance e.setId(3); e.setName("Dinnu"); mainList.add(e); Basically, since you forgot to make new instances, you were just changing the values on the same object instead of making new objects. The second potential problem is that Java Collections will use the "equals()" method on your Task Object to determine object equality. If you don't have one, it will just check to see if the Objects refer to the same object instance, rather than comparing the object's properties. Therefore, you might need to implement an equals() method on your Task object as well if you don't already have one. If you fix those things, than calling mainList.retainAll(subList) will remove all elements in mainList that are not present in subList. (finalList will not be necessary - that call will simply edit mainList) If you would like to preserve mainList instead of editing it, then do this instead: List&lt;Task&gt; finalList = new ArrayList&lt;&gt;(mainList); //Copy main into finalList finalList.retainAll(subList); //remove elements that are not present in subList
answers question: http://stackoverflow.com/q/22018096
score: 0
type: Answer

http://stackoverflow.com/q/22141248
has body: import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JComponent; import javax.swing.SwingUtilities; import net.java.dev.designgridlayout.DesignGridLayout; import java.io.*; import net.java.dev.designgridlayout.Tag; import javax.swing.JButton; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import javax.swing.table.AbstractTableModel; import javax.swing.table.*; import java.sql.*; import javax.swing.table.TableColumn; class table1 { JFrame JF; Container C; JPanel JP; JLabel creditLabel; JComboBox credit; String[] Credit = { "Vasan Phalke", "Pansare", "Anil Kg", "Suresh", "Total Credit", "" }; String[] Names = { "Name", "Qty", "Rate/ Kg", "Total Amt." }; JTable table; DefaultTableModel model; JScrollPane scrollPane; public table1() { JF = new JFrame(); JP = new JPanel(); C = JF.getContentPane(); C.setLayout(new BorderLayout()); JF.pack(); JF.setLocationRelativeTo(null); JF.setVisible(true); DesignGridLayout layout = new DesignGridLayout(JP); creditLabel = new JLabel("Credit"); credit = new JComboBox&lt;String&gt;(Credit); model = new DefaultTableModel(Names, 6) { @Override public Class&lt;?&gt; getColumnClass(int columnIndex) { switch (columnIndex) { case 0: return String.class; case 1: return Integer.class; case 2: case 3: return Double.class; } return super.getColumnClass(columnIndex); } public Object getValueAt(int row, int column) { if (column == 3) { Integer i = (Integer) getValueAt(row, 1); Double d = (Double) getValueAt(row, 2); if (i != null &amp;&amp; d != null) { return i * d; } else { return 0 * 0; } } return super.getValueAt(row, column); } public boolean isCellEditable(int arg0, int arg1) { return true; } public void setValueAt(Object aValue, int row, int column) { super.setValueAt(aValue, row, column); fireTableCellUpdated(row, 3); } }; table = new JTable(model); {…
has title: How addition operation can be performed on this table?
answer count: 1
has comment: http://stackoverflow.com/comment/33596268
has comment: http://stackoverflow.com/comment/33596455
favorite count: 0
has answer: http://stackoverflow.com/a/22142805
has comment: http://stackoverflow.com/comment/33596232
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/22134138
has comment: http://stackoverflow.com/comment/33596179
downvote count: 3
tagged with: swing
type: Question
linked to: http://stackoverflow.com/q/7350445
tagged with: java
has comment: http://stackoverflow.com/comment/33596040
has comment: http://stackoverflow.com/comment/33596170
has comment: http://stackoverflow.com/comment/33596021
has comment: http://stackoverflow.com/comment/33598085
tagged with: jtable
upvote count: 3
score: 0
accepted answer: http://stackoverflow.com/a/22142805

http://stackoverflow.com/comment/33512900
type: QuestionComment
comment on: http://stackoverflow.com/q/22095216
has text: I will go with 1st option
score: 0
type: Comment

http://stackoverflow.com/a/22102571
upvote count: 4
downvote count: 0
has comment: http://stackoverflow.com/comment/33541967
type: Answer
has comment: http://stackoverflow.com/comment/33526963
has comment: http://stackoverflow.com/comment/33527356
answers question: http://stackoverflow.com/q/22102497
has comment: http://stackoverflow.com/comment/33527452
has body: The frame has been made visible before the button is added. Ensure that this statement appears after the component has been added. Invoke pack prior to making the frame visible to ensure that the frame is large enough to make the button visible pack(); setVisible(true);
score: 4

http://stackoverflow.com/a/22031435
answers question: http://stackoverflow.com/q/22030021
has body: package com.nanofaroque.float2String; public class Float2String { public static void main(String[] args) { String input="1234.56"; String str="."; float result=0; int j=3;//this is used for multiply by 10^j for(int i=0;i&lt;input.length();i++){ if (input.charAt(i)!=str.charAt(0)){ char m=input.charAt(i);//Convert String to Character float x=(float) input.charAt(i);//Getting the ASCI value x=x-48;//Now x converted to the real float value float y=(float) (x* (Math.pow(10, j)));//Multiplication Operation for conversion result=result+y; j=j-1; } else{ System.out.println("Welcome to my World");// to make the loop work..You can change it if you want } } System.out.println("Result after the conversion:"+result); } }
score: 0
type: Answer

http://stackoverflow.com/a/33222825
downvote count: 0
has body: You can subtract the time zone difference from now. final Calendar calendar = Calendar.getInstance(); final int utcOffset = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET); final long tempDate = new Date().getTime(); return new Date(tempDate - utcOffset);
type: Answer
answers question: http://stackoverflow.com/q/22091107
upvote count: 3
score: 3

http://stackoverflow.com/comment/33425776
type: QuestionComment
comment on: http://stackoverflow.com/q/22039466
score: 0
type: Comment
has text: That's still not clear. Please put a bit more effort into your question.

http://stackoverflow.com/comment/33593945
comment on: http://stackoverflow.com/q/22139941
score: 0
has text: Column in the sense,the values in each rows separated by comma.So take 1st value in all rows.And sort the arraylist based on that value.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33565616
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22120747
has text: @Nopiforyou: That's not what I meant. Say your test is "bli bla blub-trala". After tokenizing you would get {"bli", "bla", "blub", "trala"} and you can look those tokens up *literally* without any string matching. I don't see why it's not possible in your case to canonically split the text into words that you can look up in the dictionary. Do you have word combinations in there or what is the problem?
type: Comment

http://stackoverflow.com/q/22101359
favorite count: 0
has answer: http://stackoverflow.com/a/22101458
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22101472
has answer: http://stackoverflow.com/a/22101475
has body: I tried a problem which worked fine on C++; here is the C++ implementation. #include&lt;iostream&gt; #include&lt;string&gt; #include&lt;string.h&gt; using namespace std; int main() { int t; char str[1000100]; char num[1010]; cin&gt;&gt;t; while(t--) { cin&gt;&gt;num; cin&gt;&gt;str; int a=strlen(str); int b=strlen(num); int x=0; int flag=0; int m=0; for(int j=0;j&lt;2*b;j++) { if(m==b) { flag=1; m--; } if(m==0) { flag=0; } num[j]=num[m]; if(flag==0) m++; if(flag==1) m--; } for(int i=0;i&lt;a;i++) { if(x==2*b) x=0; if((str[i]-(num[x]-'0'))&lt;97) str[i]=char(str[i]-(num[x]-'0')+26); else str[i]=char(str[i]-(num[x]-'0')); x++; } cout&lt;&lt;str&lt;&lt;endl; //cout&lt;&lt;num; } return 0; } Here is my Java implementation. import java.util.Scanner; class sngmsg { public static void main(String[] s) { Scanner sc=new Scanner(System.in); int t; /*char[] str; str = new char[1000100]; char[] num=new char[1010];*/ String str; String num; char[] num1=new char[1010]; char[] str1=new char[1000100]; t=sc.nextInt(); for(int l=0;l&lt;t;l++) { num=sc.next(); str=sc.nextLine(); int a=str.length(); for(int c=0;c&lt;a;c++) str1[c]=str.charAt(c); int b=num.length(); int x=0; int flag=0; int m=0; for(int j=0;j&lt;2*b;j++) { if(m==b) { flag=1; m--; } if(m==0) { flag=0; } num1[j]=num.charAt(m); if(flag==0) m++; if(flag==1) m--; } for(int i=0;i&lt;a;i++) { if(x==2*b) x=0; if(int(str1[i])-(num1[x])&lt;97) str1[i]=char(int(str1[i])-num1[x])+26); else str1[i]=char(str1[i]-(num1[x]-'0')); x++; } } } } In the section if(int(str1[i])-(num1[x])&lt;97) str1[i]=char(int(str1[i])-num1[x])+26); else str1[i]=char(str1[i]-(num1[x]-'0')); x++; it is giving an error: unexpected type required:value found: class '.class' expected ; expected and similar errors in these lines. Any help?
answer count: 4
has answer: http://stackoverflow.com/a/22101474
tagged with: c++
score: 2
downvote count: 0
tagged with: java
type: Question
upvote count: 2
has title: '.class.' error in java

http://stackoverflow.com/a/22163650
answers question: http://stackoverflow.com/q/22163499
downvote count: 0
type: Answer
has body: Please try the following regex (clientId=[0-9]+)[.\s]*(Dstid=[0-9]+) make sure to escape \ when using it Pattern p = Pattern.compile("(clientId=[0-9]+)[.\\s]*(Dstid=[0-9]+)");
score: 1
upvote count: 1

http://stackoverflow.com/comment/54492850
score: 0
type: AnswerComment
has text: This answer works great! it is taken from here mostly: https://android.googlesource.com/platform/development/+/master/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MusicService.java
type: Comment
comment on: http://stackoverflow.com/a/22831521

http://stackoverflow.com/comment/76789691
comment on: http://stackoverflow.com/a/44903169
type: AnswerComment
score: 0
has text: The entry whose value `getPage` returns is optional. You are very likely to get `null` at least as often as a `PDPage` instance if presented with PDFs from the wild.
type: Comment

http://stackoverflow.com/comment/33525032
type: QuestionComment
type: Comment
has text: You need to download it. You don't have attached java sources to the project. http://stackoverflow.com/questions/10781135/view-sources-of-used-java-classes-in-intellij-idea
comment on: http://stackoverflow.com/q/22101711
score: 0

persistence-unit
tags question: http://stackoverflow.com/q/22029614
tag name: persistence-unit
type: Tag

http://stackoverflow.com/comment/33399339
type: QuestionComment
score: 1
has text: Is there a problem here, or are you just asking for advice? StackOverflow is not the appropriate medium for the latter.
comment on: http://stackoverflow.com/q/22031114
type: Comment

http://stackoverflow.com/a/22115712
downvote count: 0
has body: &amp; is a bitwise and operator ... the binary values of 8 and 4 are 8 = 1000 4 = 0100 if you know how AND operator works then you know that 1 &amp; 0 = 0; so after a bitwise AND, there will be all 0
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/22115670

http://stackoverflow.com/q/22013771
tagged with: java
tagged with: http://stackoverflow.com/tag/json
upvote count: 8
type: Question
accepted answer: http://stackoverflow.com/a/22014164
has comment: http://stackoverflow.com/comment/33368207
linked to: http://stackoverflow.com/q/22863845
linked to: http://stackoverflow.com/q/11874919
has answer: http://stackoverflow.com/a/22014164
answer count: 1
has comment: http://stackoverflow.com/comment/33367425
score: 8
favorite count: 0
has title: Android - java.lang.RuntimeException: Stub exception while parsing String into JSONObject
tagged with: android-json
has comment: http://stackoverflow.com/comment/33367466
has body: I'm getting java.lang.RuntimeException: Stub! exception when I try to parse String to org.json.JSONObject. My Android API version is 19. Here is my String to be parsed: { "url": "http://www.google.com", "cookie": "012121", "filename": "Google" } JSONObject jsonObject = new JSONObject(str); // getting exception at this line String url = jsonObject.getString("url");
tagged with: android
has comment: http://stackoverflow.com/comment/33367637
type: AnsweredQuestion
downvote count: 0

http://stackoverflow.com/comment/33416483
score: 1
comment on: http://stackoverflow.com/q/22041151
has text: @Batty `toArray()` returns object array, not primitive.
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22074145
type: AcceptedAnswer
downvote count: 0
has body: 1. Without changing your code, you must place the file in the project's root folder. Otherwise, reference it as src/frp/dichromatic.dat 2. Doing something like this: public static void main(String[] args) { FileReader file = null; try { file = new FileReader(new File("dichromatic.dat")); } catch (FileNotFoundException e1) { System.err.println("File dichromatic.dat not found!"); e1.printStackTrace(); } BufferedReader br = new BufferedReader(file); String line; try { while ((line = br.readLine()) != null) { System.out.println(line); } } catch (IOException e) { System.err.println("Error when reading"); e.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { System.err.println("Unexpected error"); e.printStackTrace(); } } } } 3. Creation of a new txt file "formatted". In this example, the formatting will be settings the characters to uppercase. public static void main(String[] args) { FileReader file = null; BufferedWriter bw = null; File outputFile = new File("output.formatted"); try { file = new FileReader(new File("dichromatic.dat")); } catch (FileNotFoundException e1) { System.err.println("File dichromatic.dat not found!"); e1.printStackTrace(); } try { bw = new BufferedWriter(new FileWriter(outputFile)); } catch (IOException e1) { System.err.println("File is not writtable or is not a file"); e1.printStackTrace(); } BufferedReader br = new BufferedReader(file); String line; String lineformatted; try { while ((line = br.readLine()) != null) { lineformatted = format(line); bw.write(lineformatted); // if you need it bw.newLine(); } } catch (IOException e) { System.err.println("Error when processing the file!"); e.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { System.err.println("Unexpected error"); e.printStackTrace(); } } if (bw != null) { try { bw.close(); } catch (IOException e) { System.err.println("Unexpected error"); e.printStackTrace(); } } } } public static String format(String…
answers question: http://stackoverflow.com/q/22073976
type: Answer
upvote count: 3
has comment: http://stackoverflow.com/comment/33476949
score: 3
accepted answer of: http://stackoverflow.com/q/22073976
has comment: http://stackoverflow.com/comment/33475731

http://stackoverflow.com/q/22068597
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33465098
accepted answer: http://stackoverflow.com/a/22068734
has title: How do i disable the in-app settings button
type: Question
tagged with: android
tagged with: settings
answer count: 1
score: 0
tagged with: java
has answer: http://stackoverflow.com/a/22068734
has body: I made an app that only has one button and one function. The function is not important. Every app has a settings button at the top right corner (the one with the three dots). My app has no need for settings so how do i disable this settings button, or just take away the ability to click on it? (ive been googling a lot and its hard to find something in my opinion)

http://stackoverflow.com/q/22012625
favorite count: 0
has body: I have two classes implementing an interface. The classes are in two different packages. package com.service; public interface PServices{ } package com.transaction.service.v2; @Transactional(propagation = Propagation.REQUIRED, rollbackFor=Exception.class) public class PServicesImpl implements PServices {} package com.transaction.service.v1; @Transactional(propagation = Propagation.REQUIRED, rollbackFor=Exception.class) public class PServicesImpl implements PServices {} I initialize the classes in the spring xml as follows: &lt;bean id="pServicesv1" class="com.transaction.service.v1.PServicesImpl" /&gt; &lt;bean id="pServicesv2" class="com.transaction.service.v2.PServicesImpl" /&gt; But during server startup i am getting the following error. No unique bean of type com.service.PServices is defined: expected single bean but found 2 How to initialize multiple classes here? I cannot use annotations due to restrictions..
has answer: http://stackoverflow.com/a/22013082
type: UnansweredQuestion
upvote count: 1
tagged with: spring
score: 1
has title: Initialize multiple instances of classes that implements same interface in spring xml
tagged with: java
type: Question
downvote count: 0
answer count: 1

http://stackoverflow.com/q/22050391
has title: Ask users if user wishes to re-run the program
has body: I wrote the following program which displays if a number is a prime and if not a prime it display its prime factors and the next prime number. However, I am not sure how to have the program ask the user if he/she wishes to input another number. The user must answer either yes, no, y or n using any combination of lower and upper case letters. If an invalid answer is given, the program must be informed that the answer was not acceptable, and then be prompted again for another answer. The program will only prompt up to three tries otherwise the program will exit. If the answer is Yes (in any allowed form), the program must continue from step in the main function. The program is written in prototype methods because that is what is called for. If anyone can assist a newbie with the last part, i would greatly appreciate it. code: package primefactors; import java.util.Scanner; public class Primefactors { //------------------three tries check method------------------- public static int getNumberWithThreeTries(int m) { int count = 1; int number; String s = "tries"; while (count &lt;= 3) { number = getInputNumber(m); //getScore returns -1 for invalid inputs if (number &lt;= 1) { if ((3 - count) &lt; 2) { s = "try"; //just make sure that singular /plural form in the next statme is correct } if (count == 3) { System.out.println("No more tries remaining!\n"); } else { System.out.println((3 - count) + " " + s + " remaining! Try Again! \n"); } count = count + 1; } else { return number; } } return -1; } //-------------------boolean try again---work in progress--------------- public boolean askRunAgain() { System.out.println("Would u like to solve more problems? "); Scanner scanner = new Scanner(System.in); boolean askRunAgain = scanner.nextBoolean(); return askRunAgain; } //----------------------------------boolen prime check method------------------ public static boolean isPrime(int m) { for (int i = 2; i * i &lt;= m; i++) { if (m % i == 0) { return false; } } return true; } //--…
has answer: http://stackoverflow.com/a/22050439
tagged with: java
tagged with: methods
type: Question
tagged with: boolean
answer count: 1
tagged with: string
score: 0
tagged with: java.util.scanner
type: UnansweredQuestion

slider
tags question: http://stackoverflow.com/q/22068996
tag name: slider
type: Tag

http://stackoverflow.com/comment/33502666
comment on: http://stackoverflow.com/q/22089205
has text: colorRButtons[i].addActionListener(listener);
type: Comment
type: QuestionComment
score: 0

java
tags question: http://stackoverflow.com/q/22060452
tags question: http://stackoverflow.com/q/22103512
tags question: http://stackoverflow.com/q/22141433
tags question: http://stackoverflow.com/q/22071589
tags question: http://stackoverflow.com/q/22029798
tags question: http://stackoverflow.com/q/22159868
tags question: http://stackoverflow.com/q/22168486
tags question: http://stackoverflow.com/q/22153843
tags question: http://stackoverflow.com/q/22088353
tags question: http://stackoverflow.com/q/22009282
tags question: http://stackoverflow.com/q/22143320
tags question: http://stackoverflow.com/q/22098463
tags question: http://stackoverflow.com/q/22129568
tags question: http://stackoverflow.com/q/22102407
tags question: http://stackoverflow.com/q/22144643
tags question: http://stackoverflow.com/q/22064671
tags question: http://stackoverflow.com/q/22054095
tags question: http://stackoverflow.com/q/22056322
tags question: http://stackoverflow.com/q/22138758
tags question: http://stackoverflow.com/q/22123614
tags question: http://stackoverflow.com/q/22121454
tags question: http://stackoverflow.com/q/22024053
tags question: http://stackoverflow.com/q/22022169
tags question: http://stackoverflow.com/q/22078592
tags question: http://stackoverflow.com/q/22114475
tags question: http://stackoverflow.com/q/22155957
tags question: http://stackoverflow.com/q/22161025
tags question: http://stackoverflow.com/q/22035291
tags question: http://stackoverflow.com/q/22079944
tags question: http://stackoverflow.com/q/22060686
tags question: http://stackoverflow.com/q/22117744
tags question: http://stackoverflow.com/q/22154498
tags question: http://stackoverflow.com/q/22080030
tags question: http://stackoverflow.com/q/22040572
tags question: http://stackoverflow.com/q/22086119
tags question: http://stackoverflow.com/q/22020286
tags question: http://stackoverflow.com/q/22082391
tags question: http://stackoverflow.com/q/22076127
tags question: http://stackoverflow.com/q/22064853
tags question: http://stackoverflow.com/q/22061692
tags question: http://stackoverflow.com/q/22037341
tags question: http://stackoverflow.com/q/22147562
tags question: http://stackoverflow.com/q/22167192
tags question: http://stackoverflow.com/q/22070984
tags question: http://stackoverflow.com/q/22036647
tags question: http://stackoverflow.com/q/22048471
tags question: http://stackoverflow.com/q/22025977
tags question: http://stackoverflow.com/q/22096587
tags question: http://stackoverflow.com/q/22128545
tags question: http://stackoverflow.com/q/22065579
tags question: http://stackoverflow.com/q/22153449
tags question: http://stackoverflow.com/q/22127102
tags question: http://stackoverflow.com/q/22104097
tags question: http://stackoverflow.com/q/22076083
tags question: http://stackoverflow.com/q/22138460
tags question: http://stackoverflow.com/q/22144519
tags question: http://stackoverflow.com/q/22112449
tags question: http://stackoverflow.com/q/22081006
tags question: http://stackoverflow.com/q/22041403
tags question: http://stackoverflow.com/q/22164368
tags question: http://stackoverflow.com/q/22008180
tags question: http://stackoverflow.com/q/22118237
tags question: http://stackoverflow.com/q/22007636
tags question: http://stackoverflow.com/q/22025534
tags question: http://stackoverflow.com/q/22079947
tags question: http://stackoverflow.com/q/22168595
tags question: http://stackoverflow.com/q/22106019
tags question: http://stackoverflow.com/q/22044958
tags question: http://stackoverflow.com/q/22164663
tags question: http://stackoverflow.com/q/22054590
tags question: http://stackoverflow.com/q/22067567
tags question: http://stackoverflow.com/q/22050255
tags question: http://stackoverflow.com/q/22132813
tags question: http://stackoverflow.com/q/22086871
tags question: http://stackoverflow.com/q/22156876
tags question: http://stackoverflow.com/q/22168302
tags question: http://stackoverflow.com/q/22138250
tags question: http://stackoverflow.com/q/22071020
tags question: http://stackoverflow.com/q/22160865
tags question: http://stackoverflow.com/q/22038378

http://stackoverflow.com/comment/33399330
has text: @codenewb: if you called it in the constructor, it would be guaranteed to be called.
comment on: http://stackoverflow.com/a/22030846
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/a/22060096
answers question: http://stackoverflow.com/q/22059779
score: 2
has body: Each Android application is limited with 16Mb of memory. Even if you want to scale a 20MB image to small dimensions - you gonna load it to memory and get OOM. The best practice to save/load large images is to use options.inJustDecodeBounds = true; in BitmapFactory. This will not load your image to memory and will scale it just in file system. That's how i do it in my app: public static Bitmap getThumbnail(String path, int target_width, int target_height, int max_size) { try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(path, options); int scale = 1; while ((options.outWidth * options.outHeight) * (1 / Math.pow(scale, 2)) &gt; max_size) { scale++; } Log.d("boom", "scale = " + scale + ", orig-width: " + options.outWidth + ", orig-height: " + options.outHeight); Bitmap pic = null; if (scale &gt; 1) { scale--; options = new BitmapFactory.Options(); options.inSampleSize = scale; pic = BitmapFactory.decodeFile(path, options); Log.d("boom", "1th scale operation dimenions - width: " + target_width + ", target_height: " + target_height); double y = Math.sqrt(max_size / (((double) target_width) / target_height)); double x = (y / target_height) * target_width; Bitmap scaledBitmap = Bitmap.createScaledBitmap(pic, (int) x, (int) y, true); pic.recycle(); pic = scaledBitmap; System.gc(); } else { pic = BitmapFactory.decodeFile(path, options); } Log.d("boom", "bitmap size - width: " +pic.getWidth() + ", height: " + pic.getHeight()); return pic; } catch (Exception e) { Log.e("boom", e.getMessage(),e); return null; } } More info here But seems you did it fine, but you save/load SharedPreferences wrong. You saving empty string and try to parse URI them. String bb = decodeFile(filePath); ... prefsEditor.putString("photo1", bb); and on load you do: img_logo.setImageURI(Uri.parse(settings.getString("photo1", "android.resource://com.tiktak.babyalbum/" + R.drawable.ic_launcher))); will return empty string and will…
upvote count: 2
has comment: http://stackoverflow.com/comment/33451932
has comment: http://stackoverflow.com/comment/33456681
has comment: http://stackoverflow.com/comment/33451154
downvote count: 0
has comment: http://stackoverflow.com/comment/33455006
has comment: http://stackoverflow.com/comment/33456161
type: Answer
has comment: http://stackoverflow.com/comment/33463664

http://stackoverflow.com/comment/33564146
has text: In that example, yet. If I had other objects drawn to the screen, it would overlay those objects too.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22123090
type: AnswerComment

http://stackoverflow.com/comment/33530649
has text: This is very vague. Can you please tell us what driver you are using and what exception you are getting?
score: 1
comment on: http://stackoverflow.com/q/22104531
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33397033
has text: @DavidWallace You are absolutely correct. I felt that floating-point precision is good enough for this exercise but in an accounting app I'd stay away from it as well. An alternative is to get the number of cents by doing `int cents=total % 100` (disregarding any off-by-ones in there) and dollars with `total-=cents` for an integer total, and print them separately. Come to think of it that's a much better and simpler solution.
comment on: http://stackoverflow.com/a/22028591
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33493476
score: 2
has text: You're going to be calling `lookup` on an instance?
comment on: http://stackoverflow.com/q/22083689
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33437633
has text: I would avoid pack if I had a certain size and nothing inside it.
comment on: http://stackoverflow.com/q/22052709
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33607638
type: Comment
has text: The "best" approach is not to modify an AST node but add some additional information in it. Simply sub-class ANTLR's node class (Or Lexer node class). Add some attributes into it. Specify your class as `TokenClass` in ANTLR grammar. Then store some additional information this token using rule actions. PS: I'm about to think we both work on the same type of software.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22141072

http://stackoverflow.com/q/22071020
has answer: http://stackoverflow.com/a/22071080
accepted answer: http://stackoverflow.com/a/22071080
has body: I'm confused with the the java BufferedWriter write method. The java documents says that write takes int as an argument. void write(int c) Writes a single character. But I have used write method in my code, and I have passed String into it BufferedReader br=new BufferedReader(file); BufferedWriter bw=new BufferedWriter(file1); String line=null; while((line=br.readLine())!=null) { bw.write(line); // Why is this statement working? bw.write("\r\n"); } I passing "line" to bw.write(line) and "line" is a string, why is this working?Is write method overloaded?But I don't see it in docs.
type: AnsweredQuestion
tagged with: bufferedwriter
has answer: http://stackoverflow.com/a/22071191
tagged with: java
has comment: http://stackoverflow.com/comment/33469396
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/33469917
tagged with: bufferedreader
score: 0
possible better answer: http://stackoverflow.com/a/22071191
upvote count: 1
downvote count: 1
has title: Reading from a file and writing it back to a file in java(Having trouble understanding BufferedWriter write method in java)
favorite count: 0

http://stackoverflow.com/a/31138626
score: 1
answers question: http://stackoverflow.com/q/22080851
upvote count: 1
type: Answer
downvote count: 0
has body: Check your imports. Remove import android.R if it's generated there.

http://stackoverflow.com/comment/33541975
type: QuestionComment
has text: Which method is the problem? You've posted a huge amount of code but not told us which lines are the issue. Also please format your code with indentation.
comment on: http://stackoverflow.com/q/22110855
score: 0
type: Comment

http://stackoverflow.com/q/22098644
possible better answer: http://stackoverflow.com/a/22098689
has answer: http://stackoverflow.com/a/22098731
upvote count: 3
has title: Java both if() and else if() statements are being called
has comment: http://stackoverflow.com/comment/33519347
has answer: http://stackoverflow.com/a/22098689
type: Question
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/22098731
answer count: 2
has body: Okay, so I'm in the progress of making a game, and I need the collisions to work. I have an if() { } else if() {} -statement, but BOTH of them are being called. Here is my code: Inside my Player Class: public Rectangle[] tileRect; public void update() { tileRect = new Rectangle[Level1.tiles.size()]; for (int w = 0; w &lt; Level1.tiles.size(); w++) { Tile m = (Tile) Level1.tiles.get(w); tileRect[w] = m.getBounds(); if(tileRect[w].intersects(getRect())) { System.out.println("intersecting"); dy = 0; } else if (!tileRect[w].intersects(getRect())){ dy = 4; } } x += dx; y += dy; } public Rectangle getRect() { return new Rectangle(x, y, 32, 32); } Here is my Tile class (the Level1.tiles is an arrayList of tiles): package level; import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class Tile extends Rectangle { // Defines the id of the tile, used for setting textures. private static final long serialVersionUID = 1L; public int id; // Location public int x; public int y; // Variables for the terrain sprite sheet. public BufferedImage image; public String imageLocation; public BufferedImage[] sprite; public int rows = 16; public int collumns = 16; public int width = 16; public int height = 16; public Tile(int idVal, int xPos, int yPos) { x = xPos * 32; y = yPos * 32; id = idVal; setBounds(x, y, 32, 32); createImages(); } public BufferedImage getImage() { return sprite[id]; } public void createImages() { imageLocation = "res/tile/terrain.png"; try { image = ImageIO.read(new File(imageLocation)); } catch (IOException e) { System.out.println("Unable to find file " + imageLocation + ", printing stack trace!"); e.printStackTrace(); } sprite = new BufferedImage[rows * collumns]; for (int i = 0; i &lt; rows; i++) { for (int j = 0; j &lt; collumns; j++) { sprite[(i * collumns) + j] = image.getSubimage(j * width, i * height, width, height); } } } public int getXLoc() { return x; } public i…
downvote count: 0
score: 3
favorite count: 0

http://stackoverflow.com/comment/34329295
score: 0
type: Comment
type: QuestionComment
has text: @Balder yes, I thought about simply iterating over all causes and print their stack trace. However, I would like to find more documentation on how these exceptions should be treated and in what combinations they can be thrown from GWT
comment on: http://stackoverflow.com/q/22050842

http://stackoverflow.com/q/22106130
tagged with: java
has comment: http://stackoverflow.com/comment/33535093
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/22107571
has comment: http://stackoverflow.com/comment/33533818
has comment: http://stackoverflow.com/comment/33535032
has comment: http://stackoverflow.com/comment/33536135
has title: Queueing Methods With Java 8
has comment: http://stackoverflow.com/comment/33534632
score: 2
has body: I am building a game simulator that has hundreds of micro steps like the following. They each perform a unique task, but I left out the implementation details for the sake of brevity. public class Sim { static void phase() { phaseIn(); phaseOut(); } static void untap() { } static void upkeep() { } static void draw() { } ... } A Turn usually involves executing steps sequentially, but there are times when a special effect may cause the sequence to change. For example, I may be required to repeat a step twice, skip a step, or rearrange the order of the steps. These actions are all special cases, as the turn typically just occurs in order from start to finish. For example, the following series of events represents my normal turn. ... > upkeep() > draw() > preCombatMain() > ... Now, I play something that requires me to repeat my draw step. I need my turn to look like this: ... > upkeep() > draw() > draw() > preCombatMain() > ... The steps of a turn are methods, and I do not know how to enqueue or dequeue methods. I know that Java 8 has method references, but the feature is relatively new. I have been unable to apply existing tutorials to what I am trying to accomplish. I got as far as Sim::untap, but I have no idea how to assign it, invoke it, etc. How do I queue methods in Java 8, or otherwise call methods in an order determined at run-time by the choices a player makes? Note: I realize that my inability to understand may be due to a fundamental design flaw. I have never taken a game design course, I am completely open to criticism, and I will change my design if it is flawed. That said, the question is not to be misconstrued as "Please recommend a design pattern." I considered an alternate design, where I "number" each step in a massive switch statement, queue "numbers", and repeatedly switch on the front of the queue, but that seemed like a poor plan (in my opinion).
possible better answer: http://stackoverflow.com/a/22106756
downvote count: 0
has answer: http://stackoverflow.com/a/22106756
favorite count: 0
accepted answer: http://stackoverflow.com/a/22107571
has comment: http://stackoverflow.com/comment/33534431
has comment: http://stackoverflow.com/comment/33533700
upvote count: 2
has comment: http://stackoverflow.com/comment/33535368
tagged with: java-8
type: AnsweredQuestion

http://stackoverflow.com/comment/33369333
comment on: http://stackoverflow.com/q/22014970
type: Comment
type: QuestionComment
has text: what is this `ArrayList<Integer> del = new ArrayList<String>();`
score: 4

http://stackoverflow.com/a/22141727
answers question: http://stackoverflow.com/q/22132736
has comment: http://stackoverflow.com/comment/33605999
score: 0
has body: It appears that you are sending PASS before sending USER, and not the other way around as I would expect. This probably works for your local FTP server, but does not work on whatever FTP server your dyno is trying to connect to.
type: Answer

http://stackoverflow.com/comment/76883614
type: Comment
has text: @M_M You can use one of the `IDE.openEditor` methods where you specify the `IFile` to edit,
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/22166421

http://stackoverflow.com/comment/33403776
comment on: http://stackoverflow.com/q/22015798
type: Comment
score: 0
has text: hmm should i add it as an answer so that you can accept it..:) ?
type: QuestionComment

http://stackoverflow.com/a/22154115
answers question: http://stackoverflow.com/q/22152416
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/22152416
has body: I looked for divisi2 module into ubuntu repositories and didn't find it. So, I'm assuming you don't got divisi2 by installing the module, and that's why the module isn't in the PYTHONPATH environment variable. Said that try adding manually the module to the PYTHONPATH: import sys sys.path.insert(0, path_to_divisi2_parent_folder) import divisi2 assoc = divisi2.network.conceptnet_assoc('en') U, S, _ = assoc.svd(k=100) spread = divisi2.reconstruct_activation(U, S) def similar(str1,str2): return spread.entry_named(str1,str2) In the code above, path_to_divisi2_parent_folder is the path to the folder containing the module. If the module part of a package(lets call it some_package), I recommend you insert the package's parent folder to the path instead. And use the module like this: from some_package import divisi2
has comment: http://stackoverflow.com/comment/33625011
score: 0

http://stackoverflow.com/comment/33462472
type: QuestionComment
comment on: http://stackoverflow.com/q/22059888
score: 1
has text: Absolutely no reason for close. Perfect question.
type: Comment

http://stackoverflow.com/comment/33522450
type: Comment
comment on: http://stackoverflow.com/a/22099525
score: 0
type: AnswerComment
has text: I edited the code and there should be no compile errors now. If that is still not what you were wanting, could you be a bit clearer on what you did mean please? I'm now not sure I understand

http://stackoverflow.com/comment/33565309
score: 0
type: Comment
type: QuestionComment
has text: @xp500 - Could be. Not clear.
comment on: http://stackoverflow.com/q/22123612

http://stackoverflow.com/comment/33612483
score: 0
has text: most probably the problem is that you modify the dataSet off the EDT
type: QuestionComment
comment on: http://stackoverflow.com/q/22149909
type: Comment

http://stackoverflow.com/comment/33516652
has text: i think i'm using Java 7, yes.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22097171
score: 0

http://stackoverflow.com/q/22098955
favorite count: 0
has body: I have an array, with number ranging from -100 to 100. Now, I have to make a method that copies the positive ones into an other array. I made this: static int[] ArrayCopy(int[] t) { int a = 0; int[] g = new int[0]; for (int i = 0; i &lt; t.Length; i++) { if (t[i] &gt; 0) { g[a] = t[i]; a++; } } return g; } The program terminates with IndexOutOfRange, and I don't get it.
has answer: http://stackoverflow.com/a/22099222
upvote count: 1
has title: C# Unreachable code (Property-dependant array copier )
tagged with: indexing
type: AnsweredQuestion
score: 1
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/22099222
answer count: 2
possible better answer: http://stackoverflow.com/a/22099024
tagged with: arrays
downvote count: 0
has answer: http://stackoverflow.com/a/22099024
tagged with: copy
tagged with: indexoutofrangeexception

http://stackoverflow.com/a/22134470
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22099780
has body: Time Out I use a 10 Second time out with a retry. It works ok for me. Sheet size I have used it with 80,000 cells at a time. It works fine, I have not seen the retry fail. I am using CellFeed, not ListFeed. Yes, it does not like large sheets, small sheets of 1000 cells or so are much faster. Even if I only write to part of the sheet, small sheets are much faster. (Feels like it recalculates whole sheets, as does not look to be down to data volume, but I am not sure) Exponential backoff Zig suggests an exponential backoff - would be be interested in numbers - what timeout values and failure rates people get with exponential backoff - also the impact of sheet size. I suspect start with a 3 Second Time out and double with every retry might work, but have not tested it.
downvote count: 0
upvote count: 2
type: Answer
score: 2
accepted answer of: http://stackoverflow.com/q/22099780
has comment: http://stackoverflow.com/comment/33629580
has comment: http://stackoverflow.com/comment/33596999

http://stackoverflow.com/comment/33578916
score: 0
type: AnswerComment
type: Comment
has text: I am not aware of any component which would not work.
comment on: http://stackoverflow.com/a/22129946

http://stackoverflow.com/q/22110160
has answer: http://stackoverflow.com/a/22110382
answer count: 1
downvote count: 0
tagged with: layout-manager
has comment: http://stackoverflow.com/comment/33541103
has title: What is best way to center objects in JPanel horizontally and vertically
favorite count: 0
type: UnansweredQuestion
upvote count: 1
tagged with: swing
has body: I'm trying to add a panel p1 on the left on the panelMain. Since the objects are not center vertically, I tried to add p1 on p2, which has BorderLayout. I guess this is not a good way but it doesn't even work. I didn't use GridLayout because I don't want the objects to fill up the whole JPanel. JPanel panelMain = new JPanel( new BorderLayout() ); JPanel p1 = new JPanel( new FlowLayout(FlowLayout.CENTER) ); panelText.setPreferredSize( new Dimension( 250, frame.getHeight() ) ); panelText.add( new JLabel( "Name:", SwingConstants.RIGHT) ); panelText.add( new JTextField( "First Last:", 15 ) ); panelText.add( new JLabel( " Tel:", SwingConstants.RIGHT) ); panelText.add( new JTextField( "000-000-0000", 15) ); JPanel p2 = new JPanel( new BorderLayout() ); p2.add( p1, BorderLayout.CENTER ); panelMain.add( p2,BorderLayout.WEST );
score: 1
tagged with: java
linked to: http://stackoverflow.com/q/16727564
tagged with: jpanel
has comment: http://stackoverflow.com/comment/33543410
type: Question

http://stackoverflow.com/comment/33465463
type: QuestionComment
comment on: http://stackoverflow.com/q/22068871
type: Comment
has text: This should not fail. Are you sure that `em` is not null?
score: 1

http://stackoverflow.com/q/22163898
type: Question
has answer: http://stackoverflow.com/a/22164185
has comment: http://stackoverflow.com/comment/33636890
answer count: 2
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/22164185
has answer: http://stackoverflow.com/a/22164825
has comment: http://stackoverflow.com/comment/33636589
tagged with: parameterized
has body: This is a homework assignment that I've been researching for over 2 hours and I still can't get a decent answer, so I would appreciate any help. Suppose that Bicycle is a subclass of Vehicle. Is the parameterized interface List&lt;Bicycle&gt; a subinterface of List&lt;Vehicle&gt; ? Explain briefly. My issues are: I thought you couldn't even have lists in interfaces, only methods. How can a list be an interface, let alone a subinterface? What is this question even asking, in plain English? :/ Thanks in advance!
tagged with: interface
possible better answer: http://stackoverflow.com/a/22164825
type: AnsweredQuestion
tagged with: list
has comment: http://stackoverflow.com/comment/33636599
linked to: http://stackoverflow.com/q/2745265
score: 1
has title: Can a parameterized interface be a subinterface?
tagged with: java
upvote count: 1
has comment: http://stackoverflow.com/comment/33636748

knapsack-problem
type: Tag
tag name: knapsack-problem
tags question: http://stackoverflow.com/q/22134591

background
tags question: http://stackoverflow.com/q/22113716
tag name: background
tags question: http://stackoverflow.com/q/22158992
tags question: http://stackoverflow.com/q/22075483
type: Tag
tags question: http://stackoverflow.com/q/22083867
tags question: http://stackoverflow.com/q/22146147

http://stackoverflow.com/comment/34312593
type: AnswerComment
has text: I thank you very much for your answer and sorry that I am replying after a long time; this is due to my time as I have been busy. I was thinking the same is FD_ that how I should avoid repeating questions. But it looks very good anyway for inspiration for a beginner like me.
type: Comment
comment on: http://stackoverflow.com/a/22147685
score: 0

webforms
tags question: http://stackoverflow.com/q/22151764
type: Tag
tag name: webforms

http://stackoverflow.com/a/22178938
has comment: http://stackoverflow.com/comment/33682806
answers question: http://stackoverflow.com/q/22086605
accepted answer of: http://stackoverflow.com/q/22086605
type: Answer
has comment: http://stackoverflow.com/comment/33895431
has comment: http://stackoverflow.com/comment/33700643
upvote count: 7
score: 7
has body: Procyon is a Java decompiler written in Java, and it can be called directly from Java code. For example: final PrintWriter writer = new PrintWriter(System.out); try { com.strobel.decompiler.Decompiler.decompile( "W:\\Hello.class", new com.strobel.decompiler.PlainTextOutput(writer) ); } finally { writer.flush(); } There is also a decompile() overload that accepts a DecompilerSettings instance, which you can use to toggle certain features and give the decompiler hints on how to resolve class dependencies. Feel free to contact me on BitBucket with any questions.
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/33561040
type: QuestionComment
has text: Read the javadoc of `split`.
type: Comment
comment on: http://stackoverflow.com/q/22121519
score: 4

ant
tags question: http://stackoverflow.com/q/22133654
tags question: http://stackoverflow.com/q/22075310
tags question: http://stackoverflow.com/q/22013356
tags question: http://stackoverflow.com/q/22168076
tags question: http://stackoverflow.com/q/22066090
tags question: http://stackoverflow.com/q/22078560
tags question: http://stackoverflow.com/q/22115697
tags question: http://stackoverflow.com/q/22005979
tags question: http://stackoverflow.com/q/22130667
tags question: http://stackoverflow.com/q/22071885
tags question: http://stackoverflow.com/q/22075832
type: Tag
tags question: http://stackoverflow.com/q/22035087
tags question: http://stackoverflow.com/q/22068056
tags question: http://stackoverflow.com/q/22092446
tags question: http://stackoverflow.com/q/22008769
tags question: http://stackoverflow.com/q/22093809
tags question: http://stackoverflow.com/q/22015820
tag name: ant
tags question: http://stackoverflow.com/q/22166762
tags question: http://stackoverflow.com/q/22103769
tags question: http://stackoverflow.com/q/22069118
tags question: http://stackoverflow.com/q/22093133
tags question: http://stackoverflow.com/q/22034121
tags question: http://stackoverflow.com/q/22054095

http://stackoverflow.com/comment/33635148
type: QuestionComment
comment on: http://stackoverflow.com/q/22088217
score: 0
has text: @brian: no man I want the value of first column based on the selection of second column.. selected cell is also works for me!!
type: Comment

http://stackoverflow.com/a/22152546
has body: Try this: public List&lt;Integer&gt; findDiffIndexes(String s1, String s2 ) { List&lt;Integer&gt; indexes = new ArrayList&lt;Integer&gt;(); for( int i = 0; i &lt; s1.length() &amp;&amp; i &lt; s2.length(); i++ ) { if( s1.charAt(i) != s2.charAt(i) ) { indexes.add( i ); } } return indexes; }
type: Answer
answers question: http://stackoverflow.com/q/22152374
score: 1
upvote count: 1
downvote count: 0

http://stackoverflow.com/q/22130407
accepted answer: http://stackoverflow.com/a/22130549
tagged with: encryption
downvote count: 1
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33577620
score: -1
type: Question
has answer: http://stackoverflow.com/a/22130549
upvote count: 0
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33577535
has body: How to Encrypt and Decrypt in Java using AES import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import javax.crypto.spec.SecretKeySpec; public class Encryption { public static void main(String args[]) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException{ String t = "Testing"; byte[] dataToSend = t.getBytes(); byte[] key = new byte[16]; Cipher c = Cipher.getInstance("AES"); SecretKeySpec k = new SecretKeySpec(key, "AES"); c.init(Cipher.ENCRYPT_MODE, k); byte[] encryptedData = c.doFinal(dataToSend); System.out.println(encryptedData); byte[] key2 = new byte[16]; byte[] encryptedData2 = encryptedData; Cipher c2 = Cipher.getInstance("AES"); SecretKeySpec k2 = new SecretKeySpec(key2, "AES"); c2.init(Cipher.DECRYPT_MODE, k2); byte[] data = c.doFinal(encryptedData); System.out.println(data); } }
tagged with: aes
has title: Encryption and Decryption in Java using AES

http://stackoverflow.com/comment/33504717
score: 0
type: QuestionComment
type: Comment
has text: see this http://www.learn-android-easily.com/2013/01/adding-check-boxes-in-dialog.html
comment on: http://stackoverflow.com/q/22090316

http://stackoverflow.com/q/22061461
has body: I'm reading chapter about sorting in Sedgewick's "Algorithms". Along the way I wrote 3 basic algorithms for sorting: selection, insertion and shell sort. The book says, that, despite the fact that all three have quadratic worst case complexity, shell sort should be much faster than insertion sort on random data. In the book they get 600x performance boost. But I get following multipliers (almost do not change with increasing of array size) on my laptop: selection: 5.5x insertion: 1x shell: 1.8x ! The question that bothers me is - why shell sort is almost two times slower, than insertion sort?! I guess, something is wrong with my shellsort implementation. But I almost copied it from the book: class ShellSort extends Sort { //precalculate sequence: 1, 4, 13, 40, 121, 364, 1093, ... //(3^20 - 1)/2 is enough for any array I sort private static final int[] SEQUENCE = new int[20]; static { for(int i = 1; i &lt;= SEQUENCE.length; i++) SEQUENCE[i - 1] = (int)(Math.pow(3, i) - 1) / 2; } public void sort(int[] a) { int length = a.length; int seqLen = SEQUENCE.length; int nth; int j; for(int seqi = seqLen - 1; seqi &gt;= 0; seqi--) { if(SEQUENCE[seqi] &lt; length / 3) { nth = SEQUENCE[seqi]; for(int n = 0; n &lt; length; n+=nth) { j = n; while(j &gt; 0 &amp;&amp; a[j] &lt; a[j - nth]) { exch(a, j, j-nth); j -= nth; } } } } } } Rest of the code for those, who would like to run test on their machine (doubling array size test with JVM heat up has no significant effect on the results, so this simple test is good enough for N > ~ 200 000). main: int N = 500_000; Random rand = new Random(); int[] a = new int[N]; for(int i = 0; i &lt; N; i++) a[i] = rand.nextInt(); //insertion sort int[] aCopy = Arrays.copyOf(a, a.length); long start = System.nanoTime(); new InsertionSort().sort(aCopy); System.out.println("insert:\t" + (System.nanoTime() - start)); //shell sort aCopy = Arrays.copyOf(a, a.length); start = System.nanoTime(); new ShellSort().sort(aCopy); System.out.println("shell:\t" + …
possible better answer: http://stackoverflow.com/a/22061757
tagged with: shellsort
accepted answer: http://stackoverflow.com/a/22062702
type: Question
has comment: http://stackoverflow.com/comment/33453145
tagged with: performance
tagged with: algorithm
tagged with: sorting
has answer: http://stackoverflow.com/a/62253520
has comment: http://stackoverflow.com/comment/33453847
downvote count: 0
linked to: http://stackoverflow.com/q/504103
has comment: http://stackoverflow.com/comment/33453173
favorite count: 0
has answer: http://stackoverflow.com/a/22062702
has comment: http://stackoverflow.com/comment/33452942
has comment: http://stackoverflow.com/comment/33453955
score: 6
upvote count: 6
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22061876
has answer: http://stackoverflow.com/a/22061757
linked to: http://stackoverflow.com/q/10082517
tagged with: java
has title: Insertion sort much faster than shell sort
has comment: http://stackoverflow.com/comment/33453213

http://stackoverflow.com/q/22086976
has comment: http://stackoverflow.com/comment/33499230
score: 0
has comment: http://stackoverflow.com/comment/33499228
answer count: 3
has comment: http://stackoverflow.com/comment/33499150
has comment: http://stackoverflow.com/comment/33498930
has comment: http://stackoverflow.com/comment/33498944
has comment: http://stackoverflow.com/comment/33498964
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22087052
has comment: http://stackoverflow.com/comment/33499064
has body: I am making a Mastermind program. I generate a random String with 4 numerical characters (characters cannot repeat themselves). For testing purposes, it's always 1234. The user is then asked to guess the String by inputing 4 numbers. I am making a method called PerfectMatches that checks how many guessed numbers are correct AND in the right position. Here is my code : public static int perfectMatches (String x, String y){ int i = 0; int perfectmatches = 0; for (i=0; i &lt; 4; i++){ if ((x.charAt(i)) == (y.charAt(i))){ perfectmatches++; } I tried using if statements but I felt it wasn't efficient and took longer to process for the program.
has answer: http://stackoverflow.com/a/22087102
has title: integrating if statements into a for loop with
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33498974
linked to: http://stackoverflow.com/q/10147690
tagged with: for-loop
tagged with: if-statement
has comment: http://stackoverflow.com/comment/33499591
has answer: http://stackoverflow.com/a/22087163

http://stackoverflow.com/comment/33566277
type: Comment
comment on: http://stackoverflow.com/q/22119567
has text: And the create-drop also doesn't works, so I have to manualy drop all tables after a change. Where could be the problem?
score: 0
type: QuestionComment

http://stackoverflow.com/q/22014970
has body: In my programm I have a List of Strings and a List of integer values which should be deleted from the first list. Think of somehing like this: ArrayList&lt;String&gt; items = new ArrayList&lt;String&gt;(); items.add("A"); items.add("B"); items.add("C"); ArrayList&lt;Integer&gt; del = new ArrayList&lt;Integer&gt;(); del.add(1); del.add(2); Of course I can loop throught the list with this code and delete the items: for (int i = 0; i &lt; del.size(); i++) { items.remove(del.get(i)); } But here is the problem. After the first element is deleted the index is shifted so I delete the wrong items. Is there a graceful solution for this?
score: 0
has answer: http://stackoverflow.com/a/22015030
has comment: http://stackoverflow.com/comment/33369348
has comment: http://stackoverflow.com/comment/33369359
has answer: http://stackoverflow.com/a/22015121
has comment: http://stackoverflow.com/comment/33369458
has title: Delete item from arraylist
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22015121
accepted answer: http://stackoverflow.com/a/22015030
type: Question
has comment: http://stackoverflow.com/comment/33369266
tagged with: java
has comment: http://stackoverflow.com/comment/33369411
has answer: http://stackoverflow.com/a/22015027
answer count: 3
has comment: http://stackoverflow.com/comment/33369333
tagged with: arraylist

http://stackoverflow.com/comment/44410175
type: Comment
has text: It doesn't matter. In Solution #1, totalItemCount is constant, visibleItemCount is most likely constant too, firstVisibleItem will decrease as you scroll up. In Solution #2 the position will decrease as you scroll up and won't be equal to the size of the list.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22145324

http://stackoverflow.com/comment/33474076
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22073457
has text: thanks but java says "break outside switch or loop" ohh btw i am putting it at the end of the 2nd if statement.
score: 0

http://stackoverflow.com/q/22168098
answer count: 1
has comment: http://stackoverflow.com/comment/33643876
score: 0
tagged with: java
has answer: http://stackoverflow.com/a/22168376
has title: Multithreading in Android using BluetoothChat : Wait for answer
type: UnansweredQuestion
type: Question
tagged with: android
has body: need your help again : I am using the bluetooth chat example by android and try to implement a function which waits for the answer from the handler : public void getOBD2Values() { Log.d(TAG, "Before"); writeMessage("Hello"); mNastyBusyWait = true; while(mNastyBusyWait){ //send Thread to sleep try { Thread.currentThread().sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } Log.d(TAG, "After"); } The thread should wait until the handler receives the answer : case MESSAGE_READ: byte[] readBuf = (byte[]) msg.obj; String readMessage = new String(readBuf, 0, msg.arg1); mNastyBusyWait = false; // wake Thread up again Log.d(TAG, "NOT IN IF :MESSAGE_READ: " + readMessage); break; This is a silly busy-wait approach to get the example running. Afaik the problem is that the Thread waits, but the handler is in the same class and it is never used to go on ... what would be a better approach or how can I solve this problem ? I finally get a answer from the bluetooth client ! Thanks.
has comment: http://stackoverflow.com/comment/33644111
tagged with: multithreading

http://stackoverflow.com/comment/33583224
has text: The for loop runs only once. You are only changing arrayone[0] and arraytwo[0]
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22133210
type: Comment

http://stackoverflow.com/a/22367293
has comment: http://stackoverflow.com/comment/34039788
type: Answer
has comment: http://stackoverflow.com/comment/34045737
downvote count: 0
score: 7
has body: please try this: /* * 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 test; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.TreeCell; import javafx.scene.control.TreeItem; import javafx.scene.control.TreeItem.TreeModificationEvent; import javafx.scene.control.TreeView; import javafx.scene.input.ClipboardContent; import javafx.scene.input.DataFormat; import javafx.scene.input.DragEvent; import javafx.scene.input.Dragboard; import javafx.scene.input.MouseEvent; import javafx.scene.input.TransferMode; import javafx.scene.layout.VBox; import javafx.stage.Stage; import javafx.util.Callback; public class MainApp extends Application { private EventHandler&lt;TreeModificationEvent&lt;DynamicTreeNodeModel&gt;&gt; branchExpandedEventHandler; /** * @param args the command line arguments */ public static void main(String[] args) { Application.launch(MainApp.class, args); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("Example Dynamic Tree"); primaryStage.setResizable(true); final VBox box = new VBox(); box.setFillWidth(false); Scene scene = new Scene(box); primaryStage.setScene(scene); box.getChildren().add(this.getExampleTree()); primaryStage.show(); } private TreeView&lt;DynamicTreeNodeModel&gt; getExampleTree() { DynamicTreeNodeModel rootNode = new RandomDynamicTreeNodeModel(null, "Root Node"); TreeView&lt;DynamicTreeNodeModel&gt; treeView = new TreeView&lt;DynamicTreeNodeModel&gt;(); treeView.setCellFactory(new Callback&lt;TreeView&lt;DynamicTreeNodeModel&gt;, TreeCell&lt;DynamicTreeNodeModel&gt;&gt;() { @Override public TreeCell call(TreeView&lt;DynamicTreeNodeModel&gt; param) { return new DnDCel…
upvote count: 7
accepted answer of: http://stackoverflow.com/q/22149137
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/34007963
answers question: http://stackoverflow.com/q/22149137
has comment: http://stackoverflow.com/comment/34008247

http://stackoverflow.com/a/22061644
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/22020915
downvote count: 0
has body: There will be four semaphores for each of quadrant on square. N 1 | 2 W ------ E 3 | 4 S And four threads for vehicles coming for each side. Each vehicle thread will generate random number(as you doing now) to decide which direction to turn(left, right, straight). Depending on whether you are driving British style(drive on left) or American style(drive on right), acquire locks on respective quadrant semaphore. e.g. you are going South to North: British style: acquire semaphore 3 then 1, American Style: acquire semaphore 4 then 2. class LockOrder{ List&lt;Integer&gt; leftTurn() List&lt;Integer&gt; rightTurn() List&lt;Integer&gt; straight() } create four objects LockOrder for each of direction vehicle is coming from.

http://stackoverflow.com/q/22086350
tagged with: gps
has answer: http://stackoverflow.com/a/22089185
tagged with: java
type: Question
has body: I'm trying to getting location manager inside text-view in customDialog as follows: But gives me java null pointer exception When I open Dialog and get GPS working it works fine, but when closing Dialog and GPS get it's positions it getting NPE. Note: I have edited the code for you @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tjamo3_last_date); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); addNewPoint.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(Tjamo3LastDate.this); dialog.setContentView(R.layout.custom_dialog); dialog.setTitle("اضافة نقطة فحص جديدة"); Button save =(Button)dialog.findViewById(R.id.save); if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){ txtLat = (TextView) dialog.findViewById(R.id.textView1); txtLag = (TextView) dialog.findViewById(R.id.textView2); txtLat.setText("0.0"); txtLag.setText("0.0"); } dialog.show(); save.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { EditText editText=(EditText)dialog.findViewById(R.id.editText); txtLat = (TextView) dialog.findViewById(R.id.textView1); txtLag = (TextView) dialog.findViewById(R.id.textView2); txtLat.setText(String.valueOf(mm)); txtLag.setText(String.valueOf(hh)); }); } @Override public void onLocationChanged(Location location) { hh = location.getLatitude(); mm = location.getLongitude(); }
has title: Getting GPS position in custom dialog
has comment: http://stackoverflow.com/comment/33498171
score: 0
has comment: http://stackoverflow.com/comment/33498508
answer count: 1
has comment: http://stackoverflow.com/comment/33500262
has comment: http://stackoverflow.com/comment/33497978
has comment: http://stackoverflow.com/comment/33498012
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/33498006
has comment: http://stackoverflow.com/comment/33500106
has comment: http://stackoverflow.com/comment/33497941

http://stackoverflow.com/comment/33592822
comment on: http://stackoverflow.com/q/22139201
has text: I havent exported it as yet, I am simply running it on my device to check if its working.I have added the libraries in my build paths but I have not copy-pasted them in my project folder.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33490208
type: Comment
has text: I need it to be recursive.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22081979

http://stackoverflow.com/comment/33545812
score: 0
type: Comment
has text: @jewelsea: Thanks for your effort but this solution not work for me unfortunately so I can't accept as it's good for community or for future visitor.. but for your effort I will give you my +1 yesterday. Anyway Thanks Again!!
comment on: http://stackoverflow.com/a/22089747
type: AnswerComment

http://stackoverflow.com/a/22031825
has body: can you try with this for me it's working fine one two change only Base64.DEFAULT insted of URL_SAFE and image tag alt. just check it. &lt;img height=700px src='data:image/jpg;base64,"+encodeString+"' alt='Embeded Image'/&gt; public static String bitmapToBase64String(Bitmap bmp, Bitmap.CompressFormat format, int quality) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bmp.compress(format, quality, baos); byte[] bytes = baos.toByteArray(); return Base64.encodeToString(bytes, Base64.DEFAULT); }
has comment: http://stackoverflow.com/comment/33418878
answers question: http://stackoverflow.com/q/22031636
has comment: http://stackoverflow.com/comment/33404156
score: 0
has comment: http://stackoverflow.com/comment/33405612
type: Answer

http://stackoverflow.com/comment/33492444
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22083312
has text: iterate through it and maintain counter

http://stackoverflow.com/q/22132964
has comment: http://stackoverflow.com/comment/33584580
has comment: http://stackoverflow.com/comment/33586569
has body: I'm trying to implement the tTorrent client into my program, I've looked at this link for an example (https://github.com/mpetazzoni/ttorrent/issues/16) and placed that code into the Download class of my program. Here is the code: import statements: import main.java.com.turn.ttorrent.client.Client; import main.java.com.turn.ttorrent.client.SharedTorrent; import main.java.com.turn.ttorrent.common.Torrent; import main.java.com.turn.ttorrent.tracker.TrackedTorrent; import main.java.com.turn.ttorrent.tracker.Tracker; // Create tracker instance Tracker tracker = new Tracker(InetAddress.getLocalHost()); // Load torrent file File torrentFile = new File("/path/to/torrentFile.torrent"); // Create torrent instance TrackedTorrent torrent = new TrackedTorrent(Torrent.load(torrentFile, null)); // Announce torrent tracker.announce(torrent); // Start the tracker tracker.start(); torrentFile = new File(path + ".torrent"); File downloadDir = new File("/path/to/torrents_download_dir");//unsure Client client = new Client(InetAddress.getLocalHost(), SharedTorrent.fromFile(torrentFile, downloadDir)); // Add client.share(); if you wish to share the torrent infinitely client.run(); I'm getting this error message when I hover over load: The method load(File, boolean) in the type Torrent is not applicable for the arguments (File, null) I'm also unsure what I should place in File downloadDir. I'm still a beginner and if someone could point me in the right direction to putting this into my program that would be great. I'm still a beginner.
tagged with: bittorrent
tagged with: java
answer count: 2
tagged with: file
upvote count: 1
has title: tTorrent client error
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22133126
downvote count: 0
score: 1
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/44215322

http://stackoverflow.com/comment/33559768
type: Comment
comment on: http://stackoverflow.com/a/22120793
has text: see : http://android-developers.blogspot.com/2011/06/deep-dive-into-location.html
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33441316
type: QuestionComment
comment on: http://stackoverflow.com/q/22043308
score: 1
has text: Thanks Bryan. I knew it could be done from P4V, but I was wondering whether I could do it from Eclipse as well. It is indeed in the Time Lapse view, which is also accessible from Eclipse.
type: Comment

http://stackoverflow.com/a/22058246
score: 0
has comment: http://stackoverflow.com/comment/33447718
has body: You're setting your width variable (wide), but then you're never using it in any of the loops where you actually draw the buildings. So obviously you're window width is not going to be as you expect. Many things, such as this line System.out.println ("***********"); // printTopRowOfStory and this line System.out.println ("* *** *** *"); // printWindowBorders need to be chopped up, in order to compensate for the width. Something like //Print top row of story for(int i = 0; i &lt; wide; i++) { System.out.println("**"); //Or however many... //Print top window border for(int i = 0; i &lt; wide; i++) { System.out.println("*"); //Or however many...
type: Answer
has comment: http://stackoverflow.com/comment/33447603
answers question: http://stackoverflow.com/q/22058145

http://stackoverflow.com/q/22020504
has comment: http://stackoverflow.com/comment/33379857
tagged with: java
has answer: http://stackoverflow.com/a/22021422
has answer: http://stackoverflow.com/a/22020757
has comment: http://stackoverflow.com/comment/33379895
has comment: http://stackoverflow.com/comment/33380029
has comment: http://stackoverflow.com/comment/33379834
score: 2
accepted answer: http://stackoverflow.com/a/22021422
downvote count: 0
has body: I'm trying to run this in the terminal and it compiles, creates the .class files, but won't run. The code runs and executes as planned in Netbeans (in Windows), but won't run in the terminal for my VirtualBox. The error that I'm getting is that it cannot find the main class. package stackdemo; public class ArrayStackDemo { //Demo public static void main(String args[]) { StackInt demoStack = new StackInt(); for (int i = 0; i &lt; demoStack.size(); i++) { demoStack.push(i); System.out.println(demoStack.pop()); } } } package stackdemo; import java.util.Arrays; import java.util.EmptyStackException; public class StackInt { //Instance variables private int[] numberStack; int topOfStack = -1; //Empty stack private int capacity; private final int INITIAL_CAPACITY = 10; //Default constructer public StackInt() { capacity = INITIAL_CAPACITY; numberStack = new int[capacity]; } //Size method public int size() { return capacity; } //Empty method public boolean empty() { if (topOfStack == -1) { return true; } return false; } //Push method public int push(int obj) { if (topOfStack == numberStack.length - 1) { reallocate(); } topOfStack++; numberStack[topOfStack] = obj; return obj; } //Reallocate method public void reallocate() { capacity = 2 * capacity; numberStack = Arrays.copyOf(numberStack, capacity); } //Pop method public int pop() { if (empty()) { throw new EmptyStackException(); } return numberStack[topOfStack--]; } //Peek method public int peek() { if (empty()) { throw new EmptyStackException(); } return numberStack[topOfStack]; } }
has title: My code compiled, but won't run in the terminal
has comment: http://stackoverflow.com/comment/33380246
has comment: http://stackoverflow.com/comment/33380341
has comment: http://stackoverflow.com/comment/33380185
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33380067
favorite count: 0
has comment: http://stackoverflow.com/comment/33379893
has comment: http://stackoverflow.com/comment/33379832
has comment: http://stackoverflow.com/comment/33379997
has comment: http://stackoverflow.com/comment/33379929
type: Question
upvote count: 2
answer count: 2
has comment: http://stackoverflow.com/comment/33380064
has comment: http://stackoverflow.com/comment/33380002
possible better answer: http://stackoverflow.com/a/22020757

http://stackoverflow.com/comment/33540868
has text: How would i use a jframe for it
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22110159

http://stackoverflow.com/q/22119497
tagged with: count
has answer: http://stackoverflow.com/a/22119588
answer count: 4
has answer: http://stackoverflow.com/a/22119598
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22119611
tagged with: java
accepted answer: http://stackoverflow.com/a/22119588
tagged with: output
downvote count: 1
type: Question
possible better answer: http://stackoverflow.com/a/22119595
has answer: http://stackoverflow.com/a/22119595
score: -1
has comment: http://stackoverflow.com/comment/33557338
upvote count: 0
has body: I have been asked to write a program that checks if the team name is present in the text file I had created on my computer and also say how many times it has been repeated on the file? Can you please help me out? I have written the code to check if the word is present but did not know how to check the number of times it is present. import java.util.*; import java.io.*; public class worldSeries { public boolean checkSeries () throws IOException { Scanner keyboard = new Scanner(System.in); boolean result = false; String[] winners = new String[200]; int i = 0 ; File file = new File ("WorldSeriesWinners.txt"); Scanner inputFile = new Scanner(file); while ( inputFile.hasNext () &amp;&amp; i &lt; winners.length ) { winners[i] = inputFile.nextLine(); i++; } inputFile.close(); System.out.println(" Enter the Team's name you want to check : " ); String teamName = keyboard.nextLine(); for ( int index = 0 ; index &lt; winners.length ; index ++ ) { if ( teamName.equals(winners[index])) { result = true; } } return result; } public static void main(String[]Args) { worldSeries object1 = new worldSeries(); try { System.out.println(" The search result for the Team's name is : " + object1.checkSeries ()); } catch (IOException ioe) { System.out.println(" Exception!!! "); ioe.printStackTrace(); } } }
favorite count: 0
tagged with: text-files
has title: How to count the number of times a word is in the text file

http://stackoverflow.com/a/22033265
downvote count: 2
has comment: http://stackoverflow.com/comment/33456007
has body: try to use getActionCommand() instead of getSource() as Below :- if (f.getActionCommand().equals("green")) { messageLabel.setForeground(Color.GREEN); } or you can use anonymous inner classes as below :- greenButton.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent e) { messageLabel.setForeground(Color.GREEN); } });
answers question: http://stackoverflow.com/q/22033002
upvote count: 0
type: AcceptedAnswer
type: Answer
score: -2
has comment: http://stackoverflow.com/comment/33429141
accepted answer of: http://stackoverflow.com/q/22033002

http://stackoverflow.com/comment/33512552
has text: You are right, nevertheless we needed it. Why don't you post another answer explaining how to achieve that using JVM feature? I bet OP would be gratefull.
type: AnswerComment
comment on: http://stackoverflow.com/a/22093619
score: 0
type: Comment

http://stackoverflow.com/comment/33593167
comment on: http://stackoverflow.com/a/22096145
type: AnswerComment
score: 0
has text: Still I have one issue, with above solution it will create multiple files based on split size. How can I avoid this and encrypt into single file.
type: Comment

http://stackoverflow.com/a/22156971
answers question: http://stackoverflow.com/q/22156713
score: 0
type: Answer
has body: Similar question here: Editing mp3 files in Java(ID3) You might also have luck with the Java ID3 Tag Library

jooq
tags question: http://stackoverflow.com/q/22016414
tag name: jooq
tags question: http://stackoverflow.com/q/22087751
type: Tag

http://stackoverflow.com/comment/33392964
comment on: http://stackoverflow.com/q/22027334
has text: Parsing data requires you to identify patterns, looking for markers that indicate the start/end of sections or what the data represents (possibly line by line, or even groups of lines). Once you have determined your markers, you would then write your parser to treat each section separately.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33466118
has text: Have you tried without "my-ws" like localhost:8080/myService
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22067622

http://stackoverflow.com/comment/33501472
comment on: http://stackoverflow.com/q/22088487
has text: ...and what are you actually asking here?
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33612942
has text: @StantonProgrammer If `moviearray[i]` is null, then it will throw a NullPointer Exception as you cannot call `.getTitle()` on `null`. I thought at least each entry in `moviearray` would be non-null :). You can of course include an additional check `moviearray[i] != null`, but perhaps make sure there are no `null` objects in your `moviearray` to begin with.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22150503

http://stackoverflow.com/comment/33520926
has text: It turns out that this problem only happens when using gradle version 1.11, I bumped up my project to gradle 1.9 (which is also supported by IntelliJ Idea V13) and it is working.
comment on: http://stackoverflow.com/q/22097430
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22124711
has title: Android Personal Dictionary App Issues
tagged with: words
score: -1
favorite count: 0
type: Question
tagged with: android
has body: I am trying to write a personal dictionary application on android platform. There are standard features like add,edit,delete. I will be creating a personal application database to keep track of words. Once the word is added in the personal dictionary; it should appear in the auto suggest when user is typing it in messaging/mail apps. I looked at the following code snippet and tried to incorporate in my app: UserDictionary.Words.addWord(this, "Joglekar", 1, "Jogl", getResources().getConfiguration().locale); The code executes fine but the word does not appear in the auto suggest while typing. I am testing on HTC One X as of now. Any leads on how to accomplish this ?? Have a few follow up questions but will wait for this one to resolve. :)
tagged with: dictionary
answer count: 1
tagged with: java
downvote count: 1
has answer: http://stackoverflow.com/a/26761223
upvote count: 0
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/2888896

http://stackoverflow.com/comment/33459462
has text: Well it looks like the problme is in the JNI part - it sounds like you should file a bug with libPlacemaker.
score: 1
comment on: http://stackoverflow.com/q/22065396
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33494695
has text: And you know how to do it with for-loops, but you do not know how to do it recursively? Or what is your biggest issue?
comment on: http://stackoverflow.com/q/22084420
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22081203
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22080914
accepted answer of: http://stackoverflow.com/q/22080914
type: Answer
score: 2
has body: I suppose you are encountering what is called platform default encoding. For example, when converting bytes into String using new String(byte[]), the default encoding is used to convert bytes to String. Different servers may have different setup that have a different default platform encoding. To prevent different behaviour of the servers due to different default encoding, specify the encoding to use when converting bytes[] to String. If you don't know the encoding to use, that is another matter but at least you get consistent results for the same byte stream. For example, to convert String to UTF-8 byte stream use getBytes("UTF-8") and to get back the String, use String(byte[],"UTF-8");
downvote count: 0
upvote count: 2

http://stackoverflow.com/a/22013128
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/33366094
has body: You can use custom ListView In onPostExecute(Object obj) parse your data, and set the adapter.
has comment: http://stackoverflow.com/comment/33366772
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22012888
has comment: http://stackoverflow.com/comment/33366184
answers question: http://stackoverflow.com/q/22012888
upvote count: 3
has comment: http://stackoverflow.com/comment/33366732
type: AcceptedAnswer

http://stackoverflow.com/comment/33396708
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22020463
has text: Your example code shows you reading the lines into an array of `String`s. I don't see any attempt to parse those strings into a `GBar`. If you don't have any idea how to get started, you may wish to reevaluate your participation in class or approach your instructor.
score: 0

http://stackoverflow.com/comment/33635953
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22163359
type: Comment
has text: I am reading through it. BUt will it apply CenturySchoolBook font?

http://stackoverflow.com/q/22010686
type: Question
has comment: http://stackoverflow.com/comment/33364039
tagged with: jpa
score: 0
has body: I have query like this one: final String q = "SELECT level AS \"sibling_level\", tree.* FROM category_view tree " + "where tree.child_market = :market " + "connect by prior tree.cate_xre_id = tree.cate_id " + "start with tree.cate_id = -1 or tree.cate_id = -18"; final Query query = cqb.createNativeQuery(q, params, NSISegmentationTreeViewImpl.class); List&lt;NSISegmentationTreeViewImpl&gt; segList = query.getResultList(); category_view is an database view. I got sometimes: SQLGrammarException: ORA-00904: "NSISEGMENT0_"."SIBLING_LEVEL": invalid identifier its not deterministic sometimes i have good result sometimes i have error. Database ver is 11 Any ideas? Thanks. View def: CREATE OR REPLACE FORCE "CATEGORY_VIEW" ("PARENT_ID", "PARENT_NAME", "CHILD_ID", "CHILD_NAME", "CHILD_TYPE", "CHILD_PRIORITY", "CHILD_MARKET", "CATE_XRE_ID", "CATE_ID") AS WITH sibling AS (SELECT pare.category_id parent_id, pare.name parent_name, chld.category_id child_id, chld.name child_name, csga.value child_type, cpra.value child_priority, cmra.value child_market , paxr.sub_category_id cate_xre_id, pare.category_id cate_id, ) SELECT parent_id, parent_name , child_id, child_name, child_type, child_priority, child_market, cate_xre_id, cate_id, FROM sibling ORDER BY sibling.child_name; I removed unnecessary fields, structure is the same.
tagged with: oracle-database
has comment: http://stackoverflow.com/comment/33364452
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33362527
has title: JPA, Oracle, connect by prior, level - invalid identifier
tagged with: java

http://stackoverflow.com/q/22079290
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22079402
has title: Force Java 6 usage with Java 7 installed
tagged with: java
type: Question
upvote count: 4
answer count: 1
downvote count: 0
tagged with: runtime
has body: I am trying to get Java 6 and Java 7 to co-exist on about 8 computers. Most programs we are using use Java7, but this site: https://oas1.ost.state.ok.us/forms/frmservlet does not work with Java 7. I have researched a lot based on posts here and outside. It seems that all browsers default to Java7 if it is installed. I have tried disabling Java 7 on Internet Explorer, but even the Java 1.6.0_45 plug-in runs the jre7 version javaw.exe. Firefox shows no plug-in for Java 6 if Java 7 is installed, but if i remove Java7 it works fine.
score: 4
favorite count: 0

http://stackoverflow.com/a/22017733
answers question: http://stackoverflow.com/q/22013206
upvote count: 4
has comment: http://stackoverflow.com/comment/33402292
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33408639
accepted answer of: http://stackoverflow.com/q/22013206
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/33404140
has comment: http://stackoverflow.com/comment/37751266
downvote count: 1
has comment: http://stackoverflow.com/comment/33406785
has body: libcutils.so is shipped in ndk to enable renderscript integration. It remains an undocumented system library, in the sense that Android does not promise to support all its APIs on all platforms, and especially on future platforms, see more on on android-ndk user group. This said, I should acknowledge that using ashmem is quite safe, as it is explicitly documented in Java API since v.1. I wrote a short solution for linking against libcutils.so elsewhere on SO. Here is a discussion about ashmem_create_region() API and caveats with IPC through this: https://groups.google.com/forum/m/#!topic/android-platform/L6a6Xvn4HSI. tl;nr: you still need Binder for handshake. Your Java code can access fd using some workarounds. Update: new NDK r9d is out, and libcutils.so is no longer in the platforms/android-19/arch-arm/usr/lib directory, as @Tim Murray promised in comments below.

http://stackoverflow.com/comment/33644809
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22168078
type: Comment
has text: @Drx: It is null pointer Exception. You can solve it very easily. Just post 169 line. You will get direct answer for this

http://stackoverflow.com/comment/33468807
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22070709
has text: So to clarify - you click a submit button which opens a new webpage and on that page is the `xml` data you want to parse?
type: Comment

http://stackoverflow.com/q/22098667
has title: Why are there only 63 bits in java.lang.Long(MAX_VALUE)?
has answer: http://stackoverflow.com/a/22098752
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33519659
tagged with: java
has comment: http://stackoverflow.com/comment/33519340
upvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33553431
tagged with: long-integer
accepted answer: http://stackoverflow.com/a/22098752
has comment: http://stackoverflow.com/comment/33519485
tagged with: max
answer count: 1
has comment: http://stackoverflow.com/comment/33519290
downvote count: 0
has comment: http://stackoverflow.com/comment/33520090
has comment: http://stackoverflow.com/comment/33519314
score: 1
favorite count: 0
tagged with: binary
has comment: http://stackoverflow.com/comment/33519910
has body: Can anyone explain the difference between the output from the two println statements below? public class LongTest { public static void main(String[] args) { System.out.println(Long.toBinaryString(0xffff_ffff_ffff_ffffL)); System.out.println(java.lang.Long.toBinaryString(Long.MAX_VALUE)); } } The output is: 1111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111111111111111 The first line of output contains 64 binary digits. The second line only contains 63 binary digits. If if 0xffff_ffff_ffff_ffffL were greater than Long.MAX_VALUE, I would expect a compiler error. But the program obviously does compile, so the difference in output must be due to some other reason.

http://stackoverflow.com/comment/33583896
type: Comment
has text: @SotiriosDelimanolis struggling to solve this problem, appreciate any help to find solution to this
comment on: http://stackoverflow.com/q/22133615
score: 0
type: QuestionComment

http://stackoverflow.com/q/22120093
tagged with: linux
has answer: http://stackoverflow.com/a/22120176
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33558526
tagged with: netbeans
tagged with: java
has comment: http://stackoverflow.com/comment/33558483
upvote count: 1
type: Question
downvote count: 0
tagged with: ubuntu
has body: im new at ubuntu and i want to use netbeans. I downloaded netbeans from its web site then I wrote this commands to the line hakki@hakki-K55VM:~/Downloads$ chmod +x netbeans-7.4-linux.sh hakki@hakki-K55VM:~/Downloads$ sudo bash netbeans-7.4-linux.sh [sudo] password for hakki: Configuring the installer... Searching for JVM on the system... Java SE Development Kit (JDK) was not found on this computer JDK 7 is required for installing the NetBeans IDE. Make sure that the JDK is properly installed and run installer again. You can specify valid JDK location using --javahome installer argument. To download the JDK, visit http://www.oracle.com/technetwork/java/javase/downloads After I get above notification I tried to install JDK with these commands hakki@hakki-K55VM:~$ sudo apt-get install openjdk-7-jre-headless .... done then I controled jdk installed properly and it returned below lines hakki@hakki-K55VM:~$ java -version java version "1.7.0_51" OpenJDK Runtime Environment (IcedTea 2.4.4) (7u51-2.4.4-0ubuntu0.13.10.1) OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode) After I download jdk I tried to install netbeans again but still it returns error and it cant initialize UI. How can I solve this problem? hakki@hakki-K55VM:~/Downloads$ sudo bash netbeans-7.4-linux.sh Configuring the installer... Searching for JVM on the system... Extracting installation data... Running the installer wizard... Can`t initialize UI Running in headless mode Exception: java.awt.HeadlessException thrown from the UncaughtExceptionHandler i
answer count: 1
score: 1
favorite count: 0
has title: I just try to install Netbeans but there are more probs with JDK

http://stackoverflow.com/q/22113759
answer count: 1
upvote count: 1
has body: For example, I have several friends who have labels such as teachers , doctors , singers. How can I get all my teacher friends? I can reach my goal by Cypher ,but I want more efficient ways like Java-api functions. I mean I want to get all the nodes from the node “I”, so the following way doesn't work for me GlobalGraphOperations.at(graphDb).getAllNodesWithLabel(DynamicLabel.label('teacher')); Thx for anybody can give me some advice.
tagged with: neo4j
has answer: http://stackoverflow.com/a/22115924
favorite count: 0
has title: How to get nodes or traverse by labels in Neo2.x
downvote count: 0
type: UnansweredQuestion
score: 1
tagged with: java
type: Question

http://stackoverflow.com/a/22119912
has comment: http://stackoverflow.com/comment/33558919
answers question: http://stackoverflow.com/q/22119680
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/33561417
accepted answer of: http://stackoverflow.com/q/22119680
has body: The given exception indicates that you have a runtime dependency on Java Advanced Imaging (JAI). You need additional JARs not provided with the standard JDK. Here are the JAI and JAI ImageIO Tools installation instructions: http://download.java.net/media/jai/builds/release/1_1_3/INSTALL.html#Windows http://download.java.net/media/jai-imageio/builds/release/1.1/INSTALL-jai_imageio.html#Windows You can download the installers here: http://download.java.net/media/jai/builds/release/1_1_3/ http://download.java.net/media/jai-imageio/builds/release/1.1/ Once you install JAI, you will need to include the extracted JARs in your project classpath. Maven If using Maven, JAI and JAI ImageIO Tools can be used for your project without installers: com.sun.media jai_imageio 1.1
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33558647
type: Answer

http://stackoverflow.com/q/22089940
has body: I need to track whether the application is running at webserver or NOT. For this i code one java application which sends the http request to server and track whether application is running or NOT based on response. Now i have load balancer which is balancing load among 3 server running same application and i am sending the same request , then how to find out the ip of the machine from which i am getting the response so that i can track whether application is running on that server or not. My application will run in local network where all server are running. Hopefully i am able to explain my question.
tagged with: web-development-server
type: AnsweredQuestion
tagged with: java
type: Question
answer count: 1
has answer: http://stackoverflow.com/a/22090154
score: 0
has title: To track status of application running at web server
accepted answer: http://stackoverflow.com/a/22090154
tagged with: web-services

http://stackoverflow.com/q/22149962
accepted answer: http://stackoverflow.com/a/22150070
type: Question
tagged with: derby
answer count: 2
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/22150126
has body: I am new to Apache Derby database, When i am trying to crate new database using the following command i am getting the below problem C:\&gt;java org.apache.derby.tools.ij ij version 10.10 ij&gt; connect 'jdbc:derby:Mynewdb;create=true'; Mon Mar 03 20:17:32 IST 2014 Thread[main,5,main] java.io.FileNotFoundException: derby.log (Access is denied) ---------------------------------------------------------------- Mon Mar 03 20:17:33 IST 2014: Booting Derby version The Apache Software Foundation - Apache Derby - 10.10.1.1 - (1458268): instance a816c00e-0144-886a-02f2-000000b8d0b0 on database directory C:\Mynewdb with class loader sun.misc.Launcher$AppClassLoader@11b86e7 Loaded from file:/C:/db-derby-10.10.1.1-bin/db-derby-10.10.1.1-bin/lib/derby.jar java.vendor=Sun Microsystems Inc. java.runtime.version=1.6.0_23-b05 user.dir=C:\ os.name=Windows 7 os.arch=x86 os.version=6.1 derby.system.home=null Database Class Loader started - derby.database.classpath=''
has answer: http://stackoverflow.com/a/22150070
score: 6
tagged with: jdbc
has title: apache Derby - getting java.io.FileNotFoundException: derby.log (Access is denied) when creating new database
possible better answer: http://stackoverflow.com/a/22150126
upvote count: 6
type: AnsweredQuestion
tagged with: java
linked to: http://stackoverflow.com/q/1004327

http://stackoverflow.com/comment/33362128
comment on: http://stackoverflow.com/q/22010530
score: 0
has text: Why do you think that dependency injection is going to happen when running this code as a regular client application?
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33499773
type: Comment
score: 0
has text: When you run with the webserver, are you classes available in the WEB-INF/classes folder?
comment on: http://stackoverflow.com/q/22081726
type: QuestionComment

http://stackoverflow.com/q/22157521
has body: I'm developing some modelling software in C# which relies heavily on compiled mathematical statements. They are built at runtime using Linq Expressions giving me native performance. Performance is critical as formulas are run billions of times. Longer term I'm considering moving the project to Java. However Java doesn't seem to have an equivalent library. What options can the Java platform provide for compiling mathematical statements at run-time &amp; getting native performance? (P.S. apparently Java 8 will support lambda expressions, but I doubt the framework be as advanced as Linq.Expressions)
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33625753
tagged with: expression
has comment: http://stackoverflow.com/comment/33625700
tagged with: java
has answer: http://stackoverflow.com/a/22157662
linked to: http://stackoverflow.com/q/3384970
type: Question
tagged with: c#
answer count: 1
linked to: http://stackoverflow.com/q/2946338
tagged with: linq
score: 0
has title: What alternatives does Java provide for C# expressions?

http://stackoverflow.com/comment/33552586
score: 0
type: Comment
has text: @Shraddhabhatt, feel free to ask any further questions and if you find my answer useful don`t forget to vote it up.
type: AnswerComment
comment on: http://stackoverflow.com/a/22107581

http://stackoverflow.com/q/22012061
type: Question
answer count: 2
tagged with: for-loop
downvote count: 0
has answer: http://stackoverflow.com/a/22012679
has comment: http://stackoverflow.com/comment/33370589
linked to: http://stackoverflow.com/q/2710300
possible better answer: http://stackoverflow.com/a/22012723
accepted answer: http://stackoverflow.com/a/22012679
has answer: http://stackoverflow.com/a/22012723
favorite count: 0
has comment: http://stackoverflow.com/comment/33366738
has body: Can someone explain me why my loop is going from 0 to 7? I need to get only in the first 3 cases, but the program is going through all.. The code is in the show() method. for(brojac=0; brojac&lt;3; brojac++){ switch(brojac){ case 1: figura1.setPosition(pomx[random], pomy[random]); stage.addActor(figura1); System.out.println("1"); case 2: figura2.setPosition(pomx[random], pomy[random]); stage.addActor(figura2); System.out.println("2"); case 3: figura3.setPosition(pomx[random], pomy[random]); stage.addActor(figura3); System.out.println("3"); case 4: figura4.setPosition(pomx[random], pomy[random]); stage.addActor(figura4); System.out.println("4"); case 5: figura5.setPosition(pomx[random], pomy[random]); stage.addActor(figura5); System.out.println("5"); case 6: figura6.setPosition(pomx[random], pomy[random]); stage.addActor(figura6); System.out.println("6"); case 7: figura7.setPosition(pomx[random], pomy[random]); stage.addActor(figura7); System.out.println("7"); } }
has title: Switch executes all case statements
upvote count: 1
has comment: http://stackoverflow.com/comment/57686497
tagged with: case
type: AnsweredQuestion
score: 1
tagged with: java

http://stackoverflow.com/comment/33386039
comment on: http://stackoverflow.com/q/22020652
has text: Yup I see it now, and `StringBuilder` does indeed create a new String.
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/q/22108774
tagged with: jsp
tagged with: javascript
upvote count: 1
has answer: http://stackoverflow.com/a/22161089
linked to: http://stackoverflow.com/q/3177733
has title: NumberFormatException -- Validating form submissions in a JSP file?
possible better answer: http://stackoverflow.com/a/22108808
has body: My pressing question is how to best handle this exception in a JSP web form, however I believe the below might also be able to provide an answer. I've been messing around with a java project which I have implemented as an applet/JFrame and also a web form via a JSP. In the last class I took (essentially Java 1), the method I learned for handling Exceptions such as NumberFormatException when a user is entering data is via a try/catch block within an ActionListener. Example: private ActionListener L_Weight() { return new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { double weight = Person.DEFAULT_WEIGHT; try { weight = Double.parseDouble(ae.getActionCommand()); } catch (NumberFormatException e) { //e.printStackTrace(); } person = new Person( person.getGender(), weight, person.getAge(), person.getNumberOfDrinks(), person.getHoursSinceFirstDrink()); view.updatePerson(person); } }; } So while this works for the applet/JFrame, it doesn't seem like the best usage of try/catch, I don't know what to do with the NumberFormatException other than ignore it, and it does nothing for me on the web form side. So on the web side, I have found various ideas for handling exceptions/errors, but none seem like they are the best option. My current favorite is to add onsubmit="return checkForm(this)" to my form submission, where checkForm() is javascript code that will return true if valid data is submitted. This still seems like an extraneous step, but other than declaring the variables as Strings and parsing them as doubles so that I can do try/catch errorhandling on the java side, I'm not sure where else I can validate the submissions. So I implemented the checkForm() function and it's working, just wondering if this is a good practice for form validation in a JSP: function checkForm(form) { var result = true; var numbers = /^[0-9|\.]+$/; var checkFields = new Array( form.age, form.weight, form.drinks, form.hours); for (i=0; i < checkFields.length; i++) { i…
favorite count: 0
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
tagged with: forms
has answer: http://stackoverflow.com/a/22108808
type: Question
answer count: 2
accepted answer: http://stackoverflow.com/a/22161089

http://stackoverflow.com/comment/33420233
comment on: http://stackoverflow.com/q/22027289
type: Comment
type: QuestionComment
has text: I was just using file_name.jar as a placeholder. The actual errors were `bash: stanford-corenlp-3.3.1-models.jar: command not found -bash: xom.jar: command not found -bash: joda-time.jar: command not found`.
score: 0

http://stackoverflow.com/a/22073691
has comment: http://stackoverflow.com/comment/33536884
has comment: http://stackoverflow.com/comment/33547354
has comment: http://stackoverflow.com/comment/33554368
has comment: http://stackoverflow.com/comment/33547008
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/33525334
has comment: http://stackoverflow.com/comment/33553684
answers question: http://stackoverflow.com/q/22071804
has comment: http://stackoverflow.com/comment/33544064
has comment: http://stackoverflow.com/comment/33555064
has comment: http://stackoverflow.com/comment/33528798
score: 1
has body: So if you have a basic set S = {1, 2}, then K = 2 and the set of subsets of S is {{}, {1}, {2}, {1,2}}. Assume n is still 2. Then your output will be something like ({}, {}) ({1}, {}); ({2}, {}); ({}, {1}); ({}, {2}) ({1,2}, {}); ({}, {1,2}) ({1}, {1}); ({1}, {2}); ({2}, {1}); ({2}, {2}) ({1}, {1,2}); ({1,2}, {1}); ({2}, {1,2}); ({1,2}, {2}) ({1,2}, {1,2}) Correct? The ordering with the output is a bit difficult because the result isn't fully ordered. But it still boils down to counting. Not, as I initially thought, (K+1)-ary but more (2^K)-ary. In order to determine if one set is a subset of another, using primes might be an idea. You assign a prime number to each element of your original set. In my example, that would be 2 and 3. The set of subsets can be build by generating all products of the prime numbers. In my example that would be {1 /* empty set */, 2, 3, 6}. If you have two sets, represented by your product it is easy to test the inclusion: if (a % b == 0) then b is a subset of a It's just a bunch of ideas, but they might help you finding a solution. Of course, the prime trick only works for a relatively small number of elements in your original set, but as soon as K and N grow, you'll get problems anyway. (The number of elements in your output will be (2^K)^N = 2^(NK). If K == N == 5, you'll have 2^(5 * 5) = 2^25, about 32 million output elements. And here the prime thought still works). Edit: Well I wrote a small Java Program to show my ideas. save it to Hasse.java compile it: javac Hasse.java run it: java Hasse &gt; hasse.dot run dot: dot -Tpdf -ohasse.pdf hasse.dot view it: acroread hasse.pdf Source Code: import java.lang.*; import java.util.*; public class Hasse { private static int K[] = { 1, 2, 3 }; private static int N = 2; private static int prime[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 }; // // PK[0][] is the array of "subsets" // PK[1][] is the array of number of elements of K particip…
has comment: http://stackoverflow.com/comment/33553831
downvote count: 0
has comment: http://stackoverflow.com/comment/33555226
has comment: http://stackoverflow.com/comment/33507480
has comment: http://stackoverflow.com/comment/33554460
has comment: http://stackoverflow.com/comment/33544212
has comment: http://stackoverflow.com/comment/33552213

http://stackoverflow.com/a/22080336
has comment: http://stackoverflow.com/comment/33488616
has comment: http://stackoverflow.com/comment/33487865
answers question: http://stackoverflow.com/q/22080151
score: 1
has body: dont set 404 status ,set null for this case,ant error status like 404 means creating html for that
has comment: http://stackoverflow.com/comment/33511135
upvote count: 1
type: Answer
downvote count: 0

android
tags question: http://stackoverflow.com/q/22096412
tags question: http://stackoverflow.com/q/22119916
tags question: http://stackoverflow.com/q/22034854
tags question: http://stackoverflow.com/q/22119045
tags question: http://stackoverflow.com/q/22116969
tags question: http://stackoverflow.com/q/22090672
tags question: http://stackoverflow.com/q/22063509
tags question: http://stackoverflow.com/q/22124711
tags question: http://stackoverflow.com/q/22058421
tags question: http://stackoverflow.com/q/22033423
tags question: http://stackoverflow.com/q/22017285
tags question: http://stackoverflow.com/q/22116113
tags question: http://stackoverflow.com/q/22131154
tags question: http://stackoverflow.com/q/22029815
tags question: http://stackoverflow.com/q/22068011
tags question: http://stackoverflow.com/q/22038850
tags question: http://stackoverflow.com/q/22121915
tags question: http://stackoverflow.com/q/22030574
tags question: http://stackoverflow.com/q/22087563
tags question: http://stackoverflow.com/q/22120756
tags question: http://stackoverflow.com/q/22008707
tags question: http://stackoverflow.com/q/22146362
tags question: http://stackoverflow.com/q/22079082
tags question: http://stackoverflow.com/q/22091189
tags question: http://stackoverflow.com/q/22086273
tags question: http://stackoverflow.com/q/22027904
tags question: http://stackoverflow.com/q/22082278
tags question: http://stackoverflow.com/q/22074926
tags question: http://stackoverflow.com/q/22133940
tags question: http://stackoverflow.com/q/22041519
tags question: http://stackoverflow.com/q/22093145
tags question: http://stackoverflow.com/q/22138549
tags question: http://stackoverflow.com/q/22075586
tags question: http://stackoverflow.com/q/22024899
tags question: http://stackoverflow.com/q/22137947
tags question: http://stackoverflow.com/q/22127725
tags question: http://stackoverflow.com/q/22101479
tags question: http://stackoverflow.com/q/22027763
tags question: http://stackoverflow.com/q/22071595
tags question: http://stackoverflow.com/q/22023049
tags question: http://stackoverflow.com/q/22043525
tags question: http://stackoverflow.com/q/22110624
tags question: http://stackoverflow.com/q/22029734
tags question: http://stackoverflow.com/q/22025831
tags question: http://stackoverflow.com/q/22107805
tags question: http://stackoverflow.com/q/22068597
tags question: http://stackoverflow.com/q/22125600
tags question: http://stackoverflow.com/q/22076622
tags question: http://stackoverflow.com/q/22041968
tags question: http://stackoverflow.com/q/22069934
tags question: http://stackoverflow.com/q/22132179
tags question: http://stackoverflow.com/q/22122479
tags question: http://stackoverflow.com/q/22133406
tags question: http://stackoverflow.com/q/22058223
tags question: http://stackoverflow.com/q/22160693
tags question: http://stackoverflow.com/q/22050639
tags question: http://stackoverflow.com/q/22053616
tags question: http://stackoverflow.com/q/22071632
tags question: http://stackoverflow.com/q/22068007
tags question: http://stackoverflow.com/q/22092722
tags question: http://stackoverflow.com/q/22034992
tags question: http://stackoverflow.com/q/22031711
tags question: http://stackoverflow.com/q/22050636
tags question: http://stackoverflow.com/q/22156845
tags question: http://stackoverflow.com/q/22157116
tags question: http://stackoverflow.com/q/22118063
tags question: http://stackoverflow.com/q/22114576
tags question: http://stackoverflow.com/q/22081370
tags question: http://stackoverflow.com/q/22077370
tags question: http://stackoverflow.com/q/22059779
tags question: http://stackoverflow.com/q/22032976
tags question: http://stackoverflow.com/q/22161718
tags question: http://stackoverflow.com/q/22030654
tags question: http://stackoverflow.com/q/22107128
tags question: http://stackoverflow.com/q/22072482
tags question: http://stackoverflow.com/q/22099905
tags question: http://stackoverflow.com/q/22123048
tags question: http://stackoverflow.com/q/22158432
tags question: http://stackoverflow.com/q/22154613
tags question: http://stackoverflow.com/q/22079030

http://stackoverflow.com/q/22069908
has answer: http://stackoverflow.com/a/22070271
has comment: http://stackoverflow.com/comment/33489457
has title: Edit dynamically created button in android
has answer: http://stackoverflow.com/a/22071171
has comment: http://stackoverflow.com/comment/33467266
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33467488
type: Question
accepted answer: http://stackoverflow.com/a/22071171
has answer: http://stackoverflow.com/a/22070068
has body: I am working on an android server-client application. There is a connection between the android application and the server. Based on the first message from the server, a number of buttons is created and displayed on the screen. This number usually is between 1 and 10. I don't want to initialise 10 buttons in my activity, as maybe, in the future, the number of buttons will increase to 20. This is the way I initialise buttons and show them on the screen: actionButtons = server.getActionButtons(); TableLayout buttonLayout = (TableLayout) rootView.findViewById(R.id.tblLayoutButtons); for(int i=0; i&lt; actionButtons.length; i++) { btnAction.setWidth(100); btnAction.setHeight(50); btnAction.setTag(actionButtons[i]); btnAction.setText(actionButtons[i].getName()); btnAction.setOnClickListener(btnActionClick); buttonLayout.addView(btnAction); } This all works well. But my problem is that the server sends statusupdates for the buttons, every 3 seconds. Each button stands for a light, that can be on or off. A button that is 'ON' should have another background than a button that is 'OFF'. The buttons should be updated every time an update from the server is received. How could this be done?
score: 0
answer count: 3
tagged with: android
possible better answer: http://stackoverflow.com/a/22070068
tagged with: service

http://stackoverflow.com/q/22072872
upvote count: 1
linked to: http://stackoverflow.com/q/5742543
has body: ErrorrAn invalid XML character (Unicode: 0xb) was found in the element content of the document. I get this error when i am trying to parse an xml data using dom parser ? What is the reason ? How can i solve this problem ? EDIT Here is the XML file snippet <CIRS><CIR applicantId="131906564" loanId="126907905" applicantRefId="TSFI012095G1" fan="TSFI012095"><REQUESTDATA> D DUNSTON JOSEPH WILFRED 31-07-1966 Male PASSPORT NUMBER H3359853 DRIVER'S LICENSE NUMBER R/TN/69/005545/2005 95412563#25,23778#34,87976#54 I guess the problem is in phone number tag 95412563#25,23778#34,87976#54
type: Question
has answer: http://stackoverflow.com/a/27719567
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33474218
has title: ErrorrAn invalid XML character (Unicode: 0xb) was found in the element content of the document while parsing xml with DOM parser
tagged with: domparser
tagged with: xml-parsing
downvote count: 0
answer count: 1
has comment: http://stackoverflow.com/comment/33472868
favorite count: 0
has comment: http://stackoverflow.com/comment/33472765
tagged with: http://stackoverflow.com/tag/xml
has comment: http://stackoverflow.com/comment/33472816
type: UnansweredQuestion

http://stackoverflow.com/q/22040251
upvote count: 1
type: Question
tagged with: jena
score: 1
tagged with: java
has title: Failing to create first instance of Jena TDB
has body: public void createDatabase(){ // Make a TDB-backed dataset String directory = "MyDatabases/ex1/" ; Dataset dataset = TDBFactory.createDataset(directory) ; dataset.begin(ReadWrite.READ) ; // Get model inside the transaction Model model = dataset.getDefaultModel() ; dataset.end() ; dataset.begin(ReadWrite.WRITE) ; model = dataset.getDefaultModel() ; dataset.end() ; } I have this very simple piece of code copied directly from the Jena's api webpage (http://jena.apache.org/documentation/tdb/java_api.html) trying to create a database. Getting an error when calling createDataset: Exception in thread "main" java.lang.IllegalAccessError: tried to access method com.hp.hpl.jena.sparql.core.DatasetImpl.&lt;init&gt;(Lcom/hp/hpl/jena/sparql/core/DatasetGraph;)V from class com.hp.hpl.jena.tdb.TDBFactory at com.hp.hpl.jena.tdb.TDBFactory.createDataset(TDBFactory.java:91) at com.hp.hpl.jena.tdb.TDBFactory.createDataset(TDBFactory.java:83) at com.hp.hpl.jena.tdb.TDBFactory.createDataset(TDBFactory.java:79)
downvote count: 0
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/22048283
tagged with: tdb
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22048283

http://stackoverflow.com/q/22029815
type: Question
has body: I'm a beginner of "Qt for Android" and now I'm using it to develop a communication oftware based on mobile.I hava developed java functions that call android's api as a class in a .java document.In order to Simplify UI development,the UI is based on Qt Widget program.Then I use the Qt-JNI class "QAndroidJniObject" to call these java functions according to Qt5.2 API document.Android resource file is stored in the directory:./android/src/com/comm/sipcall/SipCallSend.java.Since the less information in this regard,I developed the java and c++ program according to API document.But I encountered the following problems, and also hope to get answers: 1) The Qt program is based on Qt Widget.The java program needs to get the current application object Context in order to initialize java object.The c++ code I developed as following: //c++: QPlatformNativeInterface *interface = QApplication::platformNativeInterface(); jobject activity = (jobject)interface-&gt;nativeResourceForIntegration("QtActivity"); QAndroidJniObject* at = new QAndroidJniObject(activity); QAndroidJniObject appctx = at-&gt;callObjectMethod("getApplicationContext","()Landroid/content/Context;"); //.pro： QT += core gui gui-private Is this right? 2) The java class contains a constructor function and three public functions: java: package com.comm.sipcall; improt XXXX .... .... public class SipCallSend extends Activity { private Context context; // 接收QT的context public String sipToAddress = ""; public String sipDomain = ""; public String user_name = ""; public String pass_word = ""; public SipCallSend(){ Log.i("ddd","init"); sipToAddress = ""; sipDomain = ""; user_name = ""; pass_word = ""; } public void SetContext(Context cnt) { this.context = cnt; //Log.i("ccc",user_name); } public int Login(String domain,String username,String password){ .... sipDomain = domain; user_name = username; pass_word = password; ... return 0; } public int Call(String addrNum) { ... return 0; } } C++： QPlatformNativeInterface *interface …
tagged with: qandroidjniobject
has title: How to use the Qt Jni class "QAndroidJniObject"
score: 8
favorite count: 0
type: UnansweredQuestion
tagged with: android
tagged with: qt
tagged with: c++
has comment: http://stackoverflow.com/comment/47930267
answer count: 0
downvote count: 0
tagged with: java
upvote count: 8

http://stackoverflow.com/comment/33444284
score: 2
has text: Probably not a great idea. You should probably look into using your container's connection pool. If your container does not have one, then you might need to investigate some other connection pool implementations.
comment on: http://stackoverflow.com/q/22056379
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22094125
has comment: http://stackoverflow.com/comment/33511115
has body: I am using colors in Android but I don't know the format. Here's a working example in JAVA. public Color getColor(int i) { switch (i%8) { case 0: return Color.blue; case 1: return Color.red; case 2: return Color.magenta; case 3: return Color.orange; case 4: return Color.pink; case 5: return Color.green; case 6: return Color.cyan; case 7: return new Color(250, 220, 100); } return (new Color((i*80)%255,(i*80)%255,(i*80)%255)) ; } How can I create this using Android. What I'm trying to do is return a color of eight possibilities.
has comment: http://stackoverflow.com/comment/33510993
type: Question
tagged with: function
possible better answer: http://stackoverflow.com/a/22094304
has answer: http://stackoverflow.com/a/22094304
tagged with: colors
answer count: 3
downvote count: 0
has answer: http://stackoverflow.com/a/22130243
favorite count: 0
tagged with: return
has title: Colors in Android
tagged with: android
accepted answer: http://stackoverflow.com/a/22130243
has answer: http://stackoverflow.com/a/22094308
has comment: http://stackoverflow.com/comment/33511001
type: AnsweredQuestion
score: 3
has comment: http://stackoverflow.com/comment/33511145
upvote count: 3
tagged with: java

http://stackoverflow.com/comment/33549965
has text: His point was more that your ShoeComparator doesn't implement the Comparator interface.
type: Comment
comment on: http://stackoverflow.com/a/22114102
score: 0
type: AnswerComment

jax-ws
tags question: http://stackoverflow.com/q/22067622
tags question: http://stackoverflow.com/q/22006092
tags question: http://stackoverflow.com/q/22157589
type: Tag
tags question: http://stackoverflow.com/q/22082747
tags question: http://stackoverflow.com/q/22045926
tags question: http://stackoverflow.com/q/22022387
tags question: http://stackoverflow.com/q/22127090
tag name: jax-ws

http://stackoverflow.com/comment/33448454
has text: If your Picture is [this one](http://www2.cs.uic.edu/~i101/doc/Picture.html) it's possible your coordinates for addMessage should be `20,height-20` if you want to draw it in the bottom left. According to that doc the x is the leftmost position of the String (same for other AWT/Swing coordinates). IE you might be drawing it off the righthand side of the image.
type: Comment
comment on: http://stackoverflow.com/a/22058634
score: 1
type: AnswerComment

http://stackoverflow.com/comment/127627230
has text: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/72228499

http://stackoverflow.com/comment/33598350
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22142405
has text: Thank you so much.I was so close but never got there.
type: Comment

http://stackoverflow.com/comment/33575860
type: QuestionComment
has text: You want a `Map<Drug, List<SideEffect>>`. Or a Guava `Multimap<Drug, SideEffect>`. A `Map<Drug, SideEffect[]>` is possible as well, but arrays are fixed-length. How did you test it?
comment on: http://stackoverflow.com/q/22129523
type: Comment
score: 0

http://stackoverflow.com/q/22168755
has answer: http://stackoverflow.com/a/22169288
tagged with: android
linked to: http://stackoverflow.com/q/17821825
tagged with: connection
type: AnsweredQuestion
upvote count: 1
accepted answer: http://stackoverflow.com/a/22169288
type: Question
score: 1
tagged with: java
has body: I have an Android Application that has to fetch an XML file from a particular URL. To do this, I first check if an internet connection is available and if so, I download the file. This works fine. The issue happens when I use my app in a network where users can connect to the internet but need to provide a username and password before they can access any page i.e. Limited Access. How can I test for Limited Access to the network? Thanks.
has title: How to test for 'Limited Access' to the Internet
answer count: 1
downvote count: 0
favorite count: 0

http://stackoverflow.com/comment/33426243
score: 0
has text: I don't think that would be the problem, because I'm using mule and internally it uses db.authenticate(username, password.toCharArray()) check https://github.com/mulesoft/mongo-connector/blob/master/src/main/java/org/mule/module/mongo/MongoCloudConnector.java line 1257
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22046308

http://stackoverflow.com/comment/33465564
type: QuestionComment
comment on: http://stackoverflow.com/q/22068871
has text: Just check em is not null, other thn this no any object can throw such exeption
score: 0
type: Comment

java-8
tags question: http://stackoverflow.com/q/22096052
tags question: http://stackoverflow.com/q/22061599
tags question: http://stackoverflow.com/q/22106130
tags question: http://stackoverflow.com/q/22020887
tags question: http://stackoverflow.com/q/22016091
tags question: http://stackoverflow.com/q/22046690
tags question: http://stackoverflow.com/q/22140955
tags question: http://stackoverflow.com/q/22037263
tags question: http://stackoverflow.com/q/22125169
tags question: http://stackoverflow.com/q/22056566
tags question: http://stackoverflow.com/q/22157957
tags question: http://stackoverflow.com/q/22049931
tags question: http://stackoverflow.com/q/22090362
tags question: http://stackoverflow.com/q/22083689
tag name: java-8
tags question: http://stackoverflow.com/q/22060894
tags question: http://stackoverflow.com/q/22129471
type: Tag
tags question: http://stackoverflow.com/q/22052330
tags question: http://stackoverflow.com/q/22022359

http://stackoverflow.com/q/22083494
possible better answer: http://stackoverflow.com/a/22083590
has answer: http://stackoverflow.com/a/22083685
has answer: http://stackoverflow.com/a/22083590
has comment: http://stackoverflow.com/comment/33492845
upvote count: 1
type: AnsweredQuestion
score: 0
tagged with: java
has title: adding the total of each int in a string
has comment: http://stackoverflow.com/comment/33492768
downvote count: 1
accepted answer: http://stackoverflow.com/a/22083685
type: Question
has comment: http://stackoverflow.com/comment/33492832
answer count: 2
has comment: http://stackoverflow.com/comment/33493268
has comment: http://stackoverflow.com/comment/33492846
has body: I have 9 numbers in an string. I would like to add them all together. I am not sure what I am missing I keep getting an error on moons. What is the correct way to write this? moons is defined in the Planet class this is the Solar System class: moons holds the number of each planets moons. Ok i posted full code. in driver i add the planets and how many moons they have. I want to add all the moons together now in the SolarSystem class and System.out.println them package planets; public class Planet { String name; int moons; public Planet(String name, int moons) { this.moons = moons; this.name = name; } public String toString() { return "The Planet " + name + " Has " + moons + " Moon(s) \r\n "; } } package planets; public class SolarSystem { private Planet[]planets; private int position = 0; Planet[]moons; public SolarSystem(int size) { planets = new Planet[size]; } public void add(Planet planet) { planets[position] = planet; position++; } public int sum(Planet moons) { int sum = 0; for(int i = 0; i &lt; moons(); i++) sum += moons[]; } return sum; } public String toString(){ String result = ""; for(int i = 0; i &lt; planets.length; i++){ result += planets[i].toString(); } System.out.println("You Have " + position + " Planets In Your Solar System"); return result; } } package planets; public class Driver { public static void main(String[]args) { Planet mercury = new Planet ("Mercury", 0); Planet venus = new Planet ("Venus", 0); Planet earth = new Planet ("Earth", 1); Planet mars = new Planet ("Mars", 2); Planet jupiter = new Planet ("Jupiter", 67); Planet saturn = new Planet ("Saturn", 62); Planet uranus = new Planet ("Uranus", 27); Planet neptune = new Planet ("Neptune", 14); Planet pluto = new Planet ("Pluto", 5); SolarSystem solarSystem = new SolarSystem(9); solarSystem.add(mercury); solarSystem.add(venus); solarSystem.add(earth); solarSystem.add(mars); solarSystem.add(jupiter); solarSystem.add(saturn); solarSystem.add(uranus); solarSystem.add(neptune); solarSystem.a…
has comment: http://stackoverflow.com/comment/33492869
has comment: http://stackoverflow.com/comment/33492871
tagged with: string
has comment: http://stackoverflow.com/comment/33492772
favorite count: 0

http://stackoverflow.com/a/22142521
answers question: http://stackoverflow.com/q/22142456
score: 0
has body: When you want to read more lines then one, you should set the newline (System.getProperty("line.separator")) as separator as well.
type: Answer

http://stackoverflow.com/comment/33360775
comment on: http://stackoverflow.com/a/22009283
has text: @user3350193 The first MyFraction object is the current instance of the MyFraction class (`this`) and the second is the `o` parameter (`o` is short for `other`).
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/22097602
has comment: http://stackoverflow.com/comment/33517553
type: Answer
has body: The exception is thrown. If ran, you would see: RuntimeException("Couldn't do stuff.") Do what's in finally. If there was an outer try/catch that caught the RuntimeException, then the program could feasibily continue. The continue statement in the finally block is useless. The only time finally won't be called is if you call System.exit() or if the JVM crashes first.
score: 1
answers question: http://stackoverflow.com/q/22097466
upvote count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/33517869

http://stackoverflow.com/comment/33568696
comment on: http://stackoverflow.com/a/22124922
has text: Well, for starters, you don't have to repeat this part `java.util.logging.Logger.getLogger( YourClassNameGoeshere.class.getName() )` over and over
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/22135640
has answer: http://stackoverflow.com/a/22136062
tagged with: class
tagged with: public-members
has title: Why am I able to have a public member in a non-public class?
upvote count: 26
has comment: http://stackoverflow.com/comment/33588009
has body: class MyClass { public static final int num=90; } Why am I allowed to create a public member in a non-public class? Is there another way of accessing this member that I do not know of (other than through the class name)?
favorite count: 0
has comment: http://stackoverflow.com/comment/33587783
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33589784
answer count: 4
downvote count: 0
tagged with: java
linked to: http://stackoverflow.com/q/6264657
type: Question
has comment: http://stackoverflow.com/comment/33589415
has answer: http://stackoverflow.com/a/22136092
has answer: http://stackoverflow.com/a/22135797
score: 26
has answer: http://stackoverflow.com/a/22135791

http://stackoverflow.com/comment/33365988
type: AnswerComment
score: 0
has text: Thank you, you really cleared my doubt. As you mentioned I was confusing keyspaces with tables.
comment on: http://stackoverflow.com/a/22012348
type: Comment

http://stackoverflow.com/comment/33669303
score: 0
comment on: http://stackoverflow.com/q/22136168
type: Comment
type: QuestionComment
has text: @user3203425 Seriously, look at my blog post linked above. I wrote that due to Oracle issues with WebLogic but it worked there.

http://stackoverflow.com/a/22064806
has body: public static void max1(int[][] score) { for (int i = 0; i &lt; score.length; i++) { int max = -1; for (int j = 0; j &lt; score[i].length; j++) if (score[i][j] &gt; max) max = score[i][j]; System.out.println("max: '" + max + "'"); } } And perhaps you switched your columns and rows, means you have to switch the code too, happened already a lot to me. Try to check if i is your rows and j is your columns.
downvote count: 0
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/22064558

http://stackoverflow.com/comment/33533416
score: 3
comment on: http://stackoverflow.com/q/22105991
has text: (Also known as a "character class" in the appropriate context. There is no need for them in this case, as `"\t"` would have been equivalent, but maybe it was/will be `"[\t-]"` or something else..)
type: Comment
type: QuestionComment

recursion
type: Tag
tags question: http://stackoverflow.com/q/22077875
tags question: http://stackoverflow.com/q/22148860
tags question: http://stackoverflow.com/q/22081231
tags question: http://stackoverflow.com/q/22027030
tags question: http://stackoverflow.com/q/22055757
tags question: http://stackoverflow.com/q/22039528
tag name: recursion
tags question: http://stackoverflow.com/q/22131167
tags question: http://stackoverflow.com/q/22160555
tags question: http://stackoverflow.com/q/22058637
tags question: http://stackoverflow.com/q/22076303
tags question: http://stackoverflow.com/q/22162552
tags question: http://stackoverflow.com/q/22028317
tags question: http://stackoverflow.com/q/22085253
tags question: http://stackoverflow.com/q/22081555
tags question: http://stackoverflow.com/q/22017809
tags question: http://stackoverflow.com/q/22078687
tags question: http://stackoverflow.com/q/22071196
tags question: http://stackoverflow.com/q/22049927
tags question: http://stackoverflow.com/q/22034537
tags question: http://stackoverflow.com/q/22084420
tags question: http://stackoverflow.com/q/22085016
tags question: http://stackoverflow.com/q/22125912
tags question: http://stackoverflow.com/q/22081681
tags question: http://stackoverflow.com/q/22109227
tags question: http://stackoverflow.com/q/22135866
tags question: http://stackoverflow.com/q/22021205
tags question: http://stackoverflow.com/q/22065279
tags question: http://stackoverflow.com/q/22161724
tags question: http://stackoverflow.com/q/22078644
tags question: http://stackoverflow.com/q/22119137
tags question: http://stackoverflow.com/q/22141880
tags question: http://stackoverflow.com/q/22138865
tags question: http://stackoverflow.com/q/22021653
tags question: http://stackoverflow.com/q/22079792
tags question: http://stackoverflow.com/q/22111857
tags question: http://stackoverflow.com/q/22108710
tags question: http://stackoverflow.com/q/22067414

http://stackoverflow.com/comment/33446104
has text: I keep the size of my methods to around 30 lines which doesn't force the user to scroll when reading the method. You could break up the big void method into smaller void methods.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22057230
type: Comment

http://stackoverflow.com/comment/33397028
type: QuestionComment
has text: Clearly what you want to do??? switch meaning shifting??
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22029729

http://stackoverflow.com/comment/33389236
type: QuestionComment
has text: @mangusta someday I will know your professional secret :P
score: 0
comment on: http://stackoverflow.com/q/22025097
type: Comment

http://stackoverflow.com/comment/33359470
comment on: http://stackoverflow.com/q/22009068
type: QuestionComment
has text: Looks OK for me, but maybe you get your object-references mixed up - but we'll need more context to judge this.
score: 1
type: Comment

http://stackoverflow.com/q/22021448
upvote count: 0
tagged with: enumeration
has answer: http://stackoverflow.com/a/22021933
favorite count: 0
has answer: http://stackoverflow.com/a/22021616
answer count: 5
has body: see the below code,I am retriving elements from vector and printing using enumeration. package com.rajeev.enumeration; import java.util.Enumeration; import java.util.Vector; public class Modification_On_Eumeration { public static void main(String[] args) { Vector&lt;Integer&gt; vector = new Vector&lt;Integer&gt;(); vector.add(1); vector.add(2); System.out.println(vector);//here it is printing 12(ok) Enumeration&lt;Integer&gt; enumeration = vector.elements(); while (enumeration.hasMoreElements()) { Integer integer = (Integer) enumeration.nextElement(); System.out.print(integer);//why it is printing 123 instead of 12(reason ????) } vector.add(3); while (enumeration.hasMoreElements()) { Integer integer1 = (Integer) enumeration.nextElement(); System.out.println(integer1);//why it is not printing ??? System.out.println("why not printing"); } } } output ------ [1, 2] 123 why not printing the first while loop is printing elements of vector but the second while loop is not printing elements,why? and how the first while loop is able display 123 instead of 12 ? I am learning java help me ..
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33381628
tagged with: collections
has answer: http://stackoverflow.com/a/22021523
downvote count: 1
possible better answer: http://stackoverflow.com/a/22021616
type: Question
has title: retriving elements using enumeration
tagged with: java
has answer: http://stackoverflow.com/a/22021526
accepted answer: http://stackoverflow.com/a/22021526
score: -1
has answer: http://stackoverflow.com/a/22021553

http://stackoverflow.com/q/22015013
score: 3
downvote count: 0
tagged with: java
type: Question
linked to: http://stackoverflow.com/q/16420697
tagged with: jpa
upvote count: 3
has title: returning subset/subschema using spring data JPA
has body: I'm building a REST API using spring framework and a ran into a not-so-interesting case that i don't seem to find a solution for. So let's say that we have table Table1 with columns Col1, Col2, and Col3 and we have users of access level 1,2 and 3 Users of access level 3 are the only ones allowed to access Col3 along with all other columns, the rest are allowed to access anything else. Moreover, i want the API to be able to return a subset of the fields based on the call, I.E: if a call was made to URL /table/list?fl=col1 only the the value of Col1 will be returned. What i need to is a way to return this particular subset of the data on the API level, apparently spring data JPA doesn't allow returning a dynamic subset of the table. I was wondering what could be the cleanest way to do this without completely giving up JPA or having to rewrite all the functions in all the entities.
answer count: 1
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33369815
tagged with: spring
has comment: http://stackoverflow.com/comment/33369400
has comment: http://stackoverflow.com/comment/33372705
has answer: http://stackoverflow.com/a/22017250
tagged with: spring-mvc

http://stackoverflow.com/q/22087708
linked to: http://stackoverflow.com/q/9122277
upvote count: 1
accepted answer: http://stackoverflow.com/a/22088069
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33500146
has title: Nth output sum of (N-2)th and (N-1)th
score: 1
tagged with: java
type: Question
tagged with: for-loop
has answer: http://stackoverflow.com/a/22087931
has answer: http://stackoverflow.com/a/22088007
downvote count: 0
has answer: http://stackoverflow.com/a/22088482
has body: I cannot figure this question out no matter what i try, i may just be over thinking it, can i get a little help? Ive already tried a variety of different for loops and I can;t figure out how to get these values for(int a = 1; a&lt;1000; a++) I want to make it so the it states a+b but i dont think thats possible The following code is famous as Fibonacci, in which the Nth output is the sum of (N- 2)th and (N-1)th values. Write the for-expression to do the same task. int a=1, b=1; while (a &lt; 10000 ){ System.out.print(a+" "+b+" "); b+=a+=b; }
has answer: http://stackoverflow.com/a/22088069
has answer: http://stackoverflow.com/a/22088001
tagged with: while-loop
possible better answer: http://stackoverflow.com/a/22087789
answer count: 7
has answer: http://stackoverflow.com/a/22089089
has answer: http://stackoverflow.com/a/22087789
favorite count: 0

http://stackoverflow.com/q/22103892
has title: Camel log4j configuration when deployed inside ActiveMQ
answer count: 1
has comment: http://stackoverflow.com/comment/33576261
tagged with: java
tagged with: apache-camel
has comment: http://stackoverflow.com/comment/33899047
has comment: http://stackoverflow.com/comment/33854548
has comment: http://stackoverflow.com/comment/33572901
has comment: http://stackoverflow.com/comment/33901377
has answer: http://stackoverflow.com/a/22310496
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33576555
has comment: http://stackoverflow.com/comment/33760993
has body: I'm running some Camel 2.12.2 routes deployed inside ActiveMQ 5.9.0. The ActiveMQ log4j is working as expected, but I'm not able to get a log for my camel application when deployed inside ActiveMQ. My Camel log4j.properties looks like this: # # The logging properties used # log4j.rootLogger=INFO, console, logger # uncomment the following line to turn on Camel debugging #log4j.logger.org.apache.camel=DEBUG # Console appender log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%5p | %m%n log4j.appender.console.threshold=INFO # File appender log4j.appender.logger=org.apache.log4j.RollingFileAppender log4j.appender.logger.file=camel.log log4j.appender.logger.maxFileSize=1024KB log4j.appender.logger.maxBackupIndex=5 log4j.appender.logger.append=true log4j.appender.logger.layout=org.apache.log4j.PatternLayout log4j.appender.logger.layout.ConversionPattern=%d | %-5p | %m | %c | %t%n My camel project is using JavaDSL with SpringRouteBuilders, and when running the application with the maven camel plugin and running with maven camel:run the camel.log file is produced as expeceted. However, when packaging the camel routes and moving the jar to ActiveMQ, the log file is no longer created. I've checked the jars for slf4j, log4j and slf4j-log4j, and the versions are the same in ActiveMQ as in my pom.xml. Any clues as to what I'm missing here? EDIT: Just to clarify what I'm after here. I've experienced issues on more than one occasaion where ActiveMQ is shutting down because there is something wrong with my camel routes, but I don't see any exceptions in the activemq logs, which makes debugging extremely time consuming. Today I had such an issue, and realised that while there was still no trace of error in the log, I got a stacktrace when just doing maven camel:run on my project. A simple example (really just an example, I know why this is happening, but I want it logge…
type: Question
has comment: http://stackoverflow.com/comment/33577635
has comment: http://stackoverflow.com/comment/33853960
tagged with: log4j
accepted answer: http://stackoverflow.com/a/22310496
tagged with: activemq-classic
score: 0
tagged with: maven

http://stackoverflow.com/a/22163027
score: 1
has comment: http://stackoverflow.com/comment/33635356
upvote count: 1
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/22162886
has comment: http://stackoverflow.com/comment/33635599
accepted answer of: http://stackoverflow.com/q/22162886
has body: First you need to map the servlet with url in web.xml like below testServlet com.company.Test testServlet /test Then you need to give the url in the form action as below: your method in servlet(doGet or doPost) should match the method that you are specifying in your jsp.
type: Answer

http://stackoverflow.com/comment/33491666
type: Comment
comment on: http://stackoverflow.com/a/22050439
has text: I am not 100% sure how to do so. Any comments will be greatly appreciated
type: AnswerComment
score: 0

http://stackoverflow.com/q/22045641
tagged with: jpa
downvote count: 0
has comment: http://stackoverflow.com/comment/33472124
favorite count: 0
has answer: http://stackoverflow.com/a/44536883
has body: Using the new JPA 2.1 stored procedure call, is there any way to pass a null parameter? Here is an example usage: StoredProcedureQuery storedProcedure = em.createStoredProcedureQuery("get_item", Item.class); storedProcedure.registerStoredProcedureParameter(0, String.class, ParameterMode.IN); storedProcedure.registerStoredProcedureParameter(1, String.class, ParameterMode.IN); storedProcedure.registerStoredProcedureParameter(2, Timestamp.class, ParameterMode.IN); storedProcedure.setParameter(0, a); storedProcedure.setParameter(1, b); storedProcedure.setParameter(2, c); storedProcedure.execute(); This works when all parameters are given, but when c is null it will fail with an error from the (PostgreSQL) JDBC driver. Caused by: org.postgresql.util.PSQLException: No value specified for parameter 2 at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:216) [postgresql-9.3-1101.jdbc41.jar:] at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:244) [postgresql-9.3-1101.jdbc41.jar:] at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:559) [postgresql-9.3-1101.jdbc41.jar:] at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417) [postgresql-9.3-1101.jdbc41.jar:] at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:410) [postgresql-9.3-1101.jdbc41.jar:] at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.execute(WrappedPreparedStatement.java:404) at org.hibernate.result.internal.OutputsImpl.&lt;init&gt;(OutputsImpl.java:69) [hibernate-core-4.3.1.Final.jar:4.3.1.Final] ... 244 more I have also considered using my own class for passing the parameters, eg: storedProcedure.registerStoredProcedureParameter(0, InputParameters.class, ParameterMode.IN); storedProcedure.setParameter(0, inputParameters); This fails with: Caused by: java.lang.IllegalArgumentException: Type cannot be null I guess because it needs a type that…
has answer: http://stackoverflow.com/a/36124648
upvote count: 30
has answer: http://stackoverflow.com/a/44047228
has answer: http://stackoverflow.com/a/39034626
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/35445907
has answer: http://stackoverflow.com/a/63255571
tagged with: java
accepted answer: http://stackoverflow.com/a/44047228
has comment: http://stackoverflow.com/comment/33474851
has title: Is it possible to pass a null parameter to a stored procedure in Java JPA 2.1?
has answer: http://stackoverflow.com/a/24460150
type: Question
has answer: http://stackoverflow.com/a/22073959
has answer: http://stackoverflow.com/a/49427139
tagged with: stored-procedures
score: 30
has answer: http://stackoverflow.com/a/43579886
has comment: http://stackoverflow.com/comment/33474486
has answer: http://stackoverflow.com/a/61102822
has answer: http://stackoverflow.com/a/63972484
has comment: http://stackoverflow.com/comment/33472799
has comment: http://stackoverflow.com/comment/33425647
answer count: 13
has answer: http://stackoverflow.com/a/59085981
possible better answer: http://stackoverflow.com/a/22073959
has comment: http://stackoverflow.com/comment/33425259
has comment: http://stackoverflow.com/comment/33425674

http://stackoverflow.com/q/22121439
has body: I have come across a slight visual issue in Java (swing) when using custom fonts with a JCheckBox. I have a JCheckBox with text spanning multiple lines. When using the default font, it looks fine. However, when I use a custom font (imported on-the-fly from a .ttf file), the vertical alignment seems to be slightly offset, making it look ugly. The text accompanying the checkbox should be slightly higher than it appears. Is there any way to tweak the vertical position of the checkbox its text label? This happens when I use this code to align the checkbox at the top: checkbox.setVerticalTextPosition(SwingConstants.TOP)
linked to: http://stackoverflow.com/q/21733765
upvote count: 2
answer count: 1
favorite count: 0
tagged with: vertical-alignment
score: 2
type: AnsweredQuestion
downvote count: 0
tagged with: java
tagged with: swing
has comment: http://stackoverflow.com/comment/33561773
accepted answer: http://stackoverflow.com/a/22121988
type: Question
has comment: http://stackoverflow.com/comment/33561587
tagged with: jcheckbox
has title: JCheckBox: Vertical alignment for multi-line text
has answer: http://stackoverflow.com/a/22121988

http://stackoverflow.com/comment/33431551
has text: @NathanielWaggoner You should read all of the comments. OP says: It gives an error which says " '[' expected
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/22049247
type: Comment

http://stackoverflow.com/a/69992929
upvote count: 1
downvote count: 0
type: Answer
score: 1
has body: boolean nu = f=='f' && t=='f'; //0 boolean ei = f=='f' && t=='t'; //1 boolean zw = f=='t' && t=='f'; //2 boolean dr = f=='t' && t=='t'; //3 System.out.println( nu ? 0 : ei ? 1 : zw ? 2 : dr ? 3 : "invalid");
answers question: http://stackoverflow.com/q/22151191

http://stackoverflow.com/q/22085316
type: AnsweredQuestion
tagged with: java
tagged with: itext
has title: how to export Vietnamese text to PDF using iText
tagged with: southeast-asian-languages
type: Question
tagged with: encoding
possible better answer: http://stackoverflow.com/a/22087684
has answer: http://stackoverflow.com/a/22088399
has answer: http://stackoverflow.com/a/22087684
answer count: 2
score: 2
tagged with: http://stackoverflow.com/tag/pdf
downvote count: 0
favorite count: 0
has body: I'm facing a problem when trying to export a Vietnamese document as PDF using iText. I put Vietnamese words in .xml file like this T\u1ED5 ch\u1EE9c tham gia then having java to get the phrases from xml file and convert it into Unicode using this method: public String convertToUnicode(String s) { int i = 0, len = s.length(); char c; StringBuffer sb = new StringBuffer(len); try { while (i < len) { c = s.charAt(i++); if (c == '\\') { if (i < len) { c = s.charAt(i++); if (c == 'u') { if (Character.digit(s.charAt(i), 16) != -1 && Character.digit(s.charAt(i + 1), 16) != -1 && Character.digit(s.charAt(i + 2), 16) != -1 && Character.digit(s.charAt(i + 3), 16) != -1) { if (s.substring(i).length() >= 4) { c = (char) Integer.parseInt(s.substring(i, i + 4), 16); i += 4; } else { sb.append('\\'); } } else { sb.append('\\'); } } // add other cases here as desired... } } // fall through: \ escapes itself, quotes any character but u sb.append(c); } } catch (Exception e) { System.out.println("Error Generate PDF :: " + e.getStackTrace().toString()); return s; } return sb.toString(); } After that, export String to PDF - encoding UTF-8. But the program failed to display Vietnamese character '\u1ED5' and '\u1EE9' The output becomes "T chc tham gia" Could you please show me how to fix this issue? Thanks :)
upvote count: 2
accepted answer: http://stackoverflow.com/a/22088399

http://stackoverflow.com/q/22141202
type: UnansweredQuestion
upvote count: 1
has comment: http://stackoverflow.com/comment/33608554
has answer: http://stackoverflow.com/a/27319197
has title: DDL Generation For Db2 tables
tagged with: java
has answer: http://stackoverflow.com/a/27473847
type: Question
answer count: 2
downvote count: 0
tagged with: javascript
tagged with: db2
has body: I am working on a web project,where i will access Db2 table and display the contents of table.Now i am in need of generating the DDL schema of the tables when the users click "Generate DDL" option from the web page.Is there any command or JAVA API's to get the DDL of the Db2 tables?
tagged with: sql
score: 1
favorite count: 0

http://stackoverflow.com/comment/33483482
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22073976
has text: Of course I will be drawing curves on a canvas 2d context, but I need to know the points from the .dat file so I know where I'm drawing to.. The new question is here: http://stackoverflow.com/questions/22078454/pulling-this-custom-readdatafile-function-into-eclipse-to-print-dat-file-data-t

http://stackoverflow.com/q/22119202
has title: Give memory to object from another class Java
has answer: http://stackoverflow.com/a/22119345
favorite count: 0
has comment: http://stackoverflow.com/comment/33557867
tagged with: memory-management
has answer: http://stackoverflow.com/a/22120162
tagged with: pass-by-reference
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33556903
tagged with: java
upvote count: 1
has comment: http://stackoverflow.com/comment/33558302
has comment: http://stackoverflow.com/comment/33557321
type: Question
answer count: 2
accepted answer: http://stackoverflow.com/a/22120162
downvote count: 0
has comment: http://stackoverflow.com/comment/33557364
has comment: http://stackoverflow.com/comment/33556931
has body: I am a newbie to Java (I come from the C/C++ background) and I was having a hard time figuring out how to allocated memory of a data member in one class from another. For eg, Class A { B bInA; C cInA; public void foo(someValue) { cInA = new C(); cInA.foo(bInA, someValue) } public static void main(String args[]) { A myA = new A(); myA.foo(xyz) // myA.bInA.value should be equal to xyz } } Class B { ... } Class C { public void foo(bInA, someValue) { bInA = new B(); bInA.value = someValue; } } Can I do something like this in java? Any help will be much appreciated. ----EDIT----- Class A { B bInA; C cInA; public void foo(someValue) { cInA = new C(); bInA = new B(); cInA.foo(bInA, someValue) } public static void main(String args[]) { A myA = new A(); myA.foo(xyz) // myA.bInA.value should be equal to xyz } } Class B { ... } Class C { public void foo(bInA, someValue) { bInA.value = someValue; } }
has comment: http://stackoverflow.com/comment/33557722
possible better answer: http://stackoverflow.com/a/22119345
score: 1

http://stackoverflow.com/q/22060637
type: Question
has answer: http://stackoverflow.com/a/22060743
has comment: http://stackoverflow.com/comment/33451503
has title: Why does the constructor of java.util.Date act differently on parameters between int and long?
downvote count: 0
favorite count: 0
has body: Here's the scenario: If I pass an int to Date as below, the output would be Thu Jan 22 20:56:36 CST 1970: System.out.println(new Date(1393430400*1000)); When I pass a long, the output is just what I intend for: Thu Feb 27 00:00:00 CST 2014 System.out.println(new Date((long)1393430400*1000)); I've checked the method which the new Date(long l) invoked. It's just the same one: public Date(long date) { fastTime = date; } Could anyone give me some explanations on this problem? Thanks a lot!
answer count: 3
possible better answer: http://stackoverflow.com/a/22060666
has answer: http://stackoverflow.com/a/22060666
score: 2
linked to: http://stackoverflow.com/q/9141871
upvote count: 2
duplicate of: http://stackoverflow.com/q/9141871
has comment: http://stackoverflow.com/comment/33451437
has answer: http://stackoverflow.com/a/22060664
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/22060664
tagged with: date

http://stackoverflow.com/comment/33595312
has text: so size of name & salary list is equal or greater then salary.size() ??
type: QuestionComment
comment on: http://stackoverflow.com/q/22140643
type: Comment
score: 0

http://stackoverflow.com/q/22044294
has answer: http://stackoverflow.com/a/22044773
type: Question
score: 0
tagged with: printing
has title: Get information about print job
has comment: http://stackoverflow.com/comment/33425831
answer count: 1
has comment: http://stackoverflow.com/comment/33424668
has comment: http://stackoverflow.com/comment/33426662
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33427025
has body: I want to display information about a print job. Can be in a joptionpane with a message like: "The document will be printed to: HP1000 printer, in A4 paper, with Landscape orientation". How can I get the printer name, the size of the paper name and the orientation name information out of the job?
tagged with: java

http://stackoverflow.com/comment/33537112
comment on: http://stackoverflow.com/q/22020652
type: Comment
type: QuestionComment
has text: @Steve Kuo - Regarding the 6000 Strings... it may or may not be a big deal. When I test a single user locally for our web app, it's not. However, in production, we have many thousands of users, and we've seen excessive garbage collection. There are many other duplicated Strings, some large and some small, some with many copies, and some with fewer. My real question may be a general question about how to limit memory consumption in used libraries; however, those sorts of general questions seem to be frowned upon on StackOverflow.
score: 0

http://stackoverflow.com/comment/33587538
type: QuestionComment
comment on: http://stackoverflow.com/q/22135449
has text: Okay - I think I get it. Use a `ConcurrentHashMap` first of all - don't lock the whole `Map`. Second wrap the keys in another `Object` and lock on that in the work process. This way you can lock the _key_ and replace the value.
score: 0
type: Comment

eclipse
tags question: http://stackoverflow.com/q/22166472
tags question: http://stackoverflow.com/q/22064014
tags question: http://stackoverflow.com/q/22035861
tags question: http://stackoverflow.com/q/22140023
tags question: http://stackoverflow.com/q/22037793
tag name: eclipse
tags question: http://stackoverflow.com/q/22094644
tags question: http://stackoverflow.com/q/22145952
tags question: http://stackoverflow.com/q/22122090
tags question: http://stackoverflow.com/q/22129250
tags question: http://stackoverflow.com/q/22048499
tags question: http://stackoverflow.com/q/22075367
tags question: http://stackoverflow.com/q/22070764
tags question: http://stackoverflow.com/q/22058636
tags question: http://stackoverflow.com/q/22021466
tags question: http://stackoverflow.com/q/22023049
tags question: http://stackoverflow.com/q/22066739
tags question: http://stackoverflow.com/q/22049540
tags question: http://stackoverflow.com/q/22039876
tags question: http://stackoverflow.com/q/22124706
tags question: http://stackoverflow.com/q/22053616
tags question: http://stackoverflow.com/q/22050171
tags question: http://stackoverflow.com/q/22122411
tags question: http://stackoverflow.com/q/22109197
tags question: http://stackoverflow.com/q/22083802
tags question: http://stackoverflow.com/q/22129543
tags question: http://stackoverflow.com/q/22025897
tags question: http://stackoverflow.com/q/22023169
tags question: http://stackoverflow.com/q/22033686
tags question: http://stackoverflow.com/q/22031345
tags question: http://stackoverflow.com/q/22025380
tags question: http://stackoverflow.com/q/22117250
tags question: http://stackoverflow.com/q/22167682
tags question: http://stackoverflow.com/q/22089453
tags question: http://stackoverflow.com/q/22162967
tags question: http://stackoverflow.com/q/22154831
tags question: http://stackoverflow.com/q/22107517
tags question: http://stackoverflow.com/q/22143480
tags question: http://stackoverflow.com/q/22099944
tags question: http://stackoverflow.com/q/22050741
tags question: http://stackoverflow.com/q/22102632
tags question: http://stackoverflow.com/q/22150244
tags question: http://stackoverflow.com/q/22092794
tags question: http://stackoverflow.com/q/22028538
tags question: http://stackoverflow.com/q/22062787
tags question: http://stackoverflow.com/q/22046152
tags question: http://stackoverflow.com/q/22093809
tags question: http://stackoverflow.com/q/22098515
tags question: http://stackoverflow.com/q/22011375
tags question: http://stackoverflow.com/q/22108349
tags question: http://stackoverflow.com/q/22147507
tags question: http://stackoverflow.com/q/22024489
tags question: http://stackoverflow.com/q/22022686
tags question: http://stackoverflow.com/q/22162076
tags question: http://stackoverflow.com/q/22052510
tags question: http://stackoverflow.com/q/22146923
tags question: http://stackoverflow.com/q/22166411
tags question: http://stackoverflow.com/q/22137448
tags question: http://stackoverflow.com/q/22118700
tags question: http://stackoverflow.com/q/22029564
tags question: http://stackoverflow.com/q/22100795
tags question: http://stackoverflow.com/q/22069353
tags question: http://stackoverflow.com/q/22024030
tags question: http://stackoverflow.com/q/22073268
tags question: http://stackoverflow.com/q/22147802
tags question: http://stackoverflow.com/q/22026524
tags question: http://stackoverflow.com/q/22050194
tags question: http://stackoverflow.com/q/22045812
tags question: http://stackoverflow.com/q/22154416
tags question: http://stackoverflow.com/q/22152089
tags question: http://stackoverflow.com/q/22007784
tags question: http://stackoverflow.com/q/22045855
tags question: http://stackoverflow.com/q/22034262
tags question: http://stackoverflow.com/q/22139494
tags question: http://stackoverflow.com/q/22027815
tags question: http://stackoverflow.com/q/22106840
tags question: http://stackoverflow.com/q/22143901
tags question: http://stackoverflow.com/q/22032744
tags question: http://stackoverflow.com/q/22100973
tags question: http://stackoverflow.com/q/22033027

http://stackoverflow.com/q/22168595
answer count: 1
has answer: http://stackoverflow.com/a/22168776
tagged with: netbeans
tagged with: php
has body: I wrote a small JSP app, just to test the connection. I use XAMPP. Module Apche, mySql, Tomcat are running. I use Netbeans 7.4. The code is : <%@page language="java" contentType="text/html"%> <%@page import="java.sql.*"%> JDBC test <% Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection( "jdbc:mysql://localhost:8084/book_shop_db", "root", ""); System.out.println("CONN = " + conn); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("select * from books"); %> <% ResultSetMetaData resMetaData = rs.getMetaData(); int nCols = resMetaData.getColumnCount(); %> <% for (int kCol = 1; kCol <= nCols; kCol++) { out.print(" " + resMetaData.getColumnName(kCol) + " "); } %> <% while (rs.next()) { %> <% for (int kCol = 1; kCol <= nCols; kCol++) { out.print(" " + rs.getString(kCol) + " "); } %> <% } %> <% conn.close(); %> When I run the app, the following error appear : HTTP Status 500 - An exception occurred processing JSP page /index.jsp at line 11 where line 11 is : 11: Class.forName("com.mysql.jdbc.Driver"); In Netbeans, in Tools->Servers->Tomcat I have : username: ide password : * Ok. Password can be shown no roblem. Server port is : 8084. In XAMPP, ports are : for Apache : 100, 443 (Ok) for mySql: 3306 for Tomcat: 8005, 8809, 8080. I really am confused. How can I make the app run ? Thank you. EB
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22168776
tagged with: java
tagged with: mysql
has comment: http://stackoverflow.com/comment/33644813
type: Question
has title: Small JSP app does not work
tagged with: tomcat
score: 0

configuration-files
type: Tag
tag name: configuration-files
tags question: http://stackoverflow.com/q/22166319

http://stackoverflow.com/comment/33525479
comment on: http://stackoverflow.com/q/22101275
score: 0
type: Comment
type: QuestionComment
has text: There you go! Sorry I should have added it in the beginning.

http://stackoverflow.com/a/22009374
score: 0
has comment: http://stackoverflow.com/comment/33361303
has comment: http://stackoverflow.com/comment/33360349
has comment: http://stackoverflow.com/comment/33361040
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33362021
has body: "I will spruce it up nicely with some great functionality, but for right now, I'm only focused on making sure my structure is good. " That means, you should be sure it can take easily your great functions. :-) Aggregation can be of three kinds - none, shared or composite. Saying aggregation instead of shared or shared aggregation is a bad error. Alas, widely spread from VP-UML tool. For Abstract normally italic is used for name writing. This one is much more serious problem: you have no different lines for associations and generalizations. It is therefore almost impossible to understand your diagram. But if I take that all arrows are generalizations, ... it makes sense! But really, better use some free tool for drawing. Community version of VP-UMP, for example. Or free Papyrus on Eclipse. both your shared aggregations(allow me name them correctly, please) are strange: The left one is simply not understandable - to write diamond on one end and 1-multiplicity on the other IS allowed (shared aggregations are not defined strictly in UML standard), but such unusual use should be explained. If your DB navigator works with many databases, the diamond should be on its end normally. The right one is written in usual way, but I can't understand the sense under it - how it can be that one VideoGameDataBaseRecord has many games? I am not catching the logic. Could you repair it or explain it? I think, there should rather be normal association, with none aggregation, one- or two-sided, with 0..1 at the ends. I am terribly sorry, but I do not understand what is in etc. If there is unknown stuff in it, how can you be sure that it should be derived from Game class? Normally the things you have not formalized enough yet, are held simply out of the diagram.
has comment: http://stackoverflow.com/comment/33360599
type: Answer
answers question: http://stackoverflow.com/q/22008060
accepted answer of: http://stackoverflow.com/q/22008060

http://stackoverflow.com/comment/33516795
score: 0
type: Comment
type: QuestionComment
has text: In this case, don't use `File` anymore: use the new Files API. `Files.delete(Paths.get(Target_Folder_Name).resolve(Target_Filename + ".txt"));` <-- big advantage over `File.delete()`: throws a meaningful exception if it fails!
comment on: http://stackoverflow.com/q/22097171

http://stackoverflow.com/a/22114366
type: Answer
has body: You seem to have two problems, not sure which one affects you most. You're missing an ExceptionMapper that should map exception types on your backend to HTTP responses. You're getting a NullPointerException, regardless of the fact that the code runs within a REST container. Maybe if you look down to the stack trace of this NullPointerException, you can get a hint on what's going wrong.
answers question: http://stackoverflow.com/q/22114085
accepted answer of: http://stackoverflow.com/q/22114085
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33548150
has comment: http://stackoverflow.com/comment/33548235
has comment: http://stackoverflow.com/comment/33552790

http://stackoverflow.com/q/22156931
has title: Character encoding in query string, hebrew
tagged with: utf-8
has comment: http://stackoverflow.com/comment/33626306
accepted answer: http://stackoverflow.com/a/22159502
has comment: http://stackoverflow.com/comment/33625671
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33624696
tagged with: servlet-filters
has comment: http://stackoverflow.com/comment/33626361
type: Question
has comment: http://stackoverflow.com/comment/33624762
tagged with: java
tagged with: character-encoding
score: 4
has body: I am trying to send a GET request with query string parameter in hebrew. When the controller gets the request, the parameter is in gibberish. i've added "org.springframework.web.filter.CharacterEncodingFilter" but it didn't change a thing. Please advise how to fix it. Update: here is the the request. GET /myapp/specialties?query=%D7%92%D7%99%D7%A0%D7%A0%D7%A0%D7%A0 HTTP/1.1 Host: localhost:8080 Connection: keep-alive Accept: * Cache-Control: no-cache User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36 Content-Type: application/json;charsert=utf-8 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8,he;q=0.6 Query String Parametersview sourceview URL encoded query:גיננננ Response Headersview source Content-Type:application/json;charset=UTF-8 Date:Mon, 03 Mar 2014 20:45:17 GMT Server:Apache-Coyote/1.1 Transfer-Encoding:chunked web.xml <?xml version="1.0" encoding="UTF-8"?> med.rec contextConfigLocation classpath:spring/application-config.xml CharacterEncodingFilter org.springframework.web.filter.CharacterEncodingFilter encoding UTF-8 forceEncoding true CharacterEncodingFilter /* org.springframework.web.context.ContextLoaderListener dispatcherServlet org.springframework.web.servlet.DispatcherServlet contextConfigLocation /WEB-INF/mvc-config.xml 1 dispatcherServlet / -Roy
tagged with: servlets
upvote count: 4
has answer: http://stackoverflow.com/a/22159502
answer count: 1
downvote count: 0
favorite count: 0

http://stackoverflow.com/comment/72667716
type: Comment
comment on: http://stackoverflow.com/a/22140728
type: AnswerComment
has text: @Rpant I believe you haven't understand the rationale behind. When we are talking about `protected` in the example above, of course we have to make sure that the classes are from different package, so you do not gain accessibility through package/default (which is also part of `protected`). If things are put under same package, `protected` or package/default makes no difference. *And*, in above example, `manager.hireDay` DOES work. Please read it again to make sure you really understand :)
score: 0

http://stackoverflow.com/q/22158755
has answer: http://stackoverflow.com/a/22159116
has body: public class ListComboBox extends JFrame { private String MIS = "MULTIPLE_INTERVAL_SELECTION"; private String SIS = "SINGLE_INTERVAL_SELECTION"; private String SS = "SINGLE_SELECTION"; final int COUNTRIES = 9; private String[] countries = {"Canada", "China", "Denmark", "France", "Germany", "India", "Norway", "United Kingdom", "United States of America"}; private JList&lt;String&gt; jlst = new JList&lt;String&gt;(countries); private JLabel comboLabel = new JLabel("Choose Selection Mode: "); private JComboBox jcbo = new JComboBox(); //to hold country labels private JLabel countryLabel = new JLabel(); public static void main(String[] args) { ListComboBox frame = new ListComboBox(); frame.setSize(400, 200); frame.setTitle("Exercise 17.14"); frame.setLocationRelativeTo(null); // Center the frame frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } public ListComboBox() { //Adding selection option to combobox jcbo.addItem(MIS); jcbo.addItem(SIS); jcbo.addItem(SS); // Register listener combobox jcbo.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getItem() == MIS) { jlst.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } if (e.getItem() == SIS) { jlst.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } if (e.getItem() == SS) { jlst.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } } }); //Combobox panel JPanel combopanel = new JPanel(new FlowLayout()); combopanel.add(comboLabel); combopanel.add(jcbo); add(combopanel, BorderLayout.NORTH); //List panel JScrollPane listpanel = new JScrollPane(jlst); add(listpanel, BorderLayout.CENTER); //Bottom label panel final JPanel labelpanel = new JPanel(); labelpanel.add(countryLabel); add(labelpanel, BorderLayout.SOUTH); //List listener jlst.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { StringBuilder sb = new StringBuilder(64); int[] indices = jlst.getSelec…
tagged with: listselectionlistener
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22159116
type: Question
tagged with: jlist
answer count: 2
tagged with: swing
has answer: http://stackoverflow.com/a/22159164
tagged with: jcombobox
score: 0
tagged with: java
has title: JAVA Display item from JList in JLabel
accepted answer: http://stackoverflow.com/a/22159164

http://stackoverflow.com/q/22127457
has answer: http://stackoverflow.com/a/22127554
accepted answer: http://stackoverflow.com/a/22127464
has comment: http://stackoverflow.com/comment/33572395
favorite count: 0
has answer: http://stackoverflow.com/a/22127614
tagged with: android
has title: Array of Buttons in Java
has body: I tried to make an array of buttons: Button[] buttonlist = new Button[2]; Button btn1; Button btn2; Button btn3; btn1 = (Button) findViewById(R.id.button1); btn2 = (Button) findViewById(R.id.button2); btn3 = (Button) findViewById(R.id.button3); buttonlist[0] = btn1; buttonlist[1] = btn2; buttonlist[2] = btn3; What did I do wrong here ? Thanks !
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22128378
possible better answer: http://stackoverflow.com/a/22127614
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/22127464
downvote count: 1
type: Question
tagged with: arrays
score: 0

http://stackoverflow.com/comment/33599923
score: 0
type: QuestionComment
has text: What language is your development code is ? If is java, and if you use continuous integration servers (eg Hudson), you could schedule your tests to run at pre-defined time. Also see http://stackoverflow.com/questions/9528581/specifying-order-of-execution-in-junit-test-case
type: Comment
comment on: http://stackoverflow.com/q/22143400

http://stackoverflow.com/a/22142078
type: Answer
has body: Try with this, List&lt;MatOfPoint&gt; contours = new ArrayList&lt;MatOfPoint&gt;(); Imgproc.findContours(imgSource, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE); You have to add some value into counter before below line MatOfPoint temp_contour = contours.get(0);
has comment: http://stackoverflow.com/comment/33597546
has comment: http://stackoverflow.com/comment/33597476
answers question: http://stackoverflow.com/q/22141969
score: 0

http://stackoverflow.com/a/22103026
answers question: http://stackoverflow.com/q/22102837
upvote count: 1
has body: You can't add a String[] to a PriorityQueue because a String[] is not Comparable. The solution depends on what you really need to accomplish. Queue the Strings Use Queue's addAll() method. Queue the Strings and Retain Grouping Queue your String[] objects in a Queue. Queue the String and Retain Priority Use PriorityQueue's addAll() method. Queue the Strings, Retain Grouping, and Retain Priority Wrap your String[] in a new class. Apply the Comparable interface. Implement the compareTo() and equals() methods. Queue your custom objects in a PriorityQueue.
downvote count: 0
score: 1
type: Answer

http://stackoverflow.com/comment/33515971
comment on: http://stackoverflow.com/a/22096594
type: Comment
has text: @user3364497 see the javadoc for `SimpleDateFormat`; it is integrated into Java itself. What is more, a better library to handle time is Joda Time, if you want to use an external lib, use this one rather than Apache's
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33567462
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22124892
has text: Probably no one will read through that much code. Please post the relevant code snippets here on Stackoverflow and some more background information (details).

http://stackoverflow.com/a/22076489
upvote count: 1
type: Answer
downvote count: 0
score: 1
has body: It seems to me that you are using OSGI for dynamic linking. The first thing I would do is to check if the class in question EXPORTED? It is mandatory that the class is exported to be visible to other OSGI modules.
answers question: http://stackoverflow.com/q/22073268

http://stackoverflow.com/q/22138515
has comment: http://stackoverflow.com/comment/33593353
has answer: http://stackoverflow.com/a/22140704
has comment: http://stackoverflow.com/comment/33591608
has comment: http://stackoverflow.com/comment/33598408
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/33591588
score: 0
tagged with: java
linked to: http://stackoverflow.com/q/885009
tagged with: eclipse
type: Question
has comment: http://stackoverflow.com/comment/33997927
answer count: 1
has body: I am learning Android development and I am using the book Professional Android 4 Application Development written by Reto Meier. I am using Eclipse with the ADT plugin to follow the examples in the book. I have already read several existing posts about this issue and have tried several methods to fix it. My code is exactly as the code is in the book. Please help me, I'm anxious to move on in the book but I don't want to skip past things but I've at this stupid bug for over three hours. It's a simple To-Do List app. Here's my main Activity class. package com.example.todoolist; import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ListView; public class ToDoListActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Inflate your View LINE 19 setContentView(R.layout.activity_to_do_list); // Get references to UI widgets LINE 22 ListView myListView = (ListView)findViewById(R.id.myListView); LINE 23 final EditText myEditText = (EditText)findViewById(R.id.myEditText); // Create the Array List of to do items final ArrayList todoItems = new ArrayList (); // Create the Array Adapter to bind the array to the List View final ArrayAdapter aa; aa = new ArrayAdapter (this, android.R.layout.simple_list_item_1, todoItems); // Bind the Array Adapter to the List View myListView.setAdapter(aa); myEditText.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) if ((keyCode == KeyEvent.KEYCODE_DPAD_CENTER) || (keyCode == KeyEvent.KEYCODE_ENTER)) { todoItems.add(0, myEditText.getText().toString()); aa.notifyDataSetChanged(); myEditText.setText(""); return true; } return false; } }); } } Here's my XML file... <?xml version="1.0" encoding="utf-8"?> <EditText android…
has title: R cannot be resolved to a variable - Android
has comment: http://stackoverflow.com/comment/33591639
has comment: http://stackoverflow.com/comment/33591831

http://stackoverflow.com/a/28907372
score: 2
answers question: http://stackoverflow.com/q/22129875
downvote count: 0
type: Answer
upvote count: 2
has body: I had some troubles when stopping a Tomcat server instance using the "Stop the server" button and I felt curious about it. I went into the Eclipse manual. I don't usually go there since there are a lot of good handy answers about it here at Stackoverflow. In particular, this page tells something about the difference between "Terminate" and "Stop the server": http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.wst.server.ui.doc.user%2Ftopics%2Ftwstpins.html Extracting from the NOTE, it seems that "Stop the server" tries to shutdown the server through the normal routine of stopping, for example calling the destroy() method on a servlet. So if you could call your webapps destroy() methods...that could be a way of shutting down applications without shutting the whole server. Finally, I would recommend using "Terminate" if someone has problems with the normal process of "Stop the server", even though it is more abrupt.

http://stackoverflow.com/a/22010635
answers question: http://stackoverflow.com/q/22010118
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22010118
type: Answer
has body: To get the value of current when the check was made, declare it outside the for loop in order to have the access to the variable value and add a boolean flag isFound: int current = 0; boolean isFound = false; for(int counter=0; counter&lt;arrayValues.length; counter++) { current = arrayValues[counter]; if(current == 100) { isFound = true; // do something } } Then once the check is made you can get the value of current or print that found something: if (isFound) { System.out.println("Found Something!"); } else { System.out.println("current: " + current); } Note. If the value you are looking for is not present in the array, current is always assigned with the last value in the array.
has comment: http://stackoverflow.com/comment/33362360
score: 1
upvote count: 1

http://stackoverflow.com/a/22108959
answers question: http://stackoverflow.com/q/22108945
downvote count: 0
has body: You need to either cast one of them as a float, or declare one of the variables to be a float from the start. Otherwise, Java's integer division takes over, and just as an int divided by an int must be an int, that would apply to longs as well. float c = (float) a / b;
type: Answer
upvote count: 6
score: 6

http://stackoverflow.com/comment/33399861
comment on: http://stackoverflow.com/q/22031466
has text: You should one thread, that updates the state of the game play and the tells Swing to renderer, waiting the required amount of time in order to maintain the frame rate. Considering it's possible to [animate more the 4500 component based objects](http://stackoverflow.com/questions/14886232/swing-animation-running-extremely-slow/14902184#14902184), I doubt you should have to many problems...Without an example code, it's really impossible to know what's going wrong, but it sounds like you are spamming the EDT
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22045618
downvote count: 0
type: Answer
has body: Not sure how your grabbing the HTML. If its a local file then you can load it directly into Jsoup. If you have to fetch it from some URL then I normally use Apache's HttpClient. A quick start guide is here: HttpClient and does a good job of getting you started. That will allow you to get the data back doing something like this: HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(URL); // // here you can do things like add parameters used when connecting to the remote site // HttpResponse response = client.execute(post); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); Then (as has been suggested by Pshemo) I use Jsoup to parse and extract the data Jsoup Document document = Jsoup.parse(HTML); // OR Document doc = Jsoup.parseBodyFragment(HTML); Elements elements = doc.select("p"); // p for text
upvote count: 1
has comment: http://stackoverflow.com/comment/33425611
score: 1
answers question: http://stackoverflow.com/q/22045126

http://stackoverflow.com/q/22168571
has answer: http://stackoverflow.com/a/22168657
has title: is numerous class for specific functions good?
type: UnansweredQuestion
tagged with: android
score: 0
tagged with: java
has answer: http://stackoverflow.com/a/22168726
has answer: http://stackoverflow.com/a/22168674
type: Question
has body: my main activity has over 400 Lines Of Code and contains numerous methods which deals with pdf generations, making the page dynamic, and other condition checks.. i was wondering if i should make it all into different class files.. each specific for its task.. thereby creating at least 3-4 different classes.. so my query is 1) will this approach make the app faster.. 2) will this increase the app's size drastically?? also is there anyway to reduce the app's size? i have deleted all unnecessary pics, xml's &amp; assests.. i just want the size to be below 5mb.. Thanks in advance..
answer count: 3

http://stackoverflow.com/comment/33601076
has text: Why don't you use a TreeMap instead of writing this class? Try this: http://www.tutorialspoint.com/java/java_treemap_class.htm
score: 0
comment on: http://stackoverflow.com/q/22143652
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22124423
score: 1
has title: Weird behaviour of System.out.println in java
favorite count: 0
type: Question
accepted answer: http://stackoverflow.com/a/22124434
has body: class Foo {} class Boo extends Foo {} public class Tester { public static void main(String[]args) { Foo f = new Foo(); Boo b = new Boo(); System.out.println("****"+f==b+"****");//line 1 boolean flag = f==b; System.out.println("****"+flag+"****");//line 2 } } For line1 output is false For line2 output is ****false**** For line 2 it is concatenating properly. My question is why for line 1 it is printing just the value and not the proper output with stars.
upvote count: 1
tagged with: java
has answer: http://stackoverflow.com/a/22124434
answer count: 2
possible better answer: http://stackoverflow.com/a/22124822
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22124822
downvote count: 0

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

http://stackoverflow.com/q/22167012
type: AnsweredQuestion
score: 0
accepted answer: http://stackoverflow.com/a/22243318
answer count: 1
tagged with: interceptor
has body: My native language is not English and my English is poor,so I apologize if anything isn't clear. I have searched, but it did not help. I have a web service using cxf framework, I want to use an interceptor to intercept the request which is passed by the service invoker. I can intercept the request but I can`t find out the request params. Here is my service interface: public int modCredenceForUser(@WebParam(name = "operatorId", mode = WebParam.Mode.IN) String operatorId, @WebParam(name = "userCredenceVO", mode = WebParam.Mode.IN) Holder&lt;UserCredenceVO&gt; userCredenceVO, @WebParam(name = "res", mode = WebParam.Mode.OUT) Holder&lt;Response&gt; res) Here is part of my service invoker code: userCredenceVO = new UserCredenceVO(); ...... ...... Holder&lt;UserCredenceVO&gt; userCredenceVOHolder = new Holder&lt;UserCredenceVO&gt;(userCredenceVO); String operatorId = ServiceInvokeUtil.getOperatorId(); int result = service.modCredenceForUser(operatorId, userCredenceVOHolder, res); Here is part of my service provider code: public class AuthenticationInterceptor extends AbstractPhaseInterceptor { public AuthenticationInterceptor(){ super(Phase.RECEIVE); } /* @Override public void handleFault(Message message) { super.handleFault(message); } */ public void handleMessage(Message message) { ...... ...... } } I want to find out the request param "userCredenceVO", but how could I find it inthe message. This problem confused me a day, any help I would appreciate.
has title: cxf interceptor intercept the request, but i can not find out the request params in the message
tagged with: cxf
tagged with: java
has answer: http://stackoverflow.com/a/22243318
tagged with: web-services
type: Question

http://stackoverflow.com/q/22090203
has comment: http://stackoverflow.com/comment/33504567
tagged with: python
has title: twisted prematurely closing connection with java socket
score: 0
tagged with: java
answer count: 1
has answer: http://stackoverflow.com/a/22090868
has comment: http://stackoverflow.com/comment/33504873
type: UnansweredQuestion
tagged with: twisted
has comment: http://stackoverflow.com/comment/33504690
has body: i have the following server code: from twisted.internet.protocol import Protocol, Factory from twisted.internet import reactor from twisted.protocols.basic import NetstringReceiver class Echo(NetstringReceiver): def stringReceived(self, request): print("stringReceived: %s" % request) def connectionLost(self, reason): print(reason) this python client will repeatedly cause the server to print stringReceived: ... messages as expected with a single connection: import socket import json import sys import time HOST = 'localhost' # The remote host PORT = 6001 # The same port as used by the server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) params = { "chat_id": sys.argv[1], "session": sys.argv[2], } send = '%s:%s,' % (len(json.dumps(params)), json.dumps(params)) s.send((send.strip())) while 1: params = { "chat_id": sys.argv[1], "session": sys.argv[2], "message": sys.argv[3], } send = '%s:%s,' % (len(json.dumps(params)), json.dumps(params)) s.send(send) time.sleep(1) this java code, however, will output stringReceived: ... once. after that single output, i get the error, [Failure instance: Traceback (failure with no frames): : Connection was closed cleanly. the java socket code is: public void sendMessage(final String message) { new Thread(new Runnable(){ @Override public void run() { try { if(socket == null) { socket = new Socket("192.168.1.6", 6001); Log.i("", "CREATING:"+socket.toString()); } Log.i("", socket.toString()); OutputStream out = socket.getOutputStream(); PrintWriter output = new PrintWriter(out); output.println(String.format("%d:%s,", message.length(), message)); output.flush(); } catch (IOException e) { Log.i("exc", e.getMessage()); } } }).start(); } what is it that is closing the connection prematurely? this is the only class that has access to that socket and this is the only method that uses it.
has comment: http://stackoverflow.com/comment/33504711
type: Question
tagged with: sockets
tagged with: android

http://stackoverflow.com/q/22045165
possible better answer: http://stackoverflow.com/a/22045441
has title: Java, DatagramPacket receive, how to determine local ip interface
type: AnsweredQuestion
downvote count: 0
tagged with: java
has comment: http://stackoverflow.com/comment/33424127
upvote count: 8
type: Question
tagged with: datagram
linked to: http://stackoverflow.com/q/9481865
answer count: 2
has comment: http://stackoverflow.com/comment/33424145
has answer: http://stackoverflow.com/a/22045441
has comment: http://stackoverflow.com/comment/33424250
has body: Here's simple case when binding to all ip interfaces and specific udp port: int bindPort = 5555; // example, udp port number DatagramSocket socket = new DatagramSocket(bindPort); byte[] receiveData = new byte[1500]; DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); ... socket.receive(receivePacket); How do I know on which ip interface I received packet ? I can see there is getSocketAddress(): Gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from. but that returns remote ip+port. I would like to know local ip (local port is 5555 in this example). Is it possible with std. Java libraries ?
score: 8
has answer: http://stackoverflow.com/a/31966181
favorite count: 0
accepted answer: http://stackoverflow.com/a/31966181
has comment: http://stackoverflow.com/comment/33423985

http://stackoverflow.com/comment/33481423
type: QuestionComment
type: Comment
has text: Note that your **java** IOException **does not** come from `cp` not finding a file. Rather it is likely coming from failing to find the executable - which would actually be `su` rather than `cp`.
score: 0
comment on: http://stackoverflow.com/q/22077370

http://stackoverflow.com/a/22137452
type: Answer
has body: Yes, you can format your output either by using System.out.printf() or by using System.out.format(). Monthly Interest: 37.5 &lt;-----Would like this to display the monthly interest properly Now, in comments you mention 0.375 and then you show 37.5 here. Surly, the unit in which the value is represented will change, bear that in mind.
answers question: http://stackoverflow.com/q/22137386
has comment: http://stackoverflow.com/comment/33590185
has comment: http://stackoverflow.com/comment/33589934
score: 0
has comment: http://stackoverflow.com/comment/33589951

applet
tags question: http://stackoverflow.com/q/22165418
tags question: http://stackoverflow.com/q/22074063
tags question: http://stackoverflow.com/q/22017269
tags question: http://stackoverflow.com/q/22074387
tags question: http://stackoverflow.com/q/22101087
tags question: http://stackoverflow.com/q/22076657
tags question: http://stackoverflow.com/q/22074397
tags question: http://stackoverflow.com/q/22011647
tags question: http://stackoverflow.com/q/22089173
tags question: http://stackoverflow.com/q/22045710
tags question: http://stackoverflow.com/q/22113669
type: Tag
tags question: http://stackoverflow.com/q/22027815
tag name: applet
tags question: http://stackoverflow.com/q/22021731
tags question: http://stackoverflow.com/q/22024040
tags question: http://stackoverflow.com/q/22156945
tags question: http://stackoverflow.com/q/22088646
tags question: http://stackoverflow.com/q/22135496
tags question: http://stackoverflow.com/q/22079714
tags question: http://stackoverflow.com/q/22110759
tags question: http://stackoverflow.com/q/22026682
tags question: http://stackoverflow.com/q/22110106
tags question: http://stackoverflow.com/q/22099352
tags question: http://stackoverflow.com/q/22143120
tags question: http://stackoverflow.com/q/22156990
tags question: http://stackoverflow.com/q/22140517
tags question: http://stackoverflow.com/q/22048629
tags question: http://stackoverflow.com/q/22050158
tags question: http://stackoverflow.com/q/22086206
tags question: http://stackoverflow.com/q/22064583
tags question: http://stackoverflow.com/q/22148093
tags question: http://stackoverflow.com/q/22089190
tags question: http://stackoverflow.com/q/22019069
tags question: http://stackoverflow.com/q/22103786

http://stackoverflow.com/q/22112899
has body: String str="Today is Sunday" And the output should be "Sunday is Today" I need a code for this program in Java. Is there any other method to do it...
has comment: http://stackoverflow.com/comment/33545526
has comment: http://stackoverflow.com/comment/33545466
score: -3
upvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33545589
tagged with: java
has comment: http://stackoverflow.com/comment/33545519
has comment: http://stackoverflow.com/comment/33545477
has title: Java programming Input:Today is Sunday Output:Sunday is today
has comment: http://stackoverflow.com/comment/33545531
downvote count: 4
answer count: 2
has comment: http://stackoverflow.com/comment/33545491
has answer: http://stackoverflow.com/a/22112919
favorite count: 0
has answer: http://stackoverflow.com/a/22112934
type: UnansweredQuestion

http://stackoverflow.com/a/22115974
downvote count: 0
has body: Since you are sending null to paint, Graphics g contains null (points to nowhere). Then inside paint(...) you call setColor(...) on g, which is null. null.setColor(...) causes NullPointerException.
upvote count: 2
answers question: http://stackoverflow.com/q/22115913
type: Answer
score: 2

http://stackoverflow.com/a/22172643
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/33661509
has body: it's a bug in JDK 1.7.0_45. you must upgrade your jdk. see also Class JavaLaunchHelper is implemented in both. One of the two will be used. Which one is undefined
downvote count: 0
answers question: http://stackoverflow.com/q/22164662
has comment: http://stackoverflow.com/comment/33664548
type: Answer

http://stackoverflow.com/comment/33449847
type: AnswerComment
has text: Ah, worked perfect, thank you! My professor hadn't taught us that yet. Some of the numbers are still off my a tiny margin, but I think I might be able to round them.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22059514

http://stackoverflow.com/q/22131816
tagged with: java
has body: Where is the mistake in my code? package My; import java.text.SimpleDateFormat; import java.util.Date; public class Hello { public static void main(String[] args) { Date now = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("MMM/dd/yyyy HH:mm:ss"); String formattedDate = formatter.format(now); System.out.println(formattedDate + "&gt; Hello, " + args[0] + "!"); } } out put is Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at My.Hello.main(Hello.java:11) }
has comment: http://stackoverflow.com/comment/33580508
has comment: http://stackoverflow.com/comment/33580259
has comment: http://stackoverflow.com/comment/33580277
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/33580291
upvote count: 0
tagged with: arrays
downvote count: 5
has comment: http://stackoverflow.com/comment/33580271
has comment: http://stackoverflow.com/comment/33580315
has comment: http://stackoverflow.com/comment/33580326
has comment: http://stackoverflow.com/comment/33580306
possible better answer: http://stackoverflow.com/a/22131902
favorite count: 0
has comment: http://stackoverflow.com/comment/33580507
has answer: http://stackoverflow.com/a/22131923
has comment: http://stackoverflow.com/comment/33580439
has comment: http://stackoverflow.com/comment/33580294
has answer: http://stackoverflow.com/a/22131902
has title: Why `java.lang.ArrayIndexOutOfBoundsException: 0` with `main` method arguments
accepted answer: http://stackoverflow.com/a/22131923
has comment: http://stackoverflow.com/comment/35482784
tagged with: timestamp
type: AnsweredQuestion
score: -5
has comment: http://stackoverflow.com/comment/33580272

http://stackoverflow.com/comment/33585579
type: Comment
score: 2
has text: Could you include the whole stack trace please? :)
comment on: http://stackoverflow.com/q/22134782
type: QuestionComment

http://stackoverflow.com/comment/33551844
has text: Your request mapping is a POST to "/login" not a GET to "/login.html".
comment on: http://stackoverflow.com/q/22116377
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22015365
favorite count: 0
tagged with: heap-memory
type: UnansweredQuestion
score: 1
upvote count: 1
has title: "Unknown error" with cypher query on all relations
has answer: http://stackoverflow.com/a/22084306
type: Question
tagged with: java
tagged with: memory
has body: Using neo4j 2.0.1 I frequently observe Java heap space problems. For example when trying to delete all relations of one type I only get an "unknown error". I'm running neo4j server on my local machine (kubuntu 13.10) with 8 gig ram, 6gig java heap space. the same happens when performing the query on a virtual ubuntu server. did not observe these issues with previous versions. I also attached the neo4j output from the console. I'm not a java developer, so it does not really help me. thanks for suggestions Starting Neo4j Server console-mode... Using additional JVM arguments: -server -XX:+DisableExplicitGC -Dorg.neo4j.server.properties=conf/neo4j-server.properties -Djava.util.logging.config.file=conf/logging.properties -Dlog4j.configuration=file:conf/log4j.properties -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Xms512m -Xmx6196m Detected incorrectly shut down database, performing recovery.. 13:50:00.431 [main] WARN o.e.j.server.handler.ContextHandler - o.e.j.s.ServletContextHandler@35f6002a{/,null,null} contextPath ends with / 13:50:00.431 [main] WARN o.e.j.server.handler.ContextHandler - Empty contextPath 13:50:00.433 [main] INFO org.eclipse.jetty.server.Server - jetty-9.0.5.v20130815 13:50:00.458 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.s.h.MovedContextHandler@453831c{/,null,AVAILABLE} 13:50:00.534 [main] INFO o.e.j.w.StandardDescriptorProcessor - NO JSP Support for /webadmin, did not find org.apache.jasper.servlet.JspServlet 13:50:00.546 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.w.WebAppContext@3c3aea35{/webadmin,jar:file:/media/data/software/Neo4j/system/lib/neo4j-server-2.0.1-static-web.jar!/webadmin-html,AVAILABLE} 13:50:00.950 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@2078afe{/db/manage,null,AVAILABLE} 13:50:01.206 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@216e21b4{/db/data,null,AVAILABLE} 13:50:01.224 [main] INFO o.e…
answer count: 1
downvote count: 0
tagged with: neo4j

graphics
tag name: graphics
tags question: http://stackoverflow.com/q/22161724
tags question: http://stackoverflow.com/q/22025537
tags question: http://stackoverflow.com/q/22046832
tags question: http://stackoverflow.com/q/22031466
tags question: http://stackoverflow.com/q/22146784
tags question: http://stackoverflow.com/q/22118917
tags question: http://stackoverflow.com/q/22086827
type: Tag
tags question: http://stackoverflow.com/q/22013918
tags question: http://stackoverflow.com/q/22087998
tags question: http://stackoverflow.com/q/22115913
tags question: http://stackoverflow.com/q/22123266
tags question: http://stackoverflow.com/q/22026606
tags question: http://stackoverflow.com/q/22131342
tags question: http://stackoverflow.com/q/22160555
tags question: http://stackoverflow.com/q/22057038

http://stackoverflow.com/q/22021872
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33382318
type: Question
tagged with: iterator
linked to: http://stackoverflow.com/q/9494380
has title: Relationship between class and iterator interface
answer count: 1
has comment: http://stackoverflow.com/comment/33382400
has comment: http://stackoverflow.com/comment/33382296
has comment: http://stackoverflow.com/comment/33382343
favorite count: 0
tagged with: class
has answer: http://stackoverflow.com/a/24042484
has body: Will a class become an iterator object itself if it implements an iterator interface. For example, public class StringGridIterator implements Iterator&lt;String&gt;{ //some methods here... } or Do I need to specifically create a variable reference to an iterator object that will iterate through a certain String objects? like this... Iterator&lt;String&gt; it = object.iterator(); I don't know if this is clear enough for you to understand since I am still struggling with understanding Java concept like class and object myself.. Just leave a comment if you don't understand what I am trying to say.
upvote count: 2
downvote count: 1
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/24042484

cucumber-jvm
tag name: cucumber-jvm
type: Tag
tags question: http://stackoverflow.com/q/22150527
tags question: http://stackoverflow.com/q/22099805
tags question: http://stackoverflow.com/q/22162251

http://stackoverflow.com/q/22116789
upvote count: 1
answer count: 1
has body: I am retrieving multiple rows from table and then want that my processor process them, but i observe camel is calling my processor for every row, i want to pass List of entities following is my code from("jpa:com.pns.ab.model.LoanRequest?consumeDelete=false" + "&amp;consumer.delay=20000" + "&amp;consumer.namedQuery=selectLoanRequests" + "&amp;persistenceUnit=LoanServicePU").process(new JpaProcessor()); in processor LoanRequest lr = exchange.getIn().getBody(LoanRequest.class); but i want option like List&lt;LoanRequest&gt; requests = exchange.... Regards,
tagged with: java
tagged with: apache-camel
tagged with: jpa
downvote count: 0
score: 1
has answer: http://stackoverflow.com/a/22119312
has title: How to process multiple jpa entity to processor in camel
type: Question
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22119312
favorite count: 0

http://stackoverflow.com/comment/33453757
score: 0
type: AnswerComment
has text: Yeah, no idea what the `:08` and such may be, but it was fairly obvious that the first bit was hex.
type: Comment
comment on: http://stackoverflow.com/a/22062208

http://stackoverflow.com/comment/33565689
has text: Well it is an answer, I understand its short but some questions only need a short answer
type: Comment
score: 0
comment on: http://stackoverflow.com/a/22123882
type: AnswerComment

http://stackoverflow.com/comment/33583535
comment on: http://stackoverflow.com/q/22133585
score: 0
type: QuestionComment
has text: Print out the values of `name`, `passengers[i]` etc to see precisely what is `null`
type: Comment

http://stackoverflow.com/q/22028756
tagged with: matrix
tagged with: matrix-inverse
answer count: 4
has answer: http://stackoverflow.com/a/22028820
has body: I looked for this everywhere, but I am wrong somewhere. In my Java program, I created few 2D Arrays. Now, I need to form new 2D arrays with previous, like, inverse, transpose, multiplying , LEFT DIVISION and maybe even more. Some of them (simple) I created myself, but left division, right division, inverse I didn't. By using libs like Jama, some problem appears. java.lang.RuntimeException: Matrix is rank deficient. And I code it like this: Matrix Am=new Matrix(A); Am=Am.inverse(); A is 2D Array (m x n), and Am is new matrix created from 2DArray A. I tried to do this to get left division, but I cannot solve matrix inverse first. Where is my mistake? Does someone know another library to convert from 2DArray to Matrix, and then do harder matrix operations (left div, inv...) with it? EDIT I use inverse on this matrix to get A\P (can be computed as inverse(A)*P as I saw somewhere). Do you know how to get A\P with Jama? This is my primary probleb, left division.
has answer: http://stackoverflow.com/a/22028830
type: UnansweredQuestion
has title: Matrix operations in Java
tagged with: java
tagged with: jama
type: Question
has answer: http://stackoverflow.com/a/22028832
has answer: http://stackoverflow.com/a/22028821
linked to: http://stackoverflow.com/q/10815518
score: 0
tagged with: multidimensional-array

http://stackoverflow.com/comment/33398832
comment on: http://stackoverflow.com/q/22030798
score: 0
type: QuestionComment
type: Comment
has text: @UliKöhler So what _would_ satisfy you? If the specification and implementation don't?

http://stackoverflow.com/a/22019530
score: 1
answers question: http://stackoverflow.com/q/22019452
upvote count: 1
downvote count: 0
has body: super() refers to the base/parent class. Can be used in constructor to invoke parent constructor but must be done in the declaration of the constructor.
type: Answer

http://stackoverflow.com/comment/33403191
score: 0
has text: @EdwinDalorzo Sorry I am not aware of intern() but I can google what it is.Thanks for suggestion
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22033409

http://stackoverflow.com/comment/33446270
type: QuestionComment
comment on: http://stackoverflow.com/q/22057490
score: 0
has text: Replace the `//handle exception...` with `ex.printStackTrace();` and check for console output that looks like an error.
type: Comment

http://stackoverflow.com/a/22107741
type: AcceptedAnswer
type: Answer
answers question: http://stackoverflow.com/q/22107602
has body: You are appending your new rectangles to the same string. Add newRectangleOutput = ""; in the while loop before your for loop for all rectangles while (option == JOptionPane.YES_OPTION) { . . newRectangleOutput = ""; for (int i = 0; i &lt; rectangleNumber; i++) { . . } }
accepted answer of: http://stackoverflow.com/q/22107602
score: 0

http://stackoverflow.com/q/22107340
has title: How to set the checking of initial values in Spring?
type: UnansweredQuestion
tagged with: spring
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22107341
score: 0
has body: I am making my first spring application. Trying for some better organizing, I met a problem: The application gets the initial values of attributes from some spring file springValues. Naturally, I have to check the values got. Where have I to put the limits, against which I have to check the initial values? These limits are the initial values, too, so, they will be in another spring file springLimits. Obviously, it is senseless to put values and limits into the same file - they are pieces of information of different levels - values are far more volatile that limits. Here comes the problem - I have to tie limits to values in code, for every property separately. It doesn't look consistent or convenient to me. Is there some tool in Spring to find what limits belong to what values automatically? If I used property files instead of Spring, it would be trivial, but how to do it in Spring? As I see now, I have to tie limits to value for every value separately. And working with properties I can tie limits to value by name, for example x->UpperX, LowerX. And I'll have to write ONE checking method for all values.
answer count: 1
tagged with: initialization

http://stackoverflow.com/comment/33645301
has text: I am suppose to select only one row to save the record in the datatable.When I use the "dateselect" event when I select a row and give the date2 and when i selec another row and provide the same date2 the previously provided date in the previously selected row is not getting cleared.It remains as it is.
comment on: http://stackoverflow.com/q/22168302
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/34928726
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22022145
has text: @AnubianNoob I thought the same about `MalformedInputException` when using a `CharsetEncoder`, and yet...
type: Comment

http://stackoverflow.com/comment/33624469
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22156567
has text: why is your server sending html if you are calling it from an application?
score: 0

http://stackoverflow.com/q/22075052
answer count: 5
has answer: http://stackoverflow.com/a/22075187
has body: Is there a way that I can print out all names and values of an Object where Object can be of any class? i.e. If Object was Person and Person had a member variable Integer age; - I need a method that could receive an instance of Object (where the Object is Person in this case but could be any other type of object) and print out age - 35 where age is the member variable name and 35 is its value. Something like: public Map&lt;String, String&gt; getNamesAndValues(Object object) { Map&lt;String, String&gt; namesAndValues = new HashMap&lt;&gt;(); //Populate namesAndValues Map here using object in signature. return namesAndValues; } If variables are private or protected then it should check for getters as well.
has comment: http://stackoverflow.com/comment/33477107
score: -3
downvote count: 3
has answer: http://stackoverflow.com/a/22075182
type: AnsweredQuestion
has title: List all Names and Values of an Object
has answer: http://stackoverflow.com/a/22075149
tagged with: reflection
has answer: http://stackoverflow.com/a/22075519
tagged with: java
possible better answer: http://stackoverflow.com/a/22075149
type: Question
has answer: http://stackoverflow.com/a/22077239
upvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/22075519
has comment: http://stackoverflow.com/comment/33477593

http://stackoverflow.com/q/22039876
has body: This is what I found in the LogCat: 02-26 05:10:44.943: E/AndroidRuntime(844): FATAL EXCEPTION: main 02-26 05:10:44.943: E/AndroidRuntime(844): java.lang.RuntimeException: Unable to start activity ComponentInfo{course.labs.todomanager/course.labs.todomanager.ToDoManagerActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f060013 type #0x12 is not valid 02-26 05:10:44.943: E/AndroidRuntime(844): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211) 02-26 05:10:44.943: E/AndroidRuntime(844): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 02-26 05:10:44.943: E/AndroidRuntime(844): at android.app.ActivityThread.access$600(ActivityThread.java:141) 02-26 05:10:44.943: E/AndroidRuntime(844): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 02-26 05:10:44.943: E/AndroidRuntime(844): at android.os.Handler.dispatchMessage(Handler.java:99) 02-26 05:10:44.943: E/AndroidRuntime(844): at android.os.Looper.loop(Looper.java:137) 02-26 05:10:44.943: E/AndroidRuntime(844): at android.app.ActivityThread.main(ActivityThread.java:5103) 02-26 05:10:44.943: E/AndroidRuntime(844): at java.lang.reflect.Method.invokeNative(Native Method) 02-26 05:10:44.943: E/AndroidRuntime(844): at java.lang.reflect.Method.invoke(Method.java:525) 02-26 05:10:44.943: E/AndroidRuntime(844): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 02-26 05:10:44.943: E/AndroidRuntime(844): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 02-26 05:10:44.943: E/AndroidRuntime(844): at dalvik.system.NativeStart.main(Native Method) 02-26 05:10:44.943: E/AndroidRuntime(844): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f060013 type #0x12 is not valid 02-26 05:10:44.943: E/AndroidRuntime(844): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2309) 02-26 05:10:44.943: E/AndroidRuntime(844): at android.content.res.Resources.getL…
type: Question
tagged with: android-layout
has answer: http://stackoverflow.com/a/22083858
tagged with: eclipse
has title: A run-time error prevent my to-do application to start
answer count: 3
has answer: http://stackoverflow.com/a/22039909
has answer: http://stackoverflow.com/a/22116445
downvote count: 0
favorite count: 0
upvote count: 2
type: UnansweredQuestion
tagged with: android
score: 2
has comment: http://stackoverflow.com/comment/33414106
tagged with: java

http://stackoverflow.com/q/22074063
has answer: http://stackoverflow.com/a/32411466
tagged with: code-signing-certificate
accepted answer: http://stackoverflow.com/a/22178045
type: AnsweredQuestion
upvote count: 2
tagged with: java
has body: You can check the issue here by opening twice a .txt file (using double click or "Edit Document") or pressing "Globe". It won't be opened during second and any further attempt (In Firefox and Chrome). Just a new line appears in Java console: liveconnect: Security Exception: LiveConnect (JavaScript) blocked due to security settings. The certificate is valid: And here are strange lines in Console: security: Trust for: http://...OpenDocument.jar has ended: Thu Jan 01 02:00:00 EET 1970 security: Validate the certificate chain using CertPath API basic: Plugin2ClassLoader.getPermissions CeilingPolicy allPerms security: Validate the certificate chain using CertPath API I tried to add Application-Library-Allowable-Codebase manifest attribute, tried to add a timestamp. How to satisfy security constrains to avoid this security exception? Update1: The applet can be run once again after reload. Update2: The issue is absent under JRE version 1.7.0_45
type: Question
linked to: http://stackoverflow.com/q/21188549
has title: Java 7u51: LiveConnect (JavaScript) blocked due to security settings
has answer: http://stackoverflow.com/a/22178045
tagged with: code-signing
answer count: 2
score: 2
downvote count: 0
tagged with: applet
possible better answer: http://stackoverflow.com/a/32411466
favorite count: 0

http://stackoverflow.com/q/22021129
upvote count: 3
tagged with: java
possible better answer: http://stackoverflow.com/a/22021357
type: Question
has answer: http://stackoverflow.com/a/22021357
linked to: http://stackoverflow.com/q/375420
downvote count: 0
linked to: http://stackoverflow.com/q/133601
has answer: http://stackoverflow.com/a/22022667
has title: Nested regexps and replace
has comment: http://stackoverflow.com/comment/33381916
has comment: http://stackoverflow.com/comment/33380951
tagged with: regex
has answer: http://stackoverflow.com/a/22022267
favorite count: 0
has body: I have strings like this &lt;p0=v0 p1=v1 p2=v2 ....&gt; and I want to swap pX with vX to have something like &lt;v0=p0 v1=p1 v2=p2 ....&gt; using regexps. I want only pairs in &lt;&gt; to be swapped. I wrote: Pattern pattern = Pattern.compile("&lt;(\\w*)=(\\w*)&gt;"); Matcher matcher = pattern.matcher("&lt;p1=v1&gt;"); System.out.println(matcher.replaceAll("$2=$1")); But it works only with a single pair pX=vX Could someone explain me how to write regexp that works for multiple pairs?
answer count: 5
has answer: http://stackoverflow.com/a/22022104
type: AnsweredQuestion
score: 3
has comment: http://stackoverflow.com/comment/33381735
has answer: http://stackoverflow.com/a/22022206
accepted answer: http://stackoverflow.com/a/22022667

http://stackoverflow.com/a/22006910
has body: what you want to do is finding an user only by id, i think the following code is better: for(UserInfo user: users){ if(user.getId().equals(id)){ return user; } } i would explicitly initialize variables because it's meaningful, using default in-built mechanism will make others confused when reading your code.
answers question: http://stackoverflow.com/q/22006295
score: 0
type: Answer

http://stackoverflow.com/comment/33558822
score: 1
has text: ***Very*** similar question asked by a *different user* twenty minutes after this one was posted: http://stackoverflow.com/questions/22120122/invoking-to-type-the-team-name-twice-instead-of-once
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22119883

http://stackoverflow.com/q/22031588
has body: I am doing a bit of manual deserialization of an xml file. I need to convert all the values in the xml file (which are Strings) into the proper types. I am getting the proper type by matching the name of the xml tag to a Field in my object via reflection. Right now, the code I am using is a bit ugly: Field matchedField = getMatchingField(getNodeName(node)); Class&lt;?&gt; type = matchedField.getType(); if (Integer.class.isAssignableFrom(type)) { return Integer.parseInt(parseNode(node)); } else if (Double.class.isAssignableFrom(type)) { return Double.parseDouble(parseNode(node)); } else if // ... etc for all the types I am using Is there a way to automate this process? Something like: return ConvertToType(type, parseNode(node)); It seems that C# has something like this, does Java have a similar utility? It isn't a requirement that this has to be extensible for custom Types. I can do the conversion for custom Types manually.
tagged with: casting
downvote count: 0
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/22031745
upvote count: 1
type: AnsweredQuestion
tagged with: reflection
score: 1
tagged with: java
has title: Automatically convert a String to a dynamically determined type?
accepted answer: http://stackoverflow.com/a/22031745
type: Question

http://stackoverflow.com/comment/33596290
type: Comment
type: QuestionComment
has text: btw guessing range is between 1-100
score: 0
comment on: http://stackoverflow.com/q/22141413

swing
tags question: http://stackoverflow.com/q/22149909
tags question: http://stackoverflow.com/q/22058987
tags question: http://stackoverflow.com/q/22123614
tags question: http://stackoverflow.com/q/22118237
tags question: http://stackoverflow.com/q/22025534
tags question: http://stackoverflow.com/q/22154389
tags question: http://stackoverflow.com/q/22031086
tags question: http://stackoverflow.com/q/22117689
tags question: http://stackoverflow.com/q/22011955
tags question: http://stackoverflow.com/q/22032908
tags question: http://stackoverflow.com/q/22091974
tags question: http://stackoverflow.com/q/22165621
tags question: http://stackoverflow.com/q/22040845
tags question: http://stackoverflow.com/q/22154456
tags question: http://stackoverflow.com/q/22131726
tags question: http://stackoverflow.com/q/22117643
tags question: http://stackoverflow.com/q/22165225
tags question: http://stackoverflow.com/q/22134138
tags question: http://stackoverflow.com/q/22093464
tags question: http://stackoverflow.com/q/22005632
tags question: http://stackoverflow.com/q/22158755
tags question: http://stackoverflow.com/q/22057490
tags question: http://stackoverflow.com/q/22127307
tags question: http://stackoverflow.com/q/22103812
tags question: http://stackoverflow.com/q/22113348
tags question: http://stackoverflow.com/q/22133484
tags question: http://stackoverflow.com/q/22141063
tags question: http://stackoverflow.com/q/22130295
tags question: http://stackoverflow.com/q/22135477
tags question: http://stackoverflow.com/q/22161855
tags question: http://stackoverflow.com/q/22092365
tags question: http://stackoverflow.com/q/22162398
tags question: http://stackoverflow.com/q/22140006
tags question: http://stackoverflow.com/q/22119950
tags question: http://stackoverflow.com/q/22089481
tags question: http://stackoverflow.com/q/22055708
tags question: http://stackoverflow.com/q/22120843
tags question: http://stackoverflow.com/q/22155563
tags question: http://stackoverflow.com/q/22131947
tags question: http://stackoverflow.com/q/22081306
tags question: http://stackoverflow.com/q/22143648
tags question: http://stackoverflow.com/q/22127833
tags question: http://stackoverflow.com/q/22094893
tags question: http://stackoverflow.com/q/22023391
tags question: http://stackoverflow.com/q/22005859
tags question: http://stackoverflow.com/q/22067446
tags question: http://stackoverflow.com/q/22056821
tags question: http://stackoverflow.com/q/22066387
tags question: http://stackoverflow.com/q/22093911
tags question: http://stackoverflow.com/q/22110160
tags question: http://stackoverflow.com/q/22030630
tags question: http://stackoverflow.com/q/22076183
tags question: http://stackoverflow.com/q/22154812
tags question: http://stackoverflow.com/q/22093555
tags question: http://stackoverflow.com/q/22150143
tags question: http://stackoverflow.com/q/22143298
tags question: http://stackoverflow.com/q/22155760
tags question: http://stackoverflow.com/q/22105766
tags question: http://stackoverflow.com/q/22110106
tags question: http://stackoverflow.com/q/22107954
tags question: http://stackoverflow.com/q/22151612
tags question: http://stackoverflow.com/q/22092168
tags question: http://stackoverflow.com/q/22092196
tags question: http://stackoverflow.com/q/22091083
tags question: http://stackoverflow.com/q/22049581
tags question: http://stackoverflow.com/q/22079260
tags question: http://stackoverflow.com/q/22044486
tags question: http://stackoverflow.com/q/22121741
type: Tag
tags question: http://stackoverflow.com/q/22166549
tags question: http://stackoverflow.com/q/22150567
tags question: http://stackoverflow.com/q/22168669
tags question: http://stackoverflow.com/q/22127737
tags question: http://stackoverflow.com/q/22129200
tags question: http://stackoverflow.com/q/22030127
tags question: http://stackoverflow.com/q/22145768
tags question: http://stackoverflow.com/q/22128564
tags question: http://stackoverflow.com/q/22041044
tags question: http://stackoverflow.com/q/22032581
tags question: http://stackoverflow.com/q/22088217

http://stackoverflow.com/comment/33435827
comment on: http://stackoverflow.com/q/22028317
score: 0
type: QuestionComment
type: Comment
has text: Why not use Binet Formula? Ditch Recursion here. :D

http://stackoverflow.com/comment/33415553
score: 0
has text: I am using Jersey 1.18 and tomcat 6. As @DanielSzalay it works for me too.
type: Comment
comment on: http://stackoverflow.com/a/22035700
type: AnswerComment

http://stackoverflow.com/comment/33968319
has text: Hi mvreijn, can you please help me with Edit -2 ,i.e fetching the domain with UPN, in the above code when i pass ldapContext and zzserver.ad(UPN) as arguements, the method returns null :( . Stuck! in this really :(
type: Comment
comment on: http://stackoverflow.com/a/22091904
score: 0
type: AnswerComment

http://stackoverflow.com/q/22119798
tagged with: object
has body: I am trying to write a very basic java program that will run allow the user to enter information about some employees. What I have in mind is a for loop that will create a separate Employee object (of an Employee class, already defined) and then retain each object in memory after the entire loop has run. Something like this: String input = JOptionPane.showInputDialog("How many Employees are we " + "entering into the system?"); int numEmployees = Integer.parseInt(input); for (int count = 1; count &lt;= numEmployees; count ++) { Employee employee(count) = new Employee(); } I know this code doesn't work; but I hope it makes clear that what I am trying to do is: each iteration of the loop create a new object (employee1, employee2....employeeN) and then have some code that will allow the user to enter the needed data.I already have all the necessary accessor and mutator methods. The object would remain in memory after the loop is finished running. Any ideas? Thanks everyone!
has answer: http://stackoverflow.com/a/22119954
has comment: http://stackoverflow.com/comment/33557944
has answer: http://stackoverflow.com/a/22119842
score: 0
tagged with: for-loop
upvote count: 1
has answer: http://stackoverflow.com/a/22119872
has answer: http://stackoverflow.com/a/22119851
downvote count: 1
answer count: 7
favorite count: 0
has answer: http://stackoverflow.com/a/22119857
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22119868
has title: Creating new objects in the body of a loop
tagged with: java
has answer: http://stackoverflow.com/a/22119861
type: Question

http://stackoverflow.com/a/22151020
upvote count: 2
accepted answer of: http://stackoverflow.com/q/22116969
has body: Try to keep members of Data class too. Data class properties must be untouched to allow Gson converter fill it, as it is done based on property names. Good luck.
has comment: http://stackoverflow.com/comment/33619178
answers question: http://stackoverflow.com/q/22116969
has comment: http://stackoverflow.com/comment/33785079
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33643176
type: Answer
score: 2

http://stackoverflow.com/comment/33373205
has text: Pretty sure it's a missing `}` like the error says. Put it in an IDE. Reformat it. Chances are that will find your error.
type: Comment
comment on: http://stackoverflow.com/q/22016586
score: 0
type: QuestionComment

http://stackoverflow.com/q/22022145
upvote count: 5
tagged with: character-encoding
has comment: http://stackoverflow.com/comment/34928726
has comment: http://stackoverflow.com/comment/33382971
answer count: 2
has comment: http://stackoverflow.com/comment/33383041
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/33382943
has comment: http://stackoverflow.com/comment/34928715
has comment: http://stackoverflow.com/comment/33382911
has comment: http://stackoverflow.com/comment/33383020
has body: [Note: question basically re-edited after a lot of playing around] In Java, you have Charset, defining a character encoding. From a Charset, you can obtain two objects: a CharsetEncoder, to turn a char sequence into a byte sequence; a CharsetDecoder, to turn a byte sequence into a char sequence. Both of these classes have the following methods defined: .onUnmappableCharacter() and .onMalformedInput(). If you tell them for each of these to CodingErrorAction.REPORT they will throw either of these two exceptions: UnmappableCharacterException and MalformedInputException. With a CharsetEncoder, I am able to generate both of them: feed it with a CharBuffer containing two high surrogates following one another --> MalformedInputException; feed it with a CharBuffer containing a char (or char sequence) which the encoding cannot represent: UnmappableCharacterException. With a CharsetDecoder: feed it with an illegal byte sequence: MalformedInputException -- easy to do; UnmappableCharacterException --> how? In spite of all my research, I just couldn't do it. All of this in spite of having played a lot with CharsetDecoder. I could find no combination of Charset and byte sequence able to generare this error... Is there any at all?
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33385400
tagged with: java
has answer: http://stackoverflow.com/a/22902806
has title: How to generate an UnmappableCharacterException from CharsetDecoder's .decode()?
type: Question
has comment: http://stackoverflow.com/comment/33385559
possible better answer: http://stackoverflow.com/a/22889333
score: 5
accepted answer: http://stackoverflow.com/a/22902806
has answer: http://stackoverflow.com/a/22889333

http://stackoverflow.com/comment/33497308
comment on: http://stackoverflow.com/a/22085439
score: 0
type: Comment
type: AnswerComment
has text: What I said is especially true for this particular algorithm. It's easy to understand the concept, but the implementation is a bit unpleasant because of all the bookkeeping you need to do.

http://stackoverflow.com/comment/66208203
has text: That particular invocation doesn't prove that it isn't selecting max...
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22117167
score: 1

http://stackoverflow.com/comment/33466891
score: 0
type: AnswerComment
type: Comment
has text: Glad it helped. Good luck with the rest of your migration. :)
comment on: http://stackoverflow.com/a/22068316

http://stackoverflow.com/a/51833809
downvote count: 1
answers question: http://stackoverflow.com/q/22023460
score: 0
has body: Hope following code will help you //example, BETTER THAN USE STRING_BUILDER, this class auto escape data //this is usage example for simple xhtml public static void main(String[] args) throws Exception { XMLWriter docWriter = XMLWriter.create("html", html->{ html.children(new String[]{"head","title"}, title->title.childText("My TITLE")); html.child("body", body->{ body.attr("bgcolor", "red"); body.child("div", div->{ Map<String, String> userMap = new LinkedHashMap<String, String>(); userMap.put("roll-no", "1"); userMap.put("name", "Dharm"); div.child(userMap); }); body.child("div", div->{ Map<String, String> userMap = new LinkedHashMap<String, String>(); userMap.put("roll-no", "2"); userMap.put("name", "Pruthvi & Rajan"); //see here '&' div.child(userMap); }); }); }); //call docWriter.write() method depends on requirement //example 1:directly generate html string System.out.println(docWriter.toXMLString()); /* //example 2:write html string into stream ByteArrayOutputStream out = new ByteArrayOutputStream(); docWriter.write(out); System.out.println(out.toString()); */ /* //example 3:write html string into file java.io.File file = java.io.File.createTempFile("Test", ".html"); docWriter.write(file); java.awt.Desktop.getDesktop().open(file); */ } I have created my custom class for that dynamic xml creation by code package test.util.doc; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.OutputStream; import java.io.Writer; import java.util.Map; import java.util.function.Consumer; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Result; 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.…
type: Answer
upvote count: 1

http://stackoverflow.com/a/22957888
downvote count: 1
upvote count: 23
score: 22
type: Answer
has body: Maybe this helps: java -Dcom.sun.management.jmxremote \ -Dcom.sun.management.jmxremote.port=9010 \ -Dcom.sun.management.jmxremote.local.only=false \ -Dcom.sun.management.jmxremote.authenticate=false \ -Dcom.sun.management.jmxremote.ssl=false \ -jar xxx.jar
answers question: http://stackoverflow.com/q/22084052

http://stackoverflow.com/comment/33456681
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/22060096
has text: I added the whole code. Maybe i should change the prefsEditor.commit(); place.
score: 0

http://stackoverflow.com/comment/33631201
comment on: http://stackoverflow.com/q/22160528
score: 0
has text: @libik I am pretty sure it's for performance reasons and I understand that. Still, I think this is annoying :-)
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/58256355
has text: `Unable to build Hibernate SessionFactory: Caused by: org.hibernate.AnnotationException: Unknown Id.generator: hibernate-uuid`
type: Comment
comment on: http://stackoverflow.com/a/22149708
score: 1
type: AnswerComment

http://stackoverflow.com/q/22022252
type: Question
tagged with: iterator
tagged with: for-loop
has comment: http://stackoverflow.com/comment/33383166
answer count: 1
has comment: http://stackoverflow.com/comment/33383027
accepted answer: http://stackoverflow.com/a/22022284
tagged with: iterable
score: 0
tagged with: abstract-class
has title: Java Explicit iterator works. Implicit forloop yields "Can only iterate over an array or an instance of java.lang.Iterable"
has comment: http://stackoverflow.com/comment/33389382
has body: I've implemented Iterable&lt;> in my base class but the subclass will not allow an implicit forloop. Why is the Iterator&lt;> working correctly but the for-loop complaining of Can only iterate over an array or an instance of java.lang.Iterable I would have expected the Iterable&lt;> interface to be visible in the subclass. What am I missing? package tester; import java.util.ArrayList; import java.util.Iterator; public class TestInher { private Concrete&lt;Integer&gt; mList = new Concrete&lt;Integer&gt;(); public TestInher() {} public abstract class Base&lt;T&gt; implements Iterable&lt;T&gt; { protected ArrayList&lt;T&gt; list = new ArrayList&lt;T&gt;(); @Override public Iterator&lt;T&gt; iterator() {return list.iterator();} public abstract void add(T item); } public abstract class ClassAbstract&lt;T&gt; extends Base&lt;T&gt;{} public class Concrete&lt;T&gt; extends ClassAbstract&lt;T&gt; { @Override public void add(T item) {list.add(item);} } public void doIt() { for(int i=0; i&lt;10; i++) {mList.add(i);} Iterator&lt;Integer&gt; i = mList.iterator(); while (i.hasNext()) { System.out.println(i.next()); } //Can only iterate over an array or an instance of java.lang.Iterable for(Integer i : mList.iterator()) { } } }
has answer: http://stackoverflow.com/a/22022284
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33383921
linked to: http://stackoverflow.com/q/839178
tagged with: java

http://stackoverflow.com/comment/33555985
score: 0
has text: Read about inner classes.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22118784

http://stackoverflow.com/comment/33355407
type: AnswerComment
has text: Here, the concatenation will be done at run time since the OP's `str` isn't final.
type: Comment
comment on: http://stackoverflow.com/a/22006407
score: 0

http://stackoverflow.com/q/22013634
has comment: http://stackoverflow.com/comment/33367334
favorite count: 0
has comment: http://stackoverflow.com/comment/33367121
has answer: http://stackoverflow.com/a/22013962
has answer: http://stackoverflow.com/a/22013730
answer count: 4
has comment: http://stackoverflow.com/comment/33367228
type: AnsweredQuestion
has title: Wrong output calculating the power
upvote count: 0
has body: I've the below code. import java.util.ArrayList; import java.math.*; import java.util.Arrays; import java.util.Collections; public class Dummy { public static void main(String args[]) throws Exception { int n=12; double val=(3+Math.sqrt(5)); double ne=Math.pow(val, n); String new2=String.valueOf(ne); System.out.println(ne); String[] new1=new2.split("\\."); if(new1[0].length()&gt;3){ new1[0]=new1[0].substring(Math.max(new1[0].length() - 4, 0)); if(new1[0].length()&lt;3){ new1[0]=("0").concat(new1[0]); } else{ new1[0]=new1[0]; } } else if(new1[0].length()&lt;2){ new1[0]=("00").concat(new1[0]); } else if(new1[0].length()&lt;1){ new1[0]=("000").concat(new1[0]); } else if(new1[0].length()&lt;3){ new1[0]=("0").concat(new1[0]); } System.out.println(new1[0]); } } here i'm trying to calculate sum of 3 with root 5 and whole to power of 12 (3+sqrt(5))^12 when i do it the result i get is 4.246814719604947E8 but in real the answer is to be 424681471.960494. please let me know where am i going wrong.
type: Question
has comment: http://stackoverflow.com/comment/33367037
has answer: http://stackoverflow.com/a/22013886
tagged with: java
score: -1
possible better answer: http://stackoverflow.com/a/22013894
has answer: http://stackoverflow.com/a/22013894
accepted answer: http://stackoverflow.com/a/22013962
downvote count: 1

http://stackoverflow.com/comment/86967819
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22126187
has text: `new MulticastSocket(4444)`: if this succeeds, the client gets the same port every time.
score: 0

http://stackoverflow.com/comment/33399169
comment on: http://stackoverflow.com/q/22029346
score: 0
type: QuestionComment
type: Comment
has text: Well, so my question is.. what are those features?

http://stackoverflow.com/comment/118842549
score: 3
has text: What one mustn't forget when passing variables, rather than literals, is to wrap those in `${}` e.g. `<th:block th:replace="common::buttons(fooBar = ${bar})" />`
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22121676

http://stackoverflow.com/a/46368810
has comment: http://stackoverflow.com/comment/92223795
has body: @With(Secure.class) @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface Secure { } This will work.
has comment: http://stackoverflow.com/comment/80423297
has comment: http://stackoverflow.com/comment/92223582
score: 10
upvote count: 13
has comment: http://stackoverflow.com/comment/80812958
downvote count: 3
has comment: http://stackoverflow.com/comment/98306458
answers question: http://stackoverflow.com/q/22126851
type: Answer

http://stackoverflow.com/comment/33354650
has text: How can i integrate with my current code,could you guide me please?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22006296
type: AnswerComment

http://stackoverflow.com/comment/33616946
has text: cast int to string and use this methog
comment on: http://stackoverflow.com/q/22152858
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33583973
type: Comment
has text: This is the correct way of doing it. +1. You shouldn't be trying to test `Calendar.getInstance()` anyway, unless you work for Oracle, and you are developing a new version of it. This is an excellent illustration of refactoring your code, to introduce a break between the parts that you _should_ be testing and the parts you shouldn't. On another note, though, `getDate()` is a terrible name for these methods.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22123130

http://stackoverflow.com/q/22168649
has answer: http://stackoverflow.com/a/22169539
type: Question
answer count: 2
downvote count: 0
tagged with: shell
has title: How to import jar files when running an individual class through terminal
has comment: http://stackoverflow.com/comment/33646171
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22168727
upvote count: 1
score: 1
tagged with: java
has body: I have written this but I don't know how to add the jar file to this script. /darshan/java/jdk1.6.0_21/bin/java com.supplier.external.DeleteTableData arg1 But this is not running since I couldn't import the related jar files here. How to do this?

http://stackoverflow.com/comment/33554629
comment on: http://stackoverflow.com/a/22117288
has text: Thanks Gord Thompson.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/22150417
score: 7
tagged with: java
tagged with: mapreduce
has comment: http://stackoverflow.com/comment/33612717
type: Question
tagged with: hadoop
has answer: http://stackoverflow.com/a/39210358
tagged with: snappy
has answer: http://stackoverflow.com/a/28187884
answer count: 6
has comment: http://stackoverflow.com/comment/33613517
has comment: http://stackoverflow.com/comment/33612636
has answer: http://stackoverflow.com/a/22152376
has title: hadoop mapreduce: java.lang.UnsatisfiedLinkError: org.apache.hadoop.util.NativeCodeLoader.buildSupportsSnappy()Z
upvote count: 7
has comment: http://stackoverflow.com/comment/33612845
has comment: http://stackoverflow.com/comment/33612308
has comment: http://stackoverflow.com/comment/33612528
favorite count: 0
has answer: http://stackoverflow.com/a/24679103
has comment: http://stackoverflow.com/comment/33612660
has answer: http://stackoverflow.com/a/53966580
tagged with: sequencefile
has body: I am trying to write a snappy block compressed sequence file from a map-reduce job. I am using hadoop 2.0.0-cdh4.5.0, and snappy-java 1.0.4.1 Here is my code: package jinvestor.jhouse.mr; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.Arrays; import java.util.List; import jinvestor.jhouse.core.House; import jinvestor.jhouse.core.util.HouseAvroUtil; import jinvestor.jhouse.download.HBaseHouseDAO; import org.apache.commons.io.IOUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.LocatedFileStatus; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.RemoteIterator; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil; import org.apache.hadoop.hbase.mapreduce.TableMapper; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.SequenceFile; import org.apache.hadoop.io.compress.CompressionCodec; import org.apache.hadoop.io.compress.SnappyCodec; import org.apache.hadoop.mapred.FileOutputFormat; import org.apache.hadoop.mapred.JobConf; import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat; import org.apache.hadoop.mapreduce.Job; import org.apache.mahout.math.DenseVector; import org.apache.mahout.math.NamedVector; import org.apache.mahout.math.VectorWritable; /** * Produces mahout vectors from House entries in HBase. * * @author Michael Scott Knapp * */ public class HouseVectorizer { private final Configuration configuration; private final House minimumHouse; private final House maximumHouse; public HouseVectorizer(final Configuration configuration, final House minimumHouse, final House maximumHouse) { this.configuration = configuration; this.minimumHouse = minimumHouse; this.maximumHouse = maximumHouse; } pu…
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33612889
has comment: http://stackoverflow.com/comment/33615288
has answer: http://stackoverflow.com/a/30248555
has comment: http://stackoverflow.com/comment/33612598
downvote count: 0

http://stackoverflow.com/a/22022239
score: 0
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/22022105
type: Answer
has body: Do it in two steps: isolate what need removal remove . final Set&lt;Personne&gt; toRemove = new HashSet&lt;&gt;(); for (final Personne personne: personnes) { for (final Personne autrePersonne: personnes) { if (person.isSimilarTo(autrePersonne)) { toRemove.add(autrePersonne); } } } personnes.removeAll(toRemove); Also, you need to take care of the case where autrePersonne equals personne
has comment: http://stackoverflow.com/comment/33383956

http://stackoverflow.com/comment/33499531
comment on: http://stackoverflow.com/q/22087256
has text: you cannot put a statement outside a method, it needs some identifier so it can be referenced. it's impossible to call that from say a main method..
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22149518
upvote count: 1
has comment: http://stackoverflow.com/comment/33610668
has comment: http://stackoverflow.com/comment/33638384
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33611852
has comment: http://stackoverflow.com/comment/33611609
has comment: http://stackoverflow.com/comment/33611756
answer count: 0
downvote count: 0
score: 1
has body: I am getting results from sql and writing each record as a line to a file using BufferdWriter. The no of records will be in thousands(more than 40000 chars). Code: Iterator&lt;SyncDetail&gt; it = details.iterator(); while (it.hasNext()) { detail = it.next(); sbRec = formatStringFile(detail); m_logger.info(sbRec.toString()); strRec = sbRec.toString(); bw.write(strRec); bw.newLine(); } bw.close(); Now My question is: This code is giving correct result. But after every 4096 chars, an unexpected new line char is coming in the resulted file. May I know why is this and how can I resolve this?
favorite count: 0
has comment: http://stackoverflow.com/comment/33611180
type: Question
has comment: http://stackoverflow.com/comment/33610845
has title: BufferredWriter to write thousands of lines
has comment: http://stackoverflow.com/comment/33610654
tagged with: java

http://stackoverflow.com/comment/33511224
has text: but bro i didn't understand 'extra unconsumed char' thing.CAn you please explain in a simple way.That will be great help
comment on: http://stackoverflow.com/a/22093763
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33489072
has text: We do not see edges... you can only go "up" to the node which is very near? For example left-bottom node can only reach left-middle node?
comment on: http://stackoverflow.com/q/22081336
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22146081
upvote count: 1
type: AcceptedAnswer
type: Answer
has body: add resin-util.jar to your class path. you can download it from here
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/22146019
answers question: http://stackoverflow.com/q/22146019

http://stackoverflow.com/comment/33402345
type: Comment
type: QuestionComment
has text: yes. But since the model classes were wrong, i am always getting null pointer
score: 0
comment on: http://stackoverflow.com/q/22032976

http://stackoverflow.com/comment/33631985
comment on: http://stackoverflow.com/q/22161092
type: Comment
type: QuestionComment
has text: Yes, you should never use dollar signs in your identifiers. And you should observe standard capitalization conventions -- start function and variable names with a lower-case character, start classes with an upper-case character.
score: 0

http://stackoverflow.com/q/22124046
answer count: 3
has answer: http://stackoverflow.com/a/22124156
has answer: http://stackoverflow.com/a/22124107
tagged with: jakarta-ee
has title: I get this exception java.lang.IllegalStateException when I try to redirect to another page
tagged with: java
possible better answer: http://stackoverflow.com/a/22124100
has answer: http://stackoverflow.com/a/22124100
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22124107
has comment: http://stackoverflow.com/comment/33566014
type: Question
has body: I have the following code : util.library.mvc.Controller => Controller which extends from Servlet modules.user.controllers.UpdateController => A Controller implementation In the controller parent class I have a method wih the following content: public void redirect(HttpServletResponse response, String url) throws IOException { response.sendRedirect(url); } But when I try to use it on my controller implementation gives me the following Exception: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Integer id = Integer.parseInt(request.getParameter("id")); UserRepository users = new UserRepository(request); User user = users.getUser(id); // My validation : if (user == null) { this.redirect("list"); // throws me an exception } request.setAttribute("user", user); request.setAttribute("action", "update"); request.setAttribute("legend", "Update User"); this.render(request, response, "/user/form"); } I get the exception message in spanish but I translated it as follows: java.lang.IllegalStateException: I can not forward after response has been carried out. util.library.mvc.Controller.render(Controller.java:31) modules.user.controllers.UpdateController.doGet(UpdateController.java:33) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:728) However when I use this method in this context : protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { User user = new User(); user.populate(request); UserRepository userRepository = new UserRepository(request); userRepository.update(user); this.redirect(response, "list"); } It works fine. Any help?
has comment: http://stackoverflow.com/comment/33565973
score: 0

http://stackoverflow.com/q/22011542
answer count: 3
linked to: http://stackoverflow.com/q/1334802
favorite count: 0
tagged with: android
has comment: http://stackoverflow.com/comment/33363675
upvote count: 1
downvote count: 1
has answer: http://stackoverflow.com/a/22011661
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22011768
tagged with: java
has answer: http://stackoverflow.com/a/22011645
duplicate of: http://stackoverflow.com/q/1334802
type: Question
possible better answer: http://stackoverflow.com/a/22011645
accepted answer: http://stackoverflow.com/a/22011661
has body: I am new in using jar files in Android application. While checking code for Android apps code.google.com suggested the jar files. I don't know how to use the classes from jar files. Please help me! Thanks
has title: How to use jar file in Eclipse for android appllication
score: 0

http://stackoverflow.com/comment/33415105
comment on: http://stackoverflow.com/q/22040298
type: Comment
type: QuestionComment
has text: Well... do you have an actual HTTP server which can accept HTTP requests? Otherwise you can send all you want, nothing is going to respond.
score: 2

http://stackoverflow.com/q/22116175
tagged with: exception
has comment: http://stackoverflow.com/comment/33551306
answer count: 4
has body: I've created a custom Exception class that I want to use in my application: public class MyException extends Exception { private static final long serialVersionUID = -2151515147355511072L; private String message = null; public MyException() { super(); } public MyException(String message) { super(message); this.message = message; } public MyException(Throwable cause) { super(cause); } @Override public String toString() { return message; } @Override public String getMessage() { return message; } } But when I try to use this class, like below, it gives a compile time error. try { System.out.println("this"); } catch (MyException e) { // TODO: handle exception } Compile time error: Unreachable catch block for MyException . This exception is never thrown from the try statement body My question is if I'm extending Exception class &amp; calling super in all constructors, then why this error is occurring?
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22116229
score: 3
has comment: http://stackoverflow.com/comment/33551318
downvote count: 0
has answer: http://stackoverflow.com/a/22116229
tagged with: java
has title: Custom Exception class shows Unreachable catch block everytime
has answer: http://stackoverflow.com/a/22116215
type: Question
accepted answer: http://stackoverflow.com/a/22116233
has answer: http://stackoverflow.com/a/22116216
upvote count: 3
has answer: http://stackoverflow.com/a/22116233
favorite count: 0

http://stackoverflow.com/a/22160717
answers question: http://stackoverflow.com/q/22160555
has comment: http://stackoverflow.com/comment/33632081
has comment: http://stackoverflow.com/comment/33632003
upvote count: 2
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 2
has body: Every call to createCircles() should paint one large circle in the center and call itself recursively 3 times for the 3 smaller circles. The y coordinate always remains the same and you can recalculate the x coordinate by adding and subtracting the radius of original circle. public void createCircles(int x, int y, int rad) { Circle myCircle = new Circle(x, y, rad); circles.add(myCircle); createCircles(x - (2*rad), y, rad/3); createCircles(x, y, rad/3); createCircles(x + (2*rad), y, rad/3); } For the overflow error you can set a terminating condition on the size of rad, like if (rad &lt; 5) { return; }
accepted answer of: http://stackoverflow.com/q/22160555

http://stackoverflow.com/a/22033472
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22033253
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/22033253
has body: If your class doesn't extends a Context subclass, you need to pass a Context instance (an Activity, a Service, etc) to call openFileInput. Also you need to catch java.io.FileNotFoundException or add throws declaration to your method. Hope it helps.

maven
tags question: http://stackoverflow.com/q/22020231
tags question: http://stackoverflow.com/q/22024701
tags question: http://stackoverflow.com/q/22071675
tags question: http://stackoverflow.com/q/22033273
tags question: http://stackoverflow.com/q/22024489
tags question: http://stackoverflow.com/q/22033383
type: Tag
tags question: http://stackoverflow.com/q/22148282
tags question: http://stackoverflow.com/q/22166940
tags question: http://stackoverflow.com/q/22050194
tags question: http://stackoverflow.com/q/22083368
tags question: http://stackoverflow.com/q/22109869
tags question: http://stackoverflow.com/q/22054513
tags question: http://stackoverflow.com/q/22157220
tags question: http://stackoverflow.com/q/22074117
tags question: http://stackoverflow.com/q/22082747
tags question: http://stackoverflow.com/q/22053572
tags question: http://stackoverflow.com/q/22020533
tags question: http://stackoverflow.com/q/22059567
tags question: http://stackoverflow.com/q/22096909
tags question: http://stackoverflow.com/q/22050579
tags question: http://stackoverflow.com/q/22084549
tags question: http://stackoverflow.com/q/22065810
tags question: http://stackoverflow.com/q/22081809
tags question: http://stackoverflow.com/q/22086093
tags question: http://stackoverflow.com/q/22094313
tags question: http://stackoverflow.com/q/22152200
tags question: http://stackoverflow.com/q/22155911
tags question: http://stackoverflow.com/q/22071589
tags question: http://stackoverflow.com/q/22086119
tags question: http://stackoverflow.com/q/22015873
tags question: http://stackoverflow.com/q/22102600
tags question: http://stackoverflow.com/q/22107517
tags question: http://stackoverflow.com/q/22165182
tags question: http://stackoverflow.com/q/22011642
tags question: http://stackoverflow.com/q/22066079
tags question: http://stackoverflow.com/q/22078501
tags question: http://stackoverflow.com/q/22110847
tags question: http://stackoverflow.com/q/22150037
tags question: http://stackoverflow.com/q/22121918
tags question: http://stackoverflow.com/q/22087373
tags question: http://stackoverflow.com/q/22049033
tags question: http://stackoverflow.com/q/22038407
tags question: http://stackoverflow.com/q/22095487
tags question: http://stackoverflow.com/q/22140654
tags question: http://stackoverflow.com/q/22066931
tags question: http://stackoverflow.com/q/22104782
tags question: http://stackoverflow.com/q/22119730
tags question: http://stackoverflow.com/q/22155108
tags question: http://stackoverflow.com/q/22088654
tags question: http://stackoverflow.com/q/22075743
tags question: http://stackoverflow.com/q/22150691
tags question: http://stackoverflow.com/q/22136211
tags question: http://stackoverflow.com/q/22089663
tags question: http://stackoverflow.com/q/22053213
tags question: http://stackoverflow.com/q/22157221
tags question: http://stackoverflow.com/q/22069638
tags question: http://stackoverflow.com/q/22070666
tags question: http://stackoverflow.com/q/22117863
tags question: http://stackoverflow.com/q/22040759
tags question: http://stackoverflow.com/q/22110003
tags question: http://stackoverflow.com/q/22168396
tags question: http://stackoverflow.com/q/22061272
tags question: http://stackoverflow.com/q/22130447
tags question: http://stackoverflow.com/q/22063509
tags question: http://stackoverflow.com/q/22030175
tags question: http://stackoverflow.com/q/22092930
tags question: http://stackoverflow.com/q/22038066
tags question: http://stackoverflow.com/q/22103892
tags question: http://stackoverflow.com/q/22085993
tags question: http://stackoverflow.com/q/22121651
tags question: http://stackoverflow.com/q/22096009
tags question: http://stackoverflow.com/q/22080489
tags question: http://stackoverflow.com/q/22044812
tags question: http://stackoverflow.com/q/22140242
tags question: http://stackoverflow.com/q/22068056
tags question: http://stackoverflow.com/q/22123548
tags question: http://stackoverflow.com/q/22106164
tags question: http://stackoverflow.com/q/22148782
tags question: http://stackoverflow.com/q/22118975

http://stackoverflow.com/a/22091142
has comment: http://stackoverflow.com/comment/33506006
has comment: http://stackoverflow.com/comment/33506077
has comment: http://stackoverflow.com/comment/33507908
type: Answer
has comment: http://stackoverflow.com/comment/33506126
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/33505960
has body: You're importing java.sql.Date - which doesn't have a parameterless constructor. You meant java.util.Date, which does. However, there's no need to create a Date object at all in order to get the current time in milliseconds-since-the-Unix-epoch: cookie = new Cookie("test_cookie", Long.toString(System.currentTimeMillis()); (Or ideally, inject some kind of Clock representation into your code, so you can test it more easily.)
downvote count: 0
answers question: http://stackoverflow.com/q/22091071

http://stackoverflow.com/comment/33536242
score: 0
type: Comment
type: QuestionComment
has text: rgettman, yes, so if print 08/18/2014 i will get AUG 18, 2014
comment on: http://stackoverflow.com/q/22107407

http://stackoverflow.com/q/22121741
tagged with: message
has comment: http://stackoverflow.com/comment/33570496
has comment: http://stackoverflow.com/comment/33561608
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/33561638
type: UnansweredQuestion
tagged with: swing
has title: How to realize a waiting message?
answer count: 0
score: 1
tagged with: java
upvote count: 1
type: Question
linked to: http://stackoverflow.com/q/9554636
has body: I have a Java code and I want to show a waiting message during the elaboration. The program it's very long, I write a simply test to explain my problem: public void actionPerformed(ActionEvent evt){ showMessage.yes(); for(int i = 0; i &lt; 9999; i++) System.out.print("wait"); } The method yes() only contain a JFrame.setVisible(true) command that should show a frame with the message "waiting". The problem is that in this case the frame is showed but the content of the frame (buttons, labels etc) doesn't show until the end of the for. Obviously if in this method I leave only the showMessage.yes() the frame is showed without problems...

http://stackoverflow.com/a/22066402
has body: If I understand well, the question is "why does the binarySearch actually find the item in the list, when my comparator compares instances?" Right? Well, the answer is as simple as that: because actually it compares two identical instances (references). Integer class maintains a pool of cached instances for values between -128 and 127 (inclusive). This pool of instances is always used when valueOf is called with an argument between these values. Here you have 2 calls to valueOf(1) (more or less explicit) in your code. One is here: list.add(Integer.valueOf(s));. For one iteration through the loop, the call is actually list.add(Integer.valueOf("1"); Behind the scenes, valueOf(int) is called. And the second is here: Arrays.binarySearch(array,1,com). The boxing operation from the literal 1 to the Integer instance is actually performed via an invocation of valueOf(int).
score: 3
answers question: http://stackoverflow.com/q/22065818
has comment: http://stackoverflow.com/comment/33470392
downvote count: 0
has comment: http://stackoverflow.com/comment/33468314
has comment: http://stackoverflow.com/comment/33468894
type: Answer
has comment: http://stackoverflow.com/comment/33467509
upvote count: 3

http://stackoverflow.com/a/22168475
has comment: http://stackoverflow.com/comment/33648987
upvote count: 1
downvote count: 0
has body: In fact what you want is to prevent XSS attacks using specials character. So you don't really have to care about the characters present in the String. You just have to espace them before doing any operation on your database, using a function with the same purposes as htmlspecialchars() in PHP. Obviously such conversion can also be done in Java. To replace all HTML entities (source) : String source = "Escape the less than sign (&lt;) and ampersand (&amp;)"; String escaped = StringEscapeUtils.escapeHtml(source); // Will output "Escape the less than sign (&amp;lt;) and ampersand (&amp;amp;)" To replace only a select subset of characters (source) : String escaped = StringUtils.replaceEach(source, new String[]{"&amp;", "&lt;"}, new String[]{"&amp;amp;", "&amp;lt;"}); EDIT : To take your example, you would have to espace special characters in the variable reqnum because you'll use it in your SQL request : String checkreq=""; String reqnum=(String)findrequestmodel.requestno.trim(); reqnum = StringEscapeUtils.escapeHtml(reqnum); // Espace special characters // ... skipped code ... rs=stmt.executeQuery(" select * from myadmin where reference_no='"+reqnum+"'"); // Safe Alternative (and better) solution You should not handle this by yourself, but use something called PreparedStatement which can do it for you, plus other useful stuff.
has comment: http://stackoverflow.com/comment/33685224
type: Answer
answers question: http://stackoverflow.com/q/22141452
has comment: http://stackoverflow.com/comment/33685858
score: 1
has comment: http://stackoverflow.com/comment/33653301

http://stackoverflow.com/comment/33525634
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22101747
has text: Updated the answer. Hope it helps.
type: AnswerComment

http://stackoverflow.com/q/22155911
tagged with: maven
tagged with: overlay
upvote count: 1
has title: Create an artifact overlay
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22515875
tagged with: java
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/33658072
downvote count: 0
score: 1
favorite count: 0
accepted answer: http://stackoverflow.com/a/22515875
possible better answer: http://stackoverflow.com/a/22176985
has answer: http://stackoverflow.com/a/22176985
has comment: http://stackoverflow.com/comment/33628490
tagged with: pom.xml
has body: I would like to overlay another person's project, using customizations of specific files (ie one file would use a different controller, or display something in one way, or have different processes). We have been using an overlay that takes all of the files I have in my repository, and overlaying all of the files on top of their files so that my smaller set of customizations still act like the larger project should. We have accomplished it like this so far, but it plays havoc on the IDE. Is there a better way? I tried using maven-builder-helper-plugin but it gave me duplicate classes on the java files I had overriden. target/overlay target/overlay false **/*.java maven-antrun-plugin generate-sources run org.apache.maven.plugins maven-dependency-plugin unpack initialize unpack com.sample.service sampleService sources jar true target/overlay I should note that I'm absolutely fine with using a different direction than this one. I just couldn't figure out a better way to include all of the resource & source files that are needed from them to keep the project running properly. This is for a module that is a part of a web app. The module that is being built and the module it is overlaying are both jar's

http://stackoverflow.com/comment/33503446
has text: So you will be able to search for i.e.: a, ap, app, appl, apple to in this case get index 0 and if you only type the a letter you will get index 0 and 1 ?
type: AnswerComment
comment on: http://stackoverflow.com/a/22089299
score: 0
type: Comment

memory-model
tag name: memory-model
type: Tag
tags question: http://stackoverflow.com/q/22103791

textview
tags question: http://stackoverflow.com/q/22156845
tags question: http://stackoverflow.com/q/22050639
tag name: textview
type: Tag
tags question: http://stackoverflow.com/q/22111141
tags question: http://stackoverflow.com/q/22074716
tags question: http://stackoverflow.com/q/22005516
tags question: http://stackoverflow.com/q/22013543
tags question: http://stackoverflow.com/q/22037326

http://stackoverflow.com/comment/33357203
type: AnswerComment
comment on: http://stackoverflow.com/a/22007680
type: Comment
has text: Wrong and wrong. Question asked to avoid using instance of on that specific case, it never stated "give me a non OOP solution for a problem which only makes sense in an OOP paradigm." Furthermore, an initializer set variable is only manual at the point of coding the initializer for any class that may be used but may or may not be testable. Again, this question is so beyond what anyone should do with Java so as to be unanswerable. My answer, though you judge it to be non-useful, is still an answer that differs from yours and may suit the asker enough to get a vote! You had your chance :P
score: 0

http://stackoverflow.com/comment/33583712
has text: Way to remove _interview question_. The problem still remains. We aren't here to do your homework. Attempt something. If there is a problem, you come back, giving us all the relevant information, and then we can help you.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22133615

http://stackoverflow.com/comment/33452519
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/22054423
type: Comment
has text: No, the second System.out is not printed because it is after the if-statement. it assures the following code is only executed if markers.size() > 0. and as you can see in the previous output `markers.size() == 0`. So why are you surprised? just do read my answer again and simply never call get(i) when markers.size() == 0

facebook
tags question: http://stackoverflow.com/q/22119251
tags question: http://stackoverflow.com/q/22095867
tags question: http://stackoverflow.com/q/22110261
type: Tag
tags question: http://stackoverflow.com/q/22143093
tags question: http://stackoverflow.com/q/22070984
tags question: http://stackoverflow.com/q/22149299
tags question: http://stackoverflow.com/q/22036232
tag name: facebook
tags question: http://stackoverflow.com/q/22163696
tags question: http://stackoverflow.com/q/22168580
tags question: http://stackoverflow.com/q/22074192
tags question: http://stackoverflow.com/q/22153976
tags question: http://stackoverflow.com/q/22078389
tags question: http://stackoverflow.com/q/22035592
tags question: http://stackoverflow.com/q/22096789
tags question: http://stackoverflow.com/q/22127409
tags question: http://stackoverflow.com/q/22102553

http://stackoverflow.com/q/22104405
type: Question
has body: I am working on a project that is going to do serial communication and I want to package the java-simple-serial-connector (jssc) as part of the project. I don't want to install the jssc.jar file on the system because this project is going to be run a bunch of different machines so it would be much easier to package the .jar with my executable .jar. I have added jssc.jar to my build path but when I run the program (note it isn't finished yet) I get the following error: Exception in thread "main" java.lang.NoClassDefFoundError: SerialCommunication Caused by: java.lang.ClassNotFoundException: SerialCommunication 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) Here is my code import jssc.*; public class SerialCommunication { public static void main(String[] args) { String[] portNames; if(System.getProperty("os.name").equals("Mac OS X")){ portNames = SerialPortList.getPortNames("/dev/"); System.out.println("OS X"); } else { portNames = SerialPortList.getPortNames("COM"); System.out.println("Windows"); } for (int i = 0; i &lt; portNames.length; i++) { System.out.println(portNames[i]); } SerialPort serialPort = new SerialPort(portNames[0]); try { serialPort.openPort();// Open serial port serialPort.setParams(SerialPort.BAUDRATE_9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.writeBytes("This is a test string".getBytes()); serialPort.closePort();// Close serial port } catch (SerialPortException ex) { System.out.println(ex); } } } Under the build path I added the jssc.jar as a library and as an external library. Both of them fail in the same way. I have also cleaned the solution. EDIT: My file structure is the following /src Ser…
has comment: http://stackoverflow.com/comment/33575010
upvote count: 2
answer count: 1
tagged with: java
has answer: http://stackoverflow.com/a/22104844
has comment: http://stackoverflow.com/comment/33534161
linked to: http://stackoverflow.com/q/18870213
type: UnansweredQuestion
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33545902
has comment: http://stackoverflow.com/comment/33531405
score: 2
tagged with: jar
downvote count: 0
favorite count: 0
has title: How to add jssc.jar to Java Project

http://stackoverflow.com/comment/33391156
comment on: http://stackoverflow.com/a/22026458
score: 0
type: Comment
has text: that is because you are catching NumberFormatException in your outer try/catch block and throwing a new exception with a different message.
type: AnswerComment

http://stackoverflow.com/comment/33397919
score: 0
has text: @Crikckter any function that has a range (0,1] can be but may not be good, sigmoid have some features make it better in many applications.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22029346

http://stackoverflow.com/comment/33764774
type: Comment
has text: hello, an example of what I meant was, google play music, with drawer and tabs. is possible?
comment on: http://stackoverflow.com/a/22099525
type: AnswerComment
score: 0

http://stackoverflow.com/a/24702734
upvote count: 2
has body: I have the same problem, but I solved calling: document.enforceUpdateFields(); When a user will open the document a confirmation will be opened reguarding the updated of the fields.
type: Answer
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/22168355

http://stackoverflow.com/q/22149393
type: Question
has answer: http://stackoverflow.com/a/33128344
has comment: http://stackoverflow.com/comment/37992929
downvote count: 0
has answer: http://stackoverflow.com/a/22149708
has body: I'm trying to use generated UUIDs without @Id annotation, because my primary key is something else. The application does not generate an UUID, do you have an idea? This is my declaration: @Column(name = "APP_UUID", unique = true) @GeneratedValue(generator="system-uuid") @GenericGenerator(name="system-uuid", strategy = "uuid") private String uuid; I'm using Hibernate 4.3.0 with Oracle10g.
has title: How to use UUIDs with Hibernate as a field?
answer count: 3
favorite count: 0
possible better answer: http://stackoverflow.com/a/33128344
tagged with: uuid
has comment: http://stackoverflow.com/comment/37947687
score: 19
linked to: http://stackoverflow.com/q/277630
has answer: http://stackoverflow.com/a/22150217
type: AnsweredQuestion
upvote count: 19
tagged with: java
tagged with: hibernate
accepted answer: http://stackoverflow.com/a/22149708

http://stackoverflow.com/q/22112182
has answer: http://stackoverflow.com/a/22112195
favorite count: 0
tagged with: private
has comment: http://stackoverflow.com/comment/33544474
type: Question
has answer: http://stackoverflow.com/a/22112273
linked to: http://stackoverflow.com/q/792361
duplicate of: http://stackoverflow.com/q/792361
upvote count: 3
tagged with: java
downvote count: 1
has answer: http://stackoverflow.com/a/22112246
has title: Why is private member of a class accessible in compareTo?
has answer: http://stackoverflow.com/a/22112192
linked to: http://stackoverflow.com/q/4707504
has comment: http://stackoverflow.com/comment/33544233
answer count: 4
score: 2
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22112192
has body: I wrote the following class to fiddle around with Comparable/Serializable interfaces. package testpro; public class SerialTest implements Comparable { private int circleSize = 10; private int getCircleSize() { return circleSize; } @Override public int compareTo(Object o) { SerialTest object = (SerialTest) o; if(getCircleSize()&gt;object.getCircleSize()){ // I can access object.getCircleSize() here, but it's private.. why? return 1; } else if(getCircleSize()&lt;object.getCircleSize()){// I can access object.getCircleSize() here, but it's private.. why? return -1; } else{ return 0; } } } I'm passing an Object o to compareTo() method, but getCircleSize() is private. So how is that possible, that I've got an access to this? I'm pretty sure C++ wouldn't let it go.
possible better answer: http://stackoverflow.com/a/22112195

http://stackoverflow.com/q/22111517
linked to: http://stackoverflow.com/q/7803944
upvote count: 3
tagged with: mockito
answer count: 1
favorite count: 0
has body: I need to write a test case for a class similar to the following class: public class TestClass { public String loadBean(int i) { String s = null; if (i &lt;= 0) { s = "less"; // call some webservice that we don't need to test callWebService(s); } else { s = "more"; } return s; } private void callWebService(String s) { //Some complex code here } I need to test loadBean method only, problem is - i'm not able to skip method call to callWebService(), using PowerMock. So to explain more clearly I need to a test case which calls loadBean but do nothing when it encounters callWebService method continuing the execution flow. I read it on this same site that we can do it with PowerMockito but could not get it to work. Please help.
tagged with: powermock
type: UnansweredQuestion
has title: How to use Powermockito so that private void methods are skipped
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/22125032
type: Question
score: 3
tagged with: junit4
duplicate of: http://stackoverflow.com/q/7803944

http://stackoverflow.com/q/22073777
tagged with: superclass
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33474517
tagged with: java
possible better answer: http://stackoverflow.com/a/22073828
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33474583
has body: I can see how a subclass gets to inherit a superclass method, but what if the superclass wants to use the subclass version of the method?
tagged with: class
score: 0
answer count: 3
has title: Superclass using subclass version of method?
has answer: http://stackoverflow.com/a/22074136
has comment: http://stackoverflow.com/comment/33474613
favorite count: 0
tagged with: subclass
has answer: http://stackoverflow.com/a/22076159
accepted answer: http://stackoverflow.com/a/22076159
upvote count: 1
has answer: http://stackoverflow.com/a/22073828

http://stackoverflow.com/q/22075245
accepted answer: http://stackoverflow.com/a/22076044
type: Question
has answer: http://stackoverflow.com/a/22075902
has comment: http://stackoverflow.com/comment/33478171
answer count: 2
score: 0
linked to: http://stackoverflow.com/q/3505930
tagged with: macos
has comment: http://stackoverflow.com/comment/33477466
has comment: http://stackoverflow.com/comment/33477722
has comment: http://stackoverflow.com/comment/33477291
tagged with: android
has comment: http://stackoverflow.com/comment/33477358
has title: HTTP Request on android doesnt work
has body: I have searched everywhere but I couldn't find an answer, how can i make a HTTP request? I tried several possibilities, but none of them work. I keep getting errors. InputStream is = null; // Only display the first 500 characters of the retrieved // web page content. int len = 500; try { URL url = new URL(myurl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setReadTimeout(10000 /* milliseconds */); conn.setConnectTimeout(15000 /* milliseconds */); conn.setRequestMethod("GET"); conn.setDoInput(true); // Starts the query conn.connect(); int response = conn.getResponseCode(); Log.d("Debug:", "The response is: " + response); is = conn.getInputStream(); // Convert the InputStream into a string String contentAsString = readIt(is, len); return contentAsString; // Makes sure that the InputStream is closed after the app is // finished using it. } catch(Exception ex) { Log.v("Message: ", ex.getMessage()); return "Helemaal niks!"; } finally { if (is != null) { is.close(); } } 02-27 17:52:58.611 13571-13571/com.example.app E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.IllegalStateException: Could not execute method of the activity at android.view.View$1.onClick(View.java:3838) at android.view.View.performClick(View.java:4475) at android.view.View$PerformClick.run(View.java:18786) at android.os.Handler.handleCallback(Handler.java:730) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5419) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) at dalvik.system.NativeStart.main(Native Method)
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22075902
tagged with: reflection
has comment: http://stackoverflow.com/comment/33477435
tagged with: java
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33477768
has answer: http://stackoverflow.com/a/22076044

http://stackoverflow.com/comment/33498016
comment on: http://stackoverflow.com/q/22086406
score: 0
type: Comment
type: QuestionComment
has text: @gumenimeda sure, question is updated.

http://stackoverflow.com/q/22116299
upvote count: 2
answer count: 2
has answer: http://stackoverflow.com/a/22116818
tagged with: invocationtargetexception
has title: Solving NoSuchMethodError exception thrown using Reflection
downvote count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33552746
has comment: http://stackoverflow.com/comment/33551522
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33552590
has comment: http://stackoverflow.com/comment/33552206
has comment: http://stackoverflow.com/comment/33551906
tagged with: reflection
has comment: http://stackoverflow.com/comment/33551863
has comment: http://stackoverflow.com/comment/33551719
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22116785
has body: I am currently using Reflection to execute a set of methods in classes which reside in a different project than the one I am working on. These methods will in turn call other methods within this project. Although the method calling is succeeding, an InvocationTargetExceptioncaused by NoSuchMethodError is being thrown. I am presuming that this occurred because the methods I am calling using reflection call other methods. For this reason I have added to the class path the other project but this did not work. Please note that the other project is an open source project I'm using from GitHub and am solely using it for analysis thus I do not want to manipulate with it. Can anyone help me please? Edit: The following is my current code for reflection: public void runSelectedTests(MethodSignature test) throws Exception{ //no paramater Class&lt;?&gt; noparams[] = {}; try{ //load the test at runtime //get the class Class&lt;?&gt; cls = Class.forName(test.getClassName()); Constructor&lt;?&gt;[] cons = cls.getDeclaredConstructors(); //can use the first constructor if there are multiple //if we instantiate with all constructors you end up calling the test methods depending on //how many constructors you have Constructor&lt;?&gt; cons1 = cons[0]; Object params[] = null; if(cons1.getParameterTypes().length &gt; 0){ params = new Object[cons1.getParameterTypes().length]; } for(int i = 0; i &lt; cons1.getParameterTypes().length; i++){ String type = cons1.getParameterTypes()[i].toString(); if(type.equals("byte") || type.equals("short") || type.equals("int")){ params[i] = 0; }else if(type.equals("long")){ params[i] = (long)0.0; }else if(type.equals("float")){ params[i] = (float)0.0; }else if(type.equals("double")){ params[i] = (double)0.0; }else if(type.equals("char")){ params[i] = (char)0; }else if(type.equals("boolean")){ params[i] = false; }else{ params[i] = null; } } Object obj = cons1.newInstance(params); //call the test method Method method = cls.getDeclaredMethod(test.getName(),…
tagged with: nosuchmethoderror
type: Question

http://stackoverflow.com/a/22139851
type: Answer
has body: You can use setFormats() to replace currently installed formatter. For example: picker.setFormats(new SimpleDateFormat("MM.yyyy"));
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/22139694
downvote count: 0

http://stackoverflow.com/q/22071389
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22083014
tagged with: jfreechart
type: Question
answer count: 2
downvote count: 0
tagged with: executable-jar
has body: I have created an application using the JFreeChart library for use on another machine. Previously I have developed applications with JFreeChart (using the same libraries) which has worked fine on other machines. The only difference is this machine is running Vista. Please see below for the run-time exception I am getting: The class that cannot be found, however, is located in the highlighted jar in the below image showing my imported libraries for the JAR. I have also established that this JAR is included in the manifest for the application. See below image: So I very much need this to work and have no idea where to look next - or what is causing this problem! Development machine Java version: 1.7.0_45 Target machine Java version: 1.7.0_45 Thanks in advance.
accepted answer: http://stackoverflow.com/a/22083014
favorite count: 0
has comment: http://stackoverflow.com/comment/33470435
upvote count: 1
has comment: http://stackoverflow.com/comment/33470136
possible better answer: http://stackoverflow.com/a/22071923
type: AnsweredQuestion
has title: JFreeChart Java JAR not running on a different machine
has answer: http://stackoverflow.com/a/22071923

http://stackoverflow.com/q/22149276
tagged with: java
has comment: http://stackoverflow.com/comment/33610454
has title: Signaling with shared objects
type: Question
has comment: http://stackoverflow.com/comment/33629883
score: 0
has body: I am not able to understand, where to place methods hasDataToProcess() &amp; setHasDataToProcess() of MySignal class, in App9 class to maintain synchronization on object of type NotThreadSafe. Please help me the know the place !!! //Signalling via shared objects Code: class MySignal{ protected boolean hasDataToProcess = false; public synchronized boolean hasDataToProcess(){ return this.hasDataToProcess; } public synchronized void setHasDataToProcess(boolean hasData){ this.hasDataToProcess = true; } } class NotThreadSafe{ StringBuilder builder = new StringBuilder(); public void add(String text){ this.builder.append(text); } public void display(){ System.out.println(builder); } } public class App9 extends Thread { NotThreadSafe instance; protected MySignal sharedSignal = new MySignal(); public App9(NotThreadSafe sharedInstance){ this.instance = sharedInstance; } @Override public void run(){ this.instance.add("sham"); this.instance.display(); } public static void main(String[] args) { NotThreadSafe sharedInstance = new NotThreadSafe(); for(int i=0; i&lt;10 ; i++){ Thread t = new App9(sharedInstance); t.start(); } } }
answer count: 0
type: UnansweredQuestion
tagged with: multithreading
has comment: http://stackoverflow.com/comment/33610286

http://stackoverflow.com/comment/33613987
type: Comment
has text: The last `false` would never be evaluated in this case since the test is always `true`.
comment on: http://stackoverflow.com/a/22151270
type: AnswerComment
score: 0

http://stackoverflow.com/a/22096500
type: Answer
upvote count: 6
accepted answer of: http://stackoverflow.com/q/22096398
answers question: http://stackoverflow.com/q/22096398
has body: This would not necessarily create a leak in a classic, "permanent", sense. The garbage collector will get to the first instance of the prepared statement eventually, and call its finalizer. However, this is not a good practice to let the garbage collector deal with freeing potentially critical resources, such as DB handles: you should call the close method before reusing the prepared statement variable, or not reuse the variable at all. try { Connection = connectionFactory.getConnection(); ps = statement.prepareStamement(someQuery); // execute and read and stuff // now you want to use the ps again, since you don't want ps1, ps2, ps3, etc. // v v v v v v v v v v v SomeUtilClass.close(ps); // ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ps = statement.prepareStatement(someOtherQuery); // DOES THIS FORM A POTENTIAL LEAK? } catch (a lot of exceptions) { // process exceptions } finally { // close the resources (using util class with null-checks and everything) SomeUtilClass.close(ps); SomeUtilClass.close(connection); }
type: AcceptedAnswer
downvote count: 0
score: 6

http://stackoverflow.com/a/22150167
has comment: http://stackoverflow.com/comment/33612275
has comment: http://stackoverflow.com/comment/33612186
has comment: http://stackoverflow.com/comment/33613465
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33612119
has body: Because in permissionForm.jsp, the form has inputs for the permissions field only, hence when submiting it, it will pass on a User object with the permissions field only populated, the rest will be null. If you need to have values in the rest of the fields, add hidden inputs like this: &lt;form:form action="/show" method="post" modelAttribute="user"&gt; &lt;form:errors path="*" cssClass="errorblock" element="div"/&gt; &lt;p&gt; &lt;form:select path="permissions"&gt; &lt;form:options items="${permissions}"/&gt; &lt;/form:select&gt; &lt;form:hidden path="name"/&gt; &lt;form:hidden path="age"/&gt; &lt;form:hidden path="email"/&gt; &lt;/p&gt; &lt;p&gt;&lt;input type="submit" value="Add"/&gt;&lt;/p&gt; &lt;/form:form&gt; However, for the password field, I wouldn't advise adding a hidden field in the JSP because it will expose the password for anyone who can read html source. Another and better solution would be using the session, by storing and modifying the user in the session between forms, first store the user on the first submit: @RequestMapping(value = "/user", method = RequestMethod.POST) public String processedForm(@ModelAttribute("user") User user, BindingResult result, ModelMap model,HttpSession session) { if (result.hasErrors()) { return "form/userForm"; } session.setAttribute("user",user); ArrayList&lt;String&gt; p = new ArrayList&lt;String&gt;(); p.add("add_user"); p.add("delete_user"); model.addAttribute("permissions", p); model.addAttribute("user", user); return "form/permissionForm"; } @RequestMapping(value = "/show", method = RequestMethod.POST) public String show(@ModelAttribute("user") User user, BindingResult result,HttpSession session) { User userInSession = (User)session.getAttribute("user"); userInSession.setPermissions(user.getPermissions()); if (result.hasErrors()) { System.out.println("Error"); return "show"; } else { System.out.println(userInSession); return "show"; } }
accepted answer of: http://stackoverflow.com/q/22149945
upvote count: 1
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22149945
type: Answer

http://stackoverflow.com/a/22142947
has body: The list1 is in request scope so you can just iterate as you did, for printing SR.No. you can make use of LoopTagStatus &lt;c:forEach var="data" items="${list1}" varStatus="loop"&gt; &lt;td&gt; ${loop.count} &lt;/td&gt; &lt;td&gt; ${data} &lt;/td&gt; &lt;/c:forEach&gt; Remember ${loop.index} starts from 0 ${loop.count} starts from 1 See also JSTL core How to avoid Java Code in JSP-Files?
has comment: http://stackoverflow.com/comment/33602315
has comment: http://stackoverflow.com/comment/33599847
answers question: http://stackoverflow.com/q/22142731
type: Answer
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/33599178
has comment: http://stackoverflow.com/comment/33602143
downvote count: 0

http://stackoverflow.com/a/22155847
score: 0
has comment: http://stackoverflow.com/comment/33675194
has comment: http://stackoverflow.com/comment/33690756
answers question: http://stackoverflow.com/q/22132042
has body: You need to adjust the function signature of Commanders#getStory(java.lang.String) so it takes your extra doc argument. You can then execute your code like... Pars pars = new Pars(); Document doc = pars.doc(); Commanders.getStory(doc, spage)
has comment: http://stackoverflow.com/comment/33623939
type: Answer
has comment: http://stackoverflow.com/comment/33653077
has comment: http://stackoverflow.com/comment/33645863

http://stackoverflow.com/q/22090935
tagged with: android-studio
tagged with: android
has answer: http://stackoverflow.com/a/22099816
accepted answer: http://stackoverflow.com/a/22099816
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/51884947
downvote count: 0
tagged with: java
has comment: http://stackoverflow.com/comment/104434021
type: Question
score: 9
has body: I have few abstract classes which has different implementations in flavors. How do I make Android Studio find if method is used/overridden in all flavors. Might be, that in currently selected flavor method might look unused.
tagged with: class
has title: How to force Android Studio `see` source in other flavours, so refactoring of abstract classes would be safer
answer count: 1
tagged with: polymorphism
favorite count: 0
upvote count: 9

http://stackoverflow.com/q/22116010
has answer: http://stackoverflow.com/a/22116341
has comment: http://stackoverflow.com/comment/33551155
has answer: http://stackoverflow.com/a/22116089
tagged with: polymorphism
tagged with: generics
has title: Java Polymorphic Generic Calls
has comment: http://stackoverflow.com/comment/33551403
linked to: http://stackoverflow.com/q/1572322
has answer: http://stackoverflow.com/a/22117791
upvote count: 2
answer count: 3
accepted answer: http://stackoverflow.com/a/22116341
has comment: http://stackoverflow.com/comment/33551439
tagged with: java
has comment: http://stackoverflow.com/comment/33551208
has comment: http://stackoverflow.com/comment/33551453
score: 2
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/9759141
downvote count: 0
tagged with: inheritance
favorite count: 0
has body: I just recently started messing around with Generics in Java, and am running in to some odd behavior. This is the simplified version, but I have a base class that is extended by multiple classes that gets passed into a generic function. Inside this function, I call a method that has several versions that take different base or derived classes as parameters. If I have the following: public class A{}; public class B extends A{}; public class C extends A{}; public class Runner { public static void Run( ClassA a ){Do Something}; public static void Run( ClassB b ){Do Something}; public static void Run( ClassC c ){Do Something}; } void SomeRandomCall&lt;B extends ClassA&gt;( B b ) { Runner.Run( b ); } SomeRandomCall&lt;ClassB&gt;( new ClassB() ); I am finding in debug that Runner.Run is calling the Run( ClassA a ) instead of the Run( ClassB b ) function. Given the two functions, shouldn't Run( ClassB b ) be called since the type specific function is provided? If this isn't the case how would I be able to have a Generic function that would call be able to call functions that have signatures that take base and derived classes?
has comment: http://stackoverflow.com/comment/33551431
type: Question
possible better answer: http://stackoverflow.com/a/22116089

http://stackoverflow.com/comment/33638786
has text: Does this OP cron will run at 3:00:00? Am i right? i.e only when the minute turns `0`
comment on: http://stackoverflow.com/a/22165118
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/22138893
type: Answer
type: AcceptedAnswer
has body: OK, found the problem, I need to also copy the lib dir that contains a needed jar file into the Startup dir to make it run correctly.
accepted answer of: http://stackoverflow.com/q/22108997
score: 0
answers question: http://stackoverflow.com/q/22108997

http://stackoverflow.com/a/22156679
answers question: http://stackoverflow.com/q/22156616
downvote count: 0
has body: I'm wildly guessing what you're asking here, if you intend to see 50, you need to change System.out.println("result"); //This will print: result to System.out.println(result); //This will print: 50 Reason: "result" is the String literal "result", if you want to refer to the variable result, you need to remove the quotes. Besides that, your code seems correct to me.
type: Answer
score: 2
upvote count: 2

http://stackoverflow.com/q/22078074
has title: Merging two methods that read two files to reading one file with one method
type: Question
score: 0
answer count: 1
has body: I am creating a bayesian filter system in Java. At the moment my code learns spam and good text by using separate .txt files; learn.spam("spam.txt"); and learn.good("good.txt"). Both methods are pretty much identical to each other: public void good(String file) throws IOException { A2ZFileReader fr = new A2ZFileReader(file); String content = fr.getContent(); String[] tokens = content.split(splitregex); int goodTotal = 0; for (int i = 0; i &lt; tokens.length; i++) { String word = tokens[i].toLowerCase(); Matcher m = wordregex.matcher(word); if (m.matches()) { goodTotal++; if (words.containsKey(word)) { Word w = (Word) words.get(word); w.countGood(); } else { Word w = new Word(word); w.countGood(); words.put(word,w); } } } public void spam(String file) throws IOException { A2ZFileReader fr = new A2ZFileReader(file); String content = fr.getContent(); String[] tokens = content.split(splitregex); int spamTotal = 0;//tokenizer.countTokens(); for (int i = 0; i &lt; tokens.length; i++) { String word = tokens[i].toLowerCase(); Matcher m = wordregex.matcher(word); if (m.matches()) { spamTotal++; if (words.containsKey(word)) { Word w = (Word) words.get(word); w.countBad(); } else { Word w = new Word(word); w.countBad(); words.put(word,w); } } } Iterator iterator = words.values().iterator(); while (iterator.hasNext()) { Word word = (Word) iterator.next(); word.calcBadProb(spamTotal); } } Now the problem I am trying to fix is that instead of having two .txt files I have the following: spam Gamble tonight only for a cheap price of $5 per hand. ham Sex, I love it. I need it now. ham yeah I know, I am going tonight that that place, ;) Come join me. You know you want to ham It is pretty expensive, just this and that for only ($900) spam Call 123123123 to use for free porn The messages are only one per line, spam messages start with spam and good messages start with ham with one tab. How can I change the methods so that I can train it using only one method and one .txt file.
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22078283
tagged with: refactoring
tagged with: java

http://stackoverflow.com/a/22168181
answers question: http://stackoverflow.com/q/22168004
downvote count: 1
has body: Alter the format in the spreadsheet to match the format from your test. Or the other way around if I have read wrong. They both need to be to 2 decimal places. At least that is what I think it is.
upvote count: 0
type: Answer
score: -1

http://stackoverflow.com/comment/33438852
type: QuestionComment
has text: Which is hiding, which is overriding?
score: 0
comment on: http://stackoverflow.com/q/22053413
type: Comment

http://stackoverflow.com/q/22077680
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33482957
tagged with: java
has comment: http://stackoverflow.com/comment/33482269
has comment: http://stackoverflow.com/comment/33483673
type: Question
has title: java.lang.LinkageError when loading class from .zip file
has comment: http://stackoverflow.com/comment/33484640
has body: I'm trying to make a class loader that will load .class files inside a .zip file. I followed this tutorial (https://weblogs.java.net/blog/2008/07/25/how-load-classes-jar-or-zip), but when i run the program, i get this error: java.lang.LinkageError: loader (instance of org/freeforums/geforce/genforcer/main/ZipClassLoader): attempted duplicate class definition for name: "test/TestClass" The error comes from line 30, which is: return defineClass(filename, out.toByteArray, 0, out.size()); I call the method by using: zipClassLoaderObj.findClass("test.TestClass"); Does anyone know what i'm doing wrong?
has comment: http://stackoverflow.com/comment/33482603
has answer: http://stackoverflow.com/a/22078958
score: 0
has comment: http://stackoverflow.com/comment/33483291
answer count: 1
has comment: http://stackoverflow.com/comment/33482468
has comment: http://stackoverflow.com/comment/33483832
accepted answer: http://stackoverflow.com/a/22078958
has comment: http://stackoverflow.com/comment/33482783

http://stackoverflow.com/a/22049987
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/33433713
has body: I realized what is the problem. It seems that mongo work using user for each DB stored in the DB itself. I created the user in the same db and it works. It a very weird feature because I will have a lot of duplicated users in mongo, one for each DB that I have. Minus one for user managing in Mongo...
answers question: http://stackoverflow.com/q/22045285
accepted answer of: http://stackoverflow.com/q/22045285

http://stackoverflow.com/comment/33571499
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22126807
has text: check if servlet2 is avialable in / i mean the path.
type: Comment

http://stackoverflow.com/comment/33359596
comment on: http://stackoverflow.com/a/22009137
type: Comment
score: 1
has text: This is indeed the working way to solve the problem when the test method has only a single parameter and that parameter is vararg.
type: AnswerComment

http://stackoverflow.com/comment/33417076
has text: If the OP wants exactly 32.63 (with that scale) then that's what he is going to need.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22031789

http://stackoverflow.com/comment/33415246
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22040508
has text: http://www.docjar.com/html/api/java/lang/Integer.java.html (for example)

http://stackoverflow.com/q/22042197
tagged with: xsd
tagged with: xslt
score: 2
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22043516
downvote count: 0
answer count: 1
has title: How to drive XML generation from XSD and rules?
tagged with: http://stackoverflow.com/tag/xml
favorite count: 0
tagged with: xpath
has body: I am looking for a standard technology to drive the generation of an XML document based on an XSD and a set of rules. Basically I have XSDs that tell me what the XML should look like and what elements are mandatory or optional. What is not in the XSDs is a set of business rules that say things like "if such element's value is this, that other element is actually mandatory" or "if such element's value is that, that other element should be omitted". What I have in mind is something that would process the XSDs along with the rules (maybe expressed in something like XPath) and call back my code to generate the mandatory values. The structure of the final document would change dynamically depending on the values of the elements driving the conditions. I guess I could do something close to what I want with XSLTs. I'd generate all the values with and then use an XSLT to enforce the conditions. But in my case some values maybe take long to produce so I want to avoid computing unnecessary values, meaning values that will be later discarded by the business rules. Does such a technology exist? FYI I am coding in Java but I am hoping to find a generic technology if possible. Cheers, Tom
upvote count: 2
type: UnansweredQuestion

http://stackoverflow.com/q/22127725
accepted answer: http://stackoverflow.com/a/22127954
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/33572732
type: Question
has comment: http://stackoverflow.com/comment/33572775
has title: Returning from Web Intent, Android camera app stops
answer count: 1
has answer: http://stackoverflow.com/a/22127954
has comment: http://stackoverflow.com/comment/33573003
linked to: http://stackoverflow.com/q/8868732
tagged with: android
has body: I have an android app that scans qr codes. Then it displays the result by showing the clickable link for the website. When i click the link I will be redirected to the website but when i click back button on my phone it should return to the app but there is an error. It says the app stopped. I think that I do not have the code that will handle the activity when I return from the website. can you please help me? What should I do? Thanks. :) 03-02 20:58:53.454: E/AndroidRuntime(11165): FATAL EXCEPTION: main 03-02 20:58:53.454: E/AndroidRuntime(11165): java.lang.RuntimeException: Method called after release() 03-02 20:58:53.454: E/AndroidRuntime(11165): at android.hardware.Camera.setPreviewDisplay(Native Method) 03-02 20:58:53.454: E/AndroidRuntime(11165): at android.hardware.Camera.setPreviewDisplay(Camera.java:519) 03-02 20:58:53.454: E/AndroidRuntime(11165): at net.sourceforge.zbar.android.CameraTest.CameraPreview.surfaceCreated(CameraPreview.java:63) 03-02 20:58:53.454: E/AndroidRuntime(11165): at android.view.SurfaceView.updateWindow(SurfaceView.java:605) 03-02 20:58:53.454: E/AndroidRuntime(11165): at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:237) 03-02 20:58:53.454: E/AndroidRuntime(11165): at android.view.View.dispatchWindowVisibilityChanged(View.java:8019) 03-02 20:58:53.454: E/AndroidRuntime(11165): at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1081) 03-02 20:58:53.454: E/AndroidRuntime(11165): at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1081) 03-02 20:58:53.454: E/AndroidRuntime(11165): at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1081) 03-02 20:58:53.454: E/AndroidRuntime(11165): at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1081) 03-02 20:58:53.454: E/AndroidRuntime(11165): at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1081) 03-02 20:58:53.454: E/AndroidRuntime(11165): at android.view.ViewRootIm…
type: AnsweredQuestion

http://stackoverflow.com/q/22129875
score: 3
has answer: http://stackoverflow.com/a/28907372
tagged with: java
has comment: http://stackoverflow.com/comment/33593731
has answer: http://stackoverflow.com/a/22139787
tagged with: eclipse
tagged with: tomcat6
type: Question
has comment: http://stackoverflow.com/comment/33592939
answer count: 2
has title: Difference between stop and terminate options of tomcat in eclipse
has comment: http://stackoverflow.com/comment/33592785
downvote count: 0
favorite count: 0
has body: What is the difference between stop and terminate options of tomcat in eclipse. I am using eclipse Kepler for Java EE. What are their equivalent command line options in unix? Does stop means stopping web application and terminate means stopping tomcat server ? Edit : Terminate i can see in debug perspective , which is equivalent to terminating any java program. Now the doubt left is what stop does ? .if it is stopping tomcat how can i stop only webapp without stopping tomcat server.
has comment: http://stackoverflow.com/comment/33592532
upvote count: 3
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33576494
has comment: http://stackoverflow.com/comment/33592808

http://stackoverflow.com/a/22131227
type: AcceptedAnswer
downvote count: 0
has body: This should have been 2 different questions. I'll address the first part only: If you care whether your program actually works, then yes, you absolutely should test it, in one way or another. If you can't find a better way to do it, then manual testing could be used. Yes, you will need to run a server while you test. But not testing really just means that your users are "testing" it for you. When they find bugs, it will be harder to fix them than if you found them yourself while running in your development environment. Tools like JUnit are useful, but you don't have to use them to automate your tests, if they don't do what you want. You can just as easily write your own test script, which starts up an instance of the server, and then drives the client code through a series of operations. If one of your checks fails, just throw an exception and crash the test script. Since you mentioned JUnit, I'm guessing that you are working in Java. If you decide to write a test script like I just described, remember you can use any JVM-compatible language to do so. If you find the network-related integration tests are too slow to run them all the time, then you don't have to do so. Just keep that test script around, and run it any time you change something which might affect the network-related functionality. Or at least run it before you release a new version of the program to your users. In my experience, comm and networking are rich sources of hard-to-find bugs. There are so many corner cases. What happens if a client suddenly drops the connection part-way through a request? What if there are too many clients? What if a message is corrupted somehow in transit? Depending on how stringent your requirements for reliability are, you may need to do a lot of stress testing.
accepted answer of: http://stackoverflow.com/q/22130701
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/22130701
score: 1

http://stackoverflow.com/a/22045965
has body: Look into ThreadPoolExecutor's constructors. You may provide a bounded queue and a rejection policy to your executor. The rejection policy tells the executor what to do when you try to submit more tasks than it can handle. Example: ExecutorService executor = new ThreadPoolExecutor(N_THREADS, N_THREADS, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue&lt;Runnable&gt;(CAPACITY), new ThreadPoolExecutor.CallerRunsPolicy());
answers question: http://stackoverflow.com/q/22042120
type: Answer
score: 2
downvote count: 0
upvote count: 2

http://stackoverflow.com/a/22084427
answers question: http://stackoverflow.com/q/22084373
upvote count: 8
has comment: http://stackoverflow.com/comment/82632044
score: 7
has comment: http://stackoverflow.com/comment/71469997
has comment: http://stackoverflow.com/comment/79359853
has comment: http://stackoverflow.com/comment/64791702
has body: The easiest way is to use Math library. Use Math.pow(a, b) and the result will be a^b If you want to do it yourself, you have to use for-loop // Works only for b &gt;= 1 public static double myPow(double a, int b){ double res =1; for (int i = 0; i &lt; b; i++) { res *= a; } return res; } Using: double base = 2; int exp = 3; double whatIWantToKnow = myPow(2, 3);
downvote count: 1
has comment: http://stackoverflow.com/comment/33494850
type: Answer

http://stackoverflow.com/a/22100855
answers question: http://stackoverflow.com/q/22100795
upvote count: 1
has body: Check the current execution dir: new java.io.File(".").getAbsolutePath() will tell you.
has comment: http://stackoverflow.com/comment/33523554
has comment: http://stackoverflow.com/comment/33523618
downvote count: 0
has comment: http://stackoverflow.com/comment/33523869
has comment: http://stackoverflow.com/comment/33532469
type: Answer
has comment: http://stackoverflow.com/comment/33524091
score: 1

http://stackoverflow.com/a/22102878
type: AcceptedAnswer
score: 4
has body: This seems to launch a new thread each time a file is a photo in the for loop? Is there a way I can launch the thread once, and just pass it the file name when it is a photo? I'd use an ExecutorService instead of launching threads directly. Then you can have a single thread handling the thread-pool and you submit as many files as you want to the thread-pool. See the java tutorial. // this starts a thread-pool with 1 thread ExecutorService threadPool = Executors.newFixedThreadPool(1); for (File f : files) { // you can submit many files but only 1 thread will process them threadPool.submit(new ImageRunnable(file)); } // once we have submitted all jobs to the thread pool, it should be shutdown threadPool.shutdown(); Let's say I have an arrayList objectin thread 1, I would like to fill it up in Thread 2, and remove objects from it in Thread 1, I know it needs to be synchronized, I tried the example but the arraylist seems to be empty in thread 1 after I filled it in thread 2, What am I missing? Completely different question which is harder to answer without the specific code. You need to make sure that you are synchronizing both around the updates and the reading of the list. You might want to consider switching to using a BlockingQueue which takes care of the locking for you. You then can have one thread add(...) to the queue and the other one calls take().
has comment: http://stackoverflow.com/comment/33527776
type: Answer
upvote count: 4
downvote count: 0
has comment: http://stackoverflow.com/comment/33528003
accepted answer of: http://stackoverflow.com/q/22102828
has comment: http://stackoverflow.com/comment/33527578
answers question: http://stackoverflow.com/q/22102828

http://stackoverflow.com/comment/33536318
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22107417
score: 0
has text: Cool, never got the idea to declare a special char in java so far, seems to work fine :-) @fge

http://stackoverflow.com/comment/33519279
type: AnswerComment
comment on: http://stackoverflow.com/a/22090555
has text: this should help to understand how it works: https://java.net/projects/websocket-spec/sources/source-code-repository/content/tags/javax.websocket-all-1.0-final/api/server/src/main/java/javax/websocket/server/ServerEndpointConfig.java?rev=351
score: 0
type: Comment

serialization
tags question: http://stackoverflow.com/q/22154498
tags question: http://stackoverflow.com/q/22017145
tags question: http://stackoverflow.com/q/22132452
tags question: http://stackoverflow.com/q/22148361
tags question: http://stackoverflow.com/q/22078407
tags question: http://stackoverflow.com/q/22018531
tag name: serialization
tags question: http://stackoverflow.com/q/22121722
tags question: http://stackoverflow.com/q/22113310
tags question: http://stackoverflow.com/q/22130979
tags question: http://stackoverflow.com/q/22020334
tags question: http://stackoverflow.com/q/22047835
type: Tag
tags question: http://stackoverflow.com/q/22096274
tags question: http://stackoverflow.com/q/22090815
tags question: http://stackoverflow.com/q/22079054
tags question: http://stackoverflow.com/q/22049560
tags question: http://stackoverflow.com/q/22154311
tags question: http://stackoverflow.com/q/22082451
tags question: http://stackoverflow.com/q/22152018
tags question: http://stackoverflow.com/q/22048419
tags question: http://stackoverflow.com/q/22087938

http://stackoverflow.com/q/22127105
has comment: http://stackoverflow.com/comment/33574015
type: AnsweredQuestion
has body: I have written a Java code that must run only after successful shutting down of weblogic server. The code shuts down the weblogic server and performs the required operations and then restarts the servers. My question now is .. Is there a way by which 1 can keep a tab on the weblogic console to see if the shutdown proceess is over or not or if there were some exceptions thrown by the server during startup or shut down(not manually but programmatically)?? In my local machine I had made the thread to sleep until the server was shutdown completely by keeping the average time to shut (manually). The code goes as under: static final String DOMAIN_NAMES = "domainNames"; static final String DOMAIN_HOME="domainHome"; public static void main(String[] argss) { AbstractApplicationContext context=new FileSystemXmlApplicationContext(new String[]{"src/main/resources/redeployconfig.xml"}); StepOneRedeploy stepOne=(StepOneRedeploy) context.getBean("stepOneRedeploy"); stepOne.setProperties(); Properties prop=stepOne.getProperties(); String domainNames = prop.getProperty(DOMAIN_NAMES); System.out.println(domainNames); String domainHome = prop.getProperty(DOMAIN_HOME); StringTokenizer domainNamesTokens= new StringTokenizer(domainNames,","); StringTokenizer domainNamesTokens2=domainNamesTokens; ArrayList&lt;String&gt; serverIPListArray = new ArrayList&lt;String&gt;(); while (domainNamesTokens.hasMoreElements()) { String domainName=domainNamesTokens.nextToken(); System.out.println(domainName); serverIPListArray.add(domainName); } while(domainNamesTokens2.hasMoreElements()) { String domainName=domainNamesTokens2.nextToken(); /** Stopping weblogicserver **/ String domainPathToShutServer = domainHome + domainName+"/stopWebLogic.cmd"; String commandToShutServer="cmd /C start "+domainPathToShutServer; try { Process p = Runtime.getRuntime().exec(commandToShutServer,null); } catch (Exception e) { e.printStackTrace(); } /**Putting thread to sleep for 1 minute**/ try { Thread.sleep(20000); } catc…
tagged with: java
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/22129395
accepted answer: http://stackoverflow.com/a/22129395
score: 0
has answer: http://stackoverflow.com/a/22128611
possible better answer: http://stackoverflow.com/a/22128611
has comment: http://stackoverflow.com/comment/33572294
has title: How can 1 catch the exceptions thrown by the executable run using Java code?

http://stackoverflow.com/comment/33470129
score: 2
has text: why don't you try it then tell us if it worked or not ?
type: Comment
comment on: http://stackoverflow.com/q/22071463
type: QuestionComment

http://stackoverflow.com/a/22103149
type: Answer
answers question: http://stackoverflow.com/q/22103056
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/33530191
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22103056
has body: There are two issues here: Transitioning from SOAP to REST Transitioning from from older versions of WS API to v2.0. Transitioning from SOAP to REST: Indeed we no longer support SOAP and xml, and there is no WSDL for v2.0. There is no standard refactoring path: the old code that used SOAP interface needs to be re-written using REST interface, often from scratch. We have a Rally Java REST Toolkit, available in this github repository. Transitioning from from older versions of WS API to v2.0: As far as transition from 1.43 to v2.0, a main difference is in how collections are handled. In v2.0 we removed the ability to return child collections in the same response for performance reasons. In v2.0 fetching a collection will return an object with the count and the url from which to get the collection data. AppSDK2rc1 works with v2.0 of WS API. In the older versions of WS API certain fetch lists create a lot recursive calls, and all the collections included in the fetch make the call quite expensive. In WS API v2.0 this will not happen, since a separate call will have to be made in order to get objects of the collections. The code fragments below are both REST examples, but show how to refactor code to upgrade to v2.0. Let's say you want to retrieve Test Cases associated with the Test Set. Instead of this (which works in 1.43 because the collection is returned): int numberOfTestCases = testSetJsonObject.get("TestCases").getAsJsonArray().size(); if(numberOfTestCases&gt;0) { for (int j=0;j&lt;numberOfTestCases;j++) { System.out.println(testSetJsonObject.get("TestCases").getAsJsonArray().get(j).getAsJsonObject().get("FormattedID")); } } Do this: //TestCases is an object with a Count and a ref to load the collection int numberOfTestCases = testSetJsonObject.getAsJsonObject("TestCases").get("Count").getAsInt(); if(numberOfTestCases &gt; 0) { QueryRequest testCaseRequest = new QueryRequest(testSetJsonObject.getAsJsonObject("TestCases")); testCaseRequest.setFetch(new Fetch("Format…

http://stackoverflow.com/q/22147817
has comment: http://stackoverflow.com/comment/33623946
type: Question
answer count: 1
upvote count: 17
has title: Binding @Provides method as eager singleton
tagged with: java
has body: I want to make a binding using a method annotated with @Provides into an eager singleton. I've found bug 216, which suggests this isn't possible, but doesn't mention the @Provides annotation explicitly. I currently have a class that requests the eager singletons in time by itself being a singleton, but it's not a very nice solution. public class LogicModule extends AbstractModule { @Override public void configure() { bind(SomeDep.class); bind(MyWorkaround.class).asEagerSingleton(); } // cannot add eager requirement here @Provides @Singleton Logic createLogic(SomeDep dep) { return LogicCreator.create(dep); } private static class MyWorkaround { @Inject Logic logic; } } Can I change something near the comment that would make the workaround class obsolete?
has answer: http://stackoverflow.com/a/22196741
tagged with: guice
downvote count: 0
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22196741
score: 17
favorite count: 0

http://stackoverflow.com/comment/33540629
type: QuestionComment
has text: Do you use Eclipse to code? Did you try debugging? Also, what's the expected vs actual output? What do you expect [ [2, 4, 6], [1, 3, 5] ] to give you?
score: 0
comment on: http://stackoverflow.com/q/22109913
type: Comment

http://stackoverflow.com/a/22130987
type: Answer
has body: You are talking about command line arguments, so... I was wondering if the java line "if (args[0].length > 2)" is a valid line. No. args is a String[], therefore args[0] is a String. And a String does not have a length public static field. However: I want to find out if the amount of numbers in the first array is longer than two digits So, as mentioned, args[0] is a String. It is not an array!. Unlike C, for instance, there is no "direct mapping" of a String to a char[]. In fact, C has nothing like String. With Java, you'd have to use .toCharArray() to get a char[] from a String. If you want to find if a String has more than two numbers, then you should write: if (args[0].matches("[0-9]{2,}")) This will check both that the string is 2 characters long or more, and that all characters in it are digits. This uses a regular expression to check your argument. If the regex succeeds, you can then convert to an integer using: Integer.parseInt(args[0]) provided there is no overflow!
score: 0
answers question: http://stackoverflow.com/q/22130869

http://stackoverflow.com/comment/33635210
comment on: http://stackoverflow.com/q/22163004
type: Comment
type: QuestionComment
has text: @Nomanaliabbasi Ohh! not really.
score: 0

http://stackoverflow.com/q/22020317
has body: I will like to setup performance monitoring on an application running on Railo 4 using New Relic. I have consulted the java docs on Railo, Railo google groups, etc but no one seems to have a perfect step by step. Here is what I have done so far: Extracted newrelic into Railo's install folder. Added this line to setenv.sh export JAVA_OPTS="$JAVA_OPTS -javaagent:c/railo/newrelic/newrelic.jar" Restarted the Railo-Tomcat service Added this line to the onapplicationstart function application.NewRelic = createObject( "java", "com.newrelic.api.agent.NewRelic" ); Added this line to the onrequeststart function if ( structKeyExists( application, "NewRelic" ) ) { application.NewRelic.setTransactionName( "CFML", CGI.SCRIPT_NAME ); } My application is still not sending metrics to New Relic. I will appreciate a step by step instruction of what to do as I can't seem to find that anywhere else and I have no idea what to do.
score: 1
tagged with: java
upvote count: 1
has comment: http://stackoverflow.com/comment/33380642
type: Question
downvote count: 0
answer count: 2
has title: Setting up New Relic for Railo 4.x on Windows
tagged with: railo
has comment: http://stackoverflow.com/comment/33493005
favorite count: 0
has comment: http://stackoverflow.com/comment/33616535
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22152708
has answer: http://stackoverflow.com/a/22022632
tagged with: tomcat7
tagged with: newrelic

http://stackoverflow.com/a/22454184
has comment: http://stackoverflow.com/comment/34196821
has body: I had a similar issue where I wanted to convert an Android generated BASE64 string to Binary with Javascript and atob function was keep giving me errors. My first guess was like yours to use URL_SAFE instead of DEFAULT, but none of them worked, then I figure it out that I need to use Base64.NO_WRAP method to get it working. I tested Base64.NO_WRAP and displaying inline image and IT WORKED!!!! Hope this save you some nerves, because I did had some till I figure it out how to do it. So to give the nice answer, change: return Base64.encodeToString(bytes, Base64.URL_SAFE); to this: return Base64.encodeToString(bytes, Base64.NO_WRAP); E
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/34959849
downvote count: 0
answers question: http://stackoverflow.com/q/22031636
type: Answer
has comment: http://stackoverflow.com/comment/37799694
score: 7
accepted answer of: http://stackoverflow.com/q/22031636
upvote count: 7
has comment: http://stackoverflow.com/comment/34960382

http://stackoverflow.com/q/22054774
answer count: 1
tagged with: dynamic-jasper
has answer: http://stackoverflow.com/a/22066654
type: AnsweredQuestion
score: 0
has body: I am trying to load a JasperReports jrxml template to my DynamicReport object but I am getting a null pointer without knowing from where it comes. The code practically is like this: DynamicReport dr = new DynamicReport(); DynamicReportBuilder drb = new DynamicReportBuilder(); ...... drb.setTemplateFile("styles/myreport.jrxml"); dr = drb.build(); Then I call JasperPrint jp = DynamicJasperHelper.generateJasperPrint(dr, new ClassicLayoutManager(), resultSetDataSource); The error is this: java.lang.NullPointerException at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperDesign(DynamicJasperHelper.java:200) at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperReport(DynamicJasperHelper.java:535) at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperReport(DynamicJasperHelper.java:518) at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperPrint(DynamicJasperHelper.java:283) at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperPrint(DynamicJasperHelper.java:236) Does anyone has any idea? ps: I am using iReport 5 (tried even with 4) with DynamicJasper 3.1.8.
accepted answer: http://stackoverflow.com/a/22066654
type: Question
tagged with: jasper-reports
tagged with: java
has title: NullPointer while loading jrxml file with DynamicReport object

http://stackoverflow.com/a/22019138
answers question: http://stackoverflow.com/q/22018921
score: 0
type: Answer
has body: The because of auto boxing Double a = 1; equals to Double a = Integer.valueOf(1); Double b = 1.0; equals to Double b = Double.valueOf(1); double c = 1; equals to double c = (double) 1; What more you can do is to mark your number with D. Double d = 1D; equals to Double d = Double.valueOf(1);

http://stackoverflow.com/comment/33377627
score: 0
comment on: http://stackoverflow.com/q/22019069
type: Comment
type: QuestionComment
has text: that's the problem, the only thing i find are using those serverlets

http://stackoverflow.com/q/22085186
has comment: http://stackoverflow.com/comment/33496374
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/513084
type: Question
has answer: http://stackoverflow.com/a/22109808
score: 0
has comment: http://stackoverflow.com/comment/33496027
tagged with: android
tagged with: android-sqlite
answer count: 1
tagged with: java
has body: I have a very big CSV file (25 MB) with 90K lines and i am trying to make an Android app that will load this What would be the most efficient way to load it to SQL db? Is that even possible? Any idea how long loading it will take? Thank you
has title: loading big CSV file to SQLITE database
accepted answer: http://stackoverflow.com/a/22109808
has comment: http://stackoverflow.com/comment/33540123

http://stackoverflow.com/q/22019393
tagged with: swing
has comment: http://stackoverflow.com/comment/33387564
type: Question
has comment: http://stackoverflow.com/comment/33377587
tagged with: object
has title: How to add 2 objects or more to one JFrame in Java?
has body: I tried looking but no questions were helpful. Here's my code to begin with: Player player = new Player(); Block1 block1 = new Block1(); JFrame ow = new JFrame(); ow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ow.setSize(500,500); ow.setTitle("My Game"); ow.setVisible(true); ow.setLocation(400, 100); ow.add(block1); ow.add(player); but it will only add the last one, someone said (when I searched old questions) that it erases the previous one because they are both in the same location. So I modified it this way: JPanel jp = new JPanel(); jp.setSize(500, 500); Player player = new Player(); Block1 block1 = new Block1(); JFrame ow = new JFrame(); jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); jp.add(player); jp.add(block1); ow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ow.setSize(500,500); ow.setTitle("My Game"); ow.setVisible(true); ow.setLocation(400, 100); ow.add(jp); It did work, putting them both visible but... it sort of made two square panels so I can't go near block 1 with my player. Any help?
score: 0
has comment: http://stackoverflow.com/comment/33387562
answer count: 1
has comment: http://stackoverflow.com/comment/33377669
has comment: http://stackoverflow.com/comment/33387563
tagged with: jframe
has comment: http://stackoverflow.com/comment/33377976
has comment: http://stackoverflow.com/comment/33377633
has answer: http://stackoverflow.com/a/22019435
type: UnansweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33387565

http://stackoverflow.com/comment/33634111
has text: how do i direct add background in my JPanel declare in my code sir for example ping.setBackground(Color.RED); i can set but only color . so i need it to be a picture something like that .
type: AnswerComment
comment on: http://stackoverflow.com/a/22162416
score: 0
type: Comment

http://stackoverflow.com/comment/33430078
comment on: http://stackoverflow.com/q/22048106
has text: When I change that, the app just crashes. I'll add the xml file(prior to changes) to the above.
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/q/22065279
possible better answer: http://stackoverflow.com/a/22065758
has comment: http://stackoverflow.com/comment/33459685
has answer: http://stackoverflow.com/a/22065758
has title: Recursively calculate e^x with Java using MacLaurin Series
downvote count: 0
has answer: http://stackoverflow.com/a/22065670
has comment: http://stackoverflow.com/comment/33459523
has comment: http://stackoverflow.com/comment/33459767
answer count: 3
accepted answer: http://stackoverflow.com/a/22065670
favorite count: 0
has answer: http://stackoverflow.com/a/22065792
has comment: http://stackoverflow.com/comment/33459244
type: AnsweredQuestion
tagged with: recursion
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33459437
upvote count: 1
has body: I need to write a recursive java method that will compute e^x called e(x,n) with the signature, public static double eThree(double x, long n) and it must use the MacLaurin series to compute e^x, which is the following observation: 1 + x(1 + x/2( 1 + x/3(1 + x/4(1 + ... )))) e(x,0)= 1 A call to this would return a result of 1 With some help earlier, I was able to make one that didn't require this format, but I'm not sure what I would code in order to use the format above. Thanks guys, really appreciate any help that will be given!
type: Question

http://stackoverflow.com/a/22137560
answers question: http://stackoverflow.com/q/22137526
score: 1
accepted answer of: http://stackoverflow.com/q/22137526
has body: Check the documentation of scanner: If no such pattern is detected in the input up to the next line separator, then null is returned and the scanner's position is unchanged. You call s.findInLine(keyword).isEmpty() == false, if the word is not contained in findInLine(keyword) will be null, thus you'd be calling null.isEmpty(). There's your exception ;) You don't have to check for isEmpty(), s.findInLine(keyword)!= null should be enough.
upvote count: 1
type: AcceptedAnswer
type: Answer
downvote count: 0

http://stackoverflow.com/q/22114306
has title: How can we control if a variable exists or not in Java?
type: AnsweredQuestion
upvote count: 3
tagged with: java
tagged with: local-variables
has body: In Java how can we control if a variable was already created or not ? For example, I want to create a button with the variable name kutu but if there already is a button with the variable name kutu I don't want to create it. button1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ JButton kutu=new JButton("my box"); kutu.setBounds(480, 620,120, 50);add(kutu); remove(button1); revalidate(); repaint(); }}); This is the code. There are 24 buttons (all of them have same action) and if the user clicks 2 or more buttons I dont want to create JButton kutu because kutu is already created in first click.
tagged with: swing
tagged with: jbutton
type: Question
has comment: http://stackoverflow.com/comment/33548146
score: 3
has comment: http://stackoverflow.com/comment/33548075
has comment: http://stackoverflow.com/comment/33548254
has comment: http://stackoverflow.com/comment/33548079
has answer: http://stackoverflow.com/a/22114525
answer count: 1
downvote count: 0
tagged with: controls
accepted answer: http://stackoverflow.com/a/22114525
favorite count: 0
has comment: http://stackoverflow.com/comment/33548286
has comment: http://stackoverflow.com/comment/33548145
has comment: http://stackoverflow.com/comment/33548178
has comment: http://stackoverflow.com/comment/33548115
has comment: http://stackoverflow.com/comment/33548195

http://stackoverflow.com/q/22120920
tagged with: custom-adapter
tagged with: android
accepted answer: http://stackoverflow.com/a/22120985
tagged with: android-activity
has answer: http://stackoverflow.com/a/22120985
has body: Making a custom spinner and I want to asynchronously retrieve images and json from the web. I found a library to help with that, loopj, and it works perfectly, however when I try to put it in my Adapter class, it doesn't like "findViewById" since I am not extending Activity, but I am already extending ArrayAdapter. Is there any way to extend both? I don't fully understand extend, so I apologize if that's a stupid question, but how can I solve my problem? Instead of hardcoding images in I would much rather be able to import them from web. My problem is at the "SmartViewImage image = ..." code. I am not sure how to solve this issue and still be able to asynchronously do what I want. I will also want to retrieve text so I am kind of stuck at this point. Any help is appreciated. public class CustomAdapter extends ArrayAdapter&lt;String&gt;{ private Activity activity; private ArrayList data; public Resources res; SpinnerModel tempValues=null; LayoutInflater inflater; /************* CustomAdapter Constructor *****************/ public CustomAdapter( MainActivity activitySpinner, int textViewResourceId, ArrayList objects, Resources resLocal ) { super(activitySpinner, textViewResourceId, objects); /********** Take passed values **********/ activity = activitySpinner; data = objects; res = resLocal; /*********** Layout inflator to call external xml layout () **********************/ inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @Override public View getDropDownView(int position, View convertView,ViewGroup parent) { return getCustomView(position, convertView, parent); } @Override public View getView(int position, View convertView, ViewGroup parent) { return getCustomView(position, convertView, parent); } public View getCustomView(int position, View convertView, ViewGroup parent) { /********** Inflate spinner_rows.xml file for each row ( Defined below ) ************/ View row = inflater.inflate(R.layout.spinner_rows, parent, false); /**…
possible better answer: http://stackoverflow.com/a/22120969
type: AnsweredQuestion
has title: any way to extend Activity if something else is already been extended?
has answer: http://stackoverflow.com/a/22120969
downvote count: 0
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33559990
linked to: http://stackoverflow.com/q/2515477
type: Question
answer count: 2
upvote count: 1
favorite count: 0

http://stackoverflow.com/comment/33481585
type: AnswerComment
comment on: http://stackoverflow.com/a/22076153
type: Comment
has text: that works but with a slight edit as follows: referencedColumnName = "id").
score: 1

http://stackoverflow.com/q/22073976
has title: Using java.io library in eclipse so FileInputStream can read a dat file
answer count: 2
has comment: http://stackoverflow.com/comment/33475126
has comment: http://stackoverflow.com/comment/33475211
score: 2
has comment: http://stackoverflow.com/comment/33481214
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/33483482
has answer: http://stackoverflow.com/a/22074145
linked to: http://stackoverflow.com/q/3373155
has answer: http://stackoverflow.com/a/22074308
type: AnsweredQuestion
upvote count: 2
has body: Goal: Print the data from a .dat file to the console using Eclipse. (Long-Term Goal): Executable that I can pass a .dat file to and it creates a new txt file with the data formatted. The .dat: I know the .dat file contains control points that I will need to create a graph with using ECMAScript. Eclipse Setup: Created Java Project New > Class .. called the Class FileRead Now I have FileRead.java which is: 1/ package frp; 2/ 3/ import java.io.BufferedReader; 4/ import java.io.File; 5/ import java.io.FileReader; 6/ 7/ public class FileRead { 8/ 9/ public static void main(String[] args) { 10/ FileReader file = new FileReader(new File("dichromatic.dat")); 11/ BufferedReader br = new BufferedReader(file); 12/ String temp = br.readLine(); 13/ while (temp != null) { 14/ temp = br.readLine(); 15/ System.out.println(temp); 16/ } 17/ file.close(); 18/ } 19/ 20/ } Please note this approach was borrowed from here: https://stackoverflow.com/a/18979213/3306651 1st Challenge: FileNotFoundException on LINE 10 Screenshot of Project Explorer: QUESTION: How to correctly reference the .dat file? 2nd Challenge: Unhandled exception type IOException LINES 12, 14, 17 QUESTION: How to prevent these exceptions? Thank you for your time and effort to help me, I am recreating Java applets using only JavaScript. So, I'm looking to create java tools that extract data I need to increase productivity. If you are interested in phone/web app projects involving JavaScript, feel free to contact me 8503962891
has comment: http://stackoverflow.com/comment/33479701
possible better answer: http://stackoverflow.com/a/22074308
type: Question
accepted answer: http://stackoverflow.com/a/22074145
has comment: http://stackoverflow.com/comment/33476082
has comment: http://stackoverflow.com/comment/33481309
has comment: http://stackoverflow.com/comment/33480827
tagged with: java
tagged with: eclipse
tagged with: java-io
linked to: http://stackoverflow.com/q/22078454

http://stackoverflow.com/q/22096554
type: Question
upvote count: 5
has comment: http://stackoverflow.com/comment/33515371
has comment: http://stackoverflow.com/comment/33515403
tagged with: median
has comment: http://stackoverflow.com/comment/33515694
answer count: 2
has comment: http://stackoverflow.com/comment/33515467
has title: Finding the median in java without sorting
has answer: http://stackoverflow.com/a/22097096
has comment: http://stackoverflow.com/comment/33515401
favorite count: 0
has answer: http://stackoverflow.com/a/22096591
type: UnansweredQuestion
score: 2
tagged with: java
downvote count: 3
has body: I need to write a program in java to find the median of an array of three or more integers without sorting. I need some ideas. thanks

http://stackoverflow.com/comment/33581517
comment on: http://stackoverflow.com/q/22132452
score: 0
has text: @donfuxx Ihas parameters of type string.
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22054882
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33441635
accepted answer of: http://stackoverflow.com/q/22054663
type: Answer
answers question: http://stackoverflow.com/q/22054663
has comment: http://stackoverflow.com/comment/33441759
downvote count: 0
score: 1
has body: Try this: private ArrayList&lt;String&gt; ips = new ArrayList&lt;String&gt;(); for (String site : sites) { try { address = InetAddress.getByName(new URL(site).getHost()); } catch (Exception e) { System.out.println(e); } String ip = address.getHostAddress(); ips.add(ip); }
has comment: http://stackoverflow.com/comment/33441789

tomcat
tags question: http://stackoverflow.com/q/22047860
tags question: http://stackoverflow.com/q/22137928
tags question: http://stackoverflow.com/q/22128150
tags question: http://stackoverflow.com/q/22034910
tags question: http://stackoverflow.com/q/22140017
tags question: http://stackoverflow.com/q/22145620
tags question: http://stackoverflow.com/q/22067089
tags question: http://stackoverflow.com/q/22089584
tags question: http://stackoverflow.com/q/22054610
tags question: http://stackoverflow.com/q/22117863
tags question: http://stackoverflow.com/q/22155957
tags question: http://stackoverflow.com/q/22168595
tags question: http://stackoverflow.com/q/22027230
tags question: http://stackoverflow.com/q/22130447
tags question: http://stackoverflow.com/q/22053414
tags question: http://stackoverflow.com/q/22018599
tags question: http://stackoverflow.com/q/22159687
tags question: http://stackoverflow.com/q/22022114
tags question: http://stackoverflow.com/q/22111603
tags question: http://stackoverflow.com/q/22124601
tags question: http://stackoverflow.com/q/22168752
tags question: http://stackoverflow.com/q/22149364
tags question: http://stackoverflow.com/q/22051593
tags question: http://stackoverflow.com/q/22075543
tags question: http://stackoverflow.com/q/22165966
tags question: http://stackoverflow.com/q/22133613
tags question: http://stackoverflow.com/q/22095626
tags question: http://stackoverflow.com/q/22154240
tags question: http://stackoverflow.com/q/22099648
tags question: http://stackoverflow.com/q/22142523
tags question: http://stackoverflow.com/q/22151225
tags question: http://stackoverflow.com/q/22075194
tags question: http://stackoverflow.com/q/22130667
tags question: http://stackoverflow.com/q/22155806
tag name: tomcat
tags question: http://stackoverflow.com/q/22147578
tags question: http://stackoverflow.com/q/22010745
tags question: http://stackoverflow.com/q/22158909
tags question: http://stackoverflow.com/q/22096380
tags question: http://stackoverflow.com/q/22155837
tags question: http://stackoverflow.com/q/22010430
tags question: http://stackoverflow.com/q/22051626
tags question: http://stackoverflow.com/q/22117608
tags question: http://stackoverflow.com/q/22146598
tags question: http://stackoverflow.com/q/22113598
tags question: http://stackoverflow.com/q/22114187
tags question: http://stackoverflow.com/q/22070340
tags question: http://stackoverflow.com/q/22049848
tags question: http://stackoverflow.com/q/22168348
tags question: http://stackoverflow.com/q/22120435
tags question: http://stackoverflow.com/q/22133500
tags question: http://stackoverflow.com/q/22092538
type: Tag
tags question: http://stackoverflow.com/q/22101332
tags question: http://stackoverflow.com/q/22073371
tags question: http://stackoverflow.com/q/22070764
tags question: http://stackoverflow.com/q/22150488
tags question: http://stackoverflow.com/q/22094448
tags question: http://stackoverflow.com/q/22087394
tags question: http://stackoverflow.com/q/22107308
tags question: http://stackoverflow.com/q/22086093
tags question: http://stackoverflow.com/q/22127102
tags question: http://stackoverflow.com/q/22141420
tags question: http://stackoverflow.com/q/22107517
tags question: http://stackoverflow.com/q/22161700
tags question: http://stackoverflow.com/q/22148397
tags question: http://stackoverflow.com/q/22161640
tags question: http://stackoverflow.com/q/22110856
tags question: http://stackoverflow.com/q/22150037
tags question: http://stackoverflow.com/q/22112688
tags question: http://stackoverflow.com/q/22082865
tags question: http://stackoverflow.com/q/22150328

http://stackoverflow.com/comment/33602889
score: 4
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22145281
has text: Have you considered a string of `"0123456789ABCDEF"` and either using `charAt` or `substring`? Also note that you've got *multiple* switch statements each with a single case - you'd normally want a *single* switch statement with *multiple* cases (and a `break` at the end of each `case`)

http://stackoverflow.com/q/22030748
downvote count: 2
has answer: http://stackoverflow.com/a/24573884
tagged with: javacard
upvote count: 3
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22031208
type: Question
has answer: http://stackoverflow.com/a/54808771
has body: I am looking for a way to explain or describe the concept of package, module &amp; applet in Java Card. Does any one know how to describe it, so that one could easily understand. Just to provide more information from my understanding, the structure &amp; relationships between package, module &amp; applet. Package AID |--&gt; Module AID |--&gt; Applet AID In Java Programming, A Java Package is a mechanism for organizing Java classes into namespaces But when it goes to Java Card, will it be similar? What about module? I am still searching on the web, will be great if someone can help! Thanks in advance.
favorite count: 0
has answer: http://stackoverflow.com/a/29226850
has title: Definition of package, module, applet in Java Card
answer count: 4
type: UnansweredQuestion

http://stackoverflow.com/a/22087310
upvote count: 1
downvote count: 0
type: Answer
has body: The error is because of missing braces in your class.that's why compiler is not able to understand whether it is a class, enum or interface definition. so, it is throwing this error. Fix them. Further more, You can make it this way public class mysqlconnect { static{ try { // loads com.mysql.jdbc.Driver into memory Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException cnf) { System.out.println("Driver could not be loaded: " + cnf); } } } or you need a seperate method to put the try and catch block inside it. Adding to that, you need to capitalize the class name like MySqlConnect to follow Java naming convention
score: 1
answers question: http://stackoverflow.com/q/22087256

http://stackoverflow.com/q/22043452
downvote count: 0
has comment: http://stackoverflow.com/comment/33420770
favorite count: 0
answer count: 3
has comment: http://stackoverflow.com/comment/33421147
has answer: http://stackoverflow.com/a/22044720
has body: I am trying to add a JScrollPane inside another JScrollPane. The inner JScrollPane are only going to scroll HORIZONTAL and the outer are only going to scroll VERTICAL. In this picture you can see that the horizontal scroller works when adding mainPanel(but have not added horizontal scroller here yet) Here is how it looks when adding outerVerticalScroller to the JFrame (the horizontal bar is gone): Any idea how this could be done? If I skip the mainPanel and instead type: JScrollPane outerVerticalScroller = new JScrollPane(panelScroller, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); Then it looks perfect with both scrollers: But I need that extra "mainPanel". Any ideas? public class ScrollersTest extends JFrame { public ScrollersTest() { super("A JScrollPane inside a JScrollPane"); setDefaultCloseOperation(EXIT_ON_CLOSE); init(); setVisible(true); pack(); } public void init() { ScrollablePanel panelScroller = new ScrollablePanel(new GridBagLayout()); panelScroller.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.FIT); GridBagConstraints c = new GridBagConstraints(); // INNER SCROLLPANE: ONLY SCROLL HORIZONTAL JTextArea innerText = new JTextArea("This text is inside a JScrollPane of its own. But no scroller is shown when the frames size is decreased. Wrong viewPort?...................................."); JScrollPane innerHorizantalScroller = new JScrollPane(innerText, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; panelScroller.add(innerHorizantalScroller, c); // SET SIZE OF SCROLLER HEIGHT Dimension d = innerHorizantalScroller.getPreferredSize(); innerHorizantalScroller.setPreferredSize(new Dimension(d.width, d.height * 2)); innerHorizantalScroller.setMinimumSize(new Dimension(0, d.height * 2)); // EXTRA PANEL NEEDED (BUT MAKES HORIZANTAL SCROLLING DISAPEAR) JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(panelScroller,…
has title: JScrollPane inside a JScrollPane
has answer: http://stackoverflow.com/a/22046519
type: UnansweredQuestion
upvote count: 1
tagged with: swing
has comment: http://stackoverflow.com/comment/33422164
score: 1
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22045794
tagged with: jscrollpane

http://stackoverflow.com/comment/51175986
score: 0
type: Comment
type: QuestionComment
has text: Flame: How did you solve the issue?
comment on: http://stackoverflow.com/q/22053125

http://stackoverflow.com/q/22042249
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/22070485
tagged with: spring
has comment: http://stackoverflow.com/comment/33420290
score: 0
tagged with: java
has title: Retrieve bean property value from an object
has answer: http://stackoverflow.com/a/22042832
has body: My class has multiple fields with getter and setter While trying to access the value of a property of a bean i have to check the property name and retrieve the value.. if(property is this ) mybean.getThisProperty() else if(property is that ) mybean.getThatProperty() else... How i can retireve without actually checking for the propertyname .. BeanUtils.copyProperties in Spring copies property from one bean to another
type: UnansweredQuestion
tagged with: apache-commons-beanutils

http://stackoverflow.com/comment/33486002
has text: This sounds certainly promising. I read about the waiting interval on DQ. The read is more stable than the while(true). Meaning, it won't be as heavy on performance?
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22079456

http://stackoverflow.com/q/22168355
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/38307807
has comment: http://stackoverflow.com/comment/33696812
has answer: http://stackoverflow.com/a/24702734
has comment: http://stackoverflow.com/comment/38310419
tagged with: java
has body: I need to update custom property using Apache Poi after setting the new value. I have method which set a new value for custom properties: InputStream fs = new FileInputStream("D://test.docx"); XWPFDocument document = new XWPFDocument(OPCPackage.open(fs)); POIXMLProperties props = document.getProperties(); CustomProperties cp = props.getCustomProperties(); if (cp != null) { List&lt;CTProperty&gt; ctProperties = cp.getUnderlyingProperties() .getPropertyList(); for (CTProperty ctp : ctProperties) { System.out.println(ctp.getName()); if (ctp.getName().equals("Test")) { ctp.setLpwstr("Test"); } } } document.write(new FileOutputStream(new File("D://test.docx"))); fs.close(); But when i open the document properties values is obsolete. And i have to update them manually. There is a way to update property values automatically using Apache Poi? Thanks! P.S. Sorry for my bad English.
type: Question
score: 2
downvote count: 0
answer count: 1
favorite count: 0
tagged with: ms-word
tagged with: apache-poi
upvote count: 2
has title: Update custom properties in word 2010 using apache poi

http://stackoverflow.com/q/22025189
tagged with: java
has answer: http://stackoverflow.com/a/22029151
tagged with: eclipse
type: Question
has title: Unable to instantiate activity ComponentInfo… java.lang.NullPointerException
score: 0
answer count: 2
tagged with: nullpointerexception
has body: OK, so the problem I'm having occurs when the startGame button is pressed. The app crashes when the button is pressed. The activity is instantiated in the manifest so I'm not sure where the error is. The code for the intent is a copy of the other one (which works) so I have no clue where I went wrong. Error Log: 02-25 14:46:51.064: E/AndroidRuntime(1261): FATAL EXCEPTION: main 02-25 14:46:51.064: E/AndroidRuntime(1261): Process: com.example.hegemony, PID: 1261 02-25 14:46:51.064: E/AndroidRuntime(1261): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.hegemony/com.example.hegemony.PlayerTurn}: java.lang.NullPointerException Manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.hegemony" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="19" /> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <action android:name="com.example.hegemony.STARTSCREEN" /> <category android:name="android.intent.category.DEFAULT" /> <action android:name="com.example.hegemony.SETUPHOMESCREEN" /> <category android:name="android.intent.category.DEFAULT" /> <action android:name="com.example.hegemony.SETUPPLAYER" /> <category android:name="android.intent.category.DEFAULT" /> <action android:name="com.example.hegemony.PLAYERTURN" /> <category android:name="android.intent.category.DEFAULT" /> Java Code of sending activity: public class SetupHomeScreen extends Activity{ private ArrayList<Player> p = GameMaster.players; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setup_home_screen); getActionBar().hide(); updatePlayers(); Button gotoInput = (Button) findViewById(R.id.btnSetupPlayer); gotoInput.setOnClickListener(new View.OnClickListener() { public void onClick(View v)…
type: UnansweredQuestion
tagged with: android
tagged with: android-intent
has answer: http://stackoverflow.com/a/22025375

http://stackoverflow.com/comment/33463482
has text: The question now is whether this is atomic or not, isn't it?
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22067533

http://stackoverflow.com/a/22015982
upvote count: 2
has body: you can use split String[] a = s.split("(?&lt;=^\\S+)\\s");
type: Answer
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/22015892

http://stackoverflow.com/comment/33391412
comment on: http://stackoverflow.com/a/22026049
score: 0
type: Comment
has text: OK, but isn't `n=10` and `s=3` in this case? It seems that way from your question. So maybe you want to have `i < n` and `i += s` in the outer loop. I think your inner loop is a little wrong too. But you're getting much closer now.
type: AnswerComment

http://stackoverflow.com/q/22048980
tagged with: jsf
has answer: http://stackoverflow.com/a/22050835
tagged with: java
accepted answer: http://stackoverflow.com/a/22050835
tagged with: calendar
type: Question
has title: Set start date in Calendar RichFaces
score: 0
answer count: 1
tagged with: richfaces
has body: I need to set a start date in a calendar component richfaces. I have a variable called dateInitial in my ManagedBean that have a Date (i.e 2013-07-07 are lower limit date) and I configure my calendar component : &lt;rich:calendar id="dateToEvaluate" popup="true" required="true" requiredMessage="Required Field" buttonIcon="#{request.contextPath}/resources/images/calendar.gif" value="#{valueMB.dateToEvaluate}" datePattern="dd/MM/yyyy"&gt; &lt;/rich:calendar&gt; But I need validate that the value of that are greater than my variable dateInitial, if not .. then launch a message validator with the error. Thanks for advance! and I'm sorry for my bad english.
type: AnsweredQuestion

arrays
tags question: http://stackoverflow.com/q/22081604
tags question: http://stackoverflow.com/q/22095869
tags question: http://stackoverflow.com/q/22030205
tags question: http://stackoverflow.com/q/22118012
tags question: http://stackoverflow.com/q/22034500
tags question: http://stackoverflow.com/q/22026683
tags question: http://stackoverflow.com/q/22088909
tags question: http://stackoverflow.com/q/22134317
tags question: http://stackoverflow.com/q/22050013
tags question: http://stackoverflow.com/q/22030903
tags question: http://stackoverflow.com/q/22123060
tags question: http://stackoverflow.com/q/22072889
tags question: http://stackoverflow.com/q/22166799
tags question: http://stackoverflow.com/q/22149615
tags question: http://stackoverflow.com/q/22160936
type: Tag
tags question: http://stackoverflow.com/q/22082612
tags question: http://stackoverflow.com/q/22082451
tags question: http://stackoverflow.com/q/22057252
tags question: http://stackoverflow.com/q/22031319
tags question: http://stackoverflow.com/q/22129523
tags question: http://stackoverflow.com/q/22117771
tags question: http://stackoverflow.com/q/22064558
tags question: http://stackoverflow.com/q/22080462
tags question: http://stackoverflow.com/q/22153968
tags question: http://stackoverflow.com/q/22117494
tags question: http://stackoverflow.com/q/22080451
tags question: http://stackoverflow.com/q/22050545
tags question: http://stackoverflow.com/q/22037373
tags question: http://stackoverflow.com/q/22124831
tags question: http://stackoverflow.com/q/22147080
tags question: http://stackoverflow.com/q/22116134
tags question: http://stackoverflow.com/q/22163146
tags question: http://stackoverflow.com/q/22056991
tags question: http://stackoverflow.com/q/22049353
tags question: http://stackoverflow.com/q/22138786
tags question: http://stackoverflow.com/q/22022363
tags question: http://stackoverflow.com/q/22055962
tags question: http://stackoverflow.com/q/22132483
tags question: http://stackoverflow.com/q/22021940
tags question: http://stackoverflow.com/q/22028298
tags question: http://stackoverflow.com/q/22137724
tags question: http://stackoverflow.com/q/22160736
tags question: http://stackoverflow.com/q/22106907
tags question: http://stackoverflow.com/q/22076058
tags question: http://stackoverflow.com/q/22078129
tags question: http://stackoverflow.com/q/22159868
tags question: http://stackoverflow.com/q/22124816
tags question: http://stackoverflow.com/q/22132632
tags question: http://stackoverflow.com/q/22042638
tags question: http://stackoverflow.com/q/22085954
tags question: http://stackoverflow.com/q/22032689
tags question: http://stackoverflow.com/q/22140375
tags question: http://stackoverflow.com/q/22060560
tags question: http://stackoverflow.com/q/22150454
tags question: http://stackoverflow.com/q/22087436
tags question: http://stackoverflow.com/q/22056927
tags question: http://stackoverflow.com/q/22036983
tags question: http://stackoverflow.com/q/22120325
tags question: http://stackoverflow.com/q/22033213
tags question: http://stackoverflow.com/q/22107237
tags question: http://stackoverflow.com/q/22073657
tags question: http://stackoverflow.com/q/22131167
tags question: http://stackoverflow.com/q/22131816
tags question: http://stackoverflow.com/q/22119454
tags question: http://stackoverflow.com/q/22020123
tags question: http://stackoverflow.com/q/22086624
tags question: http://stackoverflow.com/q/22085493
tags question: http://stackoverflow.com/q/22097572
tags question: http://stackoverflow.com/q/22102103
tags question: http://stackoverflow.com/q/22031012
tags question: http://stackoverflow.com/q/22068835
tags question: http://stackoverflow.com/q/22085221
tags question: http://stackoverflow.com/q/22157120
tags question: http://stackoverflow.com/q/22117181
tags question: http://stackoverflow.com/q/22158458
tags question: http://stackoverflow.com/q/22105645
tags question: http://stackoverflow.com/q/22127457
tags question: http://stackoverflow.com/q/22130944
tags question: http://stackoverflow.com/q/22055053

http://stackoverflow.com/comment/68908124
type: Comment
comment on: http://stackoverflow.com/a/22117234
score: 2
type: AnswerComment
has text: @Pere no, I mean that the OP used the annotation org.hibernate.annotations.Entity, instead of javax.persistence.Entity, and that is the actual reason why he had an error and asked this question. It's not just a side note. It's the most important part of the answer.

http://stackoverflow.com/comment/33570267
type: Comment
has text: But wouldn't that be really slow when going more then 200+ regex since they have to compile at run time? If I'd create all implementations as files and create a predefiner hashmap, I assume it will run faster. Is it possible?
comment on: http://stackoverflow.com/a/22126437
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33514321
type: QuestionComment
has text: I'm not using JSF, I'm trying to use the managed-beans/CDI capability of J2EE 6. However, after a lot of experimentation, I think you're right.
type: Comment
comment on: http://stackoverflow.com/q/22014604
score: 0

http://stackoverflow.com/comment/33665919
has text: You are very detail oriented @Kuma. Thanks for spotting this so quickly.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22138805
type: AnswerComment

http://stackoverflow.com/comment/33621066
type: Comment
has text: CDATA is not a tag so you can't look for it that way. You need to know the name of the containing tag. From your example it looks like the attribute `format="xml"` will let you find tags containing XML, which is what you're looking for. XPath would be `//*[@format='xml']`
comment on: http://stackoverflow.com/a/22152312
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33511993
has text: As long as your `Response` class is not Generic there is no point in specifying any `T` and `U`. Your type cast `(T)` inside the method is *unsafe* and the actual type for `U` does not matter as `setInnerObject` seems to accept arbitrary `Object`s. You *can* specify types for `T` and `U` and you can specify *anything* for them, it simply has not the slightest effect.
score: 1
comment on: http://stackoverflow.com/q/22092891
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33535398
type: Comment
type: QuestionComment
score: 0
has text: İ tried to to do same thing with phyton code. I belive the way is not wrong because i am able to see some part of rows, like messages.
comment on: http://stackoverflow.com/q/22102881

http://stackoverflow.com/q/22116134
has body: i am trying to draw a polygon on the Google map depending on the array list. first check for the array length then i manually add points to draw the polygon. the below code works fine. since the .add(new LatLng(array[0].a, array[0].b)) is a single line statement i am unable to loop it. Is there any way i can do this in a loop. private void drawpolygon(DistanceInfo array[]) { int lengh = array.length; if(lengh==2){ mMap.addPolygon(new PolygonOptions() .add(new LatLng(9.6632139, 80.0133258)) .add(new LatLng(array[0].a, array[0].b)) .add(new LatLng(array[1].a, array[1].b)) .fillColor(Color.GRAY)); } else if(lengh==4){ mMap.addPolygon(new PolygonOptions() .add(new LatLng(9.6632139, 80.0133258)) .add(new LatLng(array[0].a, array[0].b)) .add(new LatLng(array[1].a, array[1].b)) .add(new LatLng(array[2].a, array[2].b)) .add(new LatLng(array[3].a, array[3].b)) .fillColor(Color.GRAY)); } }
type: Question
score: 0
tagged with: google-maps
answer count: 1
tagged with: arrays
has answer: http://stackoverflow.com/a/22116227
tagged with: android
accepted answer: http://stackoverflow.com/a/22116227
type: AnsweredQuestion
has title: Drawing polygons on google Map using array[] - Android
tagged with: java

http://stackoverflow.com/q/22123429
type: Question
has answer: http://stackoverflow.com/a/23816962
has body: I would like to identify (in Java) which trigger executed, caused an exception in quartz so that I can more accurately track problems. Using a SchedulerListener I can identify the exception (which specifies the specific task which is useful) but there is no access to the specific trigger which ran. In the event that I have multiple triggers on a job, I would like to be able to identify which trigger crashed out. When the crash occurs I can query the currently executing jobs within the scheduler and hope that only 1 is running, but I would like to find a more robust solution. Ideas?
has title: How to identify the trigger that caused a scheduler exception?
answer count: 1
downvote count: 0
favorite count: 0
type: UnansweredQuestion
score: 2
upvote count: 2
tagged with: java
tagged with: quartz-scheduler

cisco
type: Tag
tag name: cisco
tags question: http://stackoverflow.com/q/22072404

http://stackoverflow.com/a/22083016
answers question: http://stackoverflow.com/q/22070764
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/33509344
has body: Try building a WAR and deploying it to a tomcat running completely outside eclipse, by dropping the WAR in the webapps directory and running the launch script. This will determine if the problem is the library dependencies or in the eclipse workspace setup. If you suspect the workspace setup, try closing all projects in eclipse and deleting them from the workspace. Do a mvn clean install from the command line and make sure that works. Then delete all of the following eclipse file: .project, .classpath and .settings, choose Import as Maven Project and try again, make sure eclipse uses the same maven and the same settings.xml as the command line. If the problem remains, try to add a ServletContextListenerat the very beginning of your web.xml, and print out the locations of some of the classes involved: System.out.println("All locations of missing class WicketApplication: " + getClass().getclassLoader().getResources("com/plop2/plop3/presentation/WicketApplication.class") ); System.out.println("Currently used version of WicketApplication: " + getClass().getclassLoader().getResource("com/plop2/plop3/presentation/WicketApplication.class") ); There are two explanations for the class not found exception: either the class is not on the classpath (because the jar is not there or due to eclipse classpath problems), or the class is there but it's not visible by the class that needs it, as the class that needs it is in a server classloader. Also check JHades, a tool I wrote to help diagnose classpath problems.
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22070764
type: Answer

http://stackoverflow.com/q/22125823
has answer: http://stackoverflow.com/a/22129530
downvote count: 0
type: UnansweredQuestion
tagged with: amazon-rds
score: 1
has body: I have a java-based JPA2/hibernate web app deployed using Elastic Beanstalk that connects to an EC2 instance and RDS MySQL DB, used to be on micro and small classes. This was until the latency was unbearable, took like 30 seconds to load a page. Then i went to poke around the metrics and saw 100% cpu utilisation bottlenecks on the AWS RDS DB instance. Currently only having less than 10 users concurrently using it. So I went ahead to upgrade them to m3.large classes. The first few minutes were fast as lightning but soon choked again. I went to take a look at the config monitoring for my elastic beanstalk and it was 3% CPU utilisation but my RDS CPU utilisation reaches 100% very quickly and once again takes roughly 30 seconds to load a single page. This is my first experience using AWS's services so I'm really clueless as I heard it was supposed to be much better than this. Does anyone know whats going on? Or how i can debug this? Am I making too many calls to the DB when using hibernate thus choking it?
tagged with: java
tagged with: hibernate
tagged with: mysql
type: Question
upvote count: 1
answer count: 1
tagged with: amazon-web-services
favorite count: 0
has title: AWS RDS CPU Utilisation 100%

http://stackoverflow.com/comment/33556674
comment on: http://stackoverflow.com/q/22111857
type: QuestionComment
has text: Use a JSON parser to parse it, update what you want to in the resulting structures, and then use the companion JSON serializer to produce a new JSON string. You can use any of a dozen different parser/serializer kits, and probably the simpler the better.
score: 0
type: Comment

http://stackoverflow.com/q/22045697
type: UnansweredQuestion
tagged with: android
has body: I'm trying to create my first Android app and I have an issue. I have web service with https protocol, to get the data from the server I use AsyncHttpClient library, it has been working with http, but once I've changed it to https it's gives me an error: No peer certificate I did some research online, I found some advice how to fix it but I was abel to make it works. This are just some of the links I tried: link 1 link 2 My code to call a web service: AsyncHttpClient client = new AsyncHttpClient(); client.get(QUERY_URL, new JsonHttpResponseHandler() { @Override public void onSuccess(JSONObject jsonObject) { Log.d("test", jsonObject.toString()); } @Override public void onFailure(int statusCode, Throwable throwable, JSONObject error) { Log.e("test", "Error: " + statusCode + " " + throwable.getMessage()); } }); Maybe there is some other library which you recommend for calling https async?
score: 0
has answer: http://stackoverflow.com/a/22046174
tagged with: java
linked to: http://stackoverflow.com/q/21833804
tagged with: android-async-http
type: Question
duplicate of: http://stackoverflow.com/q/21833804
has title: AsyncHttpClient with SSL protocol
answer count: 1

http://stackoverflow.com/comment/33400305
type: Comment
type: QuestionComment
has text: Thanks! It is a nice tutorial, I'll look through. However, is it possible to do it without using threads?
comment on: http://stackoverflow.com/q/22031628
score: 0

http://stackoverflow.com/comment/33520975
has text: `Collections.min(Arrays.asList(yourArray))`
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22096824
score: 1

http://stackoverflow.com/comment/33531952
has text: @skiwi Right, that's why I put "inherited" in quotes. The point is it appears you *can't* call static methods that are on an interface *except* by using the name of the interface class. So here it's not useful.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22084062

http://stackoverflow.com/a/22101472
downvote count: 0
type: Answer
has body: You are missing a package name at the start of the file. Also the class should be public. package something.somethingelse; import java.util.Scanner; public class sngmsg{
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/22101359

http://stackoverflow.com/comment/33584999
score: 2
has text: if `number` is 4, how many times does the for-loop execute?
comment on: http://stackoverflow.com/q/22134469
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/33442177
has text: `[\d\D]` is almost equivalent to `.`; `[\d\D]` will include newline characters where `.` will not in this case. See [RexEgg](http://rexegg.com/regex-quickstart.html)'s documentation for the classes.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22051506
score: 1

http://stackoverflow.com/q/22041733
has answer: http://stackoverflow.com/a/38758768
favorite count: 0
answer count: 12
has answer: http://stackoverflow.com/a/37761621
tagged with: textfield
has title: How to add search icon with text as hint in Text Field ?
type: UnansweredQuestion
tagged with: android
has answer: http://stackoverflow.com/a/22041804
score: 6
has answer: http://stackoverflow.com/a/22043153
has answer: http://stackoverflow.com/a/22041821
has answer: http://stackoverflow.com/a/29692442
tagged with: java
downvote count: 3
has answer: http://stackoverflow.com/a/22041925
has answer: http://stackoverflow.com/a/22041846
has answer: http://stackoverflow.com/a/22041874
type: Question
upvote count: 9
has body: I want to add a search icon with text as hint in text field as photo below xml file
has answer: http://stackoverflow.com/a/22042361
has answer: http://stackoverflow.com/a/34072983
has comment: http://stackoverflow.com/comment/36561076
has answer: http://stackoverflow.com/a/22041753

http://stackoverflow.com/a/22081554
has body: Assuming "str" is a StringBuilder or StringBuffer, you want to remove the "input.contains" check and str.append there. You also want to change the str.setCharAt to the following: if (Character.isUpperCase(input.charAt(i)) &amp;&amp; i != 0) { str.append(' '); // adds a space str.append(Character.toLowerCase(input.charAt(i)); // add lowercase. } else { // Not an upper case, so just append it normally. // EDIT: Added (char) cast to get the right overload of append. str.append((char)input.charAt(i)); } Basically, what this says is "If its an uppercase letter, append a space then the lower case value, otherwise just append it as is."
has comment: http://stackoverflow.com/comment/33489712
upvote count: 1
answers question: http://stackoverflow.com/q/22081418
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33489840

http://stackoverflow.com/comment/33384021
score: 0
has text: In C/C+ supports pointers. Java doesn't support pointers, so doing char[] *args would not be valid.
type: QuestionComment
comment on: http://stackoverflow.com/q/22022722
type: Comment

http://stackoverflow.com/q/22102150
has body: Here is what I have done:- // compile Runtime.getRuntime().exec("javac C:\\dir1\\dir2\\dir3\\Main.java"); // run Runtime.getRuntime().exec("java C:\\dir1\\dir2\\dir3\\Main"); I am successfully able to compile this file but cannot run it. I have tried using exec("cd C:\\dir1\\dir2\\dir3") before using exec("java Main") but to no benefit. Any ideas?
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/22102629
accepted answer: http://stackoverflow.com/a/22102629
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33526737
tagged with: java
has title: Use Java Runtime to compile/run .java files?
type: Question
tagged with: runtime

http://stackoverflow.com/a/22077587
upvote count: 1
has comment: http://stackoverflow.com/comment/33482159
score: 1
answers question: http://stackoverflow.com/q/22077187
downvote count: 0
has body: A solution that should be a bit more efficient than yours (which is already really efficient) is the following. public String convertWord(String word) { StringBuilder sb = new StringBuilder(); char[] charArr = word.toCharArray(); for(int i = 0; i &lt; charArr.length; i++) { // Single character case if(charArr[i] == 'i' &amp;&amp; (i+1 &lt; charArr.length) &amp;&amp; charArr[i+1] = ' ') { sb.append('I'); } else { sb.append(word.charAt(i)); } } return sb.toString(); }
type: Answer

http://stackoverflow.com/a/23263921
upvote count: 0
has body: As Ankit answered there is no API to check whether Media Player is paused or not ,we have to check it programmatically like this private boolean pause=true; //A Boolean variable to check your state declare it true or false here depends upon your requirement Now you can make a method here to check that whenever you want to check player is pause public void checkplayer(MediaPlayer player){ if(isPause=true) //check your declared state if you set false or true here Player.pause(); else if(isPause=false){ Player.play(); or Player.stop(); }
downvote count: 1
score: -1
answers question: http://stackoverflow.com/q/22167731
type: Answer

http://stackoverflow.com/comment/33428605
type: AnswerComment
has text: It's also more or less using String.valueof() and then converting to a char Array which was explicitly noted to be an invalid solution.
type: Comment
score: 1
comment on: http://stackoverflow.com/a/22047421

http://stackoverflow.com/q/22040812
has body: we have to work with a very specific class in Java that has the following property: protected SPSExchangedDocumentType spsExchangedDocument; public SPSExchangedDocumentType getSPSExchangedDocument() { return spsExchangedDocument; } I use the instance of that class inside a jsp page: &lt;c:out value = "${certificate.spsExchangedDocument.id.value}"/&gt; It throws me the following exception: javax.el.PropertyNotFoundException: The class 'un.unece.uncefact.data.standard.spscertificate._5.SPSCertificateType' does not have the property 'spsExchangedDocument'. at javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:579) at javax.el.BeanELResolver.getValue(BeanELResolver.java:281) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175) at com.sun.el.parser.AstValue.getValue(AstValue.java:138) at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:206) at org.apache.jasper.runtime.PageContextImpl.evaluateExpression(PageContextImpl.java:1001) I think the problem is directly with the fact, that the property is called spsExchangedDocument, but the method is called getSPSExchangedDocument. I cannot change the code of the class, because it's generated automatically from XSD, that we cannot alter, so I should change the page. But what name should I use in order for EL to resolve it properly: spsExchangedDocument. SPSExchangedDocument. sPSExchangedDocument. What is the rule for such naming conventions in java and EL anyway?
has title: How to resolve the name properly by BeanELResolver
has comment: http://stackoverflow.com/comment/33415910
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/22041274
upvote count: 2
answer count: 1
accepted answer: http://stackoverflow.com/a/22041274
tagged with: java
has comment: http://stackoverflow.com/comment/33416406
tagged with: resolver
type: AnsweredQuestion
score: 2
downvote count: 0
tagged with: jsp

http://stackoverflow.com/a/22056197
answers question: http://stackoverflow.com/q/22056159
type: Answer
accepted answer of: http://stackoverflow.com/q/22056159
has comment: http://stackoverflow.com/comment/33444195
has comment: http://stackoverflow.com/comment/33444112
has body: Set&lt;T&gt; c = new Set&lt;T&gt;(); c.retainAll(b); return c; c never has any of the elements of a to start with. You never mentioned a anywhere in that block of code, in fact. Perhaps you meant Set&lt;T&gt; c = new Set&lt;T&gt;(a);
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33444007
has comment: http://stackoverflow.com/comment/33443994

http://stackoverflow.com/q/22097665
type: Question
tagged with: sql-server
score: 0
answer count: 2
tagged with: sql
has comment: http://stackoverflow.com/comment/33517383
has body: I'm trying to connect to a sql server with JDBC in java. My server uses a windows authentication. I use this code: String url = "jdbc:sqlserver://MYPC\\MYSERVER;databaseName=MYDB;integratedSecurity=true"; Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); Connection conn = DriverManager.getConnection(url); In my classpath i have the file: jtds-1.3.1.jar and sqljdbc4.jar And i have a VM argument: -Djava.library.path="SQLPATH\jtds\x64\SSO" When i run the code, i have this exception: com.microsoft.sqlserver.jdbc.SQLServerException: Unable to connect to the host MYPC Do you know what is wrong?
has answer: http://stackoverflow.com/a/22097820
type: UnansweredQuestion
tagged with: jdbc
has title: Unable to connect to sql server 2008 with jdbc
has answer: http://stackoverflow.com/a/22097844
tagged with: java

http://stackoverflow.com/comment/33547897
type: Comment
comment on: http://stackoverflow.com/a/22114153
score: 0
type: AnswerComment
has text: it still doesn't write anything on the output file.

http://stackoverflow.com/q/22148361
downvote count: 0
type: UnansweredQuestion
score: 1
has comment: http://stackoverflow.com/comment/33609019
favorite count: 0
tagged with: serialization
type: Question
tagged with: android
has title: pass specific object to other activity (Jsch)
has comment: http://stackoverflow.com/comment/33608674
has comment: http://stackoverflow.com/comment/33618071
upvote count: 1
tagged with: network-programming
has comment: http://stackoverflow.com/comment/33608578
tagged with: java
tagged with: parcelable
has body: I have a problem with passing a Object from one activity to another. I'm using the Jsch() Class because I want to make an Sftp Connection. This in my Login Activty: ServerConnect lLogin = new ServerConnect(lUser,lPass,lIP,lPort); ASYNCLogin lASYNC = new ASYNCLogin(lLogin,getBaseContext()); lASYNC.execute(); My ASYNC Task: @Override protected Integer doInBackground(Void... params) { if(mServerConnect.connectServer()) return 1; return 0; } @Override protected void onPostExecute(Integer result) { //Toast.makeText(mContext, "Sucessfully Connected!", Toast.LENGTH_LONG).show(); Intent lListFiles = new Intent(mContext,ListFilesActivity.class); lListFiles.putExtra("ServerConnect", mServerConnect); lListFiles.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(lListFiles); } The connect Method in my ServerConnect Class: public boolean connectServer() { try { mSession=mSsh.getSession(mUsername,mServerIP,mServerPort); mSession.setConfig(mConfig); mSession.setPassword(mPassword); mSession.connect(); mChannel = mSession.openChannel("sftp"); mChannel.connect(); } } How I get the Object in the other Activity: mLogin = (ServerConnect) getIntent().getSerializableExtra("ServerConnect"); I tried it with Serializable, but it doesnt' work because I cant't implement the Serializable interface in the java.lang.Object Class.... I also tried it with Parcelable, but I don't know how to write the custom Class into a Parcable. Are there other ways to pass the Object from the Login Activity to another? Logcat: 03-03 13:35:40.583: E/AndroidRuntime(4186): FATAL EXCEPTION: main 03-03 13:35:40.583: E/AndroidRuntime(4186): Process: com.example.securebox, PID: 4186 03-03 13:35:40.583: E/AndroidRuntime(4186): java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.example.securebox.ServerConnect) 03-03 13:35:40.583: E/AndroidRuntime(4186): at android.os.Parcel.writeSerializable(Parcel.java:1312) 03-03 13:35:40.583: E/AndroidRuntime(4186): at a…
has comment: http://stackoverflow.com/comment/33608715
has comment: http://stackoverflow.com/comment/33608831
answer count: 0

http://stackoverflow.com/a/22100940
has body: Absent a complete example, I'm not sure I can explain your result, but setComponentPopupMenu() works on a JPanel added to a dialog's content pane. The code below is based on this example. import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.JDialog; import javax.swing.JFileChooser; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JScrollPane; import javax.swing.KeyStroke; /** * @see https://stackoverflow.com/a/22100940/230513 * @see https://stackoverflow.com/questions/5129294 */ public class Test { private void display() { JDialog d = new JDialog(); d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); final ImagePanel imagePanel = new ImagePanel(); d.add(new JScrollPane(imagePanel)); d.setJMenuBar(imagePanel.menuBar); d.pack(); d.setLocationRelativeTo(null); d.setVisible(true); } public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { new Test().display(); } }); } private static class ImagePanel extends JPanel { private static final int MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); private JFileChooser chooser = new JFileChooser(); private Action openAction = new ImageOpenAction("Open"); private Action clearAction = new ClearAction("Clear"); private JMenuBar menuBar = new JMenuBar(); private JPopupMenu popup = new JPopupMenu(); private BufferedImage image; public ImagePanel() { this.setComponentPopupMenu(popup); popup.add("Popup Menu"); popup.add(new JMenuItem(openAction)); popup.add(new JMenuItem(clearAction)); JMenu menu = new JMenu("File"); menu.setMnemonic('F'); menu.add…
upvote count: 3
score: 3
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/22097855

http://stackoverflow.com/comment/33372389
score: 0
has text: It will return the same instance no matter in which class the method is defined, so it is completely pointless. In every context you could call ```getMHandle()```, you could more easily call ```this``` or use the instance on which you would call it.
comment on: http://stackoverflow.com/q/22016405
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22166772
answers question: http://stackoverflow.com/q/22164871
has body: No bean named 'userdao' is defined you have to define either UserDao in xml configuration as a bean or annotate UserDao class with @component if you are following the annotation based config then please uncomment the following portion in your config xml &lt;!-- &lt;context:annotation-config /&gt; &lt;context:component-scan base-package="com.quest.*&gt;" /&gt; &lt;mvc:annotation-driven /&gt; --&gt;
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33648455
has comment: http://stackoverflow.com/comment/33646597
has comment: http://stackoverflow.com/comment/33649756
has comment: http://stackoverflow.com/comment/33649897
type: Answer
accepted answer of: http://stackoverflow.com/q/22164871

http://stackoverflow.com/comment/34788048
type: Comment
has text: Hi Kevin, I followed your tutorial. It only works when I setContentView in the abstract view. Otherwise I get a NullPointerException. How can I solve this?
comment on: http://stackoverflow.com/a/22144355
type: AnswerComment
score: 0

http://stackoverflow.com/a/22139802
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22139494
has comment: http://stackoverflow.com/comment/33651248
has comment: http://stackoverflow.com/comment/33650392
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/33650674
upvote count: 2
has comment: http://stackoverflow.com/comment/33650280
has comment: http://stackoverflow.com/comment/33651166
has comment: http://stackoverflow.com/comment/33650224
has comment: http://stackoverflow.com/comment/33650705
has comment: http://stackoverflow.com/comment/33872161
has comment: http://stackoverflow.com/comment/33651071
has comment: http://stackoverflow.com/comment/33650491
has body: try this..,it happens soetime Try window-&gt;show view-&gt;devices-&gt;view menu-&gt;Reset adb and again run application. and this also rightclick on your project---&gt;Run As ---&gt;Run Configuration.----&gt; here you will get window just folow that..,and try to run..,it will work.
has comment: http://stackoverflow.com/comment/33651189
answers question: http://stackoverflow.com/q/22139494

http://stackoverflow.com/comment/33478480
type: QuestionComment
score: 9
type: Comment
has text: http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#in ?
comment on: http://stackoverflow.com/q/22075866

http://stackoverflow.com/q/22113234
type: AnsweredQuestion
score: 3
downvote count: 0
has answer: http://stackoverflow.com/a/22117571
tagged with: websocket
favorite count: 0
type: Question
tagged with: netty
has body: I have a websocket server using Netty (4.0.17) that answers requests from a JavaScript client. The communication works fine but I have an exception when I try to immediately send a greeting message when a client connects. My code looks like that : public class LiveOthelloWSHandler extends SimpleChannelInboundHandler&lt;TextWebSocketFrame&gt; { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { super.channelActive(ctx); ChannelFuture f = ctx.channel().writeAndFlush(new TextWebSocketFrame("(gameID=0)[LiveOthelloServer="+ VERSION_NUMBER + "]\n")); } // ... @Override protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame frame) throws Exception { final String request = frame.text(); Channel thisChannel = ctx.channel(); // Do something with request // Write back thisChannel.writeAndFlush(new TextWebSocketFrame(response + "\n")); } } The channelRead0() is ok, the client sends messages and the server answers back without any issue. What doesn't work is the "greetings" part. I would like to send a welcoming message to the client (the string using VERSION_NUMBER in the ChannelActive() method) but I always get an exception : java.lang.UnsupportedOperationException: unsupported message type: TextWebSocketFrame I guess this is maybe because the channelActive() gets invoked as soon as the connection is established but before the websocket handshake is complete. How can I wait for the handshake to be finished and then send the greeting message (without the client having sent any request yet)? For information, my initialization is: @Override public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast( new HttpRequestDecoder(), new HttpObjectAggregator(65536), new HttpResponseEncoder(), new WebSocketServerProtocolHandler("/websocket"), myLiveOthelloWSHandler);
accepted answer: http://stackoverflow.com/a/22117571
upvote count: 3
answer count: 1
has title: Server sending a greeting message with websocket and netty -> causing exception
tagged with: java

http://stackoverflow.com/comment/33514792
score: 0
has text: Its difficult to detect the issue from half code or paste the error stack trace
comment on: http://stackoverflow.com/q/22096083
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22070863
tagged with: android
has comment: http://stackoverflow.com/comment/33515389
tagged with: generics
tagged with: ormlite
answer count: 0
has body: I am trying to create a library which manages data. Part of it is storing stuff in databases. Since I don't know what the user of library wants to store, I am using generics. Here is my method to read a database table. public &lt;TEntity extends SyncableBase&gt; List&lt;TEntity&gt; loadItems(Class clazz) { List&lt;TEntity&gt; listToReturn = new ArrayList&lt;TEntity&gt;(); DatabaseHelperBase dbHelper = getDbHelper(); Dao&lt;TEntity, Integer&gt; dao; try { dao = dbHelper.getDao(clazz); //Is this approach correct? listToReturn = dao.queryForAll(); //This doesn't work } catch (SQLException e){ e.printStackTrace(); } return listToReturn; } And somewhere in my app (which consumes this library) I call this method like so: List&lt;ToDoCategory&gt; catList = mirrorservice.&lt;ToDoCategory&gt;loadItems(ToDoCategory.class); No matter what I do, the empty ArrayList is returned to catList. I tried similar approach with queryForId too. That didn't work either. Meanwhile, my add is working just fine! I suspect that there is something wrong with the way I'm creating Dao. What is the problem?
type: UnansweredQuestion
tagged with: java
has title: OrmLite queryForAll doesn't work
type: Question
score: 0
has comment: http://stackoverflow.com/comment/33524548

http://stackoverflow.com/q/22163004
type: Question
has title: Java GUI inputs to HTML bill
has comment: http://stackoverflow.com/comment/33635210
tagged with: java
has body: I am working on a project for a business. Using Java application, I am planning generate a sales bill. This is how it is going to work..... When I run my java application, GUI window will popup and it will ask me to enter details to generate bill......after hitting submit button some background processing should happen and it should redirect me to all data enter should be replaced by variable shown on the second pic, I also have code ready to generate this page in HTML. Not able to figure out how to make this work.
upvote count: 1
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/3695230
downvote count: 0
answer count: 0
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33635229
has comment: http://stackoverflow.com/comment/33635187

http://stackoverflow.com/comment/33625649
type: AnswerComment
score: 0
type: Comment
has text: It is up to the specific JDBC driver implementation to correctly close the resources. The fact that the API documents it does not necessarily mean that all implementations comply!
comment on: http://stackoverflow.com/a/22139876

http://stackoverflow.com/q/22131364
possible better answer: http://stackoverflow.com/a/22131403
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22131403
tagged with: java
accepted answer: http://stackoverflow.com/a/22131657
type: Question
answer count: 2
tagged with: inheritance
has body: At somewhere, that I can not remember, I read about an alternative way to instatiate a object: Generally, we instantiate (and assign) this way: User userObj = new User(); userObj.setId(1); userObj.setName("Foo"); An alternative way could be: User userObj = new User() {{ setId(1); setName("Foo"); }} I was using this alternative, and it works. 1) Anyone knows what is it? Where is Java documentation link that metion about it? I stop to use this because I was having problems with interfaces that ClassName implements, but the alternative way don't implements. Oo public class User implements Serializable { private int id; private String name; //public Getters and Setters } 2) When I try to serialize and use it (passing from one activity to another, using: putExtra(String, Serializable) it will throw NotSerializableException. Why? Edit 1: An anonnymous class also implements the parent 'implementations', like Serializable from ClassName?
score: 0
tagged with: android
has title: Alternative way to instantiate a class not implements the parent interfaces
has answer: http://stackoverflow.com/a/22131657
tagged with: assign
has comment: http://stackoverflow.com/comment/33579539
has comment: http://stackoverflow.com/comment/33579501

http://stackoverflow.com/comment/33432044
score: 0
has text: @RohitJain Doesn't the fact that a `Stream` is implemented as a pipeline guarantee this?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22046690

http://stackoverflow.com/q/22153511
type: Question
tagged with: path
tagged with: java
upvote count: 1
answer count: 1
tagged with: versioning
has title: How in Java (REST api) you can specify 2 resources located in the same path, so the execution depends on the version client had provided?
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22153631
has body: Example: @POST @Path("/commonPath") @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) public Response getMethoV1(RequestDto1 reqDto) { //logic } @POST @Path("/commonPath") @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) public Response getMethoV2(RequestDto2 reqDto) { //logic } How can this code be adjusted, so the clients who use app version 1 could go to getMethod1() and those who have switched to version 2 could use resource getMethod2()? And RequestDtos may or may not be the same class objects.
downvote count: 0
score: 1
favorite count: 0
tagged with: rest

http://stackoverflow.com/comment/33416886
comment on: http://stackoverflow.com/q/22041151
has text: About "fast", your bare-bones explicit loop solution will be as fast as it can get.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22032381
has comment: http://stackoverflow.com/comment/33401425
has comment: http://stackoverflow.com/comment/33405928
has comment: http://stackoverflow.com/comment/33405582
has body: Write a BroadcastReceiver as follows public class TheBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { WifiManager wifiManager = (WifiManager) context .getSystemService(Context.WIFI_SERVICE); NetworkInfo datainfo = intent .getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); if (datainfo != null) { if (datainfo.getType() == ConnectivityManager.TYPE_WIFI) { //have different network states here if (datainfo.getState() == datainfo.State.CONNECTING || datainfo.getState() == datainfo.State.CONNECTED) { //work accordingly } } } } } Register a BroadcastReceiver and register these entries at manifest &lt;receiver android:name="yours package details like com.a.b.c.TheBroadcastReceiver " &gt; &lt;intent-filter&gt; &lt;action android:name="android.net.wifi.supplicant.CONNECTION_CHANGE" /&gt; &lt;action android:name="android.net.wifi.STATE_CHANGE" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; Add following permission sets at manifest &lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /&gt; &lt;uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /&gt; Also visit http://developer.android.com/training/monitoring-device-state/connectivity-monitoring.html
score: 1
has comment: http://stackoverflow.com/comment/33401723
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33401666
has comment: http://stackoverflow.com/comment/33401703
answers question: http://stackoverflow.com/q/22031992
has comment: http://stackoverflow.com/comment/33401399
type: Answer
accepted answer of: http://stackoverflow.com/q/22031992
upvote count: 1

http://stackoverflow.com/q/22150741
type: UnansweredQuestion
has title: Arquillain/Shrinkwrap how to add whole META-INF directory?
tagged with: jsf-2
tagged with: jboss-arquillian
has answer: http://stackoverflow.com/a/24804656
downvote count: 0
score: 1
favorite count: 0
tagged with: shrinkwrap
type: Question
has answer: http://stackoverflow.com/a/22406470
tagged with: java
answer count: 2
upvote count: 1
has body: I want to use Arquillian + Selenium for testing my JSF Pages. My Project structure is as follows: /src/main/java - my java classes /src/main/resources /src/main/resources/META-INF - all imgs, css, js and custom composite JSF components /src/main/webapp/pages - my xhtml pages /src/main/webapp/WEB-INF - descriptors, JSF template I want to build a test deployment archive with all my needed stuff, i.e. all resources, the particular xhtml page I want to test, WEB-INF directory. I've managed to copy all of them except of the META-INF resources. Is there any method how to tell shrinkwrap to take the whole META-INF directory into the deployment? Thank you.
tagged with: arquillian-drone

http://stackoverflow.com/comment/33395717
type: Comment
comment on: http://stackoverflow.com/a/22028882
has text: I am not sure if I got it. Let's try with a simple example. Assume that I have an array of ints, e.g. int[] array = new int[3];. When this statement runs, I think - please correct me if I am wrong - that if I will print my array I will get [0, 0, 0], i.e. I have zeroes (the standard value for int[] arrays) at indexes 0, 1, and 2 (since I defined a length 3). Now if I try to do array[2] = 5 (a number) I should get [0,0,5] and not an ArrayIndexOutOfBoundsException since the index already exists upon allocation - it is a fixed array, not a dynamic one that starts from 0 and grows!
type: AnswerComment
score: 0

http://stackoverflow.com/q/22156371
has title: JavaFX TableView double selection in a filebrower
answer count: 0
score: 1
tagged with: java
tagged with: javafx
type: Question
downvote count: 0
upvote count: 1
has body: I'm currently working on a program with a filebrowser. I implemented it using a tableView which shows what's in the current folder. If I have a folder A which contains 1, 2 and 3. If I click on A. It will open A and also 1 because the first item is still selected. What I think is happening : A gets focus then become selected, it changes the view and the focus is still on the first item which becomes selected. An eventListener tracks the selection changes: table.getSelectionModel().selectedItemProperty().addListener(new ChangeListener&lt;FileItem&gt;() { @Override public void changed(ObservableValue&lt;? extends FileItem&gt; observable, FileItem oldValue, FileItem newValue) { // newValue may be null when the list is cleared (in that case do not try to download the document) if (table.getSelectionModel().getSelectedItem() != null ) { Path path = Paths.get(newValue.getFullPath()); if (newValue.isDirectory()) { showDirectory(path); } And the showfolder(): public void showDirectory(Path path){ try{ DirectoryStream&lt;Path&gt; dir = Files.newDirectoryStream(path); table.getSelectionModel().clearSelection(); if(path.getRoot().equals(path)){ parentButton.setVisible(false); } else{ parentButton.setVisible(true); } fileList.clear(); for(Path file:dir){ FileItem fileItem = new FileItem(file); fileList.add(fileItem); } currentDirectory = path.toString(); pathLabel.setText(currentDirectory); } catch (IOException e1) { e1.printStackTrace(); } } I already tried table.getSelectionModel().clearSelection() Thank you in advance for your responses. Alexis Benoist.
favorite count: 0
type: UnansweredQuestion

http://stackoverflow.com/a/25610634
downvote count: 0
upvote count: 8
has comment: http://stackoverflow.com/comment/43621833
has comment: http://stackoverflow.com/comment/101865394
answers question: http://stackoverflow.com/q/22158923
has body: You only have the Java JRE installed, you need to install the JDK in order for Oracle SQL Devloper to work. TL;DR Install the JDK, type sudo apt-get install openjdk-7-jdk in a terminal. Checking if JDK is Installed To check if you have the JDK installed, type aptitude search openjdk-7-jdk in the terminal. If you see an i beside either package then it is installed. For example, I have the 64-bit JDK installed on my machine, this is the output. $ aptitude search openjdk-7-jdk i openjdk-7-jdk - OpenJDK Development Kit (JDK) p openjdk-7-jdk:i386 - OpenJDK Development Kit (JDK) If the package does not have an i beside it, then it is not installed. Installing JDK To install in the JDK in ubuntu you need to install the package openjdk-7-jdk. Install by running sudo apt-get install openjdk-7-jdk in a terminal. Setting JAVA_HOME After installing the JDK you need to set the JAVA_HOME environment variable. You can see all the installed JDKs on your machine by running update-java-alternatives -l, choose the one you want to use and copy the third field, this field is the JAVA_HOME for that JDK. For example, on my machine $ update-java-alternatives -l java-1.7.0-openjdk-amd64 1071 /usr/lib/jvm/java-1.7.0-openjdk-amd64 This means I only have one JDK installed, java-1.7.0-openjdk-amd64, and its JAVA_HOME is /usr/lib/jvm/java-1.7.0-openjdk-amd64. Next, set the JAVA_HOME environment variable, in Bash I would set it by running this from the terminal: $ export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64 Check to make sure it was set correctly. $ echo $JAVA_HOME /usr/lib/jvm/java-1.7.0-openjdk-amd64 This will set JAVA_HOME for your current terminal session, to not have to worry about setting it again, you can add it to your ~/.bashrc file. Running Oracle SQL Developer Once the JDK is installed and the JAVA_HOME environment variable set, you can move into the sql developer directory and run the sqldeveloper.sh script. $ cd sqldeveloper $ ./sqldeveloper.sh If sqldeveloper.sh is not ex…
type: Answer
score: 8
has comment: http://stackoverflow.com/comment/102034092
has comment: http://stackoverflow.com/comment/102027469
has comment: http://stackoverflow.com/comment/43673252

http://stackoverflow.com/comment/33497575
comment on: http://stackoverflow.com/q/22086156
type: Comment
type: QuestionComment
has text: As its project make it as library and use it. or compile the project generate the .jar to import it in ur project.
score: 0

http://stackoverflow.com/q/22087150
has answer: http://stackoverflow.com/a/22087253
tagged with: calendar
has body: I am having problems with the Calendar Class. Calendar cal = Calendar.getInstance (); int iYear = cal.get (Calendar.YEAR); // get the current year int iMonth = cal.get (Calendar.MONTH); // month... int iDay = cal.get (Calendar.); // current day in the month This... No Workie!! :-( I used the debugger and found that the YEAR and the DAY_OF_MONTH are correct, however, the MONTH is 1 (January) when it SHOULD BE 2 (February). Here is where it gets even more WEIRD: I then tried cal.clear (); followed by cal.set (2014, 2, 27); // Today's Date - Feb 27, 2014 and the month was still 1 (i.e. January) I set the date to days in January, (2014, 1, 1), (2014, 1, 16),etc It correctly gave me a 1 for the month After reading and trying many things (and pulling my hair out..) I set it to a date in the future, my Birthday (2014, 5, 23) and other days. For those dates, Month was correctly set to 5 (May)
has answer: http://stackoverflow.com/a/22087243
has answer: http://stackoverflow.com/a/22087296
has answer: http://stackoverflow.com/a/22087247
score: 1
tagged with: java
answer count: 6
type: Question
has comment: http://stackoverflow.com/comment/33502964
linked to: http://stackoverflow.com/q/38922754
downvote count: 0
has answer: http://stackoverflow.com/a/48492279
favorite count: 0
has title: Calendar Class problems
has answer: http://stackoverflow.com/a/22087409
type: UnansweredQuestion
upvote count: 1

http://stackoverflow.com/a/22055192
score: 0
type: Answer
has body: If you have an interface with some standard functions, you can create a generic builder for it. The base builder would be abstract, and for each concrete implementation, there would be a concrete builder. Interface: public interface CodeNameable { String getCode(); String getName(); } Concrete implementation: public class CodeNamedCar implements CodeNameable { private String code; private String name; public CodeNamedCar(String code, String name) { this.code = code; this.name = name; } } Abstract builder: public abstract class CodeNameBuilder&lt;C extends CodeNameable&gt; { public String code; public String name; public CodeNameBuilder() { } } Concrete builder: public abstract class CarBuilder extends CodeNameBuilder&lt;CodeNamedCar&gt; { public CarBuilder() { } public CarBuilder code(String co_de) { this.code = code; return this; } public CarBuilder name(String name) { this.name = name; return this; } public CodeNameCar build() { return (new CodeNameCar(code, name)); } } Then you can use it as you hoped: CodeNamedCar car = new CarBuilder().code("thecode").name("Mazda").build(); Using this design, you'll need to check each field for correctness (non-null and non-empty, for example) in the CodeNameCar constructor. There are other ways to design it, too.
answers question: http://stackoverflow.com/q/22054989

http://stackoverflow.com/comment/37244727
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22106958
has text: @Springrbua use Blender or another 3D editor for this purpose. If you are going to use Blender, just add mesh called `Cube` and resize it as appropriate. Then export it in `.obj` format file and load this mesh in libGDX.

http://stackoverflow.com/q/22124557
has comment: http://stackoverflow.com/comment/33567485
downvote count: 0
has comment: http://stackoverflow.com/comment/33566788
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33568011
type: Question
has answer: http://stackoverflow.com/a/22124621
answer count: 1
has title: Sokoban Java Performmove error
has comment: http://stackoverflow.com/comment/33567213
has comment: http://stackoverflow.com/comment/33567272
upvote count: 1
has body: This is sokoban game in java. i'm having error when i try to perform a move. Anybody can point out the changes i have to make to make it work? Here are the errors im getting java.lang.StringIndexOutOfBoundsException: String index out of range: 49 at java.lang.String.charAt(Unknown Source) at State.stateString(State.java:32) at State.(State.java:15) at boxpushing.perform(boxpushing.java:14) import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; public class State{ private int posX; private int posY; private ArrayList&lt;Integer&gt; goalX; private ArrayList&lt;Integer&gt; goalY; private char[][] state; public State(String s){ state=stateString(s); goalX=new ArrayList&lt;Integer&gt;(); goalY=new ArrayList&lt;Integer&gt;(); locatePositionPlayerAndTargets(); } public char [][] stateString(String s){ //need to put the state string into respective array position int width = s.indexOf("\n"); //to find how many number of rows below. int height = s.length() / width; char newState[][] = new char[height][width]; int index = 0; for (int i = 0; i &lt;height; i++){ for(int j = 0; j&lt; width; j++){ newState[i][j]=s.charAt(index); index++; } index++; } return newState; } public char[][] getState(){ return state; } private void locatePositionPlayerAndTargets(){ //for player on target, target and crate on target for (int i=0; i&lt; state.length; i++){ for(int j=0; j&lt;state[0].length; j++){ if(state[i][j] == 'P'){ posX=j; posY=i; } else if (state[i][j] == '+' || state[i][j] == 'o' || state[i][j] == '@' ){ goalX.add(j); //save the goal/targets values (X and Y position) goalY.add(i); } } } } public ArrayList&lt;Integer&gt; getGoalY(){ return goalY; //return the goal/target Y's position } public ArrayList&lt;Integer&gt; getGoalX(){ return goalX; //return the goal/target X's position } public int getPosX(){ return posX; } public int getPosY(){ return posY; } public void setChar(int y, int x, char c){ //to save the current element on that particular…
has comment: http://stackoverflow.com/comment/33567565
has comment: http://stackoverflow.com/comment/33567763
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33567721
has comment: http://stackoverflow.com/comment/33567608
has comment: http://stackoverflow.com/comment/33567113
has comment: http://stackoverflow.com/comment/33567439

http://stackoverflow.com/a/22151438
score: 3
upvote count: 3
has body: Switch[] switchArray = {one, two, three, four, five}; contains references to one, two, three, four, five at the moment you create the array. Latter, you reassign those variables, but your array still points to the previous references. You need to create the array after you have assigned your views: one = (Switch) findViewById(R.id.switchOne); two = (Switch) findViewById(R.id.switchTwo); three = (Switch) findViewById(R.id.switchThree); four = (Switch) findViewById(R.id.switchFour); five = (Switch) findViewById(R.id.switchFive); // Then only switchArray = {one, two, three, four, five};
has comment: http://stackoverflow.com/comment/33615413
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33614281
downvote count: 0
has comment: http://stackoverflow.com/comment/33616441
answers question: http://stackoverflow.com/q/22151158
type: Answer
accepted answer of: http://stackoverflow.com/q/22151158

http://stackoverflow.com/a/22162414
score: 2
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22162257
upvote count: 2
answers question: http://stackoverflow.com/q/22162257
has body: You have a couple options. In the current case you have, where the JButton objects are locally scoped within the constructor, you would need to check for actionCommmand because the objects are not accessible from the ActionListener with their current scope. So you could do this class ButtLis implements ActionListener{ @Override public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if ("One".equals(command)) { // do something } } } If you wanted to compare object source, you would need to give your buttons a global scope public class Foo { JButton button = new JButton("One"); JButton button2 = new JButton("Two"); class ButtLis implements ActionListener{ @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == button) { } } } } A third option is to register the buttons individually public void go() { ... button.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent e) { // do something } }); } See more at How to use Common Button and How to Write ActionListeners
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33634277
type: Answer

http://stackoverflow.com/a/22130892
has comment: http://stackoverflow.com/comment/33578607
type: Answer
has comment: http://stackoverflow.com/comment/33578625
score: 5
upvote count: 5
downvote count: 0
has body: It's a valid line if args is declared as a String[][] - but that wouldn't be how a main method would be declared. length is a valid member of an array, but it's not a (public) member of the String class. If you're trying to check the length of a string, you want the length() method instead. For example: if (args[0].length() &gt; 2) You might want to first check that there are some arguments, using args.length. For example: public static void main(String[] args) { if (args.length == 0) { System.out.println("You need to give me an argument!"); return; } if (args[0].length() &gt; 2) { System.out.println("The first argument has more than 2 characters"); } else { System.out.println("The first argument has 0-2 characters"); } }
answers question: http://stackoverflow.com/q/22130869

http://stackoverflow.com/q/22026684
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22135757
tagged with: java
tagged with: http
type: Question
has body: I want to control vlc with java code and its web interface using http://localhost:8080 The problem is I don't know how exactly I must use the http requests. Here is some code I have written: URL url = new URL("http://127.0.0.1:8080/"); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setDoOutput(true); con.setRequestMethod("GET"); con.setRequestProperty("If-Modified-Since", "29 Oct 1999 19:43:31 GMT"); con.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0"); con.setRequestProperty("Content-Language", "en-US"); //DataOutputStream wr = new DataOutputStream(con.getOutputStream()); OutputStream wr = con.getOutputStream(); if (line.split(":")[1].equals("Play")) { wr.write("requests/status.xml?command=pl_play".getBytes()); // wr.write("play".getBytes()); } else { wr.write("requests/status.xml?command=pl_stop".getBytes()); } wr.flush(); //wr.close(); int status = con.getResponseCode(); System.out.println(status); It mainly copy/paste from google. Status returns 200..
answer count: 1
tagged with: remote-control
accepted answer: http://stackoverflow.com/a/22135757
score: 0
has title: Control Vlc with requests - java
favorite count: 0
upvote count: 1
tagged with: request
downvote count: 1
tagged with: vlc

http://stackoverflow.com/q/22152073
answer count: 2
has answer: http://stackoverflow.com/a/22152405
has comment: http://stackoverflow.com/comment/33615668
has body: I am writing a simulator which communicates with a client's piece of software over a local socket. The communication language is XML. I have written some code which works - parsing the incoming XML string into Document via the DocumentBuilder interface. I have been encountering a problem with CDATA (Having never seen it before). Basically, I need to access fields within the CDATA tag and change them. I load up a 'template' XML document (to reply to the messages with) and use values received in the first message inside the response. Some of the fields that need to be changed are in this CDATA tag (clear what I mean below). public static String getOutputMessage(String input) throws Exception{ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); Document inputDoc, outputDoc; Element messageElement = (Element)inputDoc.getElementsByTagName("TRANS").item(0); messageType = messageElement.getAttribute("name"); if (messageType.equals("processTransaction")){ outputDoc = db.parse(path+"processTransaction\\posPrintReceipt.xml"); outputDoc = changeContent(outputDoc, "PAN_NUMBER", transaction.getPan_number()); outputDoc = changeContent(outputDoc, "TOKEN", transaction.getToken()); outputDoc = changeContent(outputDoc, "TOTAL_AMOUNT", transaction.getTotal_amount()); outputDoc = changeContent(outputDoc, "TRANSACTION_TIME", transaction.getTransaction_time()); outputDoc = changeContent(outputDoc, "TRANSACTION_DATE", transaction.getTransaction_date()); } } private static Document changeContent(Document doc,String tag,String value) { System.out.println("Changing: ["+tag+" : "+value+"]"); NodeList nodes=doc.getElementsByTagName(tag); Node node = nodes.item(0); Node parent=node.getParentNode(); node.setTextContent(value); System.out.println(doc.getElementsByTagName(tag).item(0) + " " + node.getTextContent()); parent.replaceChild(node, doc.getElementsByTagName(tag).item(0)); return doc; } The functions above work on normal Elements but below is an example XML message I have to…
tagged with: cdata
possible better answer: http://stackoverflow.com/a/22152405
tagged with: parsing
tagged with: http://stackoverflow.com/tag/xml
has title: Parse CDATA from XML to enable editing Java
has answer: http://stackoverflow.com/a/22152312
accepted answer: http://stackoverflow.com/a/22152312
type: AnsweredQuestion
tagged with: java
type: Question
score: 0

http://stackoverflow.com/a/22078323
score: 2
has comment: http://stackoverflow.com/comment/33484164
answers question: http://stackoverflow.com/q/22078231
upvote count: 2
downvote count: 0
type: Answer
has body: Do it the other way around. Move the code back to your toss method and just call toss() from inside the constructor. import java.util.Random; public class Coin { // variable for a generic coin toss private String sideUp; // Constructor // ******************** Instructor notes... // This is the same code as your toss() method // It is OK to call that method from your constructor. // Don't copy/paste code or repeat yourself if not required. public Coin() { toss(); } //Void Method public final void toss() { Random rand1 = new Random(); int x = rand1.nextInt(2); if (x &gt; 0){ sideUp = "Heads"; }else{ sideUp = "Tails"; } } } As is pointed out in other comments and answers, calling methods that may be overriden from a constructor is a bad idea. Here's a good explanation for why that is: Why is it considered bad practice to call a method from within a constructor? You can make the method final as I did here to avoid the problems.

http://stackoverflow.com/a/22033974
has body: You can use Google's Gson library to convert json to Hashmap. Try below code String jsonString = "Your JSON string"; HashMap&lt;String,String&gt; map = new Gson().fromJson(jsonString, new TypeToken&lt;HashMap&lt;String, String&gt;&gt;(){}.getType());
upvote count: 59
answers question: http://stackoverflow.com/q/22011200
downvote count: 1
score: 58
type: Answer
has comment: http://stackoverflow.com/comment/113142057

http://stackoverflow.com/comment/33514005
score: 0
has text: Thanks for the detailed response, I assume if I wanted to implement this I'd have to download the stuff from github etc which I'll investigate, cheers!
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/22094531

http://stackoverflow.com/comment/33583265
score: 0
type: Comment
has text: Why wouldn't it be called multiple times? There's no conditional logic around it, so it will be called once in every call to `readMot`.
comment on: http://stackoverflow.com/a/22133012
type: AnswerComment

http://stackoverflow.com/a/22032518
answers question: http://stackoverflow.com/q/22032281
has body: I suggest you're doing it compeltely wrong. if there is only one condition to check, return a boolean. Otherwise: return a flag word whose various bits indicate the various possible errors if they are set, if you don't need to provide any information other than the failures themselves otherwise you should be throwing various kinds of exception.
has comment: http://stackoverflow.com/comment/33401719
score: 0
has comment: http://stackoverflow.com/comment/33401895
type: Answer
has comment: http://stackoverflow.com/comment/33402873

http://stackoverflow.com/comment/33387563
type: QuestionComment
has text: http://postimg.org/image /71ok93lin/ Sorry for the lousy painting (No spaces).
comment on: http://stackoverflow.com/q/22019393
score: 0
type: Comment

http://stackoverflow.com/comment/33378808
type: AnswerComment
type: Comment
has text: Probably this is true, yes... However, the notion in SO is to provide answers to the questions, which in turn need to be the correct ones. I am not sure whether he understands the fact regarding the abstract class. (and he probably wants/needs to create an object that extends Item). I see your point though
comment on: http://stackoverflow.com/a/22019769
score: 0

http://stackoverflow.com/a/58569610
type: Answer
has body: In addition to the solution posted by @Zeus, You only need to do minor change in following way. Composite PK public class OrTextPk implements Serializable{ public String userId; @Column(name="orderNo") public String orderNo' @Column(name="orderStatus") public String orderStatus; } Main entity class @Entity public class OrTest implements java.io.Serializable { @EmbeddedId private OrTextPk id; @OneToOne(fetch = FetchType.LAZY) // Note: it will help to map value of userId (UserInfo) to Pk object @MapsId("userId") @JoinColumn(name = "userId") private UserInfo user; //UserInfo is embedded class having userid . . . so on... } Now, on setting New/Persisted object of UserInfo(user), value of userId of UserInfo object will be assigned to userId of OrTextPk while persisting OrTest object.
score: 0
answers question: http://stackoverflow.com/q/22073871

http://stackoverflow.com/comment/33540071
comment on: http://stackoverflow.com/a/22106750
score: 0
type: Comment
has text: Look at these links and see if it helps you guys https://github.com/dropwizard/dropwizard/blob/19051ff1a80d7cdffa268d21f26a9e882ef7c82b/dropwizard-core/src/main/java/io/dropwizard/cli/ServerCommand.java https://github.com/dropwizard/dropwizard/blob/317f2e5cd4237fe5b94f5a525b0e3a3e4bc0667c/dropwizard-core/src/test/java/io/dropwizard/cli/ServerCommandTest.java
type: AnswerComment

http://stackoverflow.com/comment/33634829
comment on: http://stackoverflow.com/q/22162797
type: QuestionComment
has text: Add a semicolon on the end of `return ""`.
score: 3
type: Comment

http://stackoverflow.com/q/22045126
has comment: http://stackoverflow.com/comment/33424782
type: Question
upvote count: 4
tagged with: saxparser
answer count: 2
has comment: http://stackoverflow.com/comment/33424229
downvote count: 0
linked to: http://stackoverflow.com/q/22043592
score: 4
favorite count: 0
has comment: http://stackoverflow.com/comment/33425950
has comment: http://stackoverflow.com/comment/33424170
has comment: http://stackoverflow.com/comment/33425756
has answer: http://stackoverflow.com/a/22045372
tagged with: android
possible better answer: http://stackoverflow.com/a/22045618
tagged with: http://stackoverflow.com/tag/html
has answer: http://stackoverflow.com/a/22045618
has comment: http://stackoverflow.com/comment/33424909
has body: i'm trying to get body content of html page. suppose this html file: <?xml version="1.0" encoding="utf-8" standalone="no"?> text 1 text 2 what i want is : text 1 text 2 so, i thought that using SAXParser would do that (if you know simpler way please tell me) this is my code, but always i get null as body content: private final String HTML_NAME_SPACE = "http://www.w3.org/1999/xhtml"; private final String HTML_TAG = "html"; private final String BODY_TAG = "body"; public static void parseHTML(InputStream in, ContentHandler handler) throws IOException, SAXException, ParserConfigurationException { if(in != null) { try { SAXParserFactory parseFactory = SAXParserFactory.newInstance(); XMLReader reader = parseFactory.newSAXParser().getXMLReader(); reader.setContentHandler(handler); InputSource source = new InputSource(in); source.setEncoding("UTF-8"); reader.parse(source); } finally { in.close(); } } } public ContentHandler constrauctHTMLContentHandler() { RootElement root = new RootElement(HTML_NAME_SPACE, HTML_TAG); root.setStartElementListener(new StartElementListener() { @Override public void start(Attributes attributes) { String body = attributes.getValue(BODY_TAG); Log.d("html parser", "body: " + body); } }); return root.getContentHandler(); } then parseHTML(inputStream, constrauctHTMLContentHandler()); // inputStream is html file as stream what is wrong with this code?
has comment: http://stackoverflow.com/comment/33425509
has title: get body content of html file in java
has comment: http://stackoverflow.com/comment/33423912
has comment: http://stackoverflow.com/comment/33425183
has comment: http://stackoverflow.com/comment/33424008
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22045372
tagged with: java

http://stackoverflow.com/comment/33513395
type: AnswerComment
has text: @Sandy your src folder is not included in jar. Thus file not found. Keep the file which directory is available in jar or create a resourece dir and include this dir in jar.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22095096

http://stackoverflow.com/q/22166832
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/22394095
linked to: http://stackoverflow.com/q/5810869
favorite count: 0
type: UnansweredQuestion
score: 11
has answer: http://stackoverflow.com/a/22167034
upvote count: 11
linked to: http://stackoverflow.com/q/11020005
tagged with: java
type: Question
tagged with: jakarta-ee
tagged with: cancellation
tagged with: primefaces
has title: How to stop a java code from running using a stop button
has body: I have a button that calls a method from the backing Bean. This method allows to extract data from parsing html code. While the method is running i have a dialog showing a progress bar and a command button Cancel. I need when the user click the cancel button the method called by the extract button stops. This is my html code: <p:commandButton value="Start" style="width: 12%;height: 100%" update=":confirmPurchase, :confirmPurchaseTest, :mainform" id="extractbutton" ajax="true" widgetVar="ButtonExtract" actionListener="#{mailMB.searchEmails()}" icon="ui-icon-disk" styleClass="ui-priority-primary" onstart="blockUIWidget1.show();" oncomplete=" blockUIWidget1.hide();" /> <p:dialog widgetVar="blockUIWidget1" header="Hitonclick" modal="true" resizable="false" closable="false"> <p:graphicImage url="pictures/loading81.gif" width="200" height="200" alt="animated-loading-bar"/> <h:outputLabel value="Extracting is in progress. Please wait..."/> <p:commandButton value="Cancel" title="Cancel" /> </p:dialog> And here is my searchEmails method in my sessionScoped Bean public void searchEmails() throws Exception { idCustomer = (String) session.getAttribute("idCustomer"); System.out.println(idCustomer + " this is it"); Customer customer = customerBusinessLocal.findById(idCustomer); data = dataBusinessLocal.createData(new Date(), number, keyword, moteur, customer, State.REJECTED); mails = mailBusinessLocal.createEmails(keyword, number, moteur, data); System.out.println("Method was invoked"); } How can i stop the searchEmails method from running via the cancel command button?
linked to: http://stackoverflow.com/q/11158454

http://stackoverflow.com/q/22058779
has comment: http://stackoverflow.com/comment/33448860
has comment: http://stackoverflow.com/comment/33842131
has body: I'm trying to get my app to write text into a text file from an EditText and read from it into a TextView. It never updated the TextView earlier and now the app is crashing. Any advise would be very appreciated! public class MainActivity extends Activity implements OnClickListener { String file = Environment.getExternalStorageDirectory() + "/CSCI598.txt"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button rea = (Button) findViewById(R.id.reads1); rea.setOnClickListener(this); Button ap = (Button) findViewById(R.id.appends1); ap.setOnClickListener(this); } private void toast(String text) { Context context = getApplicationContext(); Toast toast = Toast.makeText(context, text, Toast.LENGTH_LONG); toast.show(); } @SuppressWarnings("resource") @Override public void onClick(View v) { TextView tv=(TextView)findViewById(R.id.textView1); EditText et=(EditText)findViewById(R.id.editText1); switch(v.getId()) { case R.id.reads1: try { FileInputStream fis = new FileInputStream(file); BufferedReader bfr = new BufferedReader(new InputStreamReader(fis)); String in; StringBuffer stringBuffer = new StringBuffer(); while ((in = bfr.readLine()) != null) { stringBuffer.append(in + "\n"); } tv.setText(stringBuffer.toString()); toast("File successfully loaded."); } catch (Exception ex) { toast("Error loading file: " + ex.getLocalizedMessage()); } break; case R.id.appends1: String txt=et.getText().toString(); try { FileWriter writer = new FileWriter(file); writer.write(txt); writer.flush(); writer.close(); toast("File successfully saved."); } catch (Exception ex) { toast("Error saving file: " + ex.getLocalizedMessage()); } break; } } }
has answer: http://stackoverflow.com/a/22058871
favorite count: 0
has comment: http://stackoverflow.com/comment/33448525
tagged with: android
accepted answer: http://stackoverflow.com/a/22058871
possible better answer: http://stackoverflow.com/a/22058865
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22058865
tagged with: java
tagged with: file
upvote count: 1
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33448435
score: 0
has title: Unable to read/write to file in android
answer count: 2
tagged with: file-io

http://stackoverflow.com/q/22135694
tagged with: junit
has title: How can I add an instance of test case into junit4 test suite without annotation/class
has body: I have some test casees declared following JUnit4 annotation @Test like below: public class SampleTest { @Test public void execute() { } } And I define a test suite declared like below: public class FacadeMockTestSuite extends TestSuite { public static Test suite() { TestSuite suite = new TestSuite("My Test"); // ... return suite; } } When I tried to add my test case into the suite, I found I can only use the class of the case, through either @SuiteClass or suite.addTest(new JUnit4TestAdapter(myTestClass)); But how can I directly insert a test case instance created by myself into the suite? Since I need to scan test case classes in my runtime and create them with non-default constructor?
favorite count: 0
answer count: 0
type: UnansweredQuestion
score: 2
tagged with: junit4
tagged with: java
type: Question
upvote count: 2
downvote count: 0

http://stackoverflow.com/comment/33511208
has text: I thought that interned strings are never GCed...
type: QuestionComment
comment on: http://stackoverflow.com/q/22094111
type: Comment
score: 1

http://stackoverflow.com/comment/33624008
type: AnswerComment
has text: I took care of the freezing by removing some things that are loading.
type: Comment
comment on: http://stackoverflow.com/a/22028242
score: 0

http://stackoverflow.com/comment/33637067
has text: let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/48920/discussion-between-bart-and-user3222718)
comment on: http://stackoverflow.com/q/22088141
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33542676
type: AnswerComment
comment on: http://stackoverflow.com/a/22110954
has text: Hmm 4.12.3 doesn't explain why you can only reference a local variable after it is declared and not through the whole block. But section 6.3 does: "The scope of a local class declaration immediately enclosed by a block (§14.2) is the **rest of the immediately enclosing block**, including its own class declaration."
type: Comment
score: 1

http://stackoverflow.com/q/22138273
downvote count: 2
upvote count: 1
has title: Java, How do I drop one single digit from a number (In order to perform a calculation on the rest of the number)?
has comment: http://stackoverflow.com/comment/33591255
type: Question
has body: I am trying to figure out part of a Java assignment and I am lost on what to do. If anyone can help or guide me in the right direction I would really appreciate it! The user has to enter a six digit "ticket number". I am trying to figure out how to drop the last digit of the number that the user input and place it into it's own variable. For instance: Ticket Number: 123456 How do I drop the "6" to make the number "12345" and put the 6 in its own variable? I tried using the \b to backspace the last digit after turning the input into a string, but that did not work. And I have realized that it would just delete the number anyway if it did work. Once the last digit is dropped we have to do calculations to get a remainder... I'm not worried about that, I have found that described in our book, I just can't figure out how to drop the digit and put it by itself. I am very new to Java (this is a Chapter 2 assignment) so please go easy on me! Thank you everyone for your help. I appreciate it! This is what I came up with and the code works: import javax.swing.JOptionPane; public class TicketNumber { public static void main(String[] args) { String ticketNumber; int Ticket, Remainder, lastDigit; ticketNumber = JOptionPane.showInputDialog(null, "Enter the six digit ticket number", "Verify Ticket", JOptionPane.INFORMATION_MESSAGE); Ticket = Integer.parseInt(ticketNumber) / 10; lastDigit = Integer.parseInt(ticketNumber) % 10; Remainder = Ticket % 7; boolean Valid = lastDigit == Remainder; JOptionPane.showMessageDialog(null, "Valid Ticket" + "\n" + Valid); } }
has answer: http://stackoverflow.com/a/22138405
has comment: http://stackoverflow.com/comment/33591070
score: -1
answer count: 3
favorite count: 0
has answer: http://stackoverflow.com/a/22138301
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22138361
tagged with: java

jsr223
tags question: http://stackoverflow.com/q/22033213
tag name: jsr223
type: Tag

http://stackoverflow.com/a/22051105
type: Answer
answers question: http://stackoverflow.com/q/22050848
has body: LSP says that every subclass must obey the same contracts as the superclass. Wether or not this is the case for Collections.unmodifiableXXX() thus depends on how this contract reads. The objects returned by Collections.unmodifiableXXX() throw an exception if one tries to call any modifying method upon them. For instance, if add() is called, an UnsupportedOperationException will be thrown. What is the general contract of add()? According to the API documentation it is: Ensures that this collection contains the specified element (optional operation). Returns true if this collection changed as a result of the call. (Returns false if this collection does not permit duplicates and already contains the specified element.) If this was the full contract, then indeed the unmodifiable variant could not be used in all places where a collection can be used. However, the specification continues and also says that: If a collection refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning false). This preserves the invariant that a collection always contains the specified element after this call returns. This explicitly allows an implementation to have code which does not add the argument of add to the collection but results in an exception. Of course this includes the obligation for the client of the collection that they take that (legal) possibility into account. Thus behavioural subtyping (or the LSP) is still fulfilled. But this shows that if one plans to have different behaviours in subclasses that must also be foreseen in the specification of the toplevel class. Good question, by the way.
has comment: http://stackoverflow.com/comment/33509504
has comment: http://stackoverflow.com/comment/42502250
upvote count: 47
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33435168
score: 47
accepted answer of: http://stackoverflow.com/q/22050848

http://stackoverflow.com/a/22095557
answers question: http://stackoverflow.com/q/22087568
type: AcceptedAnswer
has body: To begin with, you have wrong JPG magic number. It is not 4 bytes in length, only two and it is 0xffd8 (first half of your magic number). And If I understand what are you asking, then magic numbers are defined by their file type specification and they are supposed to be the same across any platform and at all times. Bluntly speaking, if you have different magic number, it is not the file you are looking for. There are some rare exceptions when the same file type have several magic numbers, but that's usually to be compatible with older/different standarts. Furthermore, if a file has correct magic number that doesn't necessarily mean that it is file of a correct type. Technically, your approach would "label" file with ONLY magic number as its data as a correct png/jpg image. Thus, checking magic number is first step (you can think it of as a somewhat "filetype hash value") in process of checking if file is valid png/jpg, but if the magic number check passes, you should continue on analyzing file structure and checking if the file contains meaningful file data according to its specification. You can easily find the specification (and actual links to official specifications) in wikipedia: http://en.wikipedia.org/wiki/Portable_Network_Graphics#Technical_details http://en.wikipedia.org/wiki/JPEG#Syntax_and_structure
type: Answer
score: 3
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22087568
upvote count: 3

http://stackoverflow.com/comment/33618764
score: 0
type: AnswerComment
has text: Oh I understand now; sorry I was confused as to what you were referring to.
type: Comment
comment on: http://stackoverflow.com/a/22153765

http://stackoverflow.com/q/22152334
tagged with: libavformat
has title: Windows advapi.dll referencing non existing dll
answer count: 0
has comment: http://stackoverflow.com/comment/33617956
type: UnansweredQuestion
tagged with: c++
tagged with: java
has comment: http://stackoverflow.com/comment/33617792
has comment: http://stackoverflow.com/comment/33618948
type: Question
tagged with: dll
tagged with: java-native-interface
has body: I am using Java JNI to load native dll module (64 bit JVM, 64 bit dll, Windows 8.1). Module is used to decode H.264 file into byte array using libavcodec, which is in precompiled shared dlls. When I played around in plain JNI (passing String to JNI and return byte[] back), I had no problem loading my DLL module. But when I added reference to avformat.dll, my dll won´t load causing unsatisfied link error: Can´t find dependant libraries. I scoped avformat using DependencyWalker. It depends on advapi.dll which depends on several dlls reporting as missing. On of them is API-MS-WIN-CORE-KERNEL32-PRIVATE-L1-1-1.DLL. This dll is really missing on my Win installation. So, now I am confused about 2 things: 1, Why does MS provided advapi.dll depend on dll which is not part of the system?. 2, When I previously tried using avformat library in form of standalone Win32 app (exe), DependencyWalker reported the same missing dlls, but it executed decoded frames without any problem. How is this possible if I am missing its dependency?
score: 0

http://stackoverflow.com/comment/33567392
type: Comment
comment on: http://stackoverflow.com/a/22124734
has text: **Cons:** It is long. It is ugly. It uses the logging facility built into Java, which is less than optimal. **Pros:** Simple one-liner. No added libraries. No configuration. Easy to copy-paste-edit. Log entries appear by default in NetBeans on-screen. **Tip:** For real work, one should use [SLF4J](http://www.slf4j.org/) and [LogBack](http://logback.qos.ch/).
score: 0
type: AnswerComment

http://stackoverflow.com/q/22034967
downvote count: 0
answer count: 1
tagged with: jar
has comment: http://stackoverflow.com/comment/33405804
favorite count: 0
has answer: http://stackoverflow.com/a/22035097
has body: I have this code: import java.net.URI; import java.util.List; import net.moraleboost.streamscraper.Stream; import net.moraleboost.streamscraper.Scraper; import net.moraleboost.streamscraper.scraper.IceCastScraper; public class Harvester { public static void main(String[] args) throws Exception { Scraper scraper = new IceCastScraper(); List&lt;Stream&gt; streams = scraper.scrape(new URI("http://host:port/")); for (Stream stream: streams) { System.out.println("Song Title: " + stream.getCurrentSong()); System.out.println("URI: " + stream.getUri()); } } } Where do I download JAR for import net.moraleboost.streamscraper.* to work? I can find source code for it but I gives me load of errors, can someone just provide me .jar so I could include in java build path library?
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
accepted answer: http://stackoverflow.com/a/22035097
type: Question
tagged with: libs
has title: streamscraper java lib eclipse
tagged with: eclipse

http://stackoverflow.com/q/22031634
linked to: http://stackoverflow.com/q/833469
accepted answer: http://stackoverflow.com/a/22031684
answer count: 1
downvote count: 0
favorite count: 0
tagged with: regex
has answer: http://stackoverflow.com/a/22031684
type: AnsweredQuestion
score: 1
has body: I would like to check URL Validation in JAVA with regular-expression. I found this comment and I tried to use it in my code as follow... private static final String PATTERN_URL = "/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&amp;=\+\$,\w]+@)?[A-Za-z0-9.-]+(:[0-9]+)?|(?:ww‌​w.|[-;:&amp;=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&amp;;%@.\w_]*)#?‌​(?:[\w]*))?)/"; ..... if (!urlString.matches(PATTERN_URL)) { System.err.println("Invalid URL"); return false; } But I got compile time exception for writing my PATTERN_URL variable. I have no idea how to format it and I am worried about will it become invalid regex if I have modified. Can anyone fix it for me without losing original ? Thanks for your helps.
tagged with: java
upvote count: 1
has title: Regular expression String for URL in JAVA
type: Question

http://stackoverflow.com/comment/33441231
has text: http://www.3dbrickpavingandnaturalstone.com/ http://www.320ranch.com/ http://a1carpetandtile.com/ http://www.adoberesort.com/ http://www.advancedlightandsound.com/ http://www.thealhonnaresort.com/ http://www.andersoncertified.com/ http://www.cabinsoftheblackhills.com/ http://www.banffcariboulodge.com/ http://www.rockymountainresort.com/ http://www.berrycreekcabins.com/ http://www.birchcliff.com/ http://www.blackbutteranch.com/ http://blueharborresort.com/ http://www.orcasislandboardwalk.com/ http://www.buffalocountyoutfitters.com/ Just a few
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22054663

http://stackoverflow.com/q/22097430
tagged with: java
has title: gradle 1.6 to 1.11 migration error
score: 0
has comment: http://stackoverflow.com/comment/33520926
answer count: 1
has answer: http://stackoverflow.com/a/22523184
tagged with: build.gradle
tagged with: testng
accepted answer: http://stackoverflow.com/a/22523184
type: AnsweredQuestion
tagged with: gradle
type: Question
has body: I have a functional test module that uses TestNG and has a gradle build script that works just fine in gradle 1.6, I was trying to bump up my gradle version to 1.11 and this module started throwing the following error. Could not find property 'projectDir' on org.gradle.api.tasks.testing.testng.TestNGOptions_Decorated@47537eb5. The error is on the following gradle task task adminTest(type: Test) { useTestNG() { systemProperties['browser'] = 'firefox' systemProperties['dbUrl'] = connectionString systemProperties['baseurl'] = "$baseurl" suites 'src/test/java/org/open/functional/testng-admin.xml' } options { listeners &lt;&lt; 'org.uncommons.reportng.HTMLReporter' listeners &lt;&lt; 'org.uncommons.reportng.JUnitXMLReporter' } workingDir = 'build/' } I couldn't find any indication if this is a known issue. Is there is any change I should make to the gradle script to make gradle 1.11 run my TestNG scripts?

http://stackoverflow.com/comment/33638180
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22142374
has text: Thank Gimby, I didn't know I had to use a framework to support @ManagedBean, I shall do it once I start off doing JSF, currently I wanted to do everything with using JSF, just JSPs only.
type: Comment

http://stackoverflow.com/comment/33633919
type: Comment
type: QuestionComment
has text: I know, I'm very new to programming and as you can tell not very good at it
score: 0
comment on: http://stackoverflow.com/q/22162275

http://stackoverflow.com/a/22142805
has comment: http://stackoverflow.com/comment/33603270
accepted answer of: http://stackoverflow.com/q/22141248
upvote count: 4
type: AcceptedAnswer
downvote count: 0
score: 4
answers question: http://stackoverflow.com/q/22141248
type: Answer
has comment: http://stackoverflow.com/comment/33599261
has body: A simplified variation of your example that incorporates this approach is shown below. Note several important points: While a JTable is not a spreadsheet, it is possible to update cells dynamically as an aid to understanding. Use a TableModelListener to update related view components. The TableModel should fire events for the least number of cells possible; fireTableDataChanged() is used for expedience on this small, fixed-size model. Always pack() the enclosing Window and make setVisible() last. Swing GUI objects should be constructed and manipulated only on the event dispatch thread. Use common coding conventions. Code, as tested: import java.awt.EventQueue; import javax.swing.*; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; public class Table1 { JFrame frame; JComboBox credit; String[] rowNames = { "Vasan Phalke", "Pansare", "Anil Kg", "Suresh", "Total Credit", ""}; String[] colNames = {"Name", "Qty", "Rate/ Kg", "Total Amt."}; JTable table; DefaultTableModel model; JScrollPane scrollPane; public Table1() { frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); credit = new JComboBox&lt;&gt;(rowNames); model = new DefaultTableModel(colNames, 6) { @Override public Class&lt;?&gt; getColumnClass(int columnIndex) { switch (columnIndex) { case 0: return String.class; case 1: return Integer.class; case 2: return Double.class; case 3: return Double.class; } return super.getColumnClass(columnIndex); } @Override public Object getValueAt(int row, int col) { if (col == 3 &amp; row == 5) { double sum = 0; for (int i = 0; i &lt; 5; i++) { sum += ((Double) getValueAt(i, 3)).doubleValue(); } return sum; } if (col == 3 &amp; row != 5) { Integer i = (Integer) getValueAt(row, 1); Double d = (Double) getValueAt(row, 2); if (i != null &amp;&amp; d != null) { return i * d; } else { return 0d; } } return super.getValueAt(row, col); } @Override public void setValueAt(Object aValue, int row, int col) { s…
has comment: http://stackoverflow.com/comment/33607292

http://stackoverflow.com/q/22088021
downvote count: 2
type: Question
has comment: http://stackoverflow.com/comment/33501184
has comment: http://stackoverflow.com/comment/33500873
upvote count: 0
score: -2
has answer: http://stackoverflow.com/a/22088149
linked to: http://stackoverflow.com/q/6867076
answer count: 2
linked to: http://stackoverflow.com/q/8501252
tagged with: nullpointerexception
has comment: http://stackoverflow.com/comment/33501276
has comment: http://stackoverflow.com/comment/33500688
favorite count: 0
tagged with: http://stackoverflow.com/tag/xml
has body: So I am just learning to write android apps, nothing specific yet but mainly toying around to see how they work. I tried to do something with tabs in the action bar, based off a tutorial I found, but I get a null pointer exception thrown before the app even launches. Here is the code: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager) findViewById(R.id.pager); actionBar = getActionBar(); mAdapter = new TabsPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(mAdapter); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); for(String tab_names : tabs) { actionBar.addTab(actionBar.newTab().setText(tab_names).setTabListener(this)); } viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } @Override public void onPageScrolled(int arg0,float arg1,int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.web_fragment, container, false); return rootView; } there are 2 other classes of the onCreateView with different layouts but are exactly the same otherwise. Here are the xml, the first is the main and the next for the fragment: &lt;android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent"/&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" android:background="#ff84…
has answer: http://stackoverflow.com/a/22088132
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/33501228
has title: Android Null pointer exception onCreate
has comment: http://stackoverflow.com/comment/33500791
tagged with: oncreate
tagged with: java

http://stackoverflow.com/q/22073431
answer count: 4
tagged with: android-asynctask
possible better answer: http://stackoverflow.com/a/22073679
has answer: http://stackoverflow.com/a/22073679
has answer: http://stackoverflow.com/a/22073568
type: AnsweredQuestion
has title: Is it possible to run the "AsyncTask" method inside another method "AsyncTask"?
tagged with: java
tagged with: http://stackoverflow.com/tag/json
accepted answer: http://stackoverflow.com/a/22073568
has answer: http://stackoverflow.com/a/22073721
has answer: http://stackoverflow.com/a/22073654
type: Question
has body: I have an activity that when started makes a call to a "json" for get data categories of songs, after that I make a call to the method "AsyncTask" for the list of songs that category from another "JSON "the problem is that when I start the activity, this is locked , after 2 seconds, the activity opens the layout and I can see the categories on the action bar and not because the songs are looking for in the background. main activity (onCreate): java.io.InputStream source = null; source = retrieveStream(UrlApi.URL_BASE + UrlApi.URL_STORE + _bundle.getString("_id") + UrlApi.CATEGORY_SONG); Log.i("URL - KARAOKE", UrlApi.URL_BASE + UrlApi.URL_STORE + _bundle.getString("_id") + UrlApi.CATEGORY_SONG); Reader reader = new InputStreamReader(source); Type happyCollection = new TypeToken&lt;Collection&lt;String&gt;&gt;() {}.getType(); _karaoke_category_response = new Gson().fromJson(reader, happyCollection); if(_karaoke_category_response.size() &lt; 1){ finish(); Toast.makeText(getApplicationContext(), "Local sin karaokes", Toast.LENGTH_SHORT).show(); }else{ Log.i("Category - response", _karaoke_category_response.toString()); _karaoke_category_adapter = new ArrayAdapter&lt;String&gt;(getSupportActionBar().getThemedContext(), R.layout.spinner_item,_karaoke_category_response); getSupportActionBar().setListNavigationCallbacks(_karaoke_category_adapter, this); } The follow code is of search the songs of that categori and set it class AsyncKaraoke extends AsyncTask&lt;Void, Void, Void&gt; { String category; public AsyncKaraoke(String category) { this.category = category; } protected void onPreExecute(){ super.onPreExecute(); setSupportProgressBarIndeterminateVisibility(true); } @Override protected Void doInBackground(Void... params) { java.io.InputStream source = null; try { source = retrieveStream(UrlApi.URL_BASE + UrlApi.URL_STORE + _bundle.getString("_id") + UrlApi.KARAOKE_URL + UrlApi.FILTER_CATEGORY + URLEncoder.encode(category, "UTF-8")); Log.i("URL - KARAOKE", UrlApi.URL_BAS…
score: 0
has comment: http://stackoverflow.com/comment/33473955
tagged with: android

http://stackoverflow.com/comment/33376120
score: 0
type: Comment
has text: @chrizstone: You are welcome. - You might also look into alternative solutions which are not direct translations of the Java code. For example, returning `NSData` as an Objective-C wrapper for the byte array.
comment on: http://stackoverflow.com/a/22018085
type: AnswerComment

http://stackoverflow.com/q/22059343
favorite count: 0
has comment: http://stackoverflow.com/comment/33449401
upvote count: 2
has comment: http://stackoverflow.com/comment/33449734
type: UnansweredQuestion
tagged with: android
tagged with: http://stackoverflow.com/tag/xml
has comment: http://stackoverflow.com/comment/33482737
tagged with: java
has comment: http://stackoverflow.com/comment/33449400
has title: Call function in string.xml
type: Question
has answer: http://stackoverflow.com/a/22059478
has body: I have created a method in a class and would like to know if it is possible to call said method in strings.xml like this: &lt;xml&gt; &lt;string name="title"&gt; getValue(Hello Word) &lt;/string&gt; &lt;xml&gt;
score: -2
linked to: http://stackoverflow.com/q/11184505
has answer: http://stackoverflow.com/a/22059432
has comment: http://stackoverflow.com/comment/33450469
answer count: 2
downvote count: 4

http://stackoverflow.com/q/22149006
downvote count: 3
tagged with: android
has comment: http://stackoverflow.com/comment/33609773
has comment: http://stackoverflow.com/comment/33610013
has comment: http://stackoverflow.com/comment/33609677
has comment: http://stackoverflow.com/comment/33609940
has comment: http://stackoverflow.com/comment/33609720
has comment: http://stackoverflow.com/comment/33609782
type: AnsweredQuestion
tagged with: oncreate
tagged with: java
has body: I have this for loop in my onCreateView for one of my fragments. for(int i = 0; i&lt;digitalIOModeSwitchArray.length;i++){ digitalIOModeSwitchArray[i].setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub } }); } Which produces the following logcat error: 03-03 08:08:50.236: E/AndroidRuntime(7350): FATAL EXCEPTION: main 03-03 08:08:50.236: E/AndroidRuntime(7350): java.lang.NullPointerException 03-03 08:08:50.236: E/AndroidRuntime(7350): at com.example.ioiorun.digitalFragment.onCreateView(digitalFragment.java:231) 03-03 08:08:50.236: E/AndroidRuntime(7350): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500) 03-03 08:08:50.236: E/AndroidRuntime(7350): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927) 03-03 08:08:50.236: E/AndroidRuntime(7350): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104) 03-03 08:08:50.236: E/AndroidRuntime(7350): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682) 03-03 08:08:50.236: E/AndroidRuntime(7350): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467) 03-03 08:08:50.236: E/AndroidRuntime(7350): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472) 03-03 08:08:50.236: E/AndroidRuntime(7350): at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141) 03-03 08:08:50.236: E/AndroidRuntime(7350): at android.support.v4.view.ViewPager.populate(ViewPager.java:1068) 03-03 08:08:50.236: E/AndroidRuntime(7350): at android.support.v4.view.ViewPager.populate(ViewPager.java:914) 03-03 08:08:50.236: E/AndroidRuntime(7350): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436) 03-03 08:08:50.236: E/AndroidRuntime(7350): at android.view.View.measure(View.java:15264) 03-03 08:08:50.236: E/Andro…
has comment: http://stackoverflow.com/comment/33609749
type: Question
tagged with: logcat
upvote count: 1
score: -2
has title: Unknown nullpointer error?
answer count: 1
has comment: http://stackoverflow.com/comment/33609931
favorite count: 0
tagged with: nullpointerexception
has answer: http://stackoverflow.com/a/22149877
accepted answer: http://stackoverflow.com/a/22149877

http://stackoverflow.com/a/22083179
type: Answer
has comment: http://stackoverflow.com/comment/33493329
has comment: http://stackoverflow.com/comment/33494198
answers question: http://stackoverflow.com/q/22083104
has comment: http://stackoverflow.com/comment/33493272
has body: If you want to reverse the mapping, then you can do something like this: //If still using Java 6 enter the generic types in the diamond Map&lt;Integer, List&lt;Character&gt;&gt; treeMap = new TreeMap&lt;&gt;(); for(Map.Entry&lt;Character, Integer&gt; entry : hashMap.entrySet()) { Integer value = entry.getValue(); if(treeMap.get(value) == null) { treeMap.put(value, new ArrayList&lt;Character&gt;()); } List&lt;Character&gt; arrayList = treeMap.get(value); arrayList.add(entry.getKey()); //You can convert the above into this if you want, as well: // treeMap.get(value).add(entry.getKey()); } Please let me know if this is what you are expecting.
type: AcceptedAnswer
score: 0
accepted answer of: http://stackoverflow.com/q/22083104

http://stackoverflow.com/comment/33427514
has text: Still no luck. Gives me a ton of unknown source errors. I tried the just Pictures version and also the bin version.
score: 0
comment on: http://stackoverflow.com/a/22046028
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33481571
comment on: http://stackoverflow.com/a/22075683
has text: You're trying to create a `HistogramPanel` but no such class exists in your code.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/a/22106127
has body: it works for me : String s="2/17/2014 11:55:00 PM"; String[] parts = s.split("[/ :]"); The output : for (String s: parts) System.out.println(s); ==> run: 2 17 2014 11 55 00 PM BUILD SUCCESSFUL (total time: 0 seconds)
answers question: http://stackoverflow.com/q/22105989
score: 0
type: Answer

http://stackoverflow.com/comment/33362627
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/22010898
type: Comment
has text: That is the default constructor, so when you declare it private you disallow user to use new Singleton()

http://stackoverflow.com/comment/33425000
score: 0
comment on: http://stackoverflow.com/q/22042973
type: Comment
type: QuestionComment
has text: Look at the response. What's the content?

http://stackoverflow.com/q/22080660
has answer: http://stackoverflow.com/a/22080784
has comment: http://stackoverflow.com/comment/33487750
has comment: http://stackoverflow.com/comment/33487793
accepted answer: http://stackoverflow.com/a/22080789
possible better answer: http://stackoverflow.com/a/22080784
has comment: http://stackoverflow.com/comment/33487785
tagged with: input
type: AnsweredQuestion
tagged with: java
type: Question
answer count: 2
linked to: http://stackoverflow.com/q/7935613
has answer: http://stackoverflow.com/a/22080789
has comment: http://stackoverflow.com/comment/33490126
has title: Entering commands into a arraylist
has body: So I have this assignment, and it says to create a arraylist using standard input, and constantly prompt the user for commands. Now, I understand how to add commands, WITHIN the code, but I dont understand how to take what the user puts in, and turn that into a command in the arraylist. Here's what I got so far: import java.util.*; import java.util.Scanner; public class assignment216{ public static void main (String args[]){ ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;(); Scanner s = new Scanner(System.in); Scanner n = new Scanner(System.in); System.out.println("Enter a command:"); String command = s.nextLine(); System.out.println("If you entered 'add', then enter a name:"); String input = n.nextLine(); } } EDIT New Code: import java.util.*; import java.util.Scanner; public class assignment216{ public static void main (String args[]){ ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;(); Scanner e = new Scanner(System.in); System.out.println("Enter command, or type 'quit' to exit"); String quit = e.next(); boolean exit = quit; if(exit = true){ System.exit(); } } }
tagged with: arraylist
score: 0

http://stackoverflow.com/comment/33794070
comment on: http://stackoverflow.com/a/22099525
score: 0
type: AnswerComment
type: Comment
has text: This should help you - http://androidhive.blogspot.co.uk/2013/05/fragment-activity-in-android-coding.html

http://stackoverflow.com/comment/33363666
type: Comment
comment on: http://stackoverflow.com/q/22005115
has text: Ref:http://blog.ngopal.com.np/2011/10/01/tableview-cell-modifiy-in-javafx/
score: 0
type: QuestionComment

http://stackoverflow.com/comment/33474522
type: AnswerComment
comment on: http://stackoverflow.com/a/22043375
score: 0
type: Comment
has text: Might take me a bit to figure this out. My IDE is giving me weird errors with this like: `Syntax error on token "(", ; expected Syntax error on token ")", ; expected` on `split2(String st)` Thanks for your reply, I will work on getting this implemented and see if this is the fix.

http://stackoverflow.com/q/22141236
has answer: http://stackoverflow.com/a/22141300
tagged with: java
tagged with: file
upvote count: 10
type: Question
score: 10
possible better answer: http://stackoverflow.com/a/22141301
has answer: http://stackoverflow.com/a/22141301
accepted answer: http://stackoverflow.com/a/22141300
answer count: 2
has title: Get path directory only and discard file in Java
downvote count: 0
favorite count: 0
has body: How do we actually discard last file from java string and just get the file path directory? Random Path input by user: C:/my folder/tree/apple.exe Desired output: C:/my folder/tree/ closest solution i found is from here . The answer from this forum only display last string acquired not the rest of it. I want to display the rest of the string.
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/9125241
linked to: http://stackoverflow.com/q/28594297

http://stackoverflow.com/q/22135813
has comment: http://stackoverflow.com/comment/33589742
has answer: http://stackoverflow.com/a/22135912
has title: Reading a Text File in Java-12
has body: Think about an text file like : line1 -&gt;5 line2 -&gt;A 10 line3 -&gt;B 15 line4 -&gt;C 25 line5 -&gt;D 5 line6 -&gt;E 30 '5' is the number of {a,b,c,d,e}. How can i hold these variables in two arrays like : Array1[5] = {A,B,C,D,E} Array2[5] = {10,15,25,5,30}
has comment: http://stackoverflow.com/comment/33587608
tagged with: java
type: Question
answer count: 2
score: 0
has answer: http://stackoverflow.com/a/22136048
has comment: http://stackoverflow.com/comment/33587589
accepted answer: http://stackoverflow.com/a/22136048
possible better answer: http://stackoverflow.com/a/22135912
type: AnsweredQuestion

http://stackoverflow.com/comment/33560833
score: 0
type: Comment
type: QuestionComment
has text: post the code for the servlet impl, without it it's difficult to tell you what are you missing.
comment on: http://stackoverflow.com/q/22121374

http://stackoverflow.com/a/22026036
answers question: http://stackoverflow.com/q/22025668
has body: When you pass a variable to a method it is copied. This means if you set that variable in the method it has no effect on the caller. i.e. it doesn't initialise the callers copy of the variable. You need to change your code to look like this. shetatch = z1[i].shetach(length); The variable shetatch inside the method has the same name. but otherwise nothing in common.
score: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22025668
type: Answer

http://stackoverflow.com/a/22056736
score: 0
has body: If it's possible, I might keep the timestamp as a Date in your database and use the locale when you want to display it. It will be more consistent and the dates will be easier to work with.
type: Answer
answers question: http://stackoverflow.com/q/22056056

http://stackoverflow.com/comment/33526635
type: Comment
comment on: http://stackoverflow.com/q/22102227
has text: Didnt seem to work either :(
score: 0
type: QuestionComment

http://stackoverflow.com/a/22091617
score: 1
has body: SOLVED IT MYSELF: internet permission was missing in manifest file Adding following to manifest file solved the problem &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
accepted answer of: http://stackoverflow.com/q/22078516
type: Answer
answers question: http://stackoverflow.com/q/22078516
upvote count: 1
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/22045779
has answer: http://stackoverflow.com/a/22067851
has body: I have recently upgraded Spring 2.5 to 3.2 and Hibernate 3 to 4.2.8 in a general upgrade of a web application. Most things are working now, but there is one Criteria transaction that is not working and has me puzzled. The new version returns no result (but no errors), while the old one retrieved properly the requested value. The code is the same one in the old and new versions, and I have verified that the argument that reaches it is the same. Here is the Java code: Criteria criteria = sessionFactory.getCurrentSession().createCriteria(ViewingResource.class); criteria.createCriteria("viewings","currentViewings"); criteria.add(Property.forName("currentViewings.id").eq(viewingId)); ViewingResource result = (ViewingResource)criteria.uniqueResult(); ViewingResource is my entity, which is defined as follows: @Entity @DiscriminatorValue("viewing") public class ViewingResource extends AbstractInformationResource { private static final long serialVersionUID = -4569093742552159052L; @OneToOne(targetEntity = Attribute.class, fetch = FetchType.LAZY) @JoinColumn private Attribute primaryAttribute; @OneToMany(targetEntity = Viewing.class, cascade = {CascadeType.PERSIST, CascadeType.MERGE}, orphanRemoval=true) @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE}) @JoinTable(name = "informationresource_viewings") @OrderBy("sort") private Set&lt;ResourceViewing&gt; viewings; public Set&lt;ResourceViewing&gt; getViewings() { return viewings; } public Attribute getPrimaryAttribute() { return primaryAttribute; } } As for the abstract class it extends: @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn( name = "type", discriminatorType = DiscriminatorType.STRING ) @Table(name = "informationresource") abstract public class AbstractInformationResource extends PersistentEntity&lt;String&gt; { private static final long serialVersionUID = 8709376067232042462L; @Id @GeneratedValue(generator="system-uuid") @GenericGenerator(name="system-uuid", strategy =…
type: AnsweredQuestion
has title: Hibernate upgrade from 3 to 4: Criteria transaction ceases to work
tagged with: java
tagged with: hibernate
type: Question
tagged with: criteria
score: 0
accepted answer: http://stackoverflow.com/a/22067851
tagged with: migration
answer count: 1

http://stackoverflow.com/a/22154813
type: Answer
has body: I was able to figure out both issues that I was having by this little bit of code. Again, thanks for all of your help! for (String line = bReader.readLine(); line != null; line = bReader.readLine()) { //Splitting the content of comma delimited file String data[] = line.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)"); //Iterating through the file and updating the table. statement = connect.prepareStatement(psQuery); for (int i =0; i &lt; data.length;i++) { temp = data[i]; temp = temp.replaceAll("\"", ""); statement.setString(i+1, temp); } statement.executeUpdate(); }
answers question: http://stackoverflow.com/q/22028487
score: 0
accepted answer of: http://stackoverflow.com/q/22028487
type: AcceptedAnswer

http://stackoverflow.com/q/22066691
tagged with: spring
possible better answer: http://stackoverflow.com/a/22067101
score: 2
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/3652090
has answer: http://stackoverflow.com/a/22067101
has answer: http://stackoverflow.com/a/59309414
tagged with: java
has answer: http://stackoverflow.com/a/22067572
linked to: http://stackoverflow.com/q/15818047
type: Question
has body: I have a servlet packaged in an ear file, and I cannot get it to resolve @Value annotated properties. The app is in two parts: a servlet packaged in a war file, which is then included by different applications packaged in an ear file. The application supplies the implementation of a class (ResourceManager) defined by an interface in the servlet, and also the property file containing the value of the property for the @Value annotated field. The war file contains: web.xml: ... extends MessageDispatcherServlet contextConfigLocation classpath:/spring-ws.xml classpath:/spring-app.xml spring-ws.xml: <context:annotation-config/> <context:property-placeholder location="classpath:/spring-ws.properties"/> The values in spring-ws.properties are referenced directly from spring-ws.xml, and all work fine. The servlet class contains: public class MyServlet extends MessageDispatcherServlet @Autowired private ResourceManager resourceManager; // original annotation - got this to work @Value("${app.name:}") private String appName; // added later - cannot get this to work The app.name is optional, hence the trailing ":". The ear file adds (packaged in a jar file in the ear lib directory): spring-app.xml: <context:property-placeholder location="classpath:/spring-app.properties"/> ... spring-app.properties: app.name=myApp My first problem was with the @Autowired annotation: not sure I ever got to the bottom of that correctly, but I managed to get it to work by adding this code to the servlet: @Override protected void initFrameworkServlet() throws ServletException { AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); bpp.setBeanFactory(getWebApplicationContext().getAutowireCapableBeanFactory()); bpp.processInjection(this); } This may not be the best way to fix this, but it was the first I found and it worked, so I used it and moved on. Then I added a @Value annotated field, and I can't find a way to make this work. The javadocs for AutowiredAnnotationBea…
linked to: http://stackoverflow.com/q/5275724
downvote count: 0
answer count: 3
accepted answer: http://stackoverflow.com/a/22067572
has title: How to resolve Spring @Value annotations in a web servlet?
favorite count: 0
upvote count: 2

http://stackoverflow.com/q/22052537
has answer: http://stackoverflow.com/a/22052731
score: 1
linked to: http://stackoverflow.com/q/12425835
linked to: http://stackoverflow.com/q/5635287
upvote count: 1
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22052731
tagged with: java
tagged with: hibernate
has body: Similar to this post, I have these (almost the same) classes: public class Project { @ManyToMany private Set&lt;Person&gt; resources; // get and set of resources } public class Person { } The difference is that my properties are private (using beans as entities). The question is: how would I create a query to return all projects of a determined person (in JPQL and/or using CriteriaQuery)? I found all these other similar questions, but none helped me, because all of them rely on the navigation from Project to Person (which doesn't exist querying from Person): JPQL ManyToMany select @ManyToMany JPA 2 complex query JPA 2.0 CriteriaQuery on tables in @ManyToMany relationship I wouldn't like to insert a property inside 'Person' just to be able to make the query, because it doesn't make sense in my model. Thanks!!
has title: JPA query with @ManyToMany relationship and no navigation
linked to: http://stackoverflow.com/q/13741096
linked to: http://stackoverflow.com/q/11892305
type: Question
tagged with: criteria
tagged with: jpa
answer count: 1
downvote count: 0
tagged with: jpql
favorite count: 0

http://stackoverflow.com/comment/33501176
type: QuestionComment
has text: You are getting correct output for what you are doing. You are getting _unexpected_ output for your assumptions.
score: 1
comment on: http://stackoverflow.com/q/22088319
type: Comment

http://stackoverflow.com/q/22097914
favorite count: 0
has comment: http://stackoverflow.com/comment/33517923
has comment: http://stackoverflow.com/comment/33517887
type: UnansweredQuestion
score: -3
has comment: http://stackoverflow.com/comment/33518041
has comment: http://stackoverflow.com/comment/33518137
upvote count: 1
has comment: http://stackoverflow.com/comment/33517863
linked to: http://stackoverflow.com/q/2149785
has body: long total = 0L; for(File f : files) { //how to add? } Here is my code. I wanna to get the size of directorys inside a directory. Does anyone have idea about how to do that?
has title: Java - Adding login in for loop
tagged with: java
has answer: http://stackoverflow.com/a/22098158
type: Question
has comment: http://stackoverflow.com/comment/33517895
has comment: http://stackoverflow.com/comment/33517878
downvote count: 4
answer count: 1
duplicate of: http://stackoverflow.com/q/2149785

http://stackoverflow.com/q/22043430
answer count: 1
tagged with: opencv
tagged with: java
has answer: http://stackoverflow.com/a/22046021
has title: I got CvException by bitmapToMat on android
has body: I'm using opencv for android. but I got same messages from released android app. that is CvException [org.opencv.core.CvException: /home/reports/ci/slave_desktop/50-SDK/opencv/modules /java/generator/src/cpp/utils.cpp:33: error: (-215) info.format == ANDROID_BITMAP_FORMAT_RGBA_8888 || info.format == ANDROID_BITMAP_FORMAT_RGB_565 in function void Java_org_opencv_android_Utils_nBitmapToMat2(JNIEnv*, jclass, jobject, jlong, jboolean)] at org.opencv.android.Utils.nBitmapToMat2(Native Method) at org.opencv.android.Utils.bitmapToMat(Utils.java:93) at org.opencv.android.Utils.bitmapToMat(Utils.java:102) I don't know What is wrong and How to fix it. Let me know please.
type: UnansweredQuestion
type: Question
tagged with: android
score: 0

http://stackoverflow.com/comment/33626673
comment on: http://stackoverflow.com/a/22156641
type: Comment
has text: @Philipp Weird, I always thought Java has nothing to do with binary code specific to the CPU it runs on. Always thought it runs entirely on a virtual machine. So that means that this isn't entirely true? Is the code that the interpretation generates, pure physical-machine-specific binary code, which gets run by the physical computer itself, like when compiling C++ code? (Just want to make sure).
score: 0
type: AnswerComment

http://stackoverflow.com/q/22017119
type: Question
tagged with: debugging
downvote count: 0
has body: I want to get the LDAP connect ssl handshake debug info ,so I set the system property "javax.net.debug" value "ssl,handshake" like this : System.property("javax.net.debug" , "ssl,handshake"); but I didn't get the ssl debug info.In my project,using log4j.xml to control the debug info, so I want to know how to configure log4j.xml to get the debug info of "javax.net.debug"? Thanks for your help!
tagged with: log4j
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/47519955
score: 6
upvote count: 6
answer count: 4
has title: how to configure log4j.xml to get the debug info of "javax.net.debug"
has answer: http://stackoverflow.com/a/50506986
tagged with: java
has answer: http://stackoverflow.com/a/22017983
has answer: http://stackoverflow.com/a/22017554

http://stackoverflow.com/comment/33382722
has text: "It depends". Insufficient information to decide. I would not recommend a blanket answer. I'm not trying to design your system.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22021732

http://stackoverflow.com/comment/33497661
comment on: http://stackoverflow.com/q/22086128
type: Comment
type: QuestionComment
has text: The case is solved. :D Please choose answer now haha.
score: 1

http://stackoverflow.com/comment/33425199
comment on: http://stackoverflow.com/q/22045664
type: Comment
type: QuestionComment
score: 1
has text: what are you trying to achieve? You're in a servlet but you're not doing anything with the request or response objects...

http://stackoverflow.com/comment/33465928
score: 0
has text: Paste the complete stack trace of the exception. It matters.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22068871

http://stackoverflow.com/q/22145213
tagged with: java
has body: I want to connect to google datastore from normal java application not GAE app, then create entity, put/get properties and build GQL query. Is this possible?? I found APIs but I don't find any sample code explains how I can connect and make the authorization to the datastore. Is it similar to this for GCS?? Thank you,
tagged with: google-cloud-datastore
downvote count: 0
type: UnansweredQuestion
has title: Connecting to google datastore from java application
score: 2
tagged with: api
favorite count: 0
type: Question
upvote count: 2
tagged with: google-app-engine
has answer: http://stackoverflow.com/a/22155658
answer count: 1

http://stackoverflow.com/q/22048662
has comment: http://stackoverflow.com/comment/34407244
downvote count: 1
type: Question
tagged with: code-conversion
upvote count: 4
answer count: 1
favorite count: 0
tagged with: combinatorics
type: UnansweredQuestion
has body: I am trying to convert the following partition generator from Python into Java and not getting the expected result: Python: def accelAsc(n): a = [0 for i in range(n + 1)] k = 1 a[0] = 0 y = n - 1 while k != 0: x = a[k - 1] + 1 k -= 1 while 2*x &lt;= y: a[k] = x y -= x k += 1 l = k + 1 while x &lt;= y: a[k] = x a[l] = y yield a[:k + 2] x += 1 y -= 1 a[k] = x + y y = x + y - 1 yield a[:k + 1] My Java: public static void partition( int n ){ int[] a = new int[ n + 1 ]; int k = 1; int y = n - 1; while( k != 0 ){ int x = a[k - 1] + 1; k -= 1; while( 2*x &lt;= y ){ a[k] = x; y -= x; k += 1; } int l = k + 1; while( x &lt;= y ){ a[k] = x; a[l] = y; for( int xValue = 0; xValue &lt;= k; xValue++ ) System.out.print( a[xValue + 2] ); System.out.println(); x += 1; y -= 1; } a[k] = x + y; y = x + y - 1; for( int xValue = 0; xValue &lt;= k; xValue++ ) System.out.print( a[xValue + 1] ); System.out.println(); } } Calling this with an argument of 5 results in the following printout: 1110 1121 132 22 42 2 3 which is incorrect.
tagged with: python
has comment: http://stackoverflow.com/comment/33431134
score: 3
has title: Convert Python partition generator to Java
tagged with: java
has answer: http://stackoverflow.com/a/28770861

http://stackoverflow.com/a/22167153
has comment: http://stackoverflow.com/comment/33642570
has comment: http://stackoverflow.com/comment/33642341
has body: String[] array = "Are you crazy".split(" "); for (int i = array.length - 1; i &gt;= 0; --i) { System.out.print(array[i] + " "); }
has comment: http://stackoverflow.com/comment/33642449
type: Answer
has comment: http://stackoverflow.com/comment/33642695
has comment: http://stackoverflow.com/comment/33642471
has comment: http://stackoverflow.com/comment/33642532
has comment: http://stackoverflow.com/comment/33642331
has comment: http://stackoverflow.com/comment/33642491
has comment: http://stackoverflow.com/comment/33642416
has comment: http://stackoverflow.com/comment/33642427
score: 0
answers question: http://stackoverflow.com/q/22167068

http://stackoverflow.com/comment/33499228
type: QuestionComment
comment on: http://stackoverflow.com/q/22086976
has text: possible duplicate of [if else loop inside a for loop?](http://stackoverflow.com/questions/10147690/if-else-loop-inside-a-for-loop)
score: 0
type: Comment

http://stackoverflow.com/comment/34679542
comment on: http://stackoverflow.com/a/22022473
has text: It is included in my path
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/22101772
has body: synchronized acquisition follows a non-fair lock policy. That is, threads that enter first while blocking may not be the first to acquire. If you want a fair lock use a new ReentrantLock(true)
answers question: http://stackoverflow.com/q/22101371
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22101371
type: Answer
has comment: http://stackoverflow.com/comment/33526079
score: 2
upvote count: 2

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

http://stackoverflow.com/a/44530876
answers question: http://stackoverflow.com/q/22015660
score: 14
has body: Try this library internally using Apache POI for converting from excel to POJO.: Poji
downvote count: 0
has comment: http://stackoverflow.com/comment/129922921
type: Answer
upvote count: 14

http://stackoverflow.com/a/77993962
answers question: http://stackoverflow.com/q/22150527
has body: In IntelliJ Reformat a code fragment﻿ In the editor, select a code fragment you want to reformat. If you don't select a code fragment, IntelliJ IDEA will reformat the whole file. Before reformatting, you can take a look at the code style settings that are applied to the selected code: press AltEnter and click Adjust code style settings. In the main menu, go to Code | Reformat Code or press CtrlAlt 0L .
score: 0
type: Answer

http://stackoverflow.com/q/22088826
has body: My code is here. I'm using code by Dr. Andrew Davison private IplImage picGrab(FrameGrabber grabber, int ID) { IplImage im = null; try { FrameRecorder rec = FrameRecorder.createDefault("vid.avi", 240, 360); rec.setVideoCodec(CV_FOURCC('M', 'J', 'P', 'G')); rec.setVideoBitrate(16); rec.setFrameRate(25); rec.setFormat("avi"); rec.setPixelFormat(1); rec.start(); im = grabber.grab(); // take a snap // cvSaveImage("capture"+captureNo+".jpg", im); rec.record(im); } catch (Exception e) { e.printStackTrace(); System.out.println("Problem grabbing image for camera " + ID); } return im; } And follow exception is occurred. com.googlecode.javacv.FrameRecorder$Exception: cvWriteFrame(): Could not record frame Problem grabbing image for camera 0 Initializing OpenCV motion detector... at com.googlecode.javacv.OpenCVFrameRecorder.record(OpenCVFrameRecorder.java:91) at photocapture.MotionPanel.picGrab(MotionPanel.java:181) at photocapture.MotionPanel.run(MotionPanel.java:100) at java.lang.Thread.run(Thread.java:744)
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/27651471
has title: How record video using javaCV
tagged with: opencv
tagged with: java
has answer: http://stackoverflow.com/a/27651734
type: Question
score: 0
answer count: 2
tagged with: javacv
has comment: http://stackoverflow.com/comment/33501983

http://stackoverflow.com/comment/33531188
has text: @Asanka have you set `knownWord = "school";` and `replaceWord = "shop";` before?
score: 0
comment on: http://stackoverflow.com/a/22103239
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/33357265
has text: Well, the purpose of a `Map` is to access entries by key, not value. Some libraries (Guava for instance) do have bidirectional maps, but removing a key given a value is not a `Map`'s "simple operation" ;)
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22007246

http://stackoverflow.com/comment/33573540
score: 0
has text: #Marko Topolnik Thank you for your comment. Maybe it would be good to alter my connection class by "implements InterruptibleChannel". Still I discovered there is a different bug in my code: it was a bad idea to start one Thread from another because then they do not work independent of each other.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22126862

http://stackoverflow.com/q/22147414
downvote count: 0
has title: getting negative length value of bytearray
favorite count: 0
has answer: http://stackoverflow.com/a/22147766
type: UnansweredQuestion
tagged with: android
score: 1
tagged with: java
upvote count: 1
has body: soc = new Socket(ip, port1); while (true) { DataInputStream dis = new DataInputStream(soc.getInputStream()); int len = dis.readInt(); Log.d("===============" + len, "-------------------" + len); byte data[] = null; data = new byte[len]; dis.readFully(data); Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, len); ImageView image = (ImageView) findViewById(R.id.imageView1); image.setImageBitmap(bmp); } This is my android code which takes the byte array from server and it display in Image.I am getting negative value of length of byte array and so app gets stopped. The above code working properly in PC. and also tell me whether I am doing right method for displaying image to screen in android. Logcat field: 03-03 12:50:27.941: E/AndroidRuntime(7283): FATAL EXCEPTION: Thread-205 03-03 12:50:27.941: E/AndroidRuntime(7283): java.lang.NegativeArraySizeException: -1393754107 03-03 12:50:27.941: E/AndroidRuntime(7283): at com.example.vnc.Screen$1.run(Screen.java:47) 03-03 12:50:27.941: E/AndroidRuntime(7283): at java.lang.Thread.run(Thread.java:856) Server Side: while(continueLoop){ try{ BufferedImage image = robot.createScreenCapture(rectangle); byte[] imageInByte; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(image,"jpg", baos); baos.flush(); imageInByte = baos.toByteArray(); baos.close(); DataOutputStream dos = new DataOutputStream(socket.getOutputStream()); dos.writeInt(imageInByte.length); System.out.println(imageInByte.length); dos.write(imageInByte); Thread.sleep(1000); dos.flush(); } catch(Exception e) {} try{ Thread.sleep(100); }catch(InterruptedException e){ e.printStackTrace(); } }
type: Question
has answer: http://stackoverflow.com/a/22147535
answer count: 2

http://stackoverflow.com/comment/33531430
comment on: http://stackoverflow.com/a/22103239
score: 0
type: Comment
has text: @Asanka no problem. Regex are a bit confusing at the beginning, but once you know how to use them well you cannot live without them anymore ;-)
type: AnswerComment

http://stackoverflow.com/a/29476832
downvote count: 0
has body: You can use the following command to run in 64 bit jre insted of renaming JRE dirs located under "HP_Fortify/HP_Fortify_SCA_and_Apps_3.70" sourceanalyzer -64 -Xmx8G -b code -scan -f results.fpr or you can you the following gradle task running ant task inside gradle task How to run HP fortify scan using gradle or Running Fortify from Gradle build on Jenkins ( By default fortify runs in 32 bit mode which limits the java heap to 1200-1600 MB on windows and 3GB on modern linux machine and it uses jre directory to run 32 bit mode, if you want to run in 64 bit mode then you should pass sourceanalyzer -64 -Xmx8G option instead of changing jre name manually to switch run mode from 32 bit to 64 bit java)
type: Answer
upvote count: 1
accepted answer of: http://stackoverflow.com/q/22027216
score: 1
answers question: http://stackoverflow.com/q/22027216
type: AcceptedAnswer

http://stackoverflow.com/a/22035036
answers question: http://stackoverflow.com/q/22034854
type: Answer
upvote count: 2
score: 2
downvote count: 0
has body: If you want two activity in a single calss use Fragments. Fragments are mini activity in Android. They combine two or more than two activity in a single activity class see following link for more detail http://developer.android.com/guide/components/fragments.html

http://stackoverflow.com/comment/33536216
type: QuestionComment
score: 0
has text: This is just how you declare character constants in Java ;) (and think about `'\n'`: two "characters" to write, but that is a single `char`)
type: Comment
comment on: http://stackoverflow.com/q/22107417

http://stackoverflow.com/comment/86258846
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/49624451
type: Comment
has text: Please format your code with the {} button. Your answer will benefit from an explanation, what your code does. Please read [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer)

http://stackoverflow.com/comment/33634920
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22162814
score: 0
has text: It might seem minor, but I would also recommend removing the comments in your code. They're not providing any useful information and are, therefore, just noise.

http://stackoverflow.com/comment/33370752
has text: This makes the receiver unable to start with a NullPointerException
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22015398
type: AnswerComment

http://stackoverflow.com/comment/33642364
type: Comment
type: QuestionComment
has text: yes enigneer..error in code only
score: 0
comment on: http://stackoverflow.com/q/22166774

http://stackoverflow.com/q/22027984
has comment: http://stackoverflow.com/comment/33394007
has answer: http://stackoverflow.com/a/22028179
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33394062
has comment: http://stackoverflow.com/comment/33393982
has comment: http://stackoverflow.com/comment/33393886
has comment: http://stackoverflow.com/comment/33394200
has comment: http://stackoverflow.com/comment/33394060
has answer: http://stackoverflow.com/a/22028073
tagged with: java
has answer: http://stackoverflow.com/a/22028127
has answer: http://stackoverflow.com/a/22028070
has title: using an array and array lists
has comment: http://stackoverflow.com/comment/33394035
has answer: http://stackoverflow.com/a/22028042
type: Question
has answer: http://stackoverflow.com/a/22028056
tagged with: arrays
answer count: 6
has body: My project is to create a program that does this: The array of type double called grades has been initialized with the test scores for a class. The course instructor would like the highest score, the lowest score, and the mean value of all the grades. I'm getting the following errors when I compile the following code: File: C:\Users\Guest\Downloads\grades.java [line: 16] Error: Type mismatch: cannot convert from double to int File: C:\Users\Guest\Downloads\grades.java [line: 23] Error: grades cannot be resolved to a variable File: C:\Users\Guest\Downloads\grades.java [line: 23] Error: Type mismatch: cannot convert from double to int import java.util.Scanner; public class grades { // global variable declaration static Scanner cin = new Scanner(System.in); static final double NUM_GRADES = 5; public static void main(String[] args) { // declare variables double highestGrade = -999999; double lowestGrade = 999999; double sumOfGrades = 0; double avgGrades = 0; double[] scores = new double[NUM_GRADES]; // array is initialized using a final variable // use a for loop to obtain data from user using the final variable for(double index=0; index &lt; NUM_GRADES; ++index) { // this puts data into the current array index grades[index] = cin.nextDouble(); // this calculates a running total of all the scores sumOfGrades += grades[index]; // if current score in the array index is bigger than the current 'highestScore' // value, then set 'highestScore' equal to the current value in the array if(grades[index] &gt; highestGrade) { highestGrade = grade[index]; } // if current score in the array index is smaller than the current 'lowestScore' // value, then set 'lowestScore' equal to the current value in the array if(lowestGrade &gt; grades[index]) { lowestGrade = grades[index]; } } { System.out.print("\nThe grade for student #"+(index+1)+" is: "+grades[index]); } // display the highest/lowest numbers to the screen System.out.print("\n\nThese are the highest and lowest grades: "); System…
has comment: http://stackoverflow.com/comment/33394268
score: 0

http://stackoverflow.com/q/22014671
accepted answer: http://stackoverflow.com/a/22047084
downvote count: 0
tagged with: maven-3
favorite count: 0
tagged with: maven
tagged with: war
upvote count: 6
answer count: 4
has body: I'm trying to test the overlay functionality of the maven-war-plugin. Basically I need to merge two war projects. So I defined a war as dependency: my.group.id my-legacy-war-project ${project.version} war And then configured the overlay: org.apache.maven.plugins maven-war-plugin my.group.id my-legacy-war-project legacy But Maven fails to build this project, complaining about this dependency: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.3:exploded (default) on project my-project: overlay [ id my.group.id:my-legacy-war-project] is not a dependency of the project. -> [Help 1] The overlay is supposed to work with Maven 3.0.5? Why the build is complaining about a dependency that's declared?
type: AnsweredQuestion
has title: Maven 3: Overlay is not a dependency of the project
tagged with: java
score: 6
has answer: http://stackoverflow.com/a/22047084
type: Question
has answer: http://stackoverflow.com/a/33913257
has answer: http://stackoverflow.com/a/58210491
has answer: http://stackoverflow.com/a/49563468
linked to: http://stackoverflow.com/q/12298178
possible better answer: http://stackoverflow.com/a/49563468

http://stackoverflow.com/comment/33406206
type: Comment
type: QuestionComment
score: 2
has text: what on earth is `char``[][] picture = buildHouse();`
comment on: http://stackoverflow.com/q/22035291

http://stackoverflow.com/comment/33578231
score: 0
type: Comment
has text: there are plenty methods to doit which one do you use?
type: QuestionComment
comment on: http://stackoverflow.com/q/22130701

http://stackoverflow.com/q/22133900
has body: I'm creating a very simple pebble app. Goal: When I click on my Android app, for the Pebble app to display the message I'm sending from my Android app. Issue: Text does not change/display on the pebble. Code Pebble .c code: #include "pebble_os.h" #include "pebble_app.h" #include "pebble_fonts.h" #define MY_UUID { 0x98, 0x15, 0xA8, 0xDA, 0x6C, 0xAC, 0x40, 0xB0, 0xAD, 0x87, 0xFC, 0xDF, 0x9E, 0x86, 0x3E, 0x91 } PBL_APP_INFO(MY_UUID, "Phone App", "Me", 1, 0, /* App version */ DEFAULT_MENU_ICON, APP_INFO_STANDARD_APP); Window window; TextLayer hello_layer; AppMessageCallbacksNode messageCallBacks; void myMessageHandler(DictionaryIterator* received, void* context) { vibes_short_pulse(); Tuple* tuple = dict_find(received, 0); text_layer_set_text(&amp;hello_layer, tuple-&gt;value-&gt;cstring); } void handle_init(AppContextRef ctx) { messageCallBacks = (AppMessageCallbacksNode) { .callbacks = { .in_received = myMessageHandler }, .context = NULL }; window_init(&amp;window, "Window Name"); window_stack_push(&amp;window, true /* Animated */); text_layer_init(&amp;hello_layer, GRect(0, 65, 144, 30)); text_layer_set_text(&amp;hello_layer, "Hello World!"); layer_add_child(window_get_root_layer(&amp;window), (Layer*)&amp;hello_layer); } void pbl_main(void *params) { PebbleAppHandlers handlers = { .init_handler = &amp;handle_init, .messaging_info = { .buffer_sizes = { .inbound = 64, .outbound = 64 } } }; app_event_loop(params, &amp;handlers); } Android Code: public class MainActivity extends Activity { private Button send; private Context context; UUID AppId = UUID .fromString("9815A8DA-6CAC-40B0-AD87-FCDF9E863E91"); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); send = (Button) findViewById(R.id.send); context = this; send.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new Thread(new Runnable() { @Override public void run() { PebbleDictionary data = n…
tagged with: pebble-sdk
tagged with: http://stackoverflow.com/tag/c
has answer: http://stackoverflow.com/a/22162266
score: 0
answer count: 1
has title: Pebble app not receiving String from phone
tagged with: android
accepted answer: http://stackoverflow.com/a/22162266
type: AnsweredQuestion
tagged with: java
tagged with: pebble-watch
type: Question

http://stackoverflow.com/comment/33465253
has text: Are other solutions more readable? The problem to solve is pretty particular...you can go newline if you don't want a line too long
score: 0
comment on: http://stackoverflow.com/a/22068573
type: Comment
type: AnswerComment

http://stackoverflow.com/a/22028242
answers question: http://stackoverflow.com/q/22027763
accepted answer of: http://stackoverflow.com/q/22027763
has comment: http://stackoverflow.com/comment/37419760
has comment: http://stackoverflow.com/comment/33394514
type: AcceptedAnswer
score: 0
type: Answer
has body: In a game you cant spend more 33ms (high performance games are in 16ms) drawing and updating the game It give you a minimun of 30 fps (frames per secon). it is well-know that in a game to draw spend more time then update. if you are drawing a lot of sprites and big surfaces, you frame rate will be bellow of 25 frames per second, and you game will look slow. you can find the nice explanation here too. https://www.youtube.com/watch?v=zVK6TKSx1lU
has comment: http://stackoverflow.com/comment/33624008
has comment: http://stackoverflow.com/comment/33445859

http://stackoverflow.com/a/22163680
type: AcceptedAnswer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33636274
has comment: http://stackoverflow.com/comment/33636395
has body: Well, instea of adding the restriction to the Criteria (which creates an AND), you must add it to the quotedLikeRestrictions disjunction: quotedLikeRestrictions.add(Restrictions.ilike("order.name", token, MatchMode.ANYWHERE));
has comment: http://stackoverflow.com/comment/33638324
has comment: http://stackoverflow.com/comment/33636819
type: Answer
has comment: http://stackoverflow.com/comment/33636558
accepted answer of: http://stackoverflow.com/q/22163158
has comment: http://stackoverflow.com/comment/33637401
answers question: http://stackoverflow.com/q/22163158
upvote count: 1
has comment: http://stackoverflow.com/comment/33636666
has comment: http://stackoverflow.com/comment/33636452
has comment: http://stackoverflow.com/comment/33636309
has comment: http://stackoverflow.com/comment/33636981

http://stackoverflow.com/a/22329026
has body: Try going with at least 2.2.2 with GlassFish 4. Prior 2.2.x Mojarra releases have well known compatibility issues with the new http://xmlns.jcp.org/jsf/ JSF namespaces. See also: f:viewParam doesn&#39;t pass required parameter when new xmlns.jcp.org namespace is used
has comment: http://stackoverflow.com/comment/33934195
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/22018409
answers question: http://stackoverflow.com/q/22018409
upvote count: 3
score: 3

http://stackoverflow.com/a/22082273
has body: This should also help incase you want to use the bufferedReader public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in)); for(int i = 0; i&lt;10; i++){ int inp = Integer.parseInt(stdin.readLine()); System.out.println("----------- "+inp); }
score: 0
answers question: http://stackoverflow.com/q/22081817
type: Answer

http://stackoverflow.com/comment/33517153
type: QuestionComment
comment on: http://stackoverflow.com/q/22097466
type: Comment
has text: Finally block is supposed to do ending things like cleanup tasks. It should not do other things than that. if you remove the continue statement it won't show the warning.
score: 0

http://stackoverflow.com/q/22033785
has answer: http://stackoverflow.com/a/22033887
type: Question
upvote count: 1
has comment: http://stackoverflow.com/comment/33403631
accepted answer: http://stackoverflow.com/a/22034043
has title: java string replace and memory
tagged with: java
has comment: http://stackoverflow.com/comment/33447538
linked to: http://stackoverflow.com/q/10827872
has answer: http://stackoverflow.com/a/22034315
possible better answer: http://stackoverflow.com/a/22033875
downvote count: 0
answer count: 5
has answer: http://stackoverflow.com/a/22033875
has comment: http://stackoverflow.com/comment/33403663
has answer: http://stackoverflow.com/a/22033963
type: AnsweredQuestion
has body: If I have a Java code segment such as: String description = someFunctionCall(); anotherFunction( description.replace(",", " " ).replace( ".", " " ) ); How many strings get created to be garbage collected later on and how can I make multiple replaces more efficient?
score: 1
tagged with: string
has comment: http://stackoverflow.com/comment/33403632
favorite count: 0
has answer: http://stackoverflow.com/a/22034043

http://stackoverflow.com/a/22116684
has comment: http://stackoverflow.com/comment/33552728
upvote count: 9
has comment: http://stackoverflow.com/comment/33552530
score: 9
downvote count: 0
has comment: http://stackoverflow.com/comment/33554841
type: Answer
answers question: http://stackoverflow.com/q/22116587
has comment: http://stackoverflow.com/comment/33552771
has body: First convert ImagePath to Bitmap Bitmap src=BitmapFactory.decodeFile(imagePath); Convert bitmap into byte array using this code: ByteArrayOutputStream baos = new ByteArrayOutputStream(); src.compress(Bitmap.CompressFormat.PNG, 100, baos); data = baos.toByteArray(); After your question in comment To show byte array into imageview use these lines of code: Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapdata , 0, bitmapdata .length); imageView.setImageBitmap(bitmap); To show imagePath into imageView you can use Bitmap src=BitmapFactory.decodeFile(imagePath); imageView.setImageBitmap(bitmap);

http://stackoverflow.com/q/22141072
has comment: http://stackoverflow.com/comment/33607638
has comment: http://stackoverflow.com/comment/33604407
has comment: http://stackoverflow.com/comment/33598415
has comment: http://stackoverflow.com/comment/33635260
tagged with: antlr
has comment: http://stackoverflow.com/comment/33705758
has comment: http://stackoverflow.com/comment/33612806
has comment: http://stackoverflow.com/comment/33613067
has comment: http://stackoverflow.com/comment/33613636
has comment: http://stackoverflow.com/comment/33615278
has comment: http://stackoverflow.com/comment/33611001
has comment: http://stackoverflow.com/comment/33596168
has comment: http://stackoverflow.com/comment/33595938
type: UnansweredQuestion
has body: how to modify an AST node and add a new node? I am using Java for this. Please help.
has title: How to modify tect of AST node in java?
has comment: http://stackoverflow.com/comment/33599513
answer count: 0
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/33599777
type: Question

http://stackoverflow.com/q/22055840
has title: Immutability and General vs. Specific Types
answer count: 3
tagged with: interface
has comment: http://stackoverflow.com/comment/33444046
favorite count: 0
has body: This is in the context of creating an interface/API. Best practices suggest using general rather than specific types in interfaces - e.g. Map rather than HashMap. Best practices also suggest preferring immutable types over mutable ones. So considering both of these suggestions (and leaving aside concerns about performance/memory-footprint, 3rd-party-libraries/dependencies and convenience/functionality) should a method in a public interface look like this public List&lt;SomeClass&gt; someMethod(...) or rather this public ImmutableList&lt;SomeClass&gt; someMethod(...)
has answer: http://stackoverflow.com/a/22056144
possible better answer: http://stackoverflow.com/a/22056165
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22056165
tagged with: guava
has comment: http://stackoverflow.com/comment/33443385
tagged with: java
has comment: http://stackoverflow.com/comment/33443313
has comment: http://stackoverflow.com/comment/33443383
has comment: http://stackoverflow.com/comment/33443292
type: Question
upvote count: 4
downvote count: 0
accepted answer: http://stackoverflow.com/a/22056144
score: 4
has answer: http://stackoverflow.com/a/22077322

http://stackoverflow.com/comment/33497399
type: Comment
comment on: http://stackoverflow.com/a/22086060
type: AnswerComment
has text: Exactly you are telling but how can i get the POM file.. Is that i need to create. currently i'm using testng so i have only the test.XML file in the src folder under my java project and the test.xml looks in this structure
score: 0

http://stackoverflow.com/comment/33455897
type: Comment
has text: @Pavel Horal: see [`Lock.newCondition()`](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/Lock.html#newCondition()) and [`ReentrantLock`](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/ReentrantLock.html)
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/22063305

http://stackoverflow.com/comment/33418847
score: 0
comment on: http://stackoverflow.com/q/22041968
type: Comment
type: QuestionComment
has text: I tried AVD Android 4.4.2 API level 19 and I get android.os.NetworkOnMainThreadException. So how do I fix it to run on any android?

http://stackoverflow.com/q/22018279
tagged with: stack
tagged with: java
has answer: http://stackoverflow.com/a/22018361
linked to: http://stackoverflow.com/q/40480
type: Question
has answer: http://stackoverflow.com/a/22018503
accepted answer: http://stackoverflow.com/a/22018503
has comment: http://stackoverflow.com/comment/33375957
has title: What is the behavior of a TreeMap instance passed into a constructor following changes in main method
tagged with: scope
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/33375662
has body: Suppose I have the setup: TreeMap&lt;Long,ClassA&gt; derkMap = new TreeMap&lt;Long,ClassA&gt;(); derkMap.put(1L,new ClassA()); Note that ClassA has public void doSomething(), which when called will change the instance's state permanently (in what precise way is irrelevant to this question). Note that once doSomething() is called, ClassA has a public boolean hasItBeenCalled() which will return true; else it'll return false if doSomething() has not been called. If I run the following sequence in my main method: (1) Pass derkMap instance to constructor of some ClassB (i.e. instantiate in my main method ClassB objectB = new ClassB(derkMap);). (2) Call derkMap.get(1L).doSomething(); from main method. (3) Within the instance of ClassB (i.e., objectB), try derkMap.get(1L).hasItBeenCalled(). Will (3) return true or false?
has comment: http://stackoverflow.com/comment/33375792
tagged with: pass-by-reference
has comment: http://stackoverflow.com/comment/33376261
tagged with: reference
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22018361

http://stackoverflow.com/comment/33615459
comment on: http://stackoverflow.com/q/22152060
score: 0
type: Comment
type: QuestionComment
has text: What does android have to do with this? Anyways, you should specify what you try to achieve: Calling these methods, do you want an iterator over the results? another arrayList just containing the results?

http://stackoverflow.com/q/22052639
downvote count: 0
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33437448
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/68987321
upvote count: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33437740
has title: Recursive Linear Search - StackOverflowError
type: Question
has body: I wanted to see if anyone could point me in the right direction on this, I feel like I am overlooking something very simple, the main is calling the search method on a list of about 45,000 words, which I believe is the problem, my code works for words that are in the first 6 or so thousand words in the list, but after that it encounters a StackOverflow error and crashes. I have a version of this that is non-recursive that works fine. I have two base cases, which are the end of the array, in which case we throw ItemNotFoundException, and if the word is found, in which case we return the index at which the item was located. My current code is: public int search(String[] words, String wordToFind) throws ItemNotFoundException { return search(words, wordToFind, 0); } private int search(String[] words, String wordToFind, int index) { incrementCount(); if(index == words.length) { // If index gets to the end of the array, then the word is not in the array throw new ItemNotFoundException(); } if (words[index].equals(wordToFind)) { // If word is found, return the index. return index; } else { // Increment index by 1 index++; // Call the search again return search(words, wordToFind, index); } } Non-recursive code that works fine: public int search(String[] words, String wordToFind) throws ItemNotFoundException { int count = 0; for (String word : words) { incrementCount(); if (word.equals(wordToFind)) { return count; } count++; } throw new ItemNotFoundException(); }
has answer: http://stackoverflow.com/a/22052677
has comment: http://stackoverflow.com/comment/33437972
answer count: 3
has answer: http://stackoverflow.com/a/22054213

http://stackoverflow.com/comment/33579507
comment on: http://stackoverflow.com/q/22104759
has text: I created two files: AlphabetHelper.java AlphabetHelperTest.java and imported the most likely needed imports. After asking on IRC they told me most likely it was a different distribution than OpenJDK or the to me known stable JDK. ArrayUtils.toObject() was reported to be a non JDK class. import org.apache.commons.lang.ArrayUtils; could be useful, but I've never done such an import. I think it may be the solution, but then it is no more java as defined by sun. It was discussed in this question http://stackoverflow.com/questions/2863954 and reported as a solution, which I am now examining.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22030159
score: 2
has comment: http://stackoverflow.com/comment/33398223
has comment: http://stackoverflow.com/comment/33398627
answers question: http://stackoverflow.com/q/22029798
downvote count: 0
has comment: http://stackoverflow.com/comment/33397899
has comment: http://stackoverflow.com/comment/33398754
has body: The problem you are facing seems to be related with argument that setCreateDate() is expecting. Since your method is declared as setCreateDate(Date) it is not compatible with setCreateDate(String), which is expected to be called when you submit the form. In order to update the current model object, you will have to retrieve it from DB using the submitted Id, update the pertinent fields and then call session.update(). You code will look like public void updateUserInfo(User user) { Session s = getSession(); Transaction t = s.beginTransaction(); User u = (User) s.load(User.class, user.getId()); u.setAddress(user.getAddress()); u.setEmail(user.getEmail()); s.update(u); t.commit(); closeSession(); } More informations about Hibernate listeners to update fields just before persisting an entity. If you want to set the createDate field just before your record is persisted, you can use @PrePersist protected void onCreate() { createDate = new Date(); } The methods annotated with @PrePersist and @PreUpdate are called just before Hibernate persist the entity for the first time or update it, respectively. You can get more information here. EDIT: I've notice you are using the Session API of Hibernate. In this case, the suggestion above won't work. In order to get it working with your current implementation, you should use the Hibernate events API. First, create an interface for objects that have to be updated just before it will be persisted (something like this) public interface Dateable { void setCreateDate(Date date); } Modify your User class to implement that interface. public class User implements Dateable { //... } Then create a Listener that listens for the SaveOrUpdateEvent on Dateable entities and modifies the create property: import org.hibernate.event.SaveOrUpdateEvent; import org.hibernate.event.def.DefaultSaveOrUpdateEventListener; public class SaveOrUpdateDateListener extends DefaultSaveOrUpdateEventListener { @Override public void onSaveOrUpdate(SaveOrUpdateEvent ev…
has comment: http://stackoverflow.com/comment/33397770
has comment: http://stackoverflow.com/comment/33398443
has comment: http://stackoverflow.com/comment/33397847
upvote count: 2
has comment: http://stackoverflow.com/comment/33397812
type: Answer

http://stackoverflow.com/q/22153423
tagged with: split
has comment: http://stackoverflow.com/comment/33618119
downvote count: 0
has comment: http://stackoverflow.com/comment/33619094
favorite count: 0
has body: I am getting the FFT back on an audio file, but it doesn't take into account the time in the song that that frequency occurred. I first tried getting the length of the file, and then spreading the FFT results equally over the track length, but that might be wrong and not give the correct frequencies back. So now I am trying to get the file split up into 1 second chunks and then return the frequency for that second alone, and then I will store that in a database to save it. But I have no clue on how to save it, all other threads I have found and research I have done only shows how to break into x amount of parts, not per second as in a song. Is there a way to do this? Sorry if this is a trivial topic, but I am very new to Java and programming, so this is quite a struggle for me. Thanks in advance Here is my code so far: File file = new File(FILENAME); float durationInSeconds = 0; Tag tag; java.util.logging.Logger.getLogger("org.jaudiotagger").setLevel(Level.OFF); AudioFile audioFile; try { audioFile = AudioFileIO.read(file); System.out.println("Track length = " + audioFile.getAudioHeader().getTrackLength()); durationInSeconds = audioFile.getAudioHeader().getTrackLength(); } catch (CannotReadException | TagException | ReadOnlyFileException | InvalidAudioFrameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { convert(); System.out.println(((durationInSeconds)/endResult.length)*1000); for(int i = 0; i &lt; endResult.length; i++) { Thread.sleep((long) (((durationInSeconds)/endResult.length)*1000)); System.out.println(endResult[i]); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
has title: Split audio file (mp3, wav, wma) into 1s chunks
has comment: http://stackoverflow.com/comment/33665855
score: 2
has comment: http://stackoverflow.com/comment/33676238
has comment: http://stackoverflow.com/comment/33618819
answer count: 0
upvote count: 2
type: UnansweredQuestion
tagged with: file
tagged with: audio
tagged with: java
tagged with: analysis
type: Question

http://stackoverflow.com/comment/33573499
type: AnswerComment
comment on: http://stackoverflow.com/a/22127990
score: 0
has text: I had a look at developers.google.com/appengine/docs/java/backends (Backend instances - which have no timeouts). Will need to look at pricing.
type: Comment

http://stackoverflow.com/comment/33627703
has text: for (Dog dog : this.dogList) { result += dog.toString() } ? Is this, what you're searching for? I assume that Dog has a toString function which is implemented by you.
type: QuestionComment
comment on: http://stackoverflow.com/q/22158613
score: 0
type: Comment

http://stackoverflow.com/q/22072834
possible better answer: http://stackoverflow.com/a/22073087
upvote count: 1
tagged with: swing
has answer: http://stackoverflow.com/a/22073541
has body: import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import net.java.dev.designgridlayout.DesignGridLayout; import java.sql.*; class databaseprob { JFrame JF; Container C,C1; JDesktopPane JDP; JInternalFrame JIF5; JLabel i1l1,i1l2; JTextField i1t1; JRadioButton i1r1,i1r2,i1r3,i1r4; JButton i1b1,i1b2,i1b3; JInternalFrame JIF1; ButtonGroup i1bg; String i1type; public databaseprob() { JF = new JFrame(); JDP = new JDesktopPane(); JF.setVisible(true); JF.pack(); JIF1 = new JInternalFrame("Register",true,true, true, true); C=JF.getContentPane(); C.add(JDP,BorderLayout.CENTER); JIF1.setVisible(true); JIF1.setBounds(10, 10, 600, 500); C1 = JIF1.getContentPane(); DesignGridLayout layout = new DesignGridLayout(C1); i1l1 = new JLabel("Head ID : "); i1l2 = new JLabel("Type : "); i1t1 = new JTextField(10); i1bg = new ButtonGroup(); ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JRadioButton radioButton = (JRadioButton)e.getSource(); i1type = radioButton.getText(); System.out.println(i1type); } }; i1r1 = new JRadioButton("Customer"); i1r1.addActionListener(actionListener); i1bg.add(i1r1); i1r2 = new JRadioButton("Supplier"); i1r2.addActionListener(actionListener); i1bg.add(i1r2); i1r3 = new JRadioButton("Staff"); i1r3.addActionListener(actionListener); i1bg.add(i1r3); i1r4 = new JRadioButton("Others"); i1r4.addActionListener(actionListener); i1bg.add(i1r4); i1b1 = new JButton("Save"); i1b1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection i1conn = DriverManager.getConnection("Jdbc:Odbc:TomsJava"); int i1headID = Integer.parseInt(i1t1.getText()); Statement i1stmt = i1conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); ResultSet i1rs = i1stmt.executeQuery("SELECT * FROM i1Register"); i1rs.moveToInsertRow(); i1rs.updateInt("Head_ID", i1headID); i1rs.up…
type: Question
tagged with: buttongroup
answer count: 3
has title: What am i doing wrong in retrieving value of button group?
has comment: http://stackoverflow.com/comment/33473021
downvote count: 0
accepted answer: http://stackoverflow.com/a/22073541
favorite count: 0
has answer: http://stackoverflow.com/a/22073035
has comment: http://stackoverflow.com/comment/33473325
tagged with: jradiobutton
has answer: http://stackoverflow.com/a/22073087
linked to: http://stackoverflow.com/q/21790021
type: AnsweredQuestion
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33504395

http://stackoverflow.com/comment/33404760
type: Comment
type: QuestionComment
has text: Also latest android gradle plugin is '0.8.6' already
comment on: http://stackoverflow.com/q/22027982
score: 0

http://stackoverflow.com/a/22083299
answers question: http://stackoverflow.com/q/22083227
has body: your loop should only have the values from 0 to 9: for (int i = 0; i &lt; num; i++)
type: Answer
score: 0

http://stackoverflow.com/comment/33675242
has text: @MarkRotteveel But surely they do? Surely there's a certification step they have to pass?
score: 0
comment on: http://stackoverflow.com/a/22139876
type: Comment
type: AnswerComment

http://stackoverflow.com/q/22008180
has comment: http://stackoverflow.com/comment/33358582
has comment: http://stackoverflow.com/comment/33357728
score: 15
downvote count: 2
has title: Getter-Setter and private variables
duplicate of: http://stackoverflow.com/q/1461598
upvote count: 17
has answer: http://stackoverflow.com/a/22008437
favorite count: 0
linked to: http://stackoverflow.com/q/10407877
tagged with: private
duplicate of: http://stackoverflow.com/q/1568091
tagged with: getter-setter
answer count: 5
has answer: http://stackoverflow.com/a/22008228
accepted answer: http://stackoverflow.com/a/22008228
possible better answer: http://stackoverflow.com/a/22008421
has answer: http://stackoverflow.com/a/22008475
has answer: http://stackoverflow.com/a/22008421
linked to: http://stackoverflow.com/q/1461598
linked to: http://stackoverflow.com/q/1568091
type: Question
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/22008649
has body: If I can change the value of private variable through getter-returned reference then isn't it bypassing the setter method? Doesn't it defeat the purpose of getter-setter and private variables public class Test{ private Dimension cannotBeChanged; public Test(int height, int width) { if(height!=3) cannotBeChanged.height = height; if(width!=3) cannotBeChanged.width = width; } public Dimension getDimension() { return cannotBeChanged; } public void setDimension(int height, int width) { if(height!=3) cannotBeChanged.height = height; if(width!=3) cannotBeChanged.width = width; } public static void main(String [] args) { Test testOne = new Test(5,5); Dimension testSecond = testOne.getDimension(); testSecond.height = 3; //Changed height and width to unwanted values testSecond.width= 3; }

http://stackoverflow.com/q/22055952
has comment: http://stackoverflow.com/comment/33443503
type: Question
has comment: http://stackoverflow.com/comment/33443541
tagged with: trigonometry
has comment: http://stackoverflow.com/comment/33444497
tagged with: java-2d
type: UnansweredQuestion
has title: How do i find sine(a) given 2 lines , each line described by 2 points?
has comment: http://stackoverflow.com/comment/33445117
has body: I have : Point2D line1_start , Point2d line1_end Point2D line1_start , Point2d line1_end Is there a formula to quickly do that?
answer count: 0
score: 0
tagged with: java

mysql
tags question: http://stackoverflow.com/q/22158006
tags question: http://stackoverflow.com/q/22035054
tags question: http://stackoverflow.com/q/22050978
tags question: http://stackoverflow.com/q/22031648
tags question: http://stackoverflow.com/q/22029583
tags question: http://stackoverflow.com/q/22103483
tags question: http://stackoverflow.com/q/22069819
tags question: http://stackoverflow.com/q/22142706
tags question: http://stackoverflow.com/q/22038066
tags question: http://stackoverflow.com/q/22066316
tags question: http://stackoverflow.com/q/22042741
tags question: http://stackoverflow.com/q/22130460
tags question: http://stackoverflow.com/q/22082706
tags question: http://stackoverflow.com/q/22152907
tags question: http://stackoverflow.com/q/22066484
tags question: http://stackoverflow.com/q/22127945
tags question: http://stackoverflow.com/q/22033556
tags question: http://stackoverflow.com/q/22136168
tags question: http://stackoverflow.com/q/22044902
tag name: mysql
tags question: http://stackoverflow.com/q/22088141
tags question: http://stackoverflow.com/q/22064160
tags question: http://stackoverflow.com/q/22070444
tags question: http://stackoverflow.com/q/22035559
tags question: http://stackoverflow.com/q/22114576
tags question: http://stackoverflow.com/q/22104396
tags question: http://stackoverflow.com/q/22028487
tags question: http://stackoverflow.com/q/22045108
tags question: http://stackoverflow.com/q/22142350
tags question: http://stackoverflow.com/q/22010038
tags question: http://stackoverflow.com/q/22095216
tags question: http://stackoverflow.com/q/22044264
tags question: http://stackoverflow.com/q/22154150
tags question: http://stackoverflow.com/q/22141776
tags question: http://stackoverflow.com/q/22042836
tags question: http://stackoverflow.com/q/22042310
tags question: http://stackoverflow.com/q/22069246
tags question: http://stackoverflow.com/q/22021069
tags question: http://stackoverflow.com/q/22127264
tags question: http://stackoverflow.com/q/22096547
tags question: http://stackoverflow.com/q/22087256
tags question: http://stackoverflow.com/q/22135600
tags question: http://stackoverflow.com/q/22105896
tags question: http://stackoverflow.com/q/22062568
tags question: http://stackoverflow.com/q/22160068
tags question: http://stackoverflow.com/q/22125216
tags question: http://stackoverflow.com/q/22006684
tags question: http://stackoverflow.com/q/22077589
tags question: http://stackoverflow.com/q/22017182
tags question: http://stackoverflow.com/q/22011496
tags question: http://stackoverflow.com/q/22113285
tags question: http://stackoverflow.com/q/22100380
tags question: http://stackoverflow.com/q/22111560
tags question: http://stackoverflow.com/q/22079521
tags question: http://stackoverflow.com/q/22046798
tags question: http://stackoverflow.com/q/22023504
type: Tag
tags question: http://stackoverflow.com/q/22041587
tags question: http://stackoverflow.com/q/22033076
tags question: http://stackoverflow.com/q/22010544
tags question: http://stackoverflow.com/q/22109202
tags question: http://stackoverflow.com/q/22096093
tags question: http://stackoverflow.com/q/22035445
tags question: http://stackoverflow.com/q/22125823
tags question: http://stackoverflow.com/q/22092747
tags question: http://stackoverflow.com/q/22097586
tags question: http://stackoverflow.com/q/22009837
tags question: http://stackoverflow.com/q/22144254
tags question: http://stackoverflow.com/q/22098745
tags question: http://stackoverflow.com/q/22114201
tags question: http://stackoverflow.com/q/22168595
tags question: http://stackoverflow.com/q/22148450
tags question: http://stackoverflow.com/q/22133571
tags question: http://stackoverflow.com/q/22139645
tags question: http://stackoverflow.com/q/22005458
tags question: http://stackoverflow.com/q/22167708
tags question: http://stackoverflow.com/q/22089344
tags question: http://stackoverflow.com/q/22093284
tags question: http://stackoverflow.com/q/22048194
tags question: http://stackoverflow.com/q/22042903

http://stackoverflow.com/q/22070261
tagged with: textarea
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/33469137
has answer: http://stackoverflow.com/a/22070464
has title: Highlight text in JavaFx TextArea
favorite count: 0
tagged with: javafx-2
has body: I have a text area like below, I need to highlight or select all the text "Highlight me". I don't find any methods to highlight the text in text area. Also I could not find any other API in JavaFX that highlights the occurrence of specific text or letter like JTextArea in Swing. Can any one suggest me on how to highlight String in the text area? Or is there any other API available apart from this text area in JavaFX? My Code: public class FXTextArea extends Application { /** * @param args * the command line arguments */ public static void main(String[] args) { launch(args); } @Override public void start(final Stage primaryStage) { Group root = new Group(); final TextArea textArea = TextAreaBuilder.create().prefWidth(390) .wrapText(true).build(); ScrollPane scrollPane = new ScrollPane(); scrollPane.getStyleClass().add("noborder-scroll-pane"); scrollPane.setContent(textArea); scrollPane.setFitToWidth(true); scrollPane.setPrefWidth(390); scrollPane.setPrefHeight(180); Button buttonLoad = new Button("Load"); buttonLoad.setOnAction(new EventHandler&lt;ActionEvent&gt;() { @Override public void handle(ActionEvent arg0) { FileChooser fileChooser = new FileChooser(); // Set extension filter FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter( "TXT files (*.txt)", "*.txt"); fileChooser.getExtensionFilters().add(extFilter); // Show save file dialog File file = fileChooser.showOpenDialog(primaryStage); if (file != null) { textArea.setText(readFile(file)); } System.out.println(textArea.getText(0, 30)); textArea.selectRange(0, 30); } }); VBox vBox = VBoxBuilder.create().children(buttonLoad, scrollPane) .build(); root.getChildren().add(vBox); primaryStage.setScene(new Scene(root, 400, 300)); primaryStage.show(); } private String readFile(File file) { StringBuilder stringBuffer = new StringBuilder(); BufferedReader bufferedReader = null; try { bufferedReader = new BufferedReader(new FileReader(file)); String text; while ((text = bufferedReader.readLine()) != nul…
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33468922
upvote count: 1
score: 1
tagged with: java
tagged with: javafx
type: Question

http://stackoverflow.com/q/22110836
tagged with: java
has comment: http://stackoverflow.com/comment/33541844
type: Question
answer count: 2
has body: Please take a look at this snippet: public class A { void method() { System.out.print(B.j);//This is legal! class C { void method () { System.out.print(j);//This is illegal! } } final int j = 10; class D { void method() { System.out.print(j);//This is legal! } } } } class B { static int j = 10; } We can access the 'B.j' in a place before it's definition whilst this is illegal in the case of accessing 'final int j' in class C. Does java compiler looks at local classes as simple variables/objects? Specially, what's the rationale behind this behavior? I mean forward checking is working for the B.j but it doesn't work for the 'j' inside the class C.
has answer: http://stackoverflow.com/a/22110927
has answer: http://stackoverflow.com/a/22110954
favorite count: 0
tagged with: inner-classes
upvote count: 2
type: UnansweredQuestion
downvote count: 1
linked to: http://stackoverflow.com/q/2428186
has title: Does java forward referencing act differently in different situations?
score: 1
tagged with: local-class

http://stackoverflow.com/a/22063994
has comment: http://stackoverflow.com/comment/33458847
answers question: http://stackoverflow.com/q/22063953
score: 5
upvote count: 5
downvote count: 0
has body: Use String.split() with a regex \\s+ (or \n+ for example, depending on what you exactly want). You can concat 2 or more strings if needed, but after you have the array using split() - it should be fairly easy, give it a try! good luck. Feel free to ask any question if you are having troubles implementing the 2nd part. EDIT: seems like you are having troubles with concatting the strings. This shou;d be done with simple iteration and a StringBuilder: int SIZE = 4; String[] arr = str.split("\\s+"); List&lt;String&gt; res = new ArrayList&lt;&gt;(); StringBuilder sb = new StringBuilder(); for (int i = 0; i &lt; arr.length; i++) { sb.append(arr[i]).append('\n'); if (i % SIZE == SIZE-1) { res.add(sb.toString()); sb = new StringBuilder(); } } if (sb.length() != 0) res.add(sb.toString()); System.out.println(res); } Note that res is a List&lt;String&gt;, if you want it as an array, you can always use the toArray() method.
type: AcceptedAnswer
type: Answer
has comment: http://stackoverflow.com/comment/33457625
has comment: http://stackoverflow.com/comment/33457577
accepted answer of: http://stackoverflow.com/q/22063953
has comment: http://stackoverflow.com/comment/33457801

media-player
tags question: http://stackoverflow.com/q/22069522
type: Tag
tags question: http://stackoverflow.com/q/22167731
tag name: media-player
tags question: http://stackoverflow.com/q/22076643
tags question: http://stackoverflow.com/q/22130937
tags question: http://stackoverflow.com/q/22113840
tags question: http://stackoverflow.com/q/22112807

http://stackoverflow.com/a/22167225
type: Answer
upvote count: 3
score: 3
answers question: http://stackoverflow.com/q/22166983
downvote count: 0
has body: Method getSystemResourceAsStream opens for reading, a resource of the specified name from the search path used to load classes. You are going to read a file so open a file stream: filePath = "D:/Data/sample.xml"; //Correct path String tagContent = null; XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader reader = null; try{ System.out.println("here"); reader = factory.createXMLStreamReader(new FileInputStream(new File(filePath))); System.out.println("Reader:" + reader); } catch(Exception e) { System.out.println("Error 4:" + e); } System.out.println("Reader:" + reader);

http://stackoverflow.com/q/22142374
has answer: http://stackoverflow.com/a/22161385
has body: I am trying to not have an EJB injected in my Servlet, currently I am having it directly injected into my Servlet and it works fine but I want to pass control to a controller class that will inject the EJB, and not have a Controller method or constructor that takes a reference variable of the Bean and working with it. Everything I am doing is in JSP, and I try using the @ManagedBean annotation on my Controller but nothing works. I am using only JSPs and not JSF as I am not familiar with them. Is what I am trying to do achievable and is there an alternative to this besides passing reference of the bean ? Any shed of light is highly appreciated. Thank you. Currently what I have is the following in my Servlet. package com.ejb.web; import java.io.IOException; import javax.ejb.EJB; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.ejb.customer.domain.Customer; import com.ejb.customer.service.CustomerLocal; import com.ejb.customer.util.DateUtil; /** * Servlet implementation class Servlet */ @WebServlet("/customer") public class Dispatcher extends HttpServlet { private static final long serialVersionUID = 1L; @EJB CustomerLocal customerLocal; /** * @see HttpServlet#HttpServlet() */ public Dispatcher() { super(); } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String name = request.getParameter("name"); String surname = request.getParameter("surname"); String dateOfBirth = request.getParameter("dateOfBirth"); Customer customer = new Customer(); customer.setName(name); customer.setSurname(surname); customer.setDateOfBirth(DateUtil.convertToDate(dateOfBirth)); System.out.println("Starting .....Adding"); S…
has comment: http://stackoverflow.com/comment/33599280
has comment: http://stackoverflow.com/comment/33638180
tagged with: ejb-3.0
accepted answer: http://stackoverflow.com/a/22161385
has comment: http://stackoverflow.com/comment/33602155
tagged with: jakarta-ee
type: AnsweredQuestion
has title: Delegating EJB to a Controller class rather than having it in a Servlet directly
tagged with: java
tagged with: servlets
type: Question
score: 0
tagged with: ejb
has comment: http://stackoverflow.com/comment/33601841
answer count: 1

http://stackoverflow.com/comment/33525358
comment on: http://stackoverflow.com/a/22101659
type: Comment
has text: For information: this behavior is not for all map implementations. HashMap returns null. Treemap (this case) ClassCastException
type: AnswerComment
score: 0

http://stackoverflow.com/q/22157505
downvote count: 0
tagged with: jsp
score: 1
favorite count: 0
type: Question
tagged with: jsp-tags
has comment: http://stackoverflow.com/comment/33630821
upvote count: 1
tagged with: spring
has answer: http://stackoverflow.com/a/22161726
answer count: 1
tagged with: spring-mvc
has body: i am trying to understand if it is possible to display certain HTML elements on a page based on the errors resulted during the validation of the current page. For example I have a form which has a text box hidden. When user submits the form and the form has any error, when the user sees the page with error information they should see the hidden text box visible. Tried to use pseudo code to explain what i am trying below. Setting error from Spring validation as below: In the validator class i have something like, ValidationUtils.rejectIfEmptyOrWhitespace(errors, "mainForm", "mainform.error.display.alternateText", "error occured"); In the JSP i have something like, &lt;td id="alternateTextBox" &lt;c:choose&gt; &lt;c:when test="${not empty mainForm.error}"&gt; style="width:50%;visibility:visible" &gt; &lt;/c:when&gt; &lt;c:otherwise&gt; style="width:50%;visibility:hidden" &gt; &lt;/c:otherwise&gt; &lt;/c:choose&gt; &lt;s:message code="standing_instructions.RELATIONSHIP" /&gt; &lt;form:input path="alternateText" id="alternateText" size="50"/&gt; &lt;/td&gt;
tagged with: java
has title: display HTML element based on spring error values
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22161726

http://stackoverflow.com/comment/33419709
type: AnswerComment
score: 0
type: Comment
has text: @JohnSkeet gelp me to find sollution
comment on: http://stackoverflow.com/a/22042303

http://stackoverflow.com/comment/33590624
type: Comment
comment on: http://stackoverflow.com/a/22125643
score: 0
type: AnswerComment
has text: ooh thanks man! but now i got an error regarding that. says "The left-hand side of an assignment must be a variable"

http://stackoverflow.com/a/22047191
has body: Get rid of pause(1000) you can maybe make it pause(10) or something around that. Call this.repaint() every time in your loop (outside of the if statement). Split amt into two variables: the actual amount, and the displayed amount. Only draw the displayed amount, and have key presses only increase the actual amount. Each frame, if displayed amount is less than actual amount increase it by 1. Updated... Remove pause(500) from the double buffer routine, and pause(200) from paint. In general, don't pause unless you need to do "nothing". Games never do "nothing", they almost always have a core loop that's at least rendering.
has comment: http://stackoverflow.com/comment/33432065
has comment: http://stackoverflow.com/comment/33811189
score: 0
has comment: http://stackoverflow.com/comment/33483581
has comment: http://stackoverflow.com/comment/33713172
has comment: http://stackoverflow.com/comment/33483864
type: Answer
has comment: http://stackoverflow.com/comment/33798663
has comment: http://stackoverflow.com/comment/33479604
has comment: http://stackoverflow.com/comment/33433575
has comment: http://stackoverflow.com/comment/33432578
has comment: http://stackoverflow.com/comment/33515320
has comment: http://stackoverflow.com/comment/33526185
answers question: http://stackoverflow.com/q/22046832
has comment: http://stackoverflow.com/comment/33524463
has comment: http://stackoverflow.com/comment/33468885
has comment: http://stackoverflow.com/comment/33767078
has comment: http://stackoverflow.com/comment/33529175
has comment: http://stackoverflow.com/comment/33524697
accepted answer of: http://stackoverflow.com/q/22046832
has comment: http://stackoverflow.com/comment/33431705
has comment: http://stackoverflow.com/comment/33524778
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33482810

http://stackoverflow.com/q/22131044
downvote count: 0
answer count: 1
has title: strace on two instances of java
favorite count: 0
has comment: http://stackoverflow.com/comment/33578923
has comment: http://stackoverflow.com/comment/33579209
upvote count: 1
has comment: http://stackoverflow.com/comment/33578930
type: AnsweredQuestion
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22131319
has comment: http://stackoverflow.com/comment/33579399
tagged with: strace
type: Question
has body: I want to trace the execution of a java process. For that I am using strace to analyse it. I have written two basic programs. Prog1 : Simple hello world Prog2 : Prime number calculation with lots of Sysout's. By lots I really mean lots !! I am taking strace using : strace java classfile Both the program work correctly. However, when I compare their straces, their outputs were same i.e. the system calls and their order. My queries are : What can be reason behind this ? What would be the correct way to strace a java program ? The statements being printed are not part of the strace ... actually there is no write system call in the strace output ?
accepted answer: http://stackoverflow.com/a/22131319
has comment: http://stackoverflow.com/comment/33579238
has comment: http://stackoverflow.com/comment/33579367
tagged with: execution
has comment: http://stackoverflow.com/comment/33578938
tagged with: system-calls

http://stackoverflow.com/q/22082339
tagged with: null
downvote count: 0
has comment: http://stackoverflow.com/comment/33491017
tagged with: char
answer count: 3
has answer: http://stackoverflow.com/a/22082431
possible better answer: http://stackoverflow.com/a/22082419
tagged with: incompatibility
favorite count: 0
has comment: http://stackoverflow.com/comment/33490904
tagged with: multidimensional-array
has title: Char array indexes not accepting
has body: I'm having an issue with a mock game of Tic tac toe. I'm using a two-dimensional array to represent the playing board, and have instantiated it as follows. It's required that I use a char type array. I realize that I shouldn't have to specify that each index is null, as that's the default for char, but I thought I would give it a try. public TicTacToe2D() { board = new char[3][3]; for(int i = 0; i &lt; board.length; i++) { for(int j = 0; j &lt; board[i].length; j++) { board[j] = null; } board[i] = null; } } Here I'm checking for a win condition, seeing if indexes are equal to each other and not null (the default) though I have attempted using ' ' for my array initial value. In that case I got the error: "incompatible types: char cannot be converted to char[]" public char isWin() { //Check for row wins if (board[0][0] == board[0][1] &amp;&amp; board[0][1] == board[0][2] &amp;&amp; board[0][0] != null) return true; if (board[1][0]==board[1][1] &amp;&amp; board[1][1]==board[1][2] &amp;&amp; board[1][0] != null) return true; if (board[2][0]==board[2][1] &amp;&amp; board[2][1]==board[2][2] &amp;&amp; board[2][0] != null) return true; //Check for column wins if (board[0][0]==board[1][0] &amp;&amp; board[1][0]==board[2][0] &amp;&amp; board[0][0] != null) return true; if (board[0][1]==board[1][1] &amp;&amp; board[1][1]==board[2][1] &amp;&amp; board[0][1] != null) return true; if (board[0][2]==board[1][2] &amp;&amp; board[1][2]==board[2][2] &amp;&amp; board[0][2] != null) return true; //Check for diagonal wins if (board[0][0]==board[1][1] &amp;&amp; board[1][1]==board[2][2] &amp;&amp; board[0][0] != null) return true; if (board[2][0] == board[1][1] &amp;&amp; board[1][1] == board[0][2] &amp;&amp; board[2][0] != 0) return true; else return false; } When checking if an index is null I get the error "incomparable types: char and " Any help would be greatly appreciated!
upvote count: 1
accepted answer: http://stackoverflow.com/a/22082401
type: AnsweredQuestion
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22082419
has answer: http://stackoverflow.com/a/22082401
type: Question

http://stackoverflow.com/a/22089941
type: Answer
has comment: http://stackoverflow.com/comment/33504588
has comment: http://stackoverflow.com/comment/33506217
answers question: http://stackoverflow.com/q/22089344
score: 0
has comment: http://stackoverflow.com/comment/33505557
has body: MetaData is not a report that contains spacing formats for print or display purpose. As per ResultSetMetaData documentation: An object that can be used to get information about the types and properties of the columns in a ResultSet object. It is clear that it contain's no specific information on how it has to be used for display or printing. Your way of solution combined into a result string for presentation is not good. It would always be a good practice to encapsulate the data read from ResultSet to form a Data Object. In your case it can be a StudentDegreeScheme object. Create a class with necessary getter and setters and fill them from reading the ResultSet and return the student... object to the caller. Caller should then use the same object to display or print after formatting using, for example, any HTML layout. Hope you got the point.

http://stackoverflow.com/a/22129981
answers question: http://stackoverflow.com/q/22129955
has comment: http://stackoverflow.com/comment/33576717
type: AcceptedAnswer
downvote count: 0
has body: You're correct. Sometimes it can be useful to not block for some operations, even if you're using it regularly with blocking purposes. From the javadoc for the BlockingQueue interface: A Queue that additionally supports operations that wait for the queue to become non-empty when retrieving an element, and wait for space to become available in the queue when storing an element. So the blocking property is an addition to normal queue functionality. Soo a blocking queue is a queue, but a queue is not necessarily a blocking one.
type: Answer
score: 2
accepted answer of: http://stackoverflow.com/q/22129955
upvote count: 2

http://stackoverflow.com/a/22076497
score: 0
answers question: http://stackoverflow.com/q/22076426
type: Answer
has body: As far as I know java language it is the only way to do that. But you can simply implement method into your class. And in your method also there is possibility to return your object. public MyObject myFunction(){ //do stufff... return new MyObject(); } MybObject object = myFucntion(); Or you can do it in your way. Also using Reflection you can invoke your method. Method method = foo.getClass().getMethod("doSomething", null); method.invoke(foo, null);

http://stackoverflow.com/comment/33355752
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22006824
type: QuestionComment
has text: that's the normal behavior.

http://stackoverflow.com/q/22014604
has body: I've got a J2EE app I'm converting to run on Websphere Liberty Profile (WLP). I'm specifically trying to get my EJB references injected. I've got my WLP server configured with the ejb-lite, managed-beans, and cdi features. I've placed a beans.xml file in my WEB-INF directory, and annotated an action class as a @ManagedBean, and added a @PostConstruct and @PreRemove method with logging to see if things are working. I never see my @PostConstruct and @PreRemove methods called I've tried a few things to get the injection to work, including @Inject and various flavors of @EJB with different arguments. Nothing seems to work. I don't get any errors, but there's no indication that any annotation processing is taking place. When I do a straight JNDI lookup to get the ejb, it works fine. Everything I've read indicates that this should work, but I can't figure out why it doesn't.
tagged with: cdi
has answer: http://stackoverflow.com/a/22096164
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22021957
tagged with: managed-bean
tagged with: websphere-liberty
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33514321
tagged with: jakarta-ee
answer count: 2
score: 0
has comment: http://stackoverflow.com/comment/33446952
has title: Using managed beans and injection in a J2EE application in Websphere Liberty Profile

http://stackoverflow.com/comment/33373837
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22014105
has text: Exatcly, you should use/enable cookies in your http client to make your app store the session.

http://stackoverflow.com/q/22031648
has comment: http://stackoverflow.com/comment/33405190
type: Question
upvote count: 5
tagged with: java
tagged with: indexoutofboundsexception
accepted answer: http://stackoverflow.com/a/26082871
has comment: http://stackoverflow.com/comment/33405782
answer count: 2
possible better answer: http://stackoverflow.com/a/44771707
downvote count: 0
has answer: http://stackoverflow.com/a/44771707
favorite count: 0
has comment: http://stackoverflow.com/comment/33401883
score: 5
has answer: http://stackoverflow.com/a/26082871
has title: String out of index with SQL developer
has body: I got below message from sql developer when I try to access. I did just nothing special. my connection info like below Connection name : z*sch*** Username : root Password : it just numbers and characters(en) Connect Type : basic Role : default Host name : IP4 type address Port : 3306(MySQL) SID : z*_* Sorry for '*', But I sure that I opened information that I can do. There is no long Strings, so I do not know why this program(SQLDeveloper) shows error message 'String out of range'. Give me the light! :D java.lang.StringIndexOutOfBoundsException: String index out of range: 13113 at java.lang.String.checkBounds(String.java:401) at java.lang.String.&lt;init&gt;(String.java:338) at oracle.net.ns.Packet.extractData(Packet.java:439) at oracle.net.ns.RefusePacket.&lt;init&gt;(RefusePacket.java:72) at oracle.net.ns.NSProtocol.connect(NSProtocol.java:356) at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1126) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:337) at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:552) at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(T4CConnection.java:253) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:526) at oracle.jdeveloper.db.adapter.AbstractConnectionCreator.getConnection(AbstractConnectionCreator.java:153) at oracle.dbtools.raptor.standalone.connection.RaptorConnectionCreator.getConnection(RaptorConnectionCreator.java:195) at oracle.dbtools.raptor.dialogs.conn.ConnectionPrompt.promptForPassword(ConnectionPrompt.java:67) at oracle.jdeveloper.db.adapter.DatabaseProvider.getConnection(DatabaseProvider.java:321) at oracle.jdeveloper.db.adapter.DatabaseProvider.getConnection(DatabaseProvider.java:254) at oracle.jdevimpl.db.adapter.CADatabaseFactory.createConnectionImpl(CADatabaseFactory.java:60) at oracle.javatools.db.DatabaseFactory.createConnection(DatabaseFactory.java:534) at oracle.javatoo…
type: AnsweredQuestion
tagged with: oracle-sqldeveloper
tagged with: mysql

http://stackoverflow.com/comment/33569958
type: Comment
type: QuestionComment
has text: Are you using Spring 3 or 4?
score: 0
comment on: http://stackoverflow.com/q/22125899

http://stackoverflow.com/comment/33433205
comment on: http://stackoverflow.com/q/22050249
has text: _"If a constructor does not explicitly invoke a superclass constructor, the Java compiler automatically inserts a call to the no-argument constructor of the superclass."_ http://docs.oracle.com/javase/tutorial/java/IandI/super.html
type: Comment
type: QuestionComment
score: 2

http://stackoverflow.com/comment/33411999
type: Comment
comment on: http://stackoverflow.com/a/22038632
score: 0
type: AnswerComment
has text: Is videoView.io.vov.vitamio.widget.VideoView a subclass of the original Android version ?

http://stackoverflow.com/q/22050591
tagged with: user-interface
has comment: http://stackoverflow.com/comment/33433789
tagged with: jlabel
has answer: http://stackoverflow.com/a/22050962
accepted answer: http://stackoverflow.com/a/22050962
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22050781
has body: I want to create a gui, where the window is split in half, one side has the inputs (jlabels and text fields), the other side has the output printed out. Before I add any listeners and what not I ran into a problem where I could create two seperate panels. Can anyone suggest a layout and proper way to use it? By default i only know how to use flowlayout and that wont work. On top of that my textfields wont align with my input boxes.
has comment: http://stackoverflow.com/comment/33433790
tagged with: swing
type: Question
tagged with: java
has title: How to set a proper layout for GUI in java
score: 0
has answer: http://stackoverflow.com/a/22050781
answer count: 2
tagged with: layout

http://stackoverflow.com/q/22063509
upvote count: 5
downvote count: 0
type: UnansweredQuestion
tagged with: maven
has body: I want a simple android hello world program in with maven.here is my pom.xml file <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.example.androidmaven gs-maven-android 0.1.0 apk com.google.android android 4.1.1.4 provided com.jayway.maven.plugins.android.generation2 android-maven-plugin 3.8.2 19 <deleteConflictingFiles>true</deleteConflictingFiles> true true maven-compiler-plugin 3.1 1.6 1.6 getting this error [ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:andr oid-maven-plugin:3.8.2:generate-sources (default-generate-sources) on project gs -maven-android: Execution default-generate-sources of goal com.jayway.maven.plug ins.android.generation2:android-maven-plugin:3.8.2:generate-sources failed: Erro r reading D:\adt-bundle-windows-x86-20130522\sdk\tools\tools\source.properties - > [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit ch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please rea d the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutio nException
tagged with: java
has answer: http://stackoverflow.com/a/23048031
has answer: http://stackoverflow.com/a/25668640
type: Question
has answer: http://stackoverflow.com/a/23448525
score: 5
tagged with: build-script
answer count: 3
tagged with: android
tagged with: http://stackoverflow.com/tag/xml
favorite count: 0
has title: Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin

http://stackoverflow.com/comment/33397100
has text: @geekCode - Yes I did! But I now have a solution...that is: Intent i = new Intent(getActivity(), Settings.class);
comment on: http://stackoverflow.com/q/22029677
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/33388830
has text: my comment didn't say anything about clustering column
type: Comment
comment on: http://stackoverflow.com/a/22024257
type: AnswerComment
score: 0

http://stackoverflow.com/q/22087394
tagged with: java
downvote count: 0
answer count: 1
tagged with: jsp
tagged with: tomcat
favorite count: 0
has answer: http://stackoverflow.com/a/22254562
has body: I have been developing web projects for quite a while now. Some of them hosted on Tomcat/JBOSS (Java webapps), some on Apache (PHP applications). I wish to horizontally scale my applications and came across nginx and right now I am using nginx as a reverse proxy for my tomcat and apache servers (on different machines within the LAN) Until now, I have been rendering web-pages using jsp/php templates, i.e., inserting menu-bars, headers, footers via these templates. These template(s) are dynamic, i.e., They have to be inserted depending on the Access level of the user. The user can be Administrator or Just an employee with differing access rights, which are managed by the application itself. The pages that are not accessible to a particular user should not be accessible by him (Even by directly entering the URL). Right now, we handle this by server-side redirection. Now, the problem is, I wish to reduce the load on my apache/tomcat servers without compromising on such security aspects as mentioned above. And I was wondering whether there was a way to completely separate out my jsp/php code from the static content by re-organizing my Project, but while doing this the following points have to be kept in mind, I wish to manage file level access via my application, i.e., A user should not be able to access any of the static project files by directly accessing it via the URL. I wish to use nginx as a Load balancer and for its advantage of quickly delivering static content.
score: 2
upvote count: 2
type: UnansweredQuestion
tagged with: php
has title: How best to organize my Project for optimal nginx usage
type: Question
tagged with: nginx

http://stackoverflow.com/a/24907369
type: Answer
downvote count: 0
has body: There are two key things to know for software developer using Maven: Maven 3.0.5 is just a security fix for maven 3.0.4 and nothing more. This version is fully compatible with what you had before. So if you have &lt;=3.0.4 then 3.0.5 is the easiest way to go. Some maven plugins may fail to work properly with Maven 3.1.x or 3.2.x. This happened to "flyway" for instance (which we use on our project). And I've seen some reports of other plugins failing as well. So if you can do a quick-switch, test, and nothing goes wrong, I guess you are okay with the latest version. In other aspects 3.1.x and 3.2.x are just an evolution of maven. Releases 3.1.x and 3.2.x introduce more changes to internal maven mechanics than to user experience. They are now using SLF4J internally, changed some libraries implementations, some CDI mechanisms.... However some user-friendly features are there as well. Like "version ranges" support. All in all.... I'm starting to think toward gradle :)
score: 5
answers question: http://stackoverflow.com/q/22074117
upvote count: 5

http://stackoverflow.com/a/22024873
has body: Try This public static void main(String[] args) throws IOException { Map&lt;Integer, String&gt; map = new HashMap&lt;Integer, String&gt;(); BufferedReader br = new BufferedReader(new FileReader("movieReviews.txt")); String line=""; int i=0; while (line != null) { line = br.readLine(); map.put(i,line); i++; } for(int j=0;j&lt;map.size();j++){ System.out.println(map.get(j)); } }
has comment: http://stackoverflow.com/comment/33388251
has comment: http://stackoverflow.com/comment/33388233
has comment: http://stackoverflow.com/comment/33388360
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33388408
upvote count: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22024770
answers question: http://stackoverflow.com/q/22024770

http://stackoverflow.com/comment/33503363
comment on: http://stackoverflow.com/a/22089603
type: AnswerComment
score: 0
type: Comment
has text: It will not be efficient at all

http://stackoverflow.com/q/22044934
linked to: http://stackoverflow.com/q/17721895
has body: From App Engine doc on transaction: Note: In extremely rare cases, the transaction is fully committed even if a transaction returns a timeout or internal error exception. For this reason, it's best to make transactions idempotent whenever possible. Suppose in a situation A transfers money to another person B, the operations should be in a transaction, if the above Note did occur, then it will be in inconsistent state, (the transfer action can not be idempotent). Is my understanding correct?
has answer: http://stackoverflow.com/a/22045299
type: AnsweredQuestion
type: Question
tagged with: google-app-engine
accepted answer: http://stackoverflow.com/a/22045299
has title: Is Google App Engine suitable for financial situation
score: 0
tagged with: java
answer count: 1
has comment: http://stackoverflow.com/comment/33423627

http://stackoverflow.com/comment/33387242
has text: Check the firebird.log of the server for errors around the time the application threw this error. Also: please include the full stacktrace if possible.
comment on: http://stackoverflow.com/q/22024153
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33605715
comment on: http://stackoverflow.com/q/22146598
has text: Yours isn't it a web app? Anyway, check your classpath in any case: if it does not contain the resource, you must use a file system path.
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/q/22009679
has body: I am getting just started with Netty (Using 4.0.15.Final). I want to read messages from an existing hardware device that talks a proprietary protocol. I have implemented this as follows: public class Xml2StreamProtocolDecoder extends ByteToMessageDecoder { private static final int LENGTH_OF_START_SENTINEL_IN_BYTES = 1; private static final int LENGTH_OF_END_SENTINEL_IN_BYTES = 1; private static final int LENGTH_OF_LENGTH_FIELD_IN_BYTES = 4; @Override protected void decode( ChannelHandlerContext ctx, ByteBuf in, List&lt;Object&gt; out ) throws Exception { if( in.readableBytes() &gt; LENGTH_OF_START_SENTINEL_IN_BYTES + LENGTH_OF_LENGTH_FIELD_IN_BYTES) { short startSentinel = in.readUnsignedByte(); if (startSentinel != 0x01) { throw new CorruptedFrameException( "startsentinel not as expected, was " + startSentinel + " while we expect 0x01" ); } int messageLength = getMessageLength( in ); if( in.readableBytes() &gt;= messageLength + LENGTH_OF_END_SENTINEL_IN_BYTES ) { ByteBuf result = in.slice( in.readerIndex(), messageLength ); in.skipBytes( messageLength ); short endSentinel = in.readUnsignedByte(); if( endSentinel != 0x00 ) { throw new CorruptedFrameException( "endsentinel not as expected, was " + endSentinel + " while we expect 0x00" ); } out.add( result ); } else { // Not enough bytes yet in the frame. Wait on next pass with more bytes. } } else { // Not enough bytes yet to read out the length of the frame. Wait on next pass with more bytes. } } private int getMessageLength( ByteBuf in ) { int msglen1 = in.readUnsignedByte(); int msglen2 = in.readUnsignedByte(); int msglen3 = in.readUnsignedByte(); int msglen4 = in.readUnsignedByte(); return ((msglen4 * 256 * 256 * 256) + (msglen3 * 256 * 256) + (msglen2 * 256) + msglen1); } } I have a unit test that works fine like this: ByteBuf input = Unpooled.buffer(); input.writeBytes( .... ); Xml2StreamProtocolDecoder decoder = new Xml2StreamProtocolDecoder(); EmbeddedChannel channel = new EmbeddedChannel( decoder ); channel.…
answer count: 1
has comment: http://stackoverflow.com/comment/33360986
favorite count: 0
accepted answer: http://stackoverflow.com/a/22013029
has title: IllegalReferenceCount in my custom netty Decoder
tagged with: netty
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22013029
downvote count: 0
type: Question
score: 3
linked to: http://stackoverflow.com/q/20612430
tagged with: java
has comment: http://stackoverflow.com/comment/33361541
upvote count: 3

http://stackoverflow.com/q/22160970
has answer: http://stackoverflow.com/a/22161239
has body: Does anyone see a reason why this would simply return nothing? public static float sumDigits(int n) { float retVar = 0; while (n &gt; 10) { float d; for (d = 0; d &lt; n; d *= 10); d /= 10; retVar += n / d; n %= d; } n += n; return retVar; } I called it via System.out.println(sumDigits(123) + "");
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/22161051
tagged with: println
accepted answer: http://stackoverflow.com/a/22161239
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/22160981
tagged with: floating-point
has title: Odd behavior of a float method. Overloading?
type: Question
possible better answer: http://stackoverflow.com/a/22160981

http://stackoverflow.com/comment/33493327
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22083689
has text: @OldCurmudgeon Yes, it's static so you can't.

http://stackoverflow.com/comment/33355168
comment on: http://stackoverflow.com/q/22006620
score: 0
type: Comment
has text: From browser. I think we have to import certificate to the browser but the point here is what certificate I have to import to the browser?
type: QuestionComment

teradata
type: Tag
tag name: teradata
tags question: http://stackoverflow.com/q/22076879

http://stackoverflow.com/a/22081326
type: Answer
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/33489779
has body: I don't see how you can apply recursion like this. To compute f(n) you need to compute f(3n-1), for which you need to compute f(f(3n-1)), etc. It never terminates, so you get a stack overflow. In fact I don't know why you are recursing at all, if f(3) and f(5) both = 3n-1. Evidently you haven't understood your problem correctly.
downvote count: 0
answers question: http://stackoverflow.com/q/22081231
has comment: http://stackoverflow.com/comment/33489737

http://stackoverflow.com/q/22010145
has body: I want to know if it is okay to initialize the cluster and keyspace object just once, i.e. at the start of the application and use it throughout the application. Or shall I create a different object everytime I have to interact with the data store. There maybe multiple parallel reads and writes.
tagged with: cassandra
score: 0
tagged with: hector
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/22937067
accepted answer: http://stackoverflow.com/a/22937067
type: Question
has title: Cassandra Java Client (Hector) : Using the same cluster and keyspace objects throughout the application
answer count: 1

http://stackoverflow.com/comment/33435596
score: 0
type: Comment
has text: @NiksTyagi I'm not proposing a different solution than what LukeWillis provided; on the contrary, I agree with Luke's solution. I'd phrase it a little bit differently in code, but it would be a different expression of the same idea.
type: AnswerComment
comment on: http://stackoverflow.com/a/22051403

http://stackoverflow.com/a/22117806
upvote count: 11
score: 11
type: AcceptedAnswer
downvote count: 0
has body: To answer your question "what is the best practice here?": The binary files (jars) do not belong to source code management. To handle this, developers usually use some build tool with dependecy management which will download the jars from remote repositories. Most popular in Java world are: Maven - http://maven.apache.org Gradle - http://www.gradle.org SBT - http://www.scala-sbt.org/ (primarily for Scala, but works for Java as well) Ant - http://ant.apache.org The .classpath file is IDE specific (eclipse) "project" descriptor, the practice might differ from team to team, but the most common is probably to list these files in .gitignore and not to commit them. These files might contain developer specific settings that are not to be shared within a team, or developers might use different IDEs and the repository would get polluted with these files.
accepted answer of: http://stackoverflow.com/q/22113394
type: Answer
answers question: http://stackoverflow.com/q/22113394

http://stackoverflow.com/q/22022105
accepted answer: http://stackoverflow.com/a/22022256
has title: Troubles modifying a set with multiple iterators
has comment: http://stackoverflow.com/comment/33383119
has answer: http://stackoverflow.com/a/22022239
has body: I'd like to compare elements within a set, in order to merge elements too similar. In order to gain some time, I would like to erase similarities during the iteration. Here how I try to proceed: Iterator&lt;Personne&gt; i1 = personnes.iterator(); while (i1.hasNext()) { Personne personneObservee = i1.next(); Set&lt;Personne&gt; tmp = new HashSet&lt;Personne&gt;(); tmp.addAll(personnes); Iterator&lt;Personne&gt; i2 = tmp.iterator(); while (i2.hasNext()) { Personne autrePersonne = i2.next(); if (personneObservee.isSimilarTo(autrePersonne)) { personnes.remove(autrePersonne); } } result.add(personneObservee.toString()); } As you can guess from my presence here, it doesn't work, giving me this nice stacktrace : java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:926) at java.util.HashMap$KeyIterator.next(HashMap.java:960) at NameDetectorWithBenefits.mergeSamePersons(NameDetectorWithBenefits.java:41) at App.main(App.java:71) 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 org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297) at java.lang.Thread.run(Thread.java:744) At first, I thought i1 and i2 were iterating over the same set and that I would find an answer here. As a consequence, I create a temporary set each time. However, it didn't resolve the problem. Any ideas where the trouble might come from ?
favorite count: 0
linked to: http://stackoverflow.com/q/9268399
possible better answer: http://stackoverflow.com/a/22022196
answer count: 4
has comment: http://stackoverflow.com/comment/33383410
has answer: http://stackoverflow.com/a/22022196
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/22022256
upvote count: 1
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/22022165
linked to: http://stackoverflow.com/q/1655362
score: 0
tagged with: iterator

http://stackoverflow.com/comment/33448008
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22057739
has text: i don't know why when i try your regex with notepad++ it's OK but when i do it with Pattern-Matcher in Java, it's not work. It's OK for this string "aaaaaaaa123" too.

http://stackoverflow.com/a/25404917
downvote count: 0
has comment: http://stackoverflow.com/comment/99113239
type: Answer
upvote count: 19
has comment: http://stackoverflow.com/comment/59076044
score: 19
has comment: http://stackoverflow.com/comment/49163178
has comment: http://stackoverflow.com/comment/98965133
has comment: http://stackoverflow.com/comment/98856992
has body: This happend to me because I manually added an entry to my database with the id 0 (zero). In my case EclipseLink "couldn't" handle an id with zero. So I added following to my persistence.xml: &lt;property name="eclipselink.allow-zero-id" value="true"/&gt; This property says EclipseLink to handle zero as a valid id. [1] http://meetrohan.blogspot.de/2011/11/eclipselink-null-primary-key.html
answers question: http://stackoverflow.com/q/22026715

http://stackoverflow.com/q/22119983
has title: How to put whitespaces at url for request
type: AnsweredQuestion
tagged with: parsing
score: 0
has body: I need to pass some parameters to url. Later I will extract it and I need exactly this words. It's at jsp page: &lt;li&gt; &lt;a href="&lt;c:url value="/apartments?select=threestars"/&gt;"&gt;&lt;fmt:message key="nav.dropdown.threestars"/&gt;&lt;/a&gt; &lt;/li&gt; I need exactly set three stars instead threestars, for later parsing. How to put this whitespace, that it be compatible for get method, and was possibly to extract: String type = request.getParameter("select"); And value of type => three stars. How to solve this issue?
answer count: 1
has answer: http://stackoverflow.com/a/22119998
tagged with: java
tagged with: url
tagged with: jsp
tagged with: get
accepted answer: http://stackoverflow.com/a/22119998
type: Question

http://stackoverflow.com/q/22077939
type: Question
tagged with: android
tagged with: bitmap
has answer: http://stackoverflow.com/a/22079388
tagged with: java
has body: I have a DrawingView class, which implements painting methods. It works perfectly when I paint something, but after, by the time I try to save what I've painted in a jpg file I get a black image. I've read many answers here in Stack Overflow, and blogs which explain how to do that, and don't understand why I still having the black image. Here is my code: DrawingView: public class DrawingView extends View { private Path drawPath; private Paint drawPaint; private Paint canvasPaint; private Canvas drawCanvas; private Bitmap canvasBitmap; public DrawingView(Context context, AttributeSet attrs) { super(context, attrs); drawPath = new Path(); drawPaint = new Paint(); canvasPaint = new Paint(Paint.DITHER_FLAG); drawPaint.setColor(Color.BLACK); drawPaint.setAntiAlias(true); drawPaint.setStrokeWidth(5f); drawPaint.setStyle(Paint.Style.STROKE); drawPaint.setStrokeJoin(Paint.Join.ROUND); drawPaint.setStrokeCap(Paint.Cap.ROUND); } public DrawingView(Context context) { super(context); drawPath = new Path(); drawPaint = new Paint(); drawPaint.setColor(Color.BLACK); drawPaint.setAntiAlias(true); drawPaint.setStrokeWidth(5f); drawPaint.setStyle(Paint.Style.STROKE); drawPaint.setStrokeJoin(Paint.Join.ROUND); drawPaint.setStrokeCap(Paint.Cap.ROUND); } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); canvasBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); drawCanvas = new Canvas(canvasBitmap); } @Override protected void onDraw(Canvas canvas) { canvas.drawColor(0xFFFFFF); canvas.drawBitmap(canvasBitmap, 0, 0, canvasPaint); canvas.drawPath(drawPath, drawPaint); } @Override public boolean onTouchEvent(MotionEvent event) { float touchX = event.getX(); float touchY = event.getY(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: drawPath.moveTo(touchX, touchY); break; case MotionEvent.ACTION_MOVE: drawPath.lineTo(touchX, touchY); break; case MotionEvent.ACTION_UP: drawCanvas.drawPath(drawPath, drawPaint);…
tagged with: file
upvote count: 1
answer count: 1
type: UnansweredQuestion
has title: Saving a Bitmap into a file in Android
downvote count: 0
score: 1
favorite count: 0

http://stackoverflow.com/a/22118995
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22118972
answers question: http://stackoverflow.com/q/22118972
type: Answer
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/33556453
has comment: http://stackoverflow.com/comment/33556468
has body: your jsonObject is within the jsonArray Do like this JSONArray jarray= new JSONArray(EntityUtils.toString(responseEntity)); String error=jarray.getJSONObject(0).getString("error");

http://stackoverflow.com/comment/56258605
type: Comment
has text: @michaelscheper looks like it's noted in Omkar's answer already (just past the bolded region)
comment on: http://stackoverflow.com/a/25842661
score: 0
type: AnswerComment

http://stackoverflow.com/a/22050976
score: 1
has comment: http://stackoverflow.com/comment/33459302
has comment: http://stackoverflow.com/comment/33435211
has comment: http://stackoverflow.com/comment/33435518
upvote count: 1
has comment: http://stackoverflow.com/comment/33438441
has comment: http://stackoverflow.com/comment/33441735
has body: Edit - You can't run classic ASP on Tomcat, you need IIS (or IIS Express). Maybe Tomcat is serving your pages as if they are flat HTML, but it won't do anything with the server side code. Your conn string looks fine, but here are two things to try. First, replace SQLOLEDB with SQLNCLI. (SQLNCLI10 if you're using MSSQL 2008, or SQLNCLI11 if MSSQL 2012) Second - if you want to stick with SQLOLEDB, try using Initial Catalog=DLIDEV (instead of Database=DLIDEV)
has comment: http://stackoverflow.com/comment/33436924
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33436288
accepted answer of: http://stackoverflow.com/q/22049924
answers question: http://stackoverflow.com/q/22049924
has comment: http://stackoverflow.com/comment/33436180
has comment: http://stackoverflow.com/comment/33437330
type: Answer
has comment: http://stackoverflow.com/comment/33437938

http://stackoverflow.com/comment/33385340
type: AnswerComment
has text: +1 For the most right answer. For transparent images (such as: .png), I think you need to specify `BitmapFactory.Options`.
type: Comment
score: 1
comment on: http://stackoverflow.com/a/22023272

http://stackoverflow.com/comment/33505557
comment on: http://stackoverflow.com/a/22089941
score: 0
type: AnswerComment
has text: Your way of doing it is very RAW. At learning level, that is OK to gain some practice. To make it fairly tabulated, you need to find max length of each value in a column and based on that you need to set the `format` string.
type: Comment

http://stackoverflow.com/comment/33604079
type: QuestionComment
has text: I usually use manually to format eclipse or don't use it at all.
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22145942

http://stackoverflow.com/comment/34690760
has text: the brokers need to allocate buffers in order to read messages. in the consumer configuration page the `fetch.message.max.bytes` property says `The number of byes of messages to attempt to fetch for each topic-partition in each fetch request. These bytes will be read into memory for each partition, so this helps control the memory used by the consumer.`
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22294775
type: AnswerComment

http://stackoverflow.com/comment/33411444
type: Comment
type: QuestionComment
has text: take a look at this: http://stackoverflow.com/questions/11080067/insert-select-arabic-data-android-sqlite
score: 0
comment on: http://stackoverflow.com/q/22038257

http://stackoverflow.com/comment/33438491
comment on: http://stackoverflow.com/q/22053172
type: Comment
type: QuestionComment
score: 5
has text: The answer is in the question. Test if both objects have the same class.

http://stackoverflow.com/comment/33602933
type: Comment
type: QuestionComment
has text: You can use one `switch` statement
comment on: http://stackoverflow.com/q/22145281
score: 0

http://stackoverflow.com/comment/33384025
comment on: http://stackoverflow.com/q/22022359
type: Comment
type: QuestionComment
has text: Since the Map will contain objects anyway, what's there to gain?
score: 1

http://stackoverflow.com/comment/33453961
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/22062001
has text: @StephenC:- And I somewhat agree with the comment made by Phillip in that question:- `When a language is turing-complete, every added feature could theoretically be described as "syntactic sugar".`

http://stackoverflow.com/comment/33489603
has text: Strings in Java are always in Unicode, so can represent all characters, `byte[]` is binary data. In Java one hence has to say what encoding the bytes are in to convert between bytes and String. Unfortunately often I/O functions has a method version without encoding where the default encoding of the operating system is taken.
comment on: http://stackoverflow.com/a/22081245
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33526632
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22101935
has text: What exactly do you call the "requester" here?
score: 0

http://stackoverflow.com/q/22160704
upvote count: 1
answer count: 1
tagged with: awtrobot
has comment: http://stackoverflow.com/comment/33631352
tagged with: variables
favorite count: 0
has answer: http://stackoverflow.com/a/22160770
downvote count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33631342
type: Question
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33631365
has title: Java Robot Class Using Variables
has body: I have a very simple question, or at least I think it is simple. Currently I'm trying to use the robot class with variables. What I mean by this is the following (the variables "pass" are chars.) pass1 = 0; pass2 = 0; pass3 = 0; pass4 = 0; try{ Robot robot = new Robot(); robot.delay(2000); robot.mouseMove(1318, 322); robot.keyPress(pass1); robot.keyPress(pass2); robot.keyPress(pass3); robot.keyPress(pass4); } catch (AWTException e) {e.printStackTrace();} When I run the program, I get this error (keep in mind I only get this error when the portion of the code with "pass1, pass2...etc." is in it.): Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Invalid key code at java.awt.Robot.checkKeycodeArgument(Unknown Source) at java.awt.Robot.keyPress(Unknown Source) at Cracker$2.mouseReleased(Cracker.java:117) at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$000(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.Pro…

http://stackoverflow.com/q/22076058
answer count: 2
has title: Java method returns from an array list
has body: I was wondering that is this even possible? and what is the best way to do something like this: private int NotifCountBg(int countstyle) { return new int[]{ R.drawable.count_bevel, R.drawable.count_blue, R.drawable.count_green, R.drawable.count_orange, R.drawable.count_pink, R.drawable.count_purple, R.drawable.count_red, R.drawable.count_gray }[countstyle]; }
tagged with: optimization
tagged with: arraylist
possible better answer: http://stackoverflow.com/a/22076229
has answer: http://stackoverflow.com/a/22076103
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22076229
tagged with: arrays
type: Question
tagged with: android
accepted answer: http://stackoverflow.com/a/22076103
score: 0
tagged with: java

http://stackoverflow.com/a/22125776
upvote count: 2
type: Answer
score: 2
has body: You miss a { after the for (i = 0; i &lt; rows; i++) so that the for (int j = 0; j &lt; 5; j++) loop is inside the first one. Without that, this gives: for (i = 0; i &lt; rows; i++) l = a[i][0]; // End of the for i loop, now i = rows. for (int j = 0; j &lt; 5; j++) if (l &lt; a[i][j]) // i = rows: bang. l = a[i][j];
downvote count: 0
answers question: http://stackoverflow.com/q/22125730

http://stackoverflow.com/comment/34349466
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22080443
has text: @MartinJames 5 seconds was due to an issue with the tablet I was working with. I tried other devices and everything is fine. Thanks.
score: 0

http://stackoverflow.com/a/22086410
has body: you are not changing the message array. you are just getting a temp value x for each element then increasing it. even if you tried it would show error as it is declared as final . to increase the values you can do something like this int[] message = {82, 96, 103, 103, 27, 95, 106, 105, 96, 28}; final int key = 5; for (int i = 0; i&lt; message.length; i++) message[i]+=key;
answers question: http://stackoverflow.com/q/22086356
downvote count: 0
type: Answer
score: 3
upvote count: 3

http://stackoverflow.com/q/22025668
upvote count: 0
tagged with: inheritance
has comment: http://stackoverflow.com/comment/33389659
has comment: http://stackoverflow.com/comment/33389383
has body: This is my main. package oleg; import java.util.Scanner; public class main_class { public static void main(String[] args) { // TODO Auto-generated method stub int length,shetach,num; zura[] z1 = new zura[5]; for(int i=0;i&lt;z1.length;i++) { System.out.println("Enter 1,2,or 3"); Scanner s1=new Scanner(System.in); num = s1.nextInt(); switch (num) { case 1: z1[i] = new ribua(); System.out.println("Enter length"); length=s1.nextInt(); z1[i].set_info(); z1[i].shetach(length); System.out.println(shetach); ////// here is the error break; default: System.out.println("error 3"); break; } } } This is my first class from which I inherit. package oleg; public class zura { public int shetach(int shetach) { return shetach; } public void heikef() { } public void set_info() { } } This is my second class that extands the zura class package oleg; public class ribua extends zura { int length; public int shetach(int shetach) { shetach=length*length; return shetach; } public void set_info(int length) { this.length=length; } My problem is in the main class in the row System.out.println(shetach); How am I printing the shetach?
downvote count: 8
has comment: http://stackoverflow.com/comment/33389515
favorite count: 0
has comment: http://stackoverflow.com/comment/33390041
possible better answer: http://stackoverflow.com/a/22025802
score: -8
has comment: http://stackoverflow.com/comment/33389800
tagged with: extend
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22025802
has title: Syntax error with an extend in Java
has comment: http://stackoverflow.com/comment/33389969
tagged with: java
has answer: http://stackoverflow.com/a/22026036
accepted answer: http://stackoverflow.com/a/22026036
has comment: http://stackoverflow.com/comment/33389430
type: Question
answer count: 2

http://stackoverflow.com/q/22165920
tagged with: java
type: Question
answer count: 2
score: 0
has answer: http://stackoverflow.com/a/22166659
accepted answer: http://stackoverflow.com/a/22166659
has answer: http://stackoverflow.com/a/22166590
has body: I have a Custom Classloader : CustomClassLoader(extends ClassLoader) I have a class : IntegerPrint I load my class with my Custom ClassLoader. I was expecting SOPs in the below code to return the same value. But the first SOP prints "sun.misc.Launcher$AppClassLoader@.." &amp; second SOP prints "CustomClassLoader@.." Why it happens so? Please advise. public class IntegerPrinterTest { public static void main(String[] args) throws Exception { CustomClassLoader loader = new CustomClassLoader(IntegerPrinterTest.class.getClassLoader()); Class&lt;?&gt; clazz = loader.loadClass("IntegerPrinter"); System.out.println(IntegerPrinter.class.getClassLoader()); System.out.println(clazz.getClassLoader()); } }
tagged with: classloader
possible better answer: http://stackoverflow.com/a/22166590
has title: Class & ClassLoader
type: AnsweredQuestion

http://stackoverflow.com/comment/33377243
type: AnswerComment
type: Comment
has text: I wouldn't rely on hashcode to test if the two objects have the same state. `a equals b => a.hashCode = b.hashCode`, but the reverse is not always true (you can have collisions with your hash function)
comment on: http://stackoverflow.com/a/22018197
score: 0

http://stackoverflow.com/q/22039199
has title: Is Decorator Pattern respected?
has body: As described in many examples (for example http://en.wikipedia.org/wiki/Decorator_pattern#Java) abstract Decorator class only has to forward component methods. But In my case I need to override a method just in the abstract class (for type convertion): Component public interface PagerRepository&lt;T&gt; { List&lt;T&gt; getPageEntries(); } Concrete component public abstract class ConcretePagerRepository&lt;T&gt; implements PagerRepository&lt;T&gt; { // @Override ... } Abstract Decorator public abstract class PagerRepositoryConvertionDecorator&lt;T, S&gt; implements PagerRepository&lt;S&gt; { protected PagerRepository&lt;T&gt; repo; public PagerRepositoryConvertionDecorator(PagerRepository&lt;T&gt; repo) { this.repo = repo; } @Override public List&lt;S&gt; getPageEntries() { List&lt;T&gt; entities = this.repo.getPageEntries(); List&lt;S&gt; dtos = new ArrayList&lt;S&gt;(); for (T e : entities) { dtos.add(convert(e)); } return dtos; } protected abstract S convert(T entity); } Is this a correct decorator pattern implementation?
answer count: 1
has comment: http://stackoverflow.com/comment/33413000
has comment: http://stackoverflow.com/comment/33413179
has comment: http://stackoverflow.com/comment/33414425
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33412951
tagged with: design-patterns
has comment: http://stackoverflow.com/comment/33413094
has comment: http://stackoverflow.com/comment/33413197
score: 0
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22039435

http://stackoverflow.com/comment/33358806
comment on: http://stackoverflow.com/a/22007072
score: 0
type: AnswerComment
has text: That was it all this time! Thank you!
type: Comment

http://stackoverflow.com/q/22106570
type: Question
tagged with: transactions
tagged with: java
tagged with: hibernate
tagged with: db2
score: 0
has title: Java and Hibernate, lock objects during update/write but reads always allowed
tagged with: locking
answer count: 1
has comment: http://stackoverflow.com/comment/33535481
has body: My application uses Java, Hibernate, and IBM DB2 database. I would like to use pessimistic locking when updating and writing data so other threads need to wait for the resource to be available before trying to update it. However, I want threads to always be able to read data (regardless of whether it is locked or not i.e. transactions are open for the data), and read operations never lock data. What isolation level would fulfil this in Hibernate and IBM DB2? Thanks.
has comment: http://stackoverflow.com/comment/33536329
has comment: http://stackoverflow.com/comment/33566815
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33556533
has answer: http://stackoverflow.com/a/22128500

http://stackoverflow.com/comment/33453923
type: QuestionComment
comment on: http://stackoverflow.com/q/22061923
has text: Try again by downloading the latest jar version, or you may have to limit your batch size.!
score: 0
type: Comment

http://stackoverflow.com/comment/33565413
type: Comment
type: QuestionComment
has text: For your example, would you want it to also match 7? Will the sequence always increment by 1?
comment on: http://stackoverflow.com/q/22123706
score: 0

http://stackoverflow.com/comment/33497176
comment on: http://stackoverflow.com/q/22085993
score: 0
has text: Don't quote me on this, but besides being able to run from inside an IDE, I recall there is a `mvn run` (I think it's a plugin you need to enable)
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33538979
score: 0
has text: It seems that for this particular android library I need to instruct gradle to push to a directory in the filesystem instead of pushing to maven. Not sure how to do that though.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22086273

http://stackoverflow.com/q/22092292
has comment: http://stackoverflow.com/comment/33513857
has answer: http://stackoverflow.com/a/22098086
favorite count: 0
has comment: http://stackoverflow.com/comment/33508439
tagged with: spring
has body: I started to use Spring for Dependency Injection. I added the jar spring-context-4.0.1 I added @Configuration to a class @Configuration public class SpringConfig { @Bean public CategoryDAO categoryDAO() { return new HibernateCategoryDAO(); } } where public interface CategoryDAO{ } and public class HibernateCategoryDAO implements CategoryDAO { } However, when I try to @Autowired it in a Component (more precisely a Repository) @Repository public class MyCategoryManager implements CategoryManager { @Autowired CategoryDAO categoryDAO; } categoryDAO is null. Furthermore, I see stepping through the code in debug mode that it never executes the Configuration file. What am I missing? I don't want to use XML in Spring but do I still need to add the application-context file? EDIT: Following @Gummyball answer, I added the configuration. It didn't help. I initialize MyCategoryManager class using Reflections util: Set&lt;?&gt; managers = Reflections.getSubTypesOf(CategoryManager.class); Could it be the reason? how can I overcome it?
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33515814
accepted answer: http://stackoverflow.com/a/22098086
tagged with: java
possible better answer: http://stackoverflow.com/a/22092520
type: Question
upvote count: 4
answer count: 2
tagged with: dependency-injection
has answer: http://stackoverflow.com/a/22092520
has comment: http://stackoverflow.com/comment/33514684
downvote count: 0
has title: Spring java configuration is not being called
linked to: http://stackoverflow.com/q/8075790
score: 4

javacard
tag name: javacard
tags question: http://stackoverflow.com/q/22069525
type: Tag
tags question: http://stackoverflow.com/q/22030748
tags question: http://stackoverflow.com/q/22015237

http://stackoverflow.com/comment/33380332
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22019896
has text: you mean the pom.properties in the maven-archiver folder?

http://stackoverflow.com/a/22142018
upvote count: 1
has body: Just place the vars in the select like this SELECT d.* FROM ( SELECT cs.*, @rowcnt := IF(@grp != cs.subject, 1, @rowcnt + 1) AS rowcnt, @grp := cs.subject FROM ( SELECT * FROM (select @rowcnt :=0, @grp :='') a,students ORDER BY subject, marks DESC ) cs ) d WHERE d.rowcnt &lt; 3;
type: Answer
has comment: http://stackoverflow.com/comment/33599697
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/22141776

http://stackoverflow.com/comment/48573684
type: AnswerComment
has text: Yes, your solution with CAS is better. Did you use Unsafe.compareAndSwapInt(...)?
type: Comment
comment on: http://stackoverflow.com/a/30141019
score: 0

http://stackoverflow.com/comment/33522264
type: Comment
comment on: http://stackoverflow.com/a/22099331
has text: List ist not faster then ArrayList. List<String> l = new ArrayList<String>() is just an initialization with the specific type ArrayList which implements the List interface. This has nothing todo with fastness
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33385416
comment on: http://stackoverflow.com/a/22023527
has text: @duelingwarlord can you post your changes please
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/q/22043181
tagged with: excel
tagged with: java
tagged with: displaytag
has title: WARNING: Error setting expression '6578706f7274' with value '[Ljava.lang.String;@73e4'
type: Question
answer count: 1
tagged with: struts2
score: 0
has answer: http://stackoverflow.com/a/26268378
has body: I am using display-tag in struts2 to export table into excel sheet. When I download the sheet, it downloads fine but gives this warning: com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn WARNING: Error setting expression '6578706f7274' with value '[Ljava.lang.String;@17e4898' ognl.ExpressionSyntaxException: Malformed OGNL expression: 6578706f7274 [ognl.ParseException: Encountered " &lt;INT_LITERAL&gt; "7274 "" at line 1, column 9. Was expecting one of: &lt;EOF&gt; "," ... "=" ... "?" ... "||" ... "or" ... "&amp;&amp;" ... "and" ... "|" ... "bor" ... "^" ... "xor" ... "&amp;" ... "band" ... "==" ... "eq" ... "!=" ... "neq" ... "&lt;" ... "lt" ... "&gt;" ... "gt" ... "&lt;=" ... "lte" ... "&gt;=" ... "gte" ... "in" ... "not" ... "&lt;&lt;" ... "shl" ... "&gt;&gt;" ... "shr" ... "&gt;&gt;&gt;" ... "ushr" ... "+" ... "-" ... "*" ... "/" ... "%" ... "instanceof" ... "." ... "(" ... "[" ... &lt;DYNAMIC_SUBSCRIPT&gt; ... ] at ognl.Ognl.parseExpression(Ognl.java:112) at com.opensymphony.xwork2.ognl.OgnlUtil.compile(OgnlUtil.java:241) at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:213) at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:186) at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:173) at com.opensymphony.xwork2.ognl.OgnlValueStack.setParameter(OgnlValueStack.java:151) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:292) ...... ...... and so on..... My display table in JSP file is: &lt;display:table class='displayTable' id='orderList' name='orderList' list='orderList' export="true" requestURI="listOrders" cellpadding="0" cellspacing="0" decorator="com.sanyasi.Decorator.OrderListingDataEntryDecorator"&gt; &lt;display:setProperty name="export.excel" value="true"/&gt; &lt;display:setProperty name="export.excel.filename" value="order_details.xls" /&gt; &lt;display:column title="Action" property="action"&gt;&lt;/display:column&gt; &lt…
type: UnansweredQuestion

http://stackoverflow.com/comment/33395063
has text: HTTP requests for unit tests? Sounds fishy given your interface (doesn't throw any kind of exception; what if the request fails?)
type: Comment
comment on: http://stackoverflow.com/q/22028580
score: 0
type: QuestionComment

http://stackoverflow.com/comment/33556669
type: Comment
comment on: http://stackoverflow.com/a/22118737
score: 0
type: AnswerComment
has text: `String arr[] = myString.Split(":", 2);` might be safer in this instance in case there are any wanted `:` in the second half of the String.

http://stackoverflow.com/comment/33642531
type: Comment
has text: @Raghunandan This is the line that throws, because of the lack of `implements` declaration
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22167230

http://stackoverflow.com/comment/33430638
score: 0
has text: I don't understand why your image is 205x100. Can you try ChartUtilities.writeScaledChartAsPNG(new FileOutputStream(new File("test.png")), chart, 205, 100, 4, 3); ? For me, this creates an image file 820x300.
type: Comment
comment on: http://stackoverflow.com/a/22046953
type: AnswerComment

http://stackoverflow.com/a/22119856
has comment: http://stackoverflow.com/comment/33559378
has comment: http://stackoverflow.com/comment/33559610
upvote count: 1
answers question: http://stackoverflow.com/q/22119606
type: Answer
downvote count: 0
score: 1
has body: Application is missing This is a lint error, and happens because you don't seem to have any Java class extending Application, which is mentioned in your manifest. You can ignore this error as you have done, since this is not a mandatory part of the application. build.gradle error This is a known issue with Android Studio. Workarounds can be found in this question. Deprecated methods This is because getHeight() and getWidth() were deprecated in API 13. You can use DisplayMetrics: DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int height = metrics.heightPixels; int width = metrics.widthPixels;

http://stackoverflow.com/comment/33519340
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22098667
has text: `Long.MAX_VALUE` is `0x7fffffffffffffffL`.
score: 0

http://stackoverflow.com/a/22122838
has comment: http://stackoverflow.com/comment/33563822
has comment: http://stackoverflow.com/comment/33568709
upvote count: 1
has comment: http://stackoverflow.com/comment/33567120
has comment: http://stackoverflow.com/comment/33567098
score: 1
has comment: http://stackoverflow.com/comment/33564716
has comment: http://stackoverflow.com/comment/33568620
has comment: http://stackoverflow.com/comment/33564226
has comment: http://stackoverflow.com/comment/33564303
has body: There is no .get() method for ExifInterface. LatitudeBox = exif.get(ExifInterface.TAG_GPS_LONGITUDE_REF); Did you perhaps mean: LatitudeBox.setText(exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF)); EDIT: I found it. Look at the last variable here: Button CameraButton; ImageView ImageBox; EditText LatitudeBox, LongitudeBox; String IMG = ImageBox.toString(); You haven't assigned a value to your ImageView ImageBox. So when you ImageBox.toString(), you receive a NullPointerException. Change initialization of IMG to something like: String IMG = "filename.txt";
downvote count: 0
has comment: http://stackoverflow.com/comment/33564073
answers question: http://stackoverflow.com/q/22122755
has comment: http://stackoverflow.com/comment/33566154
has comment: http://stackoverflow.com/comment/33565189
has comment: http://stackoverflow.com/comment/33563805
has comment: http://stackoverflow.com/comment/33567194
type: Answer
has comment: http://stackoverflow.com/comment/33568650
has comment: http://stackoverflow.com/comment/33567329
has comment: http://stackoverflow.com/comment/33568417
has comment: http://stackoverflow.com/comment/33567249

tuples
tags question: http://stackoverflow.com/q/22124831
tag name: tuples
type: Tag

http://stackoverflow.com/a/22104149
has comment: http://stackoverflow.com/comment/33530735
accepted answer of: http://stackoverflow.com/q/22104097
type: Answer
upvote count: 4
has comment: http://stackoverflow.com/comment/33530107
downvote count: 0
has comment: http://stackoverflow.com/comment/33530817
has comment: http://stackoverflow.com/comment/33530455
has body: when I uncomment the block of code below (which is currently commented out), the program never stops. I do not understand why? Note the javadoc of Thread#interrupt() If this thread is blocked in an invocation of the wait(), wait(long), or wait(long, int) methods of the Object class, or of the join(), join(long), join(long, int), sleep(long), or sleep(long, int), methods of this class, then its interrupt status will be cleared and it will receive an InterruptedException. So if you uncomment your code, the flag gets lifted and your if never executes. Does Thread Class maintains a static list of all the Threads that is currently running and by calling Thread.currentThread() The Thread.currentThread() method is declared as (Oracle JDK 7) public static native Thread currentThread(); In other words, it is natively implemented, probably in C code. We can assume, given the javadoc, that, somewhere, a reference to all threads is stored. The currently executing one is returned. Similarly, the Thread#isInterrupted() method calls private native boolean isInterrupted(boolean ClearInterrupted); which is also natively implemented. But we can assume it uses some boolean-style flag.
score: 4
has comment: http://stackoverflow.com/comment/33530126
has comment: http://stackoverflow.com/comment/33530968
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22104097
has comment: http://stackoverflow.com/comment/33530566

http://stackoverflow.com/q/22168437
has body: We have a Java project that we wish to distribute to users. It does not use any Java features beyond Java 1.5, so we wish it to run on Java 1.5 and above. At this point, you might rightfully note that Java 1.6 is the oldest available currently, so why target Java 1.5? However, that does not change the generic nature of the question of cross-compiling for older versions. So, the way one usually starts cross-compilation attempts is by specifying -source 1.5 and -target 1.5 options to javac, at which point one gets a famous warning about -bootclasspath not being set: $ javac -source 1.5 -target 1.5 Test.java warning: [options] bootstrap class path not set in conjunction with -source 1.5 1 warning Now, according to Oracle blog post, as well as official documentation, the correct practice for cross-compilation is to: To use javac from JDK N to cross-compiler to an older platform version, the correct practice is to: Use the older -source setting. Set the bootclasspath to compile against the rt.jar (or equivalent) for the older platform. If the second step is not taken, javac will dutifully use the old language rules combined with new libraries, which can result in class files that do not work on the older platform since references to non-existent methods can get included. For instance, quoting official documentation: % javac -source 1.6 -target 1.6 -bootclasspath jdk1.6.0/lib/rt.jar \ -extdirs "" OldCode.java This is great and has been answered many times before both on Stack Overflow and the rest of the Internet. However, none of the resources we have found seem to indicate where to actually find the rt.jar for older versions of Java. As an example, JDK 1.7 does not ship with rt.jar except its own: $ find jdk-1.7.0_45 -name rt.jar jdk-1.7.0_45/jre/lib/rt.jar That makes one think that in order to obtain rt.jar for Java 1.6, for instance, one needs to download JDK 1.6. But then two questions arise: if we download JDK 1.6, we might as well use that for compilation instead o…
tagged with: cross-compiling
type: Question
accepted answer: http://stackoverflow.com/a/31681921
upvote count: 9
has title: Where to find bootstrap classes when cross-compiling for older versions of Java?
has comment: http://stackoverflow.com/comment/33646263
tagged with: java
score: 9
answer count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33644820
favorite count: 0
has answer: http://stackoverflow.com/a/31681921
tagged with: javac
possible better answer: http://stackoverflow.com/a/28645619
has answer: http://stackoverflow.com/a/28645619
type: AnsweredQuestion

http://stackoverflow.com/q/22025537
has title: set Radius Of Rotation Affine transform
linked to: http://stackoverflow.com/q/5593066
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33389525
answer count: 0
has comment: http://stackoverflow.com/comment/33394387
has body: I have two questions regarding AffineTransforms. First, how do I change the radius of rotation so that my leaf (see code) rotes on a dime rather than over a big radius. A rotation of 45 degrees moves the leaf practically to the bottom of the screen and although it does rotate, this is not the result I'm looking for (I'm trying to get a leaf blowing in the wind effect here). Also, after I rotate the leaf, how do I recolor it. Only the edges are coming out green, the inside is coming out white. import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.geom.AffineTransform; import java.awt.geom.GeneralPath; import javax.swing.JFrame; public class MovingLeaf extends JFrame { public static void main(String[] args) { new MovingLeaf(); } public MovingLeaf() { super("Beach"); setSize(600, 500); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); GeneralPath leaf = new GeneralPath(); leaf.moveTo(300,100); leaf.quadTo(400,100,400,200); leaf.lineTo(380,180); leaf.lineTo(380,160); leaf.lineTo(360,170); leaf.lineTo(365,150); leaf.lineTo(335,155); leaf.lineTo(340,135); leaf.lineTo(320,140); leaf.lineTo(320,120); leaf.lineTo(305,125); leaf.lineTo(300,100); leaf.closePath(); g2d.setColor(Color.green); g2d.fill(leaf); AffineTransform rotation = new AffineTransform(); rotation.setToRotation(Math.toRadians(45)); g2d.fill(leaf); g2d.draw(rotation.createTransformedShape(leaf)); } }
tagged with: swing
type: Question
tagged with: graphics
has comment: http://stackoverflow.com/comment/33390458
tagged with: java
score: 0

http://stackoverflow.com/comment/33531790
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22104521
has text: Dont have Screens for win 7 now . but it was like a normal Menu.
type: Comment

http://stackoverflow.com/a/22164832
answers question: http://stackoverflow.com/q/22098187
has body: Finally I've found a workaround : private Object changeValueToSuitDestType(Object value, Class&lt;?&gt; destType) { if (destType == null || value == null) { return value; } String typeString = destType.toString(); String valueString = value.toString(); boolean isNull = TextUtils.isEmpty(valueString) || valueString.equalsIgnoreCase("null"); if (typeString.equalsIgnoreCase("boolean") || destType == Boolean.class) { if (isNull) { if (destType == Boolean.class) { return null; } else { return false; } } else { return Boolean.parseBoolean(value.toString()); } } else if (typeString.equalsIgnoreCase("byte") || destType == Byte.class) { if (isNull) { if (destType == Byte.class) { return null; } else { return 0; } } else { return Byte.parseByte(value.toString()); } } else if (typeString.equalsIgnoreCase("short") || destType == Short.class) { if (isNull) { if (destType == Short.class) { return null; } else { return 0; } } else { return Short.parseShort(value.toString()); } } else if (typeString.equalsIgnoreCase("int") || destType == Integer.class) { if (isNull) { if (destType == Integer.class) { return null; } else { return 0; } } else { return Integer.parseInt(value.toString()); } } else if (typeString.equalsIgnoreCase("long") || destType == Long.class) { if (isNull) { if (destType == Long.class) { return null; } else { return 0L; } } else { return Long.parseLong(value.toString()); } } else if (typeString.equalsIgnoreCase("float") || destType == Float.class) { if (isNull) { if (destType == Float.class) { return null; } else { return 0F; } } else { return Float.parseFloat(value.toString()); } } else if (typeString.equalsIgnoreCase("double") || destType == Double.class) { if (isNull) { if (destType == Double.class) { return null; } else { return 0D; } } else { return Double.parseDouble(value.toString()); } } else if (typeString.equalsIgnoreCase("char") || destType == Character.class) { if (isNull) { if (destType == Character.class) { return null; } else { return '\u0000'; } } e…
type: Answer
accepted answer of: http://stackoverflow.com/q/22098187
score: 0
type: AcceptedAnswer

http://stackoverflow.com/a/25064451
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/22104531
upvote count: 1
has body: DriverManager relies on JDBC spec (and driver's compliance with it) where it's noted that: The driver should return "null" if it realizes it is the wrong kind of driver to connect to the given URL. This will be common, as when the JDBC driver manager is asked to connect to a given URL it passes the URL to each loaded driver in turn. Hive's JDBC driver violates the contract and throws exception instead which interpreted by DriverManager as "driver understands the URL, but cannot establish connection for some reason". That would be fine in case DriverManager call driver's acceptsURL() not only as part of getDriver(url), but also as part of getConnection(url) method, but it doesn't.
has comment: http://stackoverflow.com/comment/77166793
type: Answer

http://stackoverflow.com/q/22108839
upvote count: 0
favorite count: 0
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/33538547
tagged with: java
downvote count: 2
has answer: http://stackoverflow.com/a/22108921
has title: Problems with layouts and understanding warnings
has body: My questions are about android programing with eclipse. First problem is LinearLayout. I've created new LinearLayouts but their names are the same. In my opinion they are LinearLayout1 and LinearLayout2 but, this does not happen. This photo: Second problem is: I'm just learning java, so I don't understand warnings.
type: Question
score: -2
has answer: http://stackoverflow.com/a/22108918
answer count: 2

http://stackoverflow.com/q/22149129
type: AnsweredQuestion
tagged with: java
score: 0
has title: How to get Paragraph absolut coordinates with iText?
has body: I need to get absolute coordinates of paragraph that I already added to the document and join an image near that. Generally my problem is below: I have a checklist with images (checked/unchecked) before each line. I already did that but if check item takes for example 2 lines, then second line starts from the begining of the page. What I want is to start this second line from position that first line is starting. It is equal to if the second line will have a margin. Thanks in advance!
has comment: http://stackoverflow.com/comment/33613048
accepted answer: http://stackoverflow.com/a/22173976
has comment: http://stackoverflow.com/comment/33613879
answer count: 1
tagged with: android
tagged with: http://stackoverflow.com/tag/pdf
tagged with: pdf-generation
has comment: http://stackoverflow.com/comment/33611902
tagged with: itext
has comment: http://stackoverflow.com/comment/33611774
has answer: http://stackoverflow.com/a/22173976
type: Question

file
tags question: http://stackoverflow.com/q/22067456
type: Tag
tags question: http://stackoverflow.com/q/22141236
tags question: http://stackoverflow.com/q/22154311
tags question: http://stackoverflow.com/q/22122317
tags question: http://stackoverflow.com/q/22049525
tags question: http://stackoverflow.com/q/22062317
tags question: http://stackoverflow.com/q/22097461
tags question: http://stackoverflow.com/q/22138758
tags question: http://stackoverflow.com/q/22138460
tags question: http://stackoverflow.com/q/22153423
tags question: http://stackoverflow.com/q/22068749
tags question: http://stackoverflow.com/q/22117498
tags question: http://stackoverflow.com/q/22087436
tag name: file
tags question: http://stackoverflow.com/q/22102029
tags question: http://stackoverflow.com/q/22129573
tags question: http://stackoverflow.com/q/22129057
tags question: http://stackoverflow.com/q/22006081
tags question: http://stackoverflow.com/q/22010955
tags question: http://stackoverflow.com/q/22117181
tags question: http://stackoverflow.com/q/22149331
tags question: http://stackoverflow.com/q/22167650
tags question: http://stackoverflow.com/q/22013330
tags question: http://stackoverflow.com/q/22050368
tags question: http://stackoverflow.com/q/22131409
tags question: http://stackoverflow.com/q/22155518
tags question: http://stackoverflow.com/q/22121667
tags question: http://stackoverflow.com/q/22006981
tags question: http://stackoverflow.com/q/22097171
tags question: http://stackoverflow.com/q/22085706
tags question: http://stackoverflow.com/q/22092594
tags question: http://stackoverflow.com/q/22149000
tags question: http://stackoverflow.com/q/22132964
tags question: http://stackoverflow.com/q/22139036
tags question: http://stackoverflow.com/q/22099648
tags question: http://stackoverflow.com/q/22153980
tags question: http://stackoverflow.com/q/22058779
tags question: http://stackoverflow.com/q/22018657
tags question: http://stackoverflow.com/q/22014745
tags question: http://stackoverflow.com/q/22077939
tags question: http://stackoverflow.com/q/22087039
tags question: http://stackoverflow.com/q/22021619
tags question: http://stackoverflow.com/q/22167174
tags question: http://stackoverflow.com/q/22156066
tags question: http://stackoverflow.com/q/22007414
tags question: http://stackoverflow.com/q/22011409
tags question: http://stackoverflow.com/q/22141468
tags question: http://stackoverflow.com/q/22132044
tags question: http://stackoverflow.com/q/22032175

http://stackoverflow.com/comment/33614695
has text: Just for curiosity: For the animations are you using libgdx animation? If not i would suggest to do that.
score: 0
comment on: http://stackoverflow.com/q/22151098
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22147354
upvote count: 3
has comment: http://stackoverflow.com/comment/33607233
has body: You should to get response error code. I made little example: int code = con.getResponseCode(); if (code == HttpURLConnection.HTTP_NOT_FOUND) { // Handle error } else { // Do your work }
downvote count: 1
has comment: http://stackoverflow.com/comment/33607083
has comment: http://stackoverflow.com/comment/33607767
type: Answer
answers question: http://stackoverflow.com/q/22147277
score: 2

http://stackoverflow.com/comment/33624806
type: QuestionComment
comment on: http://stackoverflow.com/q/22157049
score: 0
has text: Use a class that extends JDialog. Set it to modal with .setModal(true) then show it to the user. You can design its init method to build it anyway you like, and it will behave just like a JOptionPane, assuming you expose something like a .getDialogResult(), which returns true/false depending on what they clicked, and a .getValue() which returns the user input data.
type: Comment

http://stackoverflow.com/q/22078386
upvote count: 2
tagged with: java
tagged with: hibernate
accepted answer: http://stackoverflow.com/a/22080476
type: Question
has body: i am building a shopping cart using jsp and hibernate. i am filtering the content by brand size and price using checkboxes the checked checkboxes are returned to the class where hql query exists. so i want i single hql query that can handle this. as like if one of the parameter like size is empty (means user doesnt uses it to filter the content ) than an empty string is passed to the hql query which returns any value... so is there anything possible that all values can be retrived in where clause for empty string or some other alternative except coding different methods for different parameter...
answer count: 2
has comment: http://stackoverflow.com/comment/33486221
tagged with: sql
downvote count: 0
possible better answer: http://stackoverflow.com/a/22080364
has answer: http://stackoverflow.com/a/22080476
favorite count: 0
has answer: http://stackoverflow.com/a/22080364
has title: get all the values in where clause for empty stirng using hibernate
type: AnsweredQuestion
score: 2
has comment: http://stackoverflow.com/comment/33483355

http://stackoverflow.com/a/22163590
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33636216
has comment: http://stackoverflow.com/comment/33642170
answers question: http://stackoverflow.com/q/22163457
upvote count: 2
has comment: http://stackoverflow.com/comment/33636154
has comment: http://stackoverflow.com/comment/33636867
type: Answer
has body: You will need the activity context to call that method. When you create the class in activity, pass this as the context by using a constructor. save the context in class member variable and use it in class methods.

http://stackoverflow.com/comment/33622579
type: Comment
score: 0
comment on: http://stackoverflow.com/q/22155812
type: QuestionComment
has text: Use the old triple-xor technique. (Of course, you still need temps for your array indexes.)

http://stackoverflow.com/a/22012554
type: Answer
answers question: http://stackoverflow.com/q/22012143
has body: req.getSession() Returns the current HttpSession associated with this request or, if there is no current session and create is true, returns a new session. Looking closely at the first part of the definition, I guess that the session object associated with "this" request object is still not empty. And even if it is it will return a new "object" which of-course is "NOT-NULL".
score: 0

http://stackoverflow.com/a/25087136
has comment: http://stackoverflow.com/comment/39034628
type: Answer
answers question: http://stackoverflow.com/q/22053306
upvote count: 7
has body: In the technote "Programming With Assertions: Control Flow Invariants" the following code is given: void foo() { for (...) { if (...) return; } assert false; // Execution should never reach this point! } But the following note is given as well: Note: Use this technique with discretion. If a statement is unreachable as defined in the Java Language Specification, you will get a compile time error if you try to assert that it is not reached. Again, an acceptable alternative is simply to throw an AssertionError. You may not expect an AssertionError to be thrown when assertions are turned off. As AssertionError constructors are public, and since there is likely no substitution for AssertionError(String message, Throwable cause), I guess that you should expect them even if they are turned off. Throwing an AssertionError on unreachable code (i.e. without any real expression to be evaluated) will never slow down the code, as Jon Skeet suggested, so it won't hurt with regards to performance. So in the end throwing the AssertionError seems OK.
score: 7
has comment: http://stackoverflow.com/comment/48435977
downvote count: 0

http://stackoverflow.com/comment/33614587
comment on: http://stackoverflow.com/q/22151597
type: Comment
type: QuestionComment
score: 0
has text: the accepted answer here shows how to get a string from the user : http://stackoverflow.com/questions/5287538/how-to-get-basic-user-input-for-java you can use this to create your File object

http://stackoverflow.com/comment/102898675
comment on: http://stackoverflow.com/a/40934100
score: 1
type: AnswerComment
has text: It is good approach, but it does not work with native queries. -_-
type: Comment

http://stackoverflow.com/q/22118116
score: 3
upvote count: 3
tagged with: java
tagged with: multithreading
type: Question
has answer: http://stackoverflow.com/a/22118298
has body: I am trying to run a certain task every Friday in a week at any time. So I decided to use ScheduledExecutorService for this but so far I have seen examples which shows how to run task every few minutes. Below is my code which I adopted to run every day at 5 AM in the morning. How do I use this to run task every Friday in a week at any time? public static void main(String[] args) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(5); Date aDate = new Date(); Calendar with = Calendar.getInstance(); with.setTime(aDate); int hour = with.get(Calendar.HOUR_OF_DAY); int intDelayInHour = hour &lt; 5 ? 5 - hour : 24 - (hour - 5); System.out.println("Current Hour: " + hour); System.out.println("Comuted Delay for next 5 AM: " + intDelayInHour); scheduler.scheduleAtFixedRate(new Runnable() { public void run() { try { getDataFromDatabase(); } catch (Exception ex) { ex.printStackTrace(); // or loggger would be better } } }, intDelayInHour, 24, TimeUnit.HOURS); } protected static void getDataFromDatabase() { // TODO Auto-generated method stub } Can anyone provide an example how would I do this?
answer count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33554879
favorite count: 0
tagged with: scheduledexecutorservice
type: UnansweredQuestion
has title: How to run a particular task every Friday in a week at any time using ScheduledExecutorService?
has answer: http://stackoverflow.com/a/51986489

http://stackoverflow.com/comment/33568912
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22125625
has text: Yep, I think you are right, I checked documentation.
score: 0

http://stackoverflow.com/comment/33616277
comment on: http://stackoverflow.com/q/22152089
type: QuestionComment
type: Comment
has text: Can you share a bit more, like the script or class?
score: 0

http://stackoverflow.com/q/22086082
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33497885
tagged with: java
tagged with: hibernate
has answer: http://stackoverflow.com/a/22087266
tagged with: eclipse
type: Question
tagged with: jpa
has comment: http://stackoverflow.com/comment/33497714
has title: Hibernate: Many to many deletion deleting entire table
score: 0
has comment: http://stackoverflow.com/comment/33497891
answer count: 1
has comment: http://stackoverflow.com/comment/33497743
has body: I have a ManyToMany relationship between Doctor &amp; Patient through a entity AppointmentRequest. However, when I delete 1 Doctor every Doctor &amp; Patient associated through the AppointmentRequest table is deleted. Here is my code: Doctor public class Doctor implements Person { private List&lt;AppointmentRequest&gt; appointmentRequests = new ArrayList&lt;AppointmentRequest&gt;(); @OneToMany(mappedBy="doctor", targetEntity = AppointmentRequest.class, fetch=FetchType.EAGER, cascade= CascadeType.ALL) public List&lt;AppointmentRequest&gt; getAppointmentRequests() { return this.appointmentRequests; } } Patient public class Patient implements Person { private List&lt;AppointmentRequest&gt; appointmentRequests = new ArrayList&lt;AppointmentRequest&gt;(); @OneToMany(mappedBy="patient", targetEntity = AppointmentRequest.class, fetch=FetchType.EAGER, cascade= CascadeType.ALL) public List&lt;AppointmentRequest&gt; getAppointmentRequests() { return this.appointmentRequests; } } AppointmentRequest public class AppointmentRequest { private Doctor doctor; private Patient patient; @ManyToOne (fetch = FetchType.EAGER, cascade= CascadeType.ALL) @JoinColumn(name="doctor_id") public Doctor getDoctor() { return doctor; } @ManyToOne (fetch = FetchType.EAGER, cascade= CascadeType.ALL) @JoinColumn(name="patient_id") public Patient getPatient() { return patient; } } Doctor delete code public void deleteDoctor(String doctor_name) { Session session = sessionFactory.openSession(); Doctor doctor = new Doctor(); try { session.beginTransaction(); Query query = session.getNamedQuery("Doctor.findByName"); query.setString("name", doctor_name); doctor = (Doctor) query.uniqueResult(); if(doctor == null) { throw new NullPointerException(); } List&lt;AppointmentRequest&gt; appointments = doctor.getAppointmentRequests(); for(AppointmentRequest appointment:appointments) { appointment.setDoctor(null); } session.delete(doctor); session.getTransaction().commit(); } finally { session.close(); } }

http://stackoverflow.com/q/22147080
type: Question
accepted answer: http://stackoverflow.com/a/22147560
possible better answer: http://stackoverflow.com/a/22147225
tagged with: java
has comment: http://stackoverflow.com/comment/33606053
has body: I have results from an array and I want to print them in a figure eight and below is the code that does this: tempString2 = "\t" + trainTrack[5]+ "\n" + trainTrack[4] + "\t\t" + trainTrack[6] + "\n"+ trainTrack[3] + "\t\t" + trainTrack[7]+ "\n" + trainTrack[2] + "\t\t" + trainTrack[8] + "\n"+ trainTrack[1] + "\t\t" + trainTrack[9] + "\n\t" + trainTrack[0] + "\n"+ trainTrack[10] + "\t\t" + trainTrack[18] + "\n" + trainTrack[11] + "\t\t" + trainTrack[17] + "\n" + trainTrack[12] + "\t\t" + trainTrack[16] + "\n"+ trainTrack[13] + "\t\t" + trainTrack[15] + "\n\t" + trainTrack[14]; and below is what is shown when I output the string: [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] but is there a way of making it more presentable, with rounder edges so it actually looks like an eight?
has comment: http://stackoverflow.com/comment/33606825
score: 0
has answer: http://stackoverflow.com/a/22147560
answer count: 2
has comment: http://stackoverflow.com/comment/33606072
has comment: http://stackoverflow.com/comment/33606042
upvote count: 1
tagged with: arrays
downvote count: 1
has title: Print array results in a figure eight pattern
tagged with: console
favorite count: 0
has answer: http://stackoverflow.com/a/22147225
type: AnsweredQuestion

http://stackoverflow.com/q/22134366
tagged with: java
linked to: http://stackoverflow.com/q/13710524
type: Question
has body: My program is throwing a NullPointerException error upon trying to call the paint method of a ship. import java.awt.*; import java.awt.event.*; public class Ship extends Polygon implements ActionListener, KeyListener { final static Point[] shape = new Point[4]; final static Point START_POSITION = new Point(400, 300); private int windowX; private int windowY; Point pull; public Ship(int maxX, int maxY) { super(shape, START_POSITION, 0); windowX = maxX; windowY = maxY; shipInit(); init(shape); Point[] pointArray = getPoints(); pull = new Point(0, 0); } public void shipInit() { shape[0] = new Point(0, 0); shape[1] = new Point(30, 10); shape[2] = new Point(0, 20); shape[3] = new Point(10, 10); } public void paint(Graphics brush) { brush.setColor(Color.white); Point[] points = getPoints(); if (position.x &gt; windowX) { position.x -= windowX; } else if (position.x &lt; 0) { position.x += windowX; } else if (position.y &gt; windowY) { position.y -= windowY; } else if (position.y &lt; 0) { position.x += windowY; } for (int i = 0; i &lt; points.length; i++) { int x1; int y1; int x2; int y2; if (i == points.length - 1) { x1 = (int) points[i].x; y1 = (int) points[i].y; x2 = (int) points[0].x; y2 = (int) points[0].y; } else { x1 = (int) points[i].x; y1 = (int) points[i].y; x2 = (int) points[i + 1].x; y2 = (int) points[i + 1].y; } brush.drawLine(x1, y1, x2, y2); } } public void move() { position.x += 2; position.y += 5; // position.y += 1; } public void accelerate(double acceleration) { pull.x += (acceleration * Math.cos(Math.toRadians(rotation))); pull.y += (acceleration * Math.sin(Math.toRadians(rotation))); } public void keyPressed(KeyEvent e) { int keyPressed = e.getKeyCode(); if (keyPressed == KeyEvent.VK_W) System.out.println("Hi"); if (keyPressed == KeyEvent.VK_UP) { accelerate(5); position.x += pull.x; position.y += pull.y; } if (keyPressed == KeyEvent.VK_RIGHT) { rotation += 5; } if (keyPressed == KeyEvent.VK_LEFT) { rotation -= 5; } } public void keyReleased(KeyEvent …
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/33585357
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22134507
has title: Java NullPointerException in call to paint()

http://stackoverflow.com/a/22138301
type: Answer
upvote count: 4
has body: It depends on what data type you are working with. If the value is a String, you can use the substring method: String ticket = "123456"; String allButLast = ticket.substring(0, ticket.length() - 1); // becomes "12345" If it is an int value, you can use integer division: int ticket = 123456; int allButLast = ticket / 10; // truncates to 12345 If it's a float or double, you can divide by 10 and cast to an int or you can use Math.floor() to drop the fractional part after dividing by 10. EDIT: Based on the edit to your question, you can do this: public class TicketNumber { public static void main(String[] args) { String ticketNumber; int ticket, prefix, remainder, lastDigit; ticketNumber = JOptionPane.showInputDialog(null, "Enter the six digit ticket number", "Verify Ticket", JOptionPane.INFORMATION_MESSAGE); ticket = Integer.parseInt(ticketNumber); prefix = ticket / 10; lastDigit = ticket % 10; remainder = prefix % 7; boolean valid = lastDigit == remainder; JOptionPane.showMessageDialog(null, "Valid Ticket" + "\n" + valid); } } Note that Ticket, etc. are not good Java variable names; they should start with lower-case letters (e.g., ticket). I made that change in my version of the code. Note that the calculation can be written more tersely as: boolean valid = (ticket % 10) == ((ticket / 10) % 7); and you can eliminate the variables prefix, remainder, and lastDigit.
answers question: http://stackoverflow.com/q/22138273
score: 4
downvote count: 0
has comment: http://stackoverflow.com/comment/33591293

http://stackoverflow.com/a/22139934
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/33594443
upvote count: 1
answers question: http://stackoverflow.com/q/22139645
downvote count: 0
has body: i guess when you make a object as Students it may like follow : public class Students { private int StudentId = 0; private String StudentName = "defaultName"; private int StudentAge = 18; public int getStudentId() { return StudentId; } public void setStudentId(int studentId) { StudentId = studentId; } public String getStudentName() { return StudentName; } public void setStudentName(String studentName) { StudentName = studentName; } public int getStudentAge() { return StudentAge; } public void setStudentAge(int studentAge) { StudentAge = studentAge; } } maybe you will find something wrong on your object student!

http://stackoverflow.com/q/22121031
has comment: http://stackoverflow.com/comment/33560170
has title: My program gives me java.lang.ArrayIndexOutOfBoundsException: 1
has comment: http://stackoverflow.com/comment/33560331
favorite count: 0
has comment: http://stackoverflow.com/comment/33560899
score: -4
possible better answer: http://stackoverflow.com/a/22121980
has comment: http://stackoverflow.com/comment/33560225
has comment: http://stackoverflow.com/comment/33560238
type: AnsweredQuestion
upvote count: 0
accepted answer: http://stackoverflow.com/a/22121329
has body: I am writing a program to translate a phrase into pig latin by creating an array filled with the individual words of a string that the user inputs, then going through every individual word and changing it to pig latin, and printing it to the console. I usually get the error above when on the while() loop of my method: package UpGAMING; public class Methods { public void Translator(String s, String[] index, int location) { while (index[location].length() &gt; 0) { location++; if(index.length &gt; 0)s = s + index[location].substring(1) + index[location].substring(0,1).toLowerCase() + "ay"; System.out.println(s); } } } If I change the condition to simply while(true) I get the error of java.lang.ArrayIndexOutOfBounds: 2 on this line: if(index.length &gt; 0)s = s + index[location].substring(1) + index[location].substring(0,1).toLowerCase() + "ay"; Here is my class containing the main() method: package UpGAMING; import java.util.Scanner; public class Basic { public static void main(String[] args) { Methods method = new Methods(); Scanner keyboard = new Scanner(System.in); String input; int indexer = 1; String ss = ""; System.out.println("Enter the word or phrase you want to translate to Pig Latin:"); input = keyboard.next(); String[] output = input.split("\\s+"); method.Translator(input, output, indexer); System.out.println(); } } Please provide a code block of what my code should look like as I am not an experienced programmer.
has comment: http://stackoverflow.com/comment/33560228
tagged with: java
has comment: http://stackoverflow.com/comment/33560255
type: Question
answer count: 2
downvote count: 4
has answer: http://stackoverflow.com/a/22121329
has comment: http://stackoverflow.com/comment/33560154
has answer: http://stackoverflow.com/a/22121980

http://stackoverflow.com/a/22105439
score: 2
accepted answer of: http://stackoverflow.com/q/22104803
downvote count: 0
type: AcceptedAnswer
has body: Your problem isn't on the shown code. Your problem is on you class Store. EXPLANATION: What is happening is that while you iterate over Store.getAll() sockets, another socket is being inserted or removed from the same structure retrieved by Store.getAll() (much likely subclass of java.util.Collection - e.g.: LinkedList, ArrayList,HashMap, etc..). REASON: You cannot iterate over Collection while the same collection is being modified. See ConcurrentModificationException javadocs SOLUTION: Anyway, to solve your problem on the snippet shown, I suggest that you clone the structure returned by Store.getAll(). But be aware that this structure will be obsolete on its content, because there are sockets being inserted or removed in your Store class. TIP: (this won't solve your problem but will help you to program fashionably) To iterate over elements from some structure use this in Java: for(Socket s : Store.getAll()) { try { if (s.getInputStream().available() != 0) { byte[] buffer = new byte[s.getInputStream().available()]; s.getInputStream().read(buffer); new Processing(s, buffer); } } catch (IOException e) { e.printStackTrace(); } }
answers question: http://stackoverflow.com/q/22104803
upvote count: 2
type: Answer

http://stackoverflow.com/a/22163276
score: 0
has body: I had a miserable time with this on Android. You can use WebScarab to intercept browser/website communications (and you can choose to see the raw bytes as well). Basically, you set up a local proxy in your browser. It's a nice little solution. Note that if you're using the MultipartEntityBuilder from Apache HTTP Tools, you have to chain the addPart() methods together since they each return a new MulitpartEntityBuilder, as in the following code: mpeb = MultipartEntityBuilder.create() .addTextBody("action", "upload") .addPart("repo_upload_file", fbp.getBody()) .addTextBody("sesskey", jso.getString("sesskey")) .addTextBody("repo_id", "3") .addTextBody("itemid", jso.getString("itemid")) .addTextBody("author", jso.getString("author")) .addTextBody("savepath", "/") .addTextBody("title", current_filename);
type: Answer
has comment: http://stackoverflow.com/comment/33636233
has comment: http://stackoverflow.com/comment/33636113
answers question: http://stackoverflow.com/q/22163149
has comment: http://stackoverflow.com/comment/33635886

http://stackoverflow.com/q/22032693
tagged with: eclipse-plugin
favorite count: 0
tagged with: eclipse-rcp
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33406664
tagged with: swt
upvote count: 1
has answer: http://stackoverflow.com/a/22090783
type: Question
has title: Tooltip visibility in SWT
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22247142
has body: I have a Class which displays a label. When I hover the mouse over that label there is a empty tooltip being displayed. I would want to remove that tooltip(I mean I dont want it to be shown). I can easily say tooltip.setVisibility(false) but I should not change the code inside the MouseTrackListener Anonymous class. I need to use a toltip property pr anythin else so that when I extend this class I need to have an option to easily set the visibility of this tooltip if needed or disable it if not needed. Here is my Code snippet (JAVA SWT) tooltip = new ToolTip(parent.getShell(), SWT.NONE); MouseTrackListener mouseTrackListener = new MouseTrackListener() { @Override public void mouseEnter(MouseEvent e) { if (text != null &amp;&amp; !text.isEmpty()) { tooltip.setLocation(Display.getCurrent().getCursorLocation().x, Display.getCurrent().getCursorLocation().y + TOOLTIP_OFFSET_Y); tooltip.setVisible(true); } } @Override public void mouseExit(MouseEvent e) { if (text != null &amp;&amp; !text.isEmpty()) { tooltip.setVisible(false); } } @Override public void mouseHover(MouseEvent e) { }}; label.addMouseTrackListener(mouseTrackListener); iconLabel.addMouseTrackListener(mouseTrackListener);
answer count: 2
downvote count: 0

http://stackoverflow.com/q/22075866
upvote count: 1
type: Question
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/22075955
downvote count: 3
has body: What is system.in.read() here, where can i find every detail and use of it and where it is in documentation? in classes or whaterver ? char ch; ch=(char)System.in.read(); System.out.println("you typed"+ch);
answer count: 3
linked to: http://stackoverflow.com/q/1066318
score: -2
favorite count: 0
has answer: http://stackoverflow.com/a/22075927
accepted answer: http://stackoverflow.com/a/22075927
possible better answer: http://stackoverflow.com/a/22075955
has comment: http://stackoverflow.com/comment/33478480
has answer: http://stackoverflow.com/a/22075962
linked to: http://stackoverflow.com/q/11871520
has title: What is System.in.read()

http://stackoverflow.com/comment/33430629
has text: Do you really need to use that code base in particular? There is a MUCH more efficient solution than that.
comment on: http://stackoverflow.com/q/22048819
score: 0
type: Comment
type: QuestionComment

javafx
tags question: http://stackoverflow.com/q/22021811
tags question: http://stackoverflow.com/q/22135000
type: Tag
tags question: http://stackoverflow.com/q/22005328
tags question: http://stackoverflow.com/q/22034244
tags question: http://stackoverflow.com/q/22068996
tags question: http://stackoverflow.com/q/22135431
tags question: http://stackoverflow.com/q/22158087
tags question: http://stackoverflow.com/q/22139615
tags question: http://stackoverflow.com/q/22072321
tags question: http://stackoverflow.com/q/22057446
tags question: http://stackoverflow.com/q/22112402
tags question: http://stackoverflow.com/q/22028773
tag name: javafx
tags question: http://stackoverflow.com/q/22096104
tags question: http://stackoverflow.com/q/22156371
tags question: http://stackoverflow.com/q/22125479
tags question: http://stackoverflow.com/q/22085346
tags question: http://stackoverflow.com/q/22099723
tags question: http://stackoverflow.com/q/22014950
tags question: http://stackoverflow.com/q/22149137
tags question: http://stackoverflow.com/q/22088646
tags question: http://stackoverflow.com/q/22117710
tags question: http://stackoverflow.com/q/22125787
tags question: http://stackoverflow.com/q/22161586
tags question: http://stackoverflow.com/q/22056566
tags question: http://stackoverflow.com/q/22005115
tags question: http://stackoverflow.com/q/22166610
tags question: http://stackoverflow.com/q/22088119
tags question: http://stackoverflow.com/q/22150691
tags question: http://stackoverflow.com/q/22066799
tags question: http://stackoverflow.com/q/22096259
tags question: http://stackoverflow.com/q/22070261
tags question: http://stackoverflow.com/q/22074746
tags question: http://stackoverflow.com/q/22053937
tags question: http://stackoverflow.com/q/22128153
tags question: http://stackoverflow.com/q/22050427
tags question: http://stackoverflow.com/q/22088217
tags question: http://stackoverflow.com/q/22066555
tags question: http://stackoverflow.com/q/22076643
tags question: http://stackoverflow.com/q/22025332
tags question: http://stackoverflow.com/q/22079274
tags question: http://stackoverflow.com/q/22093145
tags question: http://stackoverflow.com/q/22090362
tags question: http://stackoverflow.com/q/22122127
tags question: http://stackoverflow.com/q/22023333
tags question: http://stackoverflow.com/q/22093943
tags question: http://stackoverflow.com/q/22129711

http://stackoverflow.com/comment/35557861
has text: @NaveenRamawat The jaxb plugin specifies the following files from eclipselink: com.sun.tools.xjc_2.2.0.jar, com.sun.xml.bind_2.2.0v201004141950.jar and javax.xml.bind_2.2.0v201105210649.jar. Do I need to link to some different files?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22090510

http://stackoverflow.com/comment/33621381
comment on: http://stackoverflow.com/a/22134949
type: Comment
score: 1
has text: I think you and I are actually in loud agreement. `Point` and `Point3D` are basically value objects - they're not alternative implementations of a common interface.
type: AnswerComment

http://stackoverflow.com/comment/33590622
has text: This is a web application running on a Tomcat server. Would the user be Tomcat?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22137928

count
tags question: http://stackoverflow.com/q/22119709
tags question: http://stackoverflow.com/q/22081681
tag name: count
type: Tag
tags question: http://stackoverflow.com/q/22119497

http://stackoverflow.com/comment/71090027
has text: The duplicate is not marked with a java tag. Is this really a duplicate?
score: 2
comment on: http://stackoverflow.com/q/22048692
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/34442110
type: Comment
has text: Ah, okay. That's cute, and makes sense. Thanks for the suggestion!
comment on: http://stackoverflow.com/a/22596525
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33552771
type: Comment
score: 0
type: AnswerComment
has text: Actually I want to fetch Image from Sqlite and show it in imageview. So, In what method we have to use for it
comment on: http://stackoverflow.com/a/22116684

http://stackoverflow.com/a/22035339
score: 2
answers question: http://stackoverflow.com/q/22035087
has comment: http://stackoverflow.com/comment/33406906
has comment: http://stackoverflow.com/comment/33407286
accepted answer of: http://stackoverflow.com/q/22035087
upvote count: 2
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33406969
type: Answer
has body: Update 2022 Parts of this answer are obsolete. The javafxpackager tool has been removed from the jdk and replaced with the jpackage tool. If you wish to accomplish a similar task today, I encourage you to use the joackage tool either by: Executing jpackage directly from the command line or a shell script similarly to, but different from, this answer, OR Executing joackage from a maven or grade build tool plugin, for example: the “badass jlink plugin” for gradle OR the Akmsn jpackage-maven-plugin. Sample Build Script Here is a script which creates and installs a .app bundle on OS X. #! /bin/bash ################ # package.sh # # Packages java code as a native OS X application # # - Fetches source for a Java Swing HelloWorld application from the web # - Compiles the source # - Packages the source into a native Mac application # - Installs the native Mac application # - Runs the native Mac Application # # Requires: # OS X 10.8+ # Java 8b77+ (http://jdk8.java.net/download.html) # super user rights on the execution account # # To Use: # chmod +x package.sh # ./package.sh # As the script executes sudo commands, enter your # superuser password as needed. ################ # select java version set JAVA_HOME=`/usr/libexec/java_home -v 1.8` $JAVA_HOME/bin/java -version # cleanup work directory and any existing application install if [ -d work ]; then rm -rf work fi if [ -d /Applications/HelloWorld.app ]; then sudo rm -rf /Applications/HelloWorld.app fi # create work directory and use it mkdir work cd work # fetch a simple HelloWorldSwing sample java source from the web mkdir start cd start curl -O http://docs.oracle.com/javase/tutorial/uiswing/examples/start/HelloWorldSwingProject/src/start/HelloWorldSwing.java cd .. # compile the HelloWorldSwing java source $JAVA_HOME/bin/javac start/HelloWorldSwing.java # create a jar file $JAVA_HOME/bin/jar cvf HelloWorldSwing.jar start/*.class # make an executable jar file $JAVA_HOME/bin/javafxpackager -createjar -srcdir . -appclass start…
has comment: http://stackoverflow.com/comment/33406938

http://stackoverflow.com/a/23689560
upvote count: 2
downvote count: 0
has body: Choose 'Automatically select an unused port' in debug configuration. Local server will start every time on different port, but it should solve your problem.
has comment: http://stackoverflow.com/comment/41443986
type: Answer
answers question: http://stackoverflow.com/q/22066739
score: 2

http://stackoverflow.com/a/23243811
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/22127945
upvote count: 2
has body: I had the same issue. Issue was that mysql JDBC connector was not in my bash_profile. So i add on .bash_profile : export jdbc mysql connector to classpath export CLASSPATH=${HOME}/sonar/mysql-connector-java-5.1.23/mysql-connector-java-5.1.23-bin.jar:$CLASSPATH Hope it could help
has comment: http://stackoverflow.com/comment/51529771
type: Answer

http://stackoverflow.com/comment/33530538
comment on: http://stackoverflow.com/a/22104418
type: AnswerComment
score: 0
type: Comment
has text: @Cruncher 'twas added after my original comment, I cannot answer what will be asked, only what has been :).

http://stackoverflow.com/comment/35089355
type: AnswerComment
has text: i just post my check result , and i will edit my content. it may import wrong jar , or poster want to use the method is undefined in jar.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22143112

http://stackoverflow.com/comment/33366215
comment on: http://stackoverflow.com/a/22009568
has text: lol :) I thought you have devoted my answer :) Actually I use this snippet in my projects
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33561966
comment on: http://stackoverflow.com/q/22121982
score: 3
has text: Let's see your code and what you've got so far.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33385847
score: 0
has text: I've never liked storing images directly in the database. I always prefer to store a path to the images, and have the image in a server side location.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22023504

http://stackoverflow.com/comment/33566872
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/22120747
has text: @Nopiforyou: What I don't understand is why you are not *literally* matching the splitted words. In what cases can it happen that a pattern is a *substring* of a word, but not the word itself. I mean for example if your pattern is "banana" and your word is "asdasdbanana", why are you interested in that? Why don't you just split the string in such a way that you can just check all the words for *equality* with any of the dictionary words, rather than matching proper substrings.

http://stackoverflow.com/q/22114110
has comment: http://stackoverflow.com/comment/33548197
answer count: 0
type: UnansweredQuestion
tagged with: java
type: Question
score: 0
has comment: http://stackoverflow.com/comment/33549025
has body: I want to create directory using relative paths in android. But it fails using relative paths. I got success only after absolute path. Sample Code : (Relative Path)(Not working for directory, Working for files) System.setProperty("user.dir", getFilesDir().getAbsolutePath()); File logDirectory = new File("sample"); // Success will be always false here. boolean success = logDirectory.mkdirs(); // But I got success in file creation with relative path. FileOutputStream fos = new FileOutputStream("sample.txt"); fos.write(1); fos.close(); Sample Code : (Absolute Path)(Working in both files and folder) System.setProperty("user.dir", getFilesDir().getAbsolutePath()); File logDirectory = new File(System.getProperty("user.dir") + "/sample"); // Success will be always true here. boolean success = logDirectory.mkdirs(); FileOutputStream fos = new FileOutputStream("sample.txt"); fos.write(1); fos.close();
has title: Android File Class mkdirs with relative paths doesn't working as like absolute paths
tagged with: android

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

http://stackoverflow.com/a/22059281
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33449649
accepted answer of: http://stackoverflow.com/q/22059220
has comment: http://stackoverflow.com/comment/33450358
has comment: http://stackoverflow.com/comment/33449908
has comment: http://stackoverflow.com/comment/33449550
type: Answer
has comment: http://stackoverflow.com/comment/33449614
score: 2
has comment: http://stackoverflow.com/comment/33449405
has comment: http://stackoverflow.com/comment/33450493
has body: In case your helloWorld.java file is in a package, you can run as follows : C:\Users\Admin\Documents\NetBeansProjects\javaAssignment\src\ java packageName.helloWorld Run the code from outside the helloworld package directory i.e from src directory (C:\Users\Admin\Documents\NetBeansProjects\javaAssignment\src) Also check if the name of your java file is the same as your class name (helloWorld.java) Also it seems that the name of your package is helloworld (all in small letters) however the folder name is helloWorld (note that W is capital) both the names need to match.
has comment: http://stackoverflow.com/comment/33449689
has comment: http://stackoverflow.com/comment/33450345
upvote count: 2
answers question: http://stackoverflow.com/q/22059220

http://stackoverflow.com/q/22153843
has comment: http://stackoverflow.com/comment/36868122
tagged with: unit-testing
type: Question
possible better answer: http://stackoverflow.com/a/28349562
has title: Google App Engine Data Store Unit Tests With Maven
has answer: http://stackoverflow.com/a/28349562
answer count: 2
tagged with: datanucleus
accepted answer: http://stackoverflow.com/a/31656168
has body: Trying to get my GAE 1.9.0 project's unit tests to run using maven 3.2.1. Data Store Related Tests Fail : java.util.ServiceConfigurationError: com.google.appengine.tools.development.LocalRpcService: Provider com.google.appengine.api.datastore.dev.LocalDatastoreV4Service could not be instantiated: java.lang.NoClassDefFoundError: com/google/apphosting/datastore/DatastoreV4$LookupRequestOrBuilder I understand this means i'm missing a dependency. Can't seem to find a doc on how to properly configure my pom.xml for datastore tests. The test crashes when I call helper.setup() on the helper: public final LocalServiceTestHelper helper = new LocalServiceTestHelper( new LocalDatastoreServiceTestConfig(), new LocalTaskQueueTestConfig(), new LocalBlobstoreServiceTestConfig(), new LocalUserServiceTestConfig())); referenced: https://developers.google.com/appengine/docs/java/tools/maven#junit_dependencies_optional https://developers.google.com/appengine/docs/java/tools/localunittesting#Java_Writing_Datastore_and_memcache_tests the test dependencies in my pom.xml com.google.appengine appengine-testing ${appengine.target.version} test com.google.appengine appengine-api-stubs ${appengine.target.version} test com.google.appengine appengine-api-labs ${appengine.target.version} test org.springframework spring-test 3.2.1.RELEASE test junit junit 4.11 test spring spring-mock 1.0.2 test rest of the stack trace: at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112) 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 org.apache.maven.surefire.util.ReflectionUt…
downvote count: 0
score: 8
favorite count: 0
has comment: http://stackoverflow.com/comment/36844231
upvote count: 8
tagged with: google-app-engine
has comment: http://stackoverflow.com/comment/36223379
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/34624262
tagged with: java
has answer: http://stackoverflow.com/a/31656168

http://stackoverflow.com/comment/33644304
type: AnswerComment
comment on: http://stackoverflow.com/a/22042264
score: 0
type: Comment
has text: I've tried it, but still-same problem I have sa[0]="2000;Generl;All equipment2001;General;All equipment2002;General;All equipment2003;General;All Equipment". May it be because <item> isn't the first element that I have. I have the following xml order : <systemList>*everything from example I have in the question*</system List>

http://stackoverflow.com/comment/33483553
comment on: http://stackoverflow.com/q/22078472
type: Comment
type: QuestionComment
score: 0
has text: When asking a question tell us the exact error you are getting, there is a better change we can help you if we know what to look for. BTW, where did you declare `numDTF` ?

http://stackoverflow.com/a/22064769
has body: it's really complicated understand what you really wanna..take a look some change..but I think you need to reestructure the objects. what you wanna do? can you explain better? public class GuitarAmp { //This is what I want to get from this class public GuitarAmpSound sound; --&gt; the sound you pass before call the constructor sound.setVoolume(x); sound.setDistortSetting(Y) so you pass the object sound with the attributes full of information public GuitarAmp(GuitarAmpSound sound){ this.sound = sound; } public void changeVolume(int newVolume){ this.sound.setVolume(newVolume); } } Here is the pickup class. public class GuitarPickup { public GuitarAmpSound pickupSound; public void Connect(GuitarString strings[], GuitarAmp amp) { pickupSound = new GuitarAmpSound(); //This is where I need to set it for(int i = 0; i&lt;strings.length; i++) { amp.setSound(strings[i].getSound()); } } }
answers question: http://stackoverflow.com/q/22064422
score: 0
type: Answer

http://stackoverflow.com/q/22163764
downvote count: 0
has answer: http://stackoverflow.com/a/22163917
score: 1
tagged with: string
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/22163796
tagged with: regex
linked to: http://stackoverflow.com/q/1720191
has title: parsing strings with or without regex
tagged with: java
answer count: 3
has body: I am trying create a basic file system to imitate the terminal. I am currently stuck on getting the names after the command. My first thought was to use regex to parse the commands. Examples of commands would be: mkdir hello ls cd hello However to account for many whitespaces an input could be mkdir hello. I was wondering if there is another way without using regex? Also I was curious to which method is faster? With or without regex?
upvote count: 1
accepted answer: http://stackoverflow.com/a/22163796
possible better answer: http://stackoverflow.com/a/22163832
has answer: http://stackoverflow.com/a/22163832
type: AnsweredQuestion

http://stackoverflow.com/q/22164648
has comment: http://stackoverflow.com/comment/33637977
favorite count: 0
has comment: http://stackoverflow.com/comment/33637854
tagged with: database-connection
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22165029
upvote count: 1
has title: Why this code is not updating the database & giving exception?
has comment: http://stackoverflow.com/comment/33637934
tagged with: java
downvote count: 3
tagged with: date
type: Question
has comment: http://stackoverflow.com/comment/33637991
score: -2
has comment: http://stackoverflow.com/comment/33638172
has comment: http://stackoverflow.com/comment/33637838
answer count: 1
has body: I am trying to update the database with a date received from a textfield in date format. But its not working and giving me a java.lang.NumberFormatException: For input string "". Please help. SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy"); String date = i5t1.getText(); try { i5Date=(Date) formatter.parse(date); } catch(ParseException p) { p.printStackTrace(); } PreparedStatement i5ps = i5conn.prepareStatement("Select * from DailyAnalysis"); i5ps.setDate(1, new java.sql.Date(i5Date.getTime())); ResultSet i5rs = i5ps.executeQuery(); EDITS : I am adding a small program, but this one doesnt compile due to some error, reference to Date is ambiguous, both class java.util.Date in java.util and class java.sql.Date match Date i5Date1=formatter.parse(date1); This sql date and util date are very much confusing. import java.awt.EventQueue; import javax.swing.*; import java.awt.*; import javax.swing.event.*; import java.awt.event.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.*; import java.util.*; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; public class Problem { JFrame frame; JPanel panel; JButton saveButton; JTextField dateField; JLabel dateLabel; public Problem() { frame = new JFrame(); panel = new JPanel(); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); dateLabel = new JLabel("Date"); dateField = new JTextField(20); saveButton = new JButton("Save"); saveButton.addActionListener(new ActionListener() {@Override public void actionPerformed(ActionEvent ae) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection i5conn = DriverManager.getConnection("Jdbc:Odbc:TomsJava"); SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy"); String date1 = dateField.getText(); try { Date i5Date1=formatter.parse(date1); } catch(ParseException p) { p.printStackTrace(); } String query= "Select * from DailyAnalysis where Date…

http://stackoverflow.com/q/22091880
accepted answer: http://stackoverflow.com/a/22091934
answer count: 3
score: 2
has answer: http://stackoverflow.com/a/28127975
downvote count: 0
favorite count: 0
upvote count: 2
tagged with: interface
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22091934
tagged with: java
has answer: http://stackoverflow.com/a/28127892
has comment: http://stackoverflow.com/comment/33507761
type: Question
has title: Comparable Interface
has comment: http://stackoverflow.com/comment/33507491
possible better answer: http://stackoverflow.com/a/28127892
tagged with: comparable
has body: Why is it beneficial to implement the Comparable interface instead of just defining my own compareTo() method? Another thing, how does the java.util.Arrays.sort(Object[] o) method relate to the Comparable interface such that I HAVE to implement the Comparable interface to be able to use the Arrays.sort(Object[] o) method?
has comment: http://stackoverflow.com/comment/33507738

http://stackoverflow.com/comment/33407056
has text: your generated random might be out of array bound try first + (int)(Math.random()*(last-first) -1 )
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22035667
score: 0

http://stackoverflow.com/comment/33485657
comment on: http://stackoverflow.com/a/22079075
type: Comment
score: 0
has text: @DavidWallace Or OP could add `break;` at the end of every `if`. I wouldn't do (or recommend) that, but OP used it in the "quit" check.
type: AnswerComment

http://stackoverflow.com/a/22068574
has comment: http://stackoverflow.com/comment/33466902
downvote count: 2
has body: Here you go with an example using the third-party open-source Joda-Time framework. Joda-Time is a popular replacement for the outmoded† java.util.Date &amp; .Calendar classes bundled with Java. DateTime now = DateTime.now(); // Current date-time using JVM's default time zone. DateTime pastDate = null; for ( int i = 0; i &lt; 12; i++ ) { pastDate = now.minusMonths( i ); String monthNumberAsString = String.format("%02d", pastDate.getMonthOfYear() ); // Pad leading zero if need be. System.out.println( monthNumberAsString + " - " + pastDate.getYear() ); } Generates 02 - 2014 01 - 2014 12 - 2013 11 - 2013 10 - 2013 09 - 2013 08 - 2013 07 - 2013 06 - 2013 05 - 2013 04 - 2013 03 - 2013 † Java 8 brings the new java.time package to supplant the old java.util.Date/Calendar classes. These new classes are inspired by Joda-Time, and defined by JSR 310.
score: 0
answers question: http://stackoverflow.com/q/22068406
has comment: http://stackoverflow.com/comment/33469388
type: Answer
upvote count: 2

http://stackoverflow.com/a/22162416
answers question: http://stackoverflow.com/q/22162398
has comment: http://stackoverflow.com/comment/33634111
has body: import java.awt.*; import javax.imageio.ImageIO; import javax.swing.*; import java.awt.event.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.awt.*; import javax.swing.*; import java.awt.event.*; public class imagebut extends JFrame { public static void main(String args []) { imagebut w = new imagebut(); w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); w.setSize(300,300); w.setVisible(true); } public imagebut() { setLayout(null); // :-) PicPanel mainPanel = new PicPanel("picturename.jpg"); mainPanel.setBounds(0,0,500,500); add(mainPanel); } class PicPanel extends JPanel{ private BufferedImage image; private int w,h; public PicPanel(String fname){ //reads the image try { image = ImageIO.read(getClass().getResource(fname)); w = image.getWidth(); h = image.getHeight(); } catch (IOException ioe) { System.out.println("Could not read in the pic"); //System.exit(0); } } public Dimension getPreferredSize() { return new Dimension(w,h); } //this will draw the image public void paintComponent(Graphics g){ super.paintComponent(g); g.drawImage(image,0,0,this); } } }
score: 1
has comment: http://stackoverflow.com/comment/33634396
has comment: http://stackoverflow.com/comment/33634188
has comment: http://stackoverflow.com/comment/33634429
upvote count: 2
has comment: http://stackoverflow.com/comment/33634450
downvote count: 1
has comment: http://stackoverflow.com/comment/33634343
has comment: http://stackoverflow.com/comment/33635558
has comment: http://stackoverflow.com/comment/33634657
has comment: http://stackoverflow.com/comment/33635345
type: Answer
has comment: http://stackoverflow.com/comment/33634545
has comment: http://stackoverflow.com/comment/33634866

http://stackoverflow.com/a/22142771
downvote count: 0
has body: Include \n in the delimiter file = new Scanner(new File(filename+".txt")).useDelimiter(",| |\\n");
type: Answer
answers question: http://stackoverflow.com/q/22142456
upvote count: 1
score: 1

http://stackoverflow.com/comment/33462493
has text: The fields without anything in between commas should have null values. When there's only whitespace in the string, just treat it as a normal string. If you can't use third-party libraries, you're screwed - you're going to have to re-invent so much stuff; sane date/time handling (until Java 8), handy utility functions, etc. Granted you can't just put stuff on at a whim (licenses. after all), but there are a number of solutions that can help with that (setting up a local mirror of a Maven repository which limits to approved licenses, etc).
type: Comment
comment on: http://stackoverflow.com/q/22028487
score: 0
type: QuestionComment

http://stackoverflow.com/comment/33426967
has text: Do you need the actual class of the instance or the type you pass as a parameter? Ie, if you pass a `A` but ultimately the argument is a `B` where `B` extends `A`, what should happen?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22046474

http://stackoverflow.com/comment/101865394
type: Comment
comment on: http://stackoverflow.com/a/25610634
score: 0
has text: Why do you assume that OP does not have jdk installed? I would think otherwise from his question.
type: AnswerComment

http://stackoverflow.com/q/22101118
has body: I use org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor for executing my application tasks. I would like to limit number on parallel running tasks (threads) for some number and until all (or some percentage of running tasks) threads are done do not execute new threads. How can I control, or how can I get information, how many threads does ThreadPoolExecutor is actually running to control executing new tasks? Is there some way how to solve it via ThreadPoolExecutor or do I need do it my way register new thread start and unregister when thread is done...?
has title: How to control number of running threads in ThreadPoolTaskExecutor?
score: 0
answer count: 1
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33524065
has answer: http://stackoverflow.com/a/22101316
tagged with: java
tagged with: multithreading
type: Question
has comment: http://stackoverflow.com/comment/33524118

http://stackoverflow.com/a/22160981
answers question: http://stackoverflow.com/q/22160970
type: Answer
downvote count: 1
has comment: http://stackoverflow.com/comment/33631860
upvote count: 4
score: 3
has body: Bad semicolon placement: for (d = 0; d &lt; n; d *= 10); // that terminal semicolon will mess you up! This is equivalent to: for (d = 0; d &lt; n; d *= 10) { // do nothing } Get rid of that terminal semicolon. Make your d variable local to the for loop: for (int d = 0; d &lt; n; d *= 10) {...} Always enclose all loop blocks in curly braces Good code formatting isn't there just to make your code loop pretty -- it also helps you debug.

http://stackoverflow.com/a/22036188
answers question: http://stackoverflow.com/q/22035970
score: 0
type: Answer
has body: There is a better way to do that and that is by using HashMap: //create your custom object which will be mapped public class User{ public String userId; public String userName; } ArrayList&lt;String&gt; userKeys = new ArrayList&lt;String&gt;(); HashMap&lt;String, User&gt; users = new HashMap&lt;String, User&gt;(); Now using a userKey, you can access its corresponding userData; Example: User user = users.get("yourKey");
accepted answer of: http://stackoverflow.com/q/22035970
type: AcceptedAnswer

http://stackoverflow.com/comment/33377849
type: QuestionComment
comment on: http://stackoverflow.com/q/22019254
score: 0
has text: Initialize: TextView txtInformacion = null;
type: Comment

http://stackoverflow.com/a/22172660
has body: EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(pkey, NULL); uint8_t *secret = NULL; size_t secret_len; EVP_PKEY_derive_init(ctx); EVP_PKEY_derive_set_peer(ctx, peerkey); EVP_PKEY_derive(ctx, NULL, &amp;secret_len); secret = malloc(secret_len); EVP_PKEY_derive(ctx, secret, &amp;secret_len); This code looks like its missing a few steps. For example, EVP_PKEY_paramgen_init is not present. The OpenSSL wiki has an example at Elliptic Curve Diffie-Hellman. I'm going to copy/paste it below to avoid the link-only answer, but I believe its the work of Matt Caswell. EVP_PKEY_CTX *pctx, *kctx; EVP_PKEY_CTX *ctx; unsigned char *secret; EVP_PKEY *pkey = NULL, *peerkey, *params = NULL; /* Create the context for parameter generation */ if(NULL == (pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL))) handleErrors(); /* Initialise the parameter generation */ if(1 != EVP_PKEY_paramgen_init(pctx)) handleErrors(); /* We're going to use the ANSI X9.62 Prime 256v1 curve */ if(1 != EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx, NID_X9_62_prime256v1)) handleErrors(); /* Create the parameter object params */ if (!EVP_PKEY_paramgen(pctx, &amp;params)) handleErrors(); /* Create the context for the key generation */ if(NULL == (kctx = EVP_PKEY_CTX_new(params, NULL))) handleErrors(); /* Generate the key */ if(1 != EVP_PKEY_keygen_init(kctx)) handleErrors(); if (1 != EVP_PKEY_keygen(kctx, &amp;pkey)) handleErrors(); /* Get the peer's public key, and provide the peer with our public key - * how this is done will be specific to your circumstances */ peerkey = get_peerkey(pkey); /* Create the context for the shared secret derivation */ if(NULL == (ctx = EVP_PKEY_CTX_new(pkey, NULL))) handleErrors(); /* Initialise */ if(1 != EVP_PKEY_derive_init(ctx)) handleErrors(); /* Provide the peer public key */ if(1 != EVP_PKEY_derive_set_peer(ctx, peerkey)) handleErrors(); /* Determine buffer length for shared secret */ if(1 != EVP_PKEY_derive(ctx, NULL, secret_len)) handleErrors(); /* Create the buffer */ if(NULL == (secret …
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/22149271
score: 2
upvote count: 2

http://stackoverflow.com/a/22168023
upvote count: 2
has comment: http://stackoverflow.com/comment/33644000
type: Answer
has body: servlet code to generate random numbers as follows: import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.*; /** * Servlet implementation class SampleRandomNumber */ public class SampleRandomNumber extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(“text/html”); PrintWriter out=response.getWriter(); out.println(“Result is “+(int)(((Math.random())*6)+1)); // random number With in 6 except 0. } } You can use java.util.Random, Use nextInt() method and simply add 1000 to it, if you want it to be starting from 1000 , you can simply take first no as 1000 &lt;c:set var="rand"&gt; &lt;%= java.lang.Math.round(java.lang.Math.random() * 2) %&gt; &lt;/c:set&gt; Later you can check for ${rand mod 2 == 0} and ${rand mod 2 == 1} to get your desired output.
answers question: http://stackoverflow.com/q/22167708
has comment: http://stackoverflow.com/comment/33644067
has comment: http://stackoverflow.com/comment/33643938
has comment: http://stackoverflow.com/comment/33643802
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33644630

http://stackoverflow.com/comment/33527337
score: 0
has text: this question sounds like "it doesnt work, tell me why?" you can have milions of problems when you use threads. dead locks, live locks, starvation, syncronization problems etc... please edit this question and post your code
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22102703

network-programming
tags question: http://stackoverflow.com/q/22048210
tags question: http://stackoverflow.com/q/22027676
tags question: http://stackoverflow.com/q/22085116
tags question: http://stackoverflow.com/q/22052531
tags question: http://stackoverflow.com/q/22119269
tags question: http://stackoverflow.com/q/22114510
type: Tag
tag name: network-programming
tags question: http://stackoverflow.com/q/22047330
tags question: http://stackoverflow.com/q/22168526
tags question: http://stackoverflow.com/q/22148361
tags question: http://stackoverflow.com/q/22118004
tags question: http://stackoverflow.com/q/22158475
tags question: http://stackoverflow.com/q/22030574
tags question: http://stackoverflow.com/q/22031254

http://stackoverflow.com/q/22088319
has answer: http://stackoverflow.com/a/22088366
has answer: http://stackoverflow.com/a/22088370
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33501238
upvote count: 1
type: Question
tagged with: simpledateformat
tagged with: date
accepted answer: http://stackoverflow.com/a/22088366
answer count: 2
has title: SimpleDateFormat not parsing month as expected
downvote count: 0
favorite count: 0
has body: I am facing a problem with SimpleDateFormat . when i tried to execute the program im getting output of 01-01-2014 20:18:18 insted of 10-01-2014 20:18:18 . I'm posting my code blow. Please help me find mistakes in my code . import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class ValidDate { public static void main(String[] args) { ValidDate vd = new ValidDate(); vd.processDate(); } private void processDate() { SimpleDateFormat sdf = new SimpleDateFormat("MM-DD-yyyy HH:mm:ss"); try { Date dt = sdf.parse("10-01-2014 20:18:18"); System.out.println(sdf.format(dt)); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } Thank you.
has comment: http://stackoverflow.com/comment/33501176
possible better answer: http://stackoverflow.com/a/22088370
type: AnsweredQuestion

http://stackoverflow.com/q/22133860
has comment: http://stackoverflow.com/comment/33584866
has comment: http://stackoverflow.com/comment/33584956
has answer: http://stackoverflow.com/a/22134028
accepted answer: http://stackoverflow.com/a/22134028
possible better answer: http://stackoverflow.com/a/22134145
has comment: http://stackoverflow.com/comment/33584016
score: 0
has title: Final in android Java
tagged with: android
has comment: http://stackoverflow.com/comment/33584051
has comment: http://stackoverflow.com/comment/33584742
has body: Hi am new to android development and have been watching The New Bostons Videos and have a question about the final modifier. Why when I type something like this TextView display = (TextView) findViewById(R.id.tvResults); display.setText("LEFT!!!"); in to my OnCreate class do I need to add the final modifier to display.
has comment: http://stackoverflow.com/comment/33583979
tagged with: final
has answer: http://stackoverflow.com/a/22134145
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33583992
has comment: http://stackoverflow.com/comment/33583955
type: Question
answer count: 2

button
tags question: http://stackoverflow.com/q/22055540
tags question: http://stackoverflow.com/q/22164674
type: Tag
tags question: http://stackoverflow.com/q/22021571
tags question: http://stackoverflow.com/q/22163457
tags question: http://stackoverflow.com/q/22025169
tags question: http://stackoverflow.com/q/22115510
tags question: http://stackoverflow.com/q/22035300
tag name: button

http://stackoverflow.com/comment/33464346
score: 1
comment on: http://stackoverflow.com/a/22068136
type: AnswerComment
has text: And also if you want to go to other activity then don't forget to update `manifest` file. you have to register your activity in manifest file.
type: Comment

http://stackoverflow.com/q/22082451
has title: Object[] array to String[] using Serialization
tagged with: string
has answer: http://stackoverflow.com/a/22082549
tagged with: serialization
possible better answer: http://stackoverflow.com/a/22082549
answer count: 4
accepted answer: http://stackoverflow.com/a/22082512
type: AnsweredQuestion
tagged with: java
has body: The readObject() method of the ObjectInputStream returns Object and that needs to be casted to appropriate type. what if I serialize an array of String, do I get array of Objects or Array of Strings. I tried this below. String[] arr = (String[]) objArr; fail in general case. but after Serialization, when I cast the Object returned from readObject() to String[], I do not get any Exception. so what is that returning? the method signature of readObject() is public final Object readObject() throws IOException, ClassNotFoundException which indicates it returns the Object. why casting it to String[] works here, but in a more general case (as shown below) it fails. public class UpcastDownCast { public static void main(String[] args) throws IOException, ClassNotFoundException { //the below three lines give runtime Exception Object[] objArr = {new String("hello"), new String("world")}; String[] arr = (String[]) objArr; System.out.println(Arrays.toString(arr)); String[] arrV={new String("Car"), new String("Bike")}; FileOutputStream of= new FileOutputStream("file.ser"); ObjectOutputStream oos=new ObjectOutputStream(of); oos.writeObject(arrV); FileInputStream fi = new FileInputStream("file.ser"); ObjectInputStream ois= new ObjectInputStream(fi); String[] t2= (String[]) ois.readObject(); System.out.println("after "+ Arrays.toString(t2)); } }
tagged with: objectinputstream
type: Question
tagged with: arrays
has answer: http://stackoverflow.com/a/22082722
score: 0
has answer: http://stackoverflow.com/a/22082512
has comment: http://stackoverflow.com/comment/33491061
has answer: http://stackoverflow.com/a/22082501

http://stackoverflow.com/a/22162604
has body: In addition to the space savings noted by @dasblinkenlight, a BitSet has the advantage that it will grow as needed. If you do not know beforehand how many bits will be needed, or the high numbered bits are sparse and rarely used, (e.g. you are detecting which Unicode characters are present in a document and you want to allow for the unusual "foreign" ones > 128 but you know that they will be rare) a BitSet will save even more memory.
type: Answer
answers question: http://stackoverflow.com/q/22162359
upvote count: 1
score: 1
downvote count: 0

http://stackoverflow.com/comment/33594365
type: AnswerComment
comment on: http://stackoverflow.com/a/22139452
score: 0
type: Comment
has text: Don't use `randomString(int 1000);`, use `randomString(1000);`

http://stackoverflow.com/a/22032285
upvote count: 1
answers question: http://stackoverflow.com/q/22032124
score: 1
downvote count: 0
has body: The data that you are seeing will be cached. Try closing and re-opening your DB connection. This may not even be good enough if you are using DB pooling.
type: Answer

http://stackoverflow.com/q/22049133
has comment: http://stackoverflow.com/comment/33431443
type: AnsweredQuestion
upvote count: 0
tagged with: arrays
possible better answer: http://stackoverflow.com/a/22049247
has answer: http://stackoverflow.com/a/22049247
type: Question
accepted answer: http://stackoverflow.com/a/22049376
score: -2
has comment: http://stackoverflow.com/comment/33431278
favorite count: 0
has body: I created a two dimensional array and couldn't add values, I'm used to see so maybe it's not alike in Java. The code is this way: int location[][] = new int[LEN][2]; location[0][0] = 50; location[0][1] = 0; location[1][0] = 50; location[1][1] = 50; There is no problem declaring but only assigning values into the array. NOTE: LEN is bigger than 2 and I tried numeric value.
has comment: http://stackoverflow.com/comment/33431168
has comment: http://stackoverflow.com/comment/33431590
answer count: 2
downvote count: 2
has comment: http://stackoverflow.com/comment/33431484
has comment: http://stackoverflow.com/comment/33431239
has comment: http://stackoverflow.com/comment/33431233
has title: Two-Dimen array in java?
has comment: http://stackoverflow.com/comment/33431371
tagged with: java
has comment: http://stackoverflow.com/comment/33431322
has answer: http://stackoverflow.com/a/22049376
has comment: http://stackoverflow.com/comment/33431395
has comment: http://stackoverflow.com/comment/33431300
has comment: http://stackoverflow.com/comment/33431257

navigation-drawer
tags question: http://stackoverflow.com/q/22089033
type: Tag
tags question: http://stackoverflow.com/q/22099644
tags question: http://stackoverflow.com/q/22105074
tag name: navigation-drawer

http://stackoverflow.com/q/22037263
tagged with: oop
upvote count: 5
has answer: http://stackoverflow.com/a/22037409
answer count: 2
score: 5
has body: I have a few questions about the 'new' interfaces in Java 8, I have the following code: public interface Drawable { public void compileProgram(); public Program getProgram(); public boolean isTessellated(); public boolean isInstanced(); public int getInstancesCount(); public int getDataSize(); public FloatBuffer putData(final FloatBuffer dataBuffer); public int getDataMode(); public boolean isShadowReceiver(); public boolean isShadowCaster(); //TODO use for AABB calculations default public void drawDepthPass(final int offset, final Program depthNormalProgram, final Program depthTessellationProgram) { Program depthProgram = (isTessellated()) ? depthTessellationProgram : depthNormalProgram; if (isInstanced()) { depthProgram.drawArraysInstanced(getDataMode(), offset, getDataSize(), getInstancesCount()); } else { depthProgram.drawArrays(getDataMode(), offset, getDataSize()); } } default public void draw(final int offset) { if (isInstanced()) { getProgram().use().drawArraysInstanced(getDataMode(), offset, getDataSize(), getInstancesCount()); } else { getProgram().use().drawArrays(getDataMode(), offset, getDataSize()); } } default public void delete() { getProgram().delete(); } public static int countDataSize(final Collection&lt;Drawable&gt; drawables) { return drawables.stream() .mapToInt(Drawable::getDataSize) .sum(); } public static FloatBuffer putAllData(final List&lt;Drawable&gt; drawables) { FloatBuffer dataBuffer = BufferUtils.createFloatBuffer(countDataSize(drawables) * 3); drawables.stream().forEachOrdered(drawable -&gt; drawable.putData(dataBuffer)); return (FloatBuffer)dataBuffer.clear(); } public static void drawAllDepthPass(final List&lt;Drawable&gt; drawables, final Program depthNormalProgram, final Program depthTessellationProgram) { int offset = 0; for (Drawable drawable : drawables) { if (drawable.isShadowReceiver()) { drawable.drawDepthPass(offset, depthNormalProgram, depthTessellationProgram); } offset += drawable.getDataSize(); //TODO count offset only…
has title: Using the new Java8 interface with default methods
has comment: http://stackoverflow.com/comment/33412529
downvote count: 0
favorite count: 0
type: UnansweredQuestion
tagged with: interface
tagged with: java-8
has answer: http://stackoverflow.com/a/22037835
tagged with: java
type: Question
tagged with: default-method

http://stackoverflow.com/comment/33539036
type: Comment
comment on: http://stackoverflow.com/a/22109081
has text: This is only a correct answer if the order of the `{i, j}` pairs are irrelevant. Even then, it is only a factor of ~2 improvement.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33583246
type: Comment
comment on: http://stackoverflow.com/q/22133333
has text: no I have no idea what that is, I'm using my own player that I posted
score: 0
type: QuestionComment

http://stackoverflow.com/comment/33626144
score: 1
type: Comment
has text: @ScottScooterWeidenkopf Its IntelliJIDEA from Jetbrains on Darcula theme.Brilliant UI!
type: QuestionComment
comment on: http://stackoverflow.com/q/22155745

http://stackoverflow.com/a/22112195
upvote count: 3
answers question: http://stackoverflow.com/q/22112182
score: 3
downvote count: 0
type: Answer
has body: Private method are accessible within the class itself. Since both methods residing the same class, there no problem of accessing it. The private modifier specifies that the member can only be accessed in its own class. Check here for more details

http://stackoverflow.com/q/22085224
tagged with: naming-conventions
upvote count: 5
tagged with: java
tagged with: loops
has answer: http://stackoverflow.com/a/22085289
has answer: http://stackoverflow.com/a/22085242
has body: Is it better to use the variable 'i' or a meaningful name such as 'loopCount' or 'studentsCount' etc? e.g. for (int i = 0; i &lt; 10; i++) { for (int j = 0; j &lt; 5; j++) { System.out.println(i + j); } // End of j loop } // End of i loop VS for (int outerLoop = 0; outerLoop &lt; 10; outerLoop++) { for (int innerLoop = 0; innerLoop &lt; 5; innerLoop++) { System.out.println(outerLoop + innerLoop); } // End of innerLoop } // End of outerLoop By better; the main considerations would be readability / conventions. Related question Loop iterator naming convention EDIT: I have tagged this a java, but answers for other languages are welcome.
type: Question
has answer: http://stackoverflow.com/a/22085254
score: 5
has answer: http://stackoverflow.com/a/22085640
has comment: http://stackoverflow.com/comment/33495907
has title: Looping: i vs loopCount
possible better answer: http://stackoverflow.com/a/22085290
downvote count: 0
answer count: 7
has answer: http://stackoverflow.com/a/22085290
has comment: http://stackoverflow.com/comment/33495964
favorite count: 0
has comment: http://stackoverflow.com/comment/33495952
has comment: http://stackoverflow.com/comment/33495956
has answer: http://stackoverflow.com/a/22085264
linked to: http://stackoverflow.com/q/11914581
has comment: http://stackoverflow.com/comment/33495982
accepted answer: http://stackoverflow.com/a/22085254
has answer: http://stackoverflow.com/a/22085927
type: AnsweredQuestion

http://stackoverflow.com/a/22054808
type: AcceptedAnswer
type: Answer
has comment: http://stackoverflow.com/comment/33454873
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/22054630
answers question: http://stackoverflow.com/q/22054630
upvote count: 1
has body: Both is possible. If you pack the LinkedHashSets into an other LinkedHashSet you are probably loosing type information as LinkedHashSet&lt;LinkedHashSet&lt;?&gt;&gt; is the only way to collect all kinds of LinkedHashSets in one place. You may also have a look into HashMap as normally you will at some point try to access a specfic sub-LinkedHashSet; using a map this is achieved with ease by defining constant lookup-keys in a common class or interface. If there are always the same LinkedHashSets to pass between classes, parameters or parameter objects are often a better solution as they provide type information. A parameter object's class could look like this public class Parameters { private LinkedHashSet&lt;String&gt; namesSet = null; private LinkedHashSet&lt;Locale&gt; localesSet = null; public Parameters(LinkedHashSet&lt;String&gt; namesSet, LinkedHashSet&lt;Locale&gt; localesSet) { this.namesSet = namesSet; this.localesSet = localesSet; } public Parameters() { } public LinkedHashSet&lt;String&gt; getNamesSet() { return namesSet; } public void setNamesSet(LinkedHashSet&lt;String&gt; namesSet) { this.namesSet = namesSet; } public LinkedHashSet&lt;Locale&gt; getLocalesSet() { return localesSet; } public void setLocalesSet(LinkedHashSet&lt;Locale&gt; localesSet) { this.localesSet = localesSet; } } the advantage of parameter-objects is that they keep the method-signature short and can be passed around; just be careful when changing such objects by concurrent threads ;-).

http://stackoverflow.com/q/22149047
has comment: http://stackoverflow.com/comment/33610039
tagged with: file-upload
type: UnansweredQuestion
score: 0
has comment: http://stackoverflow.com/comment/33609987
has title: Spring Java mulipart data file save
linked to: http://stackoverflow.com/q/21728168
tagged with: spring
has answer: http://stackoverflow.com/a/22149289
tagged with: java
has body: I work with Spring. I have this code on my controller @Controller public class FileUploadController { @RequestMapping(value = "/file-upload", method = RequestMethod.POST) @ResponseBody public String uploadFile(@RequestParam("file") MultipartFile file, HttpServletRequest request,ServletContext context) throws IOException { if(!file.isEmpty()) { file.transferTo(new File("/data.xml")); return "ok"; } else { return "Empty"; } } } i just want to save the uploaded file to the root directory. It seem to me that i use a absolute Path to the Root, but i don't now how i can find that out. Can anybody help me ?
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/33611413
has answer: http://stackoverflow.com/a/22149293

http://stackoverflow.com/a/22009667
has comment: http://stackoverflow.com/comment/33395940
answers question: http://stackoverflow.com/q/22008890
has body: When some one creates a java class it inherit boolean equals(Object o) method from class 'Object', as all user defined class when not extending any other class extends class Object implicitly. When this class is instantiated using new operator the equality of this objects are achieved by using this underline formula. return (this == obj); Hence it will return true if and only if both object refers to the same object on the heap i.e (a == b) = true class Abc{} Abc a = new Abc(); Abc b = a; a==b //(true) a.equals(b) //(true) And suppose they are instance of same class but are two different object than class Abc{} Abc a = new Abc(); Abc b = new Abc(); a==b; //(false) a.equals(b); //(false) But when an class created overrides this equals method then this equality is evaluated using the new formula provided while overriding it. for example .equals object override by java.util.Date public boolean equals(Object obj) { return obj instanceof Date &amp;&amp; getTime() == ((Date) obj).getTime(); } This will return true if and only both Date object have equal value returned by getTime() method. Hope this helps. Feel free to ask further questions if any doubt.
score: 0
type: Answer

http://stackoverflow.com/q/22047855
upvote count: 0
has body: i have to create a program where it counts the frequency/occurrence of X letter of words, i have got the program to work out the frequency of the words and the lengths but now i need to work out the mean length of the words entered, i am really stuck on this so if anyone can help i will be grateful This is the code i have as of yet: import javax.swing.JOptionPane; public class CountLetters { public static void main( String[] args ) { String input = JOptionPane.showInputDialog("Write a sentence." ); int amount = 0; String output = "Amount of letters:\n"; for ( int i = 0; i &lt; input.length(); i++ ) { char letter = input.charAt(i); amount++; output = input; } output += "\n" + amount; JOptionPane.showMessageDialog( null, output, "Letters", JOptionPane.PLAIN_MESSAGE ); } }
favorite count: 0
has answer: http://stackoverflow.com/a/22047989
type: UnansweredQuestion
downvote count: 1
has title: Count the Frequency of X letter words?
type: Question
tagged with: algorithm
tagged with: java
score: -1
has answer: http://stackoverflow.com/a/22047931
answer count: 2

http://stackoverflow.com/q/22166774
score: 1
tagged with: java
tagged with: http://stackoverflow.com/tag/json
possible better answer: http://stackoverflow.com/a/22167361
has comment: http://stackoverflow.com/comment/33642364
has comment: http://stackoverflow.com/comment/33641896
downvote count: 1
has answer: http://stackoverflow.com/a/22167361
type: Question
has comment: http://stackoverflow.com/comment/33641985
accepted answer: http://stackoverflow.com/a/22166984
has comment: http://stackoverflow.com/comment/33641991
has comment: http://stackoverflow.com/comment/33641952
answer count: 2
has title: Error when sending the json object to Java server standalone application
has comment: http://stackoverflow.com/comment/33641833
favorite count: 0
has comment: http://stackoverflow.com/comment/33642225
has comment: http://stackoverflow.com/comment/33641925
has comment: http://stackoverflow.com/comment/33642194
upvote count: 2
has body: I am sending the JSON object to server in a Java standalone application . JSON object is : {"dateFrom":"0001-01-01 12:00:00" ,"dateTo":"2014-03-29 04:34:49" ,"currency":"AUD" ,"requestStatus":null ,"dateTimeCreated":null ,"requestName":"ProjectedFundingRequest" ,"id":"af2e7ceb-c181-4a6b-a212-2867ea5cfded" ,"loginName":"mendiras" ,"securityToken":null ,"jsonString":null} error : net.sf.json.JSONException: Error while setting property=requestStatus type class java.lang.String Please let me know what could be the reason for the above error.
has answer: http://stackoverflow.com/a/22166984
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33642047

http://stackoverflow.com/comment/33469236
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22069554
has text: seems I want all types of concurrent access. I've already posted the code, so hope you'll look at that (only at code) http://stackoverflow.com/questions/22067533/java-map-multithreading-juggler/22068934?noredirect=1#22068934. In that example I want to change ConcurrentHashMap with something I've described in my question

http://stackoverflow.com/a/22077537
has body: You don't need hundreds of polygons to make a curve like you drew. You could get away with 40 quads on the left, and 40 on the right, and it would look pretty smooth. Raise that to 100 on each side and it will look almost perfectly smooth, and no modern device is going to have any trouble running that at 60fps. You could use the Mesh class to generate a procedural mesh for each side. You can make the mesh stay in one spot, locked to the camera, and modify it's vertices and UVs to make it look like you are panning down an infinitely long corridor. This will take a fair amount of math up front but should be smooth sailing once you have that down. Basically, your level design could be based on some kind of equation that takes Y offset as an input. Or it could be a long array of offsets, and you could use a spline equation or linear equation to interpolate between them. The output would be the UV and X coordinates which can be used to update each of the vertices of your two meshes. You can use the vertex shader to efficiently update the UV coordinates, using a constant offset uniform parameter that you update each frame. That way you don't have to move UV data to the GPU every frame. For the vertex positions, use your Mesh's underlying float[] and call setVertices() each frame to update it. Info here. Actually, it might look better if you leave the UV's and the X positions alone, and just scroll the Y positions up. Keep a couple quads of padding off top and bottom of screen, and just move the top quad to the bottom after it scrolls off screen.
upvote count: 1
has comment: http://stackoverflow.com/comment/33521678
answers question: http://stackoverflow.com/q/22037813
score: 1
downvote count: 0
type: Answer

http://stackoverflow.com/comment/33677892
type: Comment
comment on: http://stackoverflow.com/a/22139876
score: 0
type: AnswerComment
has text: @EJP No. See also DB2's batching implementation. Hint, it isn't like anyone else's.

http://stackoverflow.com/q/22009229
has body: I have a problem with maven-dbunit-plugin. The common use of maven-dbunit-plugin is running a command like mvn dbunit:operation in the shell. But now, I have a spring batch job. The work of this job is writing data by sample-data.xml file to the database. The command mvn dbunit:operation depends on the maven project with the pom.xml. This is not the style what I want. How to write code using maven-dbunit-plugin lib to resolve this problem?
has title: How to use maven dbunit plugin to write data(sample-data.xml) to database by code but not by pom.xml?
tagged with: maven-plugin
has answer: http://stackoverflow.com/a/22009795
tagged with: http://stackoverflow.com/tag/xml
type: UnansweredQuestion
tagged with: maven
linked to: http://stackoverflow.com/q/19292764
score: 0
tagged with: java
type: Question
answer count: 1

http://stackoverflow.com/a/22033460
downvote count: 0
has comment: http://stackoverflow.com/comment/33403681
has comment: http://stackoverflow.com/comment/33403383
answers question: http://stackoverflow.com/q/22033409
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/33403439
has comment: http://stackoverflow.com/comment/33403218
has comment: http://stackoverflow.com/comment/33403257
upvote count: 1
has comment: http://stackoverflow.com/comment/33403829
has comment: http://stackoverflow.com/comment/33403161
has comment: http://stackoverflow.com/comment/33403791
has body: ""+s1 creates a new String Object on the heap (since it is not declared as final). So, the references will not be same.
accepted answer of: http://stackoverflow.com/q/22033409
has comment: http://stackoverflow.com/comment/33403619
type: AcceptedAnswer

http://stackoverflow.com/comment/33650340
type: QuestionComment
has text: Go ask [meta](http://meta.stackoverflow.com)...
comment on: http://stackoverflow.com/q/22034046
score: 0
type: Comment

http://stackoverflow.com/q/22057446
has body: I am trying to load an FXML into an existing AnchorPane using: @FXML private AnchorPane content; ... AnchorPane newPane = FXMLLoader.load(getClass().getResource("/fxml/scene2.fxml")); this.content.getChildren().setAll(newPane); And all that works well, but it destroys the layout of scene2.fxml, as it shows itself in prefered size. I would like to have it dynamically adapted though to the size of the parent FXML (basically have the size that the AnchorPane of scene1.fxml has). What is wrong in my code? Where is the bug? How do I adapt the size of scene2.fxml automatically?
has comment: http://stackoverflow.com/comment/33459065
type: AnsweredQuestion
tagged with: java
tagged with: javafx
type: Question
linked to: http://stackoverflow.com/q/22066555
has comment: http://stackoverflow.com/comment/33459271
has comment: http://stackoverflow.com/comment/33449179
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/22059178
accepted answer: http://stackoverflow.com/a/22059178
tagged with: fxml
linked to: http://stackoverflow.com/q/21893300
has title: Load FXML into AnchorPane destroys Layout?

http://stackoverflow.com/comment/33536585
type: AnswerComment
comment on: http://stackoverflow.com/a/22107571
has text: Sorry for being unclear. By *"queue methods"*, I meant *"place chunks of code in a first-in, first-out structure, such as a Queue"*. Still, I think you answered the question even without understanding. If you can put methods into a `List` as you demonstrated, then it would be trivial to put them into a `Queue`. If I get it to work in a Queue instead of a List, I'll come back and edit your question (if you don't mind), and award you the answer.
score: 0
type: Comment

http://stackoverflow.com/comment/33575072
score: 1
comment on: http://stackoverflow.com/q/22128564
type: Comment
type: QuestionComment
has text: Not sure what your problem is, but your code works fine after adding a main method. The text wraps as it's supposed to.

http://stackoverflow.com/comment/33591030
comment on: http://stackoverflow.com/a/22138147
has text: May I know where `DBAdapter` come?
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33495060
type: Comment
type: QuestionComment
has text: `x` and `y` is String so try to use `equals` instead of `==`
comment on: http://stackoverflow.com/q/22084766
score: 0

http://stackoverflow.com/q/22119981
type: UnansweredQuestion
score: 2
tagged with: java
type: Question
tagged with: abstract-syntax-tree
downvote count: 0
has body: I have implemented a LL1 parser in a non recursive approach with a explicit stack. The following algorithm is from the Dragon Book: set zp to point to the first symbol of w; set X to the top stack symbol; while ( X != $ ) { /* stack is not empty */ if ( X is a ) pop the stack and advance zp; else if ( X is a terminal ) error(); else if ( M[X, a] is an error entry ) error(); else if ( M[X,a] = X -+ Y1Y2 Yk ) { output the production X -+ YlY2 - . Yk; pop the stack; push Yk, Yk-1,. . . , Yl onto the stack, with Yl on top; set X to the top stack symbol; } The book says: The parser is controlled by a program that considers X, the symbol on top of the stack, and a, the current input symbol. If X is a nonterminal, the parser chooses an X-production by consulting entry M[X, a] of the parsing table IM. (Additional code could be executed here, for example, code to construct a node in a parse tree.) Otherwise, it checks for a match between the terminal X and current input symbol a. However i need more info on how to construct the expression tree nodes under this approach. I have a node hierarchy of UnaryOperator, BinaryOperator, etc but dont know where to instanciate it. Yet i havent found any simple example of this (with for example the arithmetic language).
has title: About AST construction in LL1 non recursive parser
answer count: 1
favorite count: 0
tagged with: parsing
upvote count: 2
has answer: http://stackoverflow.com/a/27206881

http://stackoverflow.com/q/22145768
score: 1
favorite count: 0
type: Question
has comment: http://stackoverflow.com/comment/33608282
has title: Whats wrong in updating Jtable to the database.?
has comment: http://stackoverflow.com/comment/33603584
tagged with: java
has comment: http://stackoverflow.com/comment/33609612
upvote count: 1
tagged with: swing
has comment: http://stackoverflow.com/comment/33643522
has comment: http://stackoverflow.com/comment/33603847
tagged with: database
has comment: http://stackoverflow.com/comment/33609285
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33609021
tagged with: jtable
answer count: 0
downvote count: 0
has comment: http://stackoverflow.com/comment/33603850
has body: I am trying to update the following content to the database, ie, a table and a date text field, but when trying to update the jtable to the database its not working properly and i am getting a number exception. What code should i add/change? Thanks in advance. import java.awt.EventQueue; import javax.swing.*; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; import javax.swing.event.*; import java.awt.event.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.*; public class Table1 { JFrame frame; JComboBox credit; String[] rowNames = { "Vasan Phalke", "Pansare", "Anil Kg", "Suresh", "Total Credit", ""}; String[] colNames = {"Name", "Qty", "Rate/ Kg", "Total Amt."}; JTable table; DefaultTableModel model; JScrollPane scrollPane; JButton saveButton; JTextField dateField; JLabel dateLabel; public Table1() { frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); credit = new JComboBox&lt;&gt;(rowNames); dateLabel = new JLabel("Date"); dateField = new JTextField(20); saveButton = new JButton("Save"); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection("Jdbc:Odbc:TomsJava"); String i5Date1 = dateField.getText(); PreparedStatement ps = conn.prepareStatement("UPDATE DailyAnalysis SET Total_Credit = ? where Date = i5Date1"); ps.setDouble(1, (Double) table.getValueAt(5,3)); Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); ResultSet rs = stmt.executeQuery("SELECT * FROM DailyAnalysis"); rs.moveToInsertRow(); rs.updateString("Date1",i5Date1); rs.close(); ps.close(); conn.close(); } catch(SQLException e) { System.out.println(e); } catch(ClassNotFoundException z) { System.out.println(z); } catch(NumberFormatException n) { System.out.prin…

http://stackoverflow.com/comment/33430680
score: 1
type: Comment
comment on: http://stackoverflow.com/q/22048819
type: QuestionComment
has text: Don't have us solve your homework! Try it yourself and ask question about specific issues you run into.

http://stackoverflow.com/comment/33621365
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22154337
has text: Are you using Fiddler to generate the request, or simply to proxy so you can observe the traffic? I would instead recommend Chrome's Postman plugin if the former, or use the network tools in Chrome if the latter. Fiddler introduces too many other variables since you can do so much to modify the request/response.

http://stackoverflow.com/comment/33608888
type: Comment
type: QuestionComment
score: 2
comment on: http://stackoverflow.com/q/22148544
has text: Looks fine. Are there other `xsl:when` elements in your code? What happens if you remove ` ` from the code?

http://stackoverflow.com/comment/33641995
type: Comment
type: QuestionComment
has text: It's specified in the question, but all my java files reside in the folder src/com/<company_name>/forecast and I'd like the docs to go into doc/forecast
score: 0
comment on: http://stackoverflow.com/q/22166762

http://stackoverflow.com/comment/33523429
comment on: http://stackoverflow.com/a/22100412
type: AnswerComment
has text: i did it public void startElement(String uri, String localName, String qName, please see end the class , same problem
type: Comment
score: 0

http://stackoverflow.com/q/22080613
has comment: http://stackoverflow.com/comment/33487779
has comment: http://stackoverflow.com/comment/33487724
has answer: http://stackoverflow.com/a/22080683
type: UnansweredQuestion
score: -4
has title: Effective use of if statement
has body: i have three strings String firstName; String lastName; String companyName; Here is my code and i am trying to see if i can modify and re write this in a better way if(firstName!=null &amp;&amp; lastname == null) { comanyName = firstName;} if(lastname !=null &amp;&amp; firstName== null) { comanyName = lastname ;} if(firstName!=null &amp;&amp; lastname != null) { companyName = firstName.concat(lastName)} Thanks
has answer: http://stackoverflow.com/a/22080653
has answer: http://stackoverflow.com/a/22080666
tagged with: if-statement
tagged with: java
has comment: http://stackoverflow.com/comment/33487789
type: Question
downvote count: 4
upvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/22080870
answer count: 4
has comment: http://stackoverflow.com/comment/33487665

http://stackoverflow.com/a/22035368
has body: I think I found the problem, but haven't tested it yet. It seems, that I made a logical mistake. An IP address will not cause a true return, because it matches both regex patterns but a DNS name will only match the regex pattern designed for the DNS name and not the one designed for the IP-address, so it will always cause true. I think I have to combine these two patterns like this: if ( [...] || ( !serverURL.matches("^[a-zA-Z0-9]+\\.[a-zA-Z0-9]+\\.[a-zA-Z0-9]+(\\.[a-zA-Z0-9]+)?(/.+)?") &amp;&amp; !serverURL.matches("^([0-9]{1,3}\\.){3}[0-9]{1,3}(/.+)?") ) || [...] ) { [...] } Sorry, if I wasted your time.
score: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22025343
answers question: http://stackoverflow.com/q/22025343
type: Answer

http://stackoverflow.com/a/22088669
has body: Just a little trick, instead of using BlendModeuse a HBox, add the images inside the HBox and set the HBox inside the Group Group group = new Group(); HBox box = new HBox // tempImage is array of buffered Images for(int i=0; i &lt; tempImage.length ;i++){ if(tempImage[i] != null){ ImageView view = new ImageView(); Image im = SwingFXUtils.toFXImage(tempImage[i], null ); view.setImage(im); box.getChildren().add(view); } } group.getChildren.add(box); But this wont help you to get the new image, guess you don't even need it !
has comment: http://stackoverflow.com/comment/33502198
type: Answer
has comment: http://stackoverflow.com/comment/33503083
has comment: http://stackoverflow.com/comment/33502110
has comment: http://stackoverflow.com/comment/33502887
answers question: http://stackoverflow.com/q/22088119
score: 0

http://stackoverflow.com/a/22618462
answers question: http://stackoverflow.com/q/22016669
has comment: http://stackoverflow.com/comment/34705679
score: 3
has comment: http://stackoverflow.com/comment/34705525
has body: Checking permissions In your question you stated that you then want to check the permission with java.security.Policy, but without using a spi.policy file. From the PolicySpi API, you can see that a PolicySpi object features 4 methods: engineGetPermissions(CodeSource codesource) engineGetPermissions(ProtectionDomain domain) engineImplies(ProtectionDomain domain, Permission permission) engineRefresh() However, you might not need PolicySpi as there are easier solutions to check permissions. See: Security Manager vs Access Controller AccessController usage Since you haven't specified what kind of permission you will grant, I will assume it is a permission concerning a java.security.CodeSource object. To check all current permissions for a file: public static void main(String[] args) { CodeSource source; try { source = new CodeSource(new URL("file:/c:/*"), (java.security.cert.Certificate[]) null); Policy policy = Policy.getPolicy(); System.out.println(policy.getPermissions(source)); } catch (IOException e) { e.printStackTrace(); } } A nice example for the SecurityManager checkPermission() is this tutorial. For checking specific FilePermissions, you can use: FilePermission perm = new FilePermission("path/file", "read"); AccessController.checkPermission(perm); Granting permissions Granting permissions at runtime can be done with java.lang.RuntimePermission. For other examples of how to grant permissions to a file, I suggest you read the following: Access Control Mechanisms and Algorithms Configuring spi.policy files Security Managers and Permissions That should bring you a long way! Good luck!
upvote count: 3
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/34705077
has comment: http://stackoverflow.com/comment/34704383
accepted answer of: http://stackoverflow.com/q/22016669
type: Answer
has comment: http://stackoverflow.com/comment/34869056

http://stackoverflow.com/a/22169539
has comment: http://stackoverflow.com/comment/33647078
score: 0
has comment: http://stackoverflow.com/comment/33647505
answers question: http://stackoverflow.com/q/22168649
type: Answer
has comment: http://stackoverflow.com/comment/33647419
has body: /darshan/java/jdk1.6.0_21/bin/java -classpath PATH_TO_YOUR_JAR com.supplier.external.DeleteTableData arg1
has comment: http://stackoverflow.com/comment/33653599

http://stackoverflow.com/q/22150519
has answer: http://stackoverflow.com/a/24840876
tagged with: sqlite
answer count: 1
has comment: http://stackoverflow.com/comment/33612622
has comment: http://stackoverflow.com/comment/33619233
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33819493
has comment: http://stackoverflow.com/comment/33692102
has comment: http://stackoverflow.com/comment/33765228
has body: I'm running Sqlite on windows 7 and using a java program from within Eclipse, to attempt to load data from an input file, into a sqlite database table. The sqlite exe file, the java sqlite JDBC jar file and the database file are all in the same directory. I've read most of the threads which sound like they were close to answering this problem but not solved so far. I've changed the folder permissions so anybody/everybody has update/change access to the folder(where the db file is), but still no joy. I have established a database connection (see display below) but am now stuck and I've run out of ideas - can anybody help? The code fails on Line 30 public class Database { public void loadPersonData() { Connection connection = null; PreparedStatement preparedStatement = null; try { connection = ConnectionConfig.getConnection(); preparedStatement = connection .prepareStatement("INSERT INTO PERSON(PERSON_ID,LAST_NAME,FIRST_NAME,STREET,CITY) " + "VALUES(?,?,?,?,?)"); for (PersonData x : ReadPersonData.personList) { preparedStatement.setInt(1, x.getPersonID()); preparedStatement.setString(2, x.getLastName()); preparedStatement.setString(3, x.getFirstName()); preparedStatement.setString(4, x.getStreet()); preparedStatement.setString(5, x.getCity()); preparedStatement.addBatch(); } THIS IS LINE 30 ->>>>> preparedStatement.executeBatch(); } catch (Exception e) { e.printStackTrace(); Currently the error messages are as below :- database connection established java.sql.SQLException: unable to open database file at org.sqlite.core.DB.throwex(DB.java:859) at org.sqlite.core.DB.executeBatch(DB.java:760) at org.sqlite.core.CorePreparedStatement.executeBatch(CorePreparedStatement.java:77) at Database.loadPersonData(Database.java:30) at MainApp.main(MainApp.java:16) java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (Connection is closed) at org.sqlite.core.DB.newSQLException(DB.java:890) at org.sqlite.core.CoreStatement.internalClose(CoreStatement.java:109) at org.s…
has title: SQLite java error " unable to open database file"
has comment: http://stackoverflow.com/comment/33635972
has comment: http://stackoverflow.com/comment/33648194
tagged with: java
has comment: http://stackoverflow.com/comment/33765313
has comment: http://stackoverflow.com/comment/33742202
type: Question
has comment: http://stackoverflow.com/comment/33619514
has comment: http://stackoverflow.com/comment/33765497
tagged with: database
score: 0
has comment: http://stackoverflow.com/comment/33811356
has comment: http://stackoverflow.com/comment/33758504

http://stackoverflow.com/comment/33372819
comment on: http://stackoverflow.com/a/22005338
score: 0
type: AnswerComment
type: Comment
has text: It dosent work and i get error, should i change the androidManifest too? this is part of my AndroidManifest `<activity android:name="com.artifex.mupdf.MuPDFActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:background="@android:color/white" android:label="Android PDF Reader"> <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.DEFAULT"/>`

http://stackoverflow.com/q/22011915
score: 3
has title: Hibernate LazyCollection with custom filter
downvote count: 0
favorite count: 0
answer count: 0
upvote count: 3
type: UnansweredQuestion
tagged with: lazy-loading
tagged with: java
tagged with: hibernate
type: Question
has body: I want to get number of active entities so I have the filter: @FilterDef(name = "onlyActive", defaultCondition = "IS_ACTIVE = '1'") then I use it with lazyCollection: @OneToMany(mappedBy = "databaseInstance") @LazyCollection(LazyCollectionOption.EXTRA) @Filter(name = "onlyActive") public List&lt;CloudInstance&gt; getCloudInstances() { return cloudInstances; } filter is added to the session, lazy collection is initialized but when calling getCloudInstances().size(); I get select count(ID) from CLOUD_INSTANCES where databaseInstance_ID =? It does not append IS_ACTIVE = '1' to the query, so the filter does not work. When I remove @LazyCollection and add eager fetch the filter works correctly. Is it possible to make this filter working with lazy collection?

http://stackoverflow.com/comment/33459685
type: QuestionComment
has text: The that is not `e ^ x`. And the formula is specifically for calculating that. Please first be clear with what you want. If you want the value of that formula, then your method should take just single argument.
comment on: http://stackoverflow.com/q/22065279
score: 0
type: Comment

http://stackoverflow.com/q/22088114
tagged with: java
has comment: http://stackoverflow.com/comment/33501694
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/23199594
has answer: http://stackoverflow.com/a/46585746
tagged with: user-interface
downvote count: 0
favorite count: 0
has title: Java Swing MVC dynamic components
has body: I have used the MVC pattern extensively in web applications in C# ASP.net and PHP CodeIgniter + Laravel, but now I have to implement it for a java Swing application and I'm a bit lost when it comes to actually dynamically adding elements (like a JPanel) to a View from an event. In any Web MVC framework, I would simply return a partial view and inject it in a div. More explanations: I have a View that has only one thing: a button that the MainController listens on. When I click the button, the view tells the controller to call the method "buttonClicked()". The result of that should be that a JPanel is created and added to the view, but how do I do that in Java Swing MVC? Like I said, in a web MVC framework, I would probably do something like "return new partialView(model)". Since the only classes that should be dependent on the Swing framework are the Views, I understand that the JPanel is created in there, but isn't the controller (or the model) supposed to tell the view where to place it? How does that work? Thanks. I hope by thoughts were clear enough, I'm just starting with java.
type: UnansweredQuestion
upvote count: 1
tagged with: swing
tagged with: model-view-controller
score: 1

jboss-arquillian
tags question: http://stackoverflow.com/q/22150741
tag name: jboss-arquillian
type: Tag
tags question: http://stackoverflow.com/q/22031207

http://stackoverflow.com/comment/33434907
score: 1
comment on: http://stackoverflow.com/q/22051234
type: Comment
type: QuestionComment
has text: Use an array instead of a zillion variables?

http://stackoverflow.com/q/22021358
has body: The method org.eclipse.core.runtime.IProgressMonitor.worked(int) receives integer which means increment. This means, that the only units available are natural units. It can't be percents, for example. So, if I process some files in the job, I can't report the counting stage, because the first method I should call is org.eclipse.core.runtime.IProgressMonitor.beginTask(String, int) which requires me to know the total amount. How to accomplish? UPDATE I wrote a wrapper below, but this looks absurd one need to do so: public class ProgressMonitorDoubleWrapper implements IProgressMonitor { private IProgressMonitor delegate; private int currentWork, totalWork; private double currentWorkDouble; public ProgressMonitorDoubleWrapper(IProgressMonitor monitor) { this.delegate = monitor; } @Override public void beginTask(String name, int totalWork) { beginTask(name, (double) totalWork); } public void beginTask(String name, double totalWork) { this.totalWork = (int) totalWork; currentWork = 0; currentWorkDouble = 0; delegate.beginTask(name, this.totalWork); } @Override public void done() { delegate.done(); } @Override public void internalWorked(double work) { delegate.internalWorked(work); } @Override public boolean isCanceled() { return delegate.isCanceled(); } @Override public void setCanceled(boolean value) { delegate.setCanceled(value); } @Override public void setTaskName(String name) { delegate.setTaskName(name); } @Override public void subTask(String name) { delegate.subTask(name); } @Override public void worked(int work) { worked((double)work); } public void worked(double work) { currentWorkDouble += work; int increment = (int)(currentWorkDouble - (double)currentWork); currentWork += increment; delegate.worked(increment); } }
favorite count: 0
upvote count: 1
type: AnsweredQuestion
has title: How to set worked precisely in IProgressMonitor in Eclipse plugin?
tagged with: progressmonitor
score: 1
tagged with: java
tagged with: eclipse
has answer: http://stackoverflow.com/a/22022161
accepted answer: http://stackoverflow.com/a/22022161
type: Question
answer count: 1
downvote count: 0
tagged with: eclipse-plugin
tagged with: eclipse-rcp

http://stackoverflow.com/comment/33484710
type: AnswerComment
type: Comment
has text: It makes absolute sense. A class is a blurprint for an object. It just describes things. Methods actually contain the behavior, or execution.
score: 1
comment on: http://stackoverflow.com/a/22079073

http://stackoverflow.com/a/22054641
has comment: http://stackoverflow.com/comment/33441302
downvote count: 0
has comment: http://stackoverflow.com/comment/33441536
has comment: http://stackoverflow.com/comment/33441563
accepted answer of: http://stackoverflow.com/q/22054590
has body: Well start by asking yourself when the else will be fulfilled: when guess != -1 and firstTimmer == true. You don't ever set firstTimmer, which needs to be set to true to pass through the the else block. You also need to remove the break in your else if, otherwise it will never reach the else on the next iteration. Also, having both playing = false and break in your if statement is redundant. Both will do the same thing individually. while (playing){ if (guess == -1){ playing = false; break; }else if (!firstTimmer){ got = true; System.out.print("Do you want to change the number range? Yes(1) No(2)"); guess = input.nextInt(); if (guess == 1){ System.out.print("Insert the new x: "); x = 1+input.nextInt(); }else if(guess == 2){ System.out.println("Let's go then!"); }else{ System.out.print("I didn't ask for that number, x won't change."); } firstTimmer = true; //break; }else{
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/22054590
type: AcceptedAnswer

http://stackoverflow.com/comment/33614619
type: Comment
comment on: http://stackoverflow.com/a/22151471
has text: @aliteralmind By popular demand, of course.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33574677
comment on: http://stackoverflow.com/q/22122213
has text: @PeterNiederwieser - I've updated my question to include that I'm doing a clean. I've even manually deleted the install directory to be sure and the files (start scripts/propery file) are being moved but the property file still has the placeholders.
score: 0
type: Comment
type: QuestionComment

sql-server
tags question: http://stackoverflow.com/q/22042741
tags question: http://stackoverflow.com/q/22154150
tags question: http://stackoverflow.com/q/22049924
tags question: http://stackoverflow.com/q/22136214
tags question: http://stackoverflow.com/q/22155244
type: Tag
tags question: http://stackoverflow.com/q/22058662
tag name: sql-server
tags question: http://stackoverflow.com/q/22031581
tags question: http://stackoverflow.com/q/22103426
tags question: http://stackoverflow.com/q/22097665
tags question: http://stackoverflow.com/q/22092704

http://stackoverflow.com/q/22158288
tagged with: variables
tagged with: android
tagged with: http://stackoverflow.com/tag/xml
type: UnansweredQuestion
has title: Proper way to modify variables from an XML layout in Android
type: Question
tagged with: java
has body: I am currently trying to learn Android programming, and have now come across my first problem: What is the proper/preferred (or are there any other ways) to use an XML layout with variables as strings? For example, I have a text field in one Activity/layout, then a button forwards to another Avctivity with a new layout. But I want to display the string the user entered in the previous screen to modify or replace the strings called from my xml template. One way to do this is to: TextView myTextView = (TextView) findViewById(R.id.display_string); myTextView.setText("new_string"); Esentially the strings in this Activity's XML template depends on the actions in the previous Activity. Is this the best way to do this, or is there a better way to handle cases like this, without the need to explicitly redefine all the strings I wish to use?
has answer: http://stackoverflow.com/a/22158356
score: 0
tagged with: layout
answer count: 1

http://stackoverflow.com/q/22164787
downvote count: 0
tagged with: junit
has comment: http://stackoverflow.com/comment/47180895
linked to: http://stackoverflow.com/q/14845690
upvote count: 11
favorite count: 0
has title: org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
has answer: http://stackoverflow.com/a/22164950
possible better answer: http://stackoverflow.com/a/75525855
score: 11
has answer: http://stackoverflow.com/a/75525855
type: AnsweredQuestion
tagged with: java
tagged with: matcher
accepted answer: http://stackoverflow.com/a/22164950
type: Question
has body: My method in the service and test class : public void updateSubModuleOrder(Long[] data, Long moduleSysId, Long userId) { try { for (int i = 0; i &lt; data.length; i++) { SubModule subModule=new SubModule(); int temp = i + 1; userSubmodule.setDsplySeq(temp); userSubModuleDao.saveOrUpdate(userSubmodule); @Test public void testupdateSubModuleOrder(){ UserModuleServiceImpl userModuleServiceImpl = new UserModuleServiceImpl(); UserSubModuleDao userSubModuleDao = mock(User//set the required param ,some code here// UserSubModuleId userSubModuleId=new UserSubModuleId(); //some code// when(userSubModuleDao.findById((any(UserSubModuleId.class)),false)).thenReturn(userSubModule); when(userSubModuleDao.saveOrUpdate(any(UserSubModule.class))).thenReturn(null); userModuleServiceImpl.updateSubModuleOrder(data, moduleSysId, userId); };* the error I get is FAILED: testupdateSubModuleOrder org.mockito.exceptions.misusing.InvalidUseOfMatchersException: Invalid use of argument matchers! 2 matchers expected, 1 recorded: -&gt; at com.TestUserModuleServiceImpl.testupdateSubModuleOrder(TestUserModuleServiceImpl.java:267) This exception may occur if matchers are combined with raw values: //incorrect: someMethod(anyObject(), "raw String"); When using matchers, all arguments have to be provided by matchers. For example: //correct: someMethod(anyObject(), eq("String by matcher")); the method findbyID is a baseDao method which my dao extends . It is not a final or static but still I'm getting this problem.
answer count: 2
tagged with: mockito
has comment: http://stackoverflow.com/comment/33638247

http://stackoverflow.com/comment/33543520
type: Comment
comment on: http://stackoverflow.com/a/22111230
type: AnswerComment
has text: @AnkitJain the cause is plain from the error messags: your input has slashes instead of dashes between the date parts. Try using pattern `"dd/MM/yyyy"`
score: 0

encryption
tags question: http://stackoverflow.com/q/22007780
tags question: http://stackoverflow.com/q/22138277
tags question: http://stackoverflow.com/q/22144519
tags question: http://stackoverflow.com/q/22085170
tags question: http://stackoverflow.com/q/22049759
tags question: http://stackoverflow.com/q/22132268
tags question: http://stackoverflow.com/q/22014507
tag name: encryption
tags question: http://stackoverflow.com/q/22067552
tags question: http://stackoverflow.com/q/22129488
tags question: http://stackoverflow.com/q/22078113
tags question: http://stackoverflow.com/q/22034269
tags question: http://stackoverflow.com/q/22102881
tags question: http://stackoverflow.com/q/22078859
tags question: http://stackoverflow.com/q/22057966
tags question: http://stackoverflow.com/q/22119186
type: Tag
tags question: http://stackoverflow.com/q/22130407

http://stackoverflow.com/comment/33774377
comment on: http://stackoverflow.com/a/22099525
type: AnswerComment
has text: yes I have, and I have been running, but now I have another way to give PagerTitleStrip but, you know another way to get the tabs?
score: 0
type: Comment

http://stackoverflow.com/a/22027324
has body: You can create your own exception class and throw the instance of that class from a method. The exception class: // Extending Exception makes your class throwable class MyException extends Exception { public MyException( String string ) { super( string ); } } And for parsing the input string to integer, call a method like this : int width = parseInt(args[0]); where your parseInt() method throws your custom exception as follows: private int parseInt( String number ) throws Exception { try { return Integer.parseInt( number ); } catch ( Exception e ) { throw new MyException( "The input is not a number" ); } } Now, you can catch your custom exception MyException similar to other standard exceptions: // catching your custom exception catch ( MyException e ) { System.err.println( e ); } // if there's one than more argument error will be displayed catch (ArrayIndexOutOfBoundsException exception) { System.out.println("Please supply width, depth and hight arguments!"); System.out.println("Exception message was: '" + exception.getMessage() + "'"); System.err.println(exception); } // catch // if a negative number is entered error will be displayed catch (NumberFormatException exception) { System.out.println("Dimensions for a cube can't be negative, please " + "insert only positive whole numbers!"); System.out.println("Exception message was: '" + exception.getMessage() + "'"); System.err.println(exception); } // catch
score: -1
has comment: http://stackoverflow.com/comment/33393066
upvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/22026301
has comment: http://stackoverflow.com/comment/33394188
downvote count: 1

http://stackoverflow.com/a/22129330
type: Answer
answers question: http://stackoverflow.com/q/22129291
upvote count: 4
downvote count: 0
score: 4
has body: You can have a look at the official documentation here I think you can use an iterator to traverse on the map's keyset to achieve what you want. Sample code here: import java.util.HashMap; import java.util.Iterator; import java.util.Map; public class Test { public static void main(String[] args) { Map&lt;Integer, String&gt; map = new HashMap&lt;Integer, String&gt;() { { put(1, "One"); put(2, "Two"); put(3, "Three"); put(4, "Four"); put(5, "Five"); } }; Iterator&lt;Integer&gt; iter = map.keySet().iterator(); while(iter.hasNext()){ System.out.println(iter.next()); } }

http://stackoverflow.com/comment/33509049
type: Comment
type: QuestionComment
has text: Ok I will, should I use a normal Thread or a Swing Worker?
score: 0
comment on: http://stackoverflow.com/q/22086206

http://stackoverflow.com/comment/33541957
has text: Shouldn't `decode(String str, int flags)` have the flag parameter?
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22110753
type: Comment

http://stackoverflow.com/q/22120066
has comment: http://stackoverflow.com/comment/33559041
downvote count: 0
possible better answer: http://stackoverflow.com/a/37944192
has answer: http://stackoverflow.com/a/22122813
accepted answer: http://stackoverflow.com/a/22120095
favorite count: 0
answer count: 9
has answer: http://stackoverflow.com/a/22120137
tagged with: android
has title: Programmatically Exit Android Application Without finish()
has answer: http://stackoverflow.com/a/25759496
upvote count: 6
has answer: http://stackoverflow.com/a/25577197
has answer: http://stackoverflow.com/a/22120320
has comment: http://stackoverflow.com/comment/33563505
score: 6
has answer: http://stackoverflow.com/a/22120083
linked to: http://stackoverflow.com/q/14001963
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22120095
has answer: http://stackoverflow.com/a/22120136
tagged with: java
has body: Before you tell me that this question has already been asked, let me tell you that none of those questions have an answer that suits me. I have a main Activity for my app. Before it runs, I have a splash screen Activity. If I call finish(), the program returns to my splash screen. I do not want this. Do not tell me to use finish(). I have heard that it is bad practice to not let Android close the app on its own. I know what I am doing...probably.... I want to be able to completely close the application from the second activity. Does anyone know of a way I can do this?
has answer: http://stackoverflow.com/a/37944192
linked to: http://stackoverflow.com/q/17899668
has comment: http://stackoverflow.com/comment/33560497

http://stackoverflow.com/comment/89495161
type: Comment
score: 0
comment on: http://stackoverflow.com/a/22125032
type: AnswerComment
has text: @Prasobh.K check PowerMockito.method

http://stackoverflow.com/q/22021634
answer count: 1
favorite count: 0
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/4530428
duplicate of: http://stackoverflow.com/q/4530428
has comment: http://stackoverflow.com/comment/33382029
score: 1
tagged with: java
upvote count: 1
tagged with: swing
type: Question
has title: Painting App's background in background thread?
has comment: http://stackoverflow.com/comment/33382199
has answer: http://stackoverflow.com/a/22025249
has body: I've got a window (public class Panel extends JPanel) that is setting its background from URL @Override protected void paintComponent(Graphics g) { super.paintComponent(g); try { this.imgBG = ImageIO.read(new URL("http://myhost.com/bg.png")); } catch (Exception e) { System.out.println("[ERROR] Could not load custom background image! Using resources."); this.imgBG = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/Resources/bg.png")); } g.drawImage(imgBG, 0, 0, this); } If it won't load an image, then it will use one from Resources. The problem is those images are heavy in memory and loading them is lagging whole window. Is there a way I can paint BG in background thread? If not, is this a good solution: Use LayeredPanel Create JLabel with size of window and place it in background Make new Runnable thread that will get image and JLabel.setIcon(image)
downvote count: 0

http://stackoverflow.com/a/22022196
upvote count: 1
has comment: http://stackoverflow.com/comment/33383809
has body: Use Iterator#remove() rather than Set#remove(Object). So replace the following line personnes.remove(autrePersonne); with i2.remove(); See here for more details.
score: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/33383521
has comment: http://stackoverflow.com/comment/33383030
type: Answer
answers question: http://stackoverflow.com/q/22022105

http://stackoverflow.com/comment/33409900
comment on: http://stackoverflow.com/q/22037373
score: 0
type: Comment
type: QuestionComment
has text: I completely forgot to change that… after so long i did not even notice it… although the problem now would be to get a return?

http://stackoverflow.com/q/22146598
tagged with: servlets
has title: The use of getResourceAsStream for BufferedReader and InputStream
has answer: http://stackoverflow.com/a/22147037
answer count: 1
tagged with: jsp
tagged with: tomcat
has comment: http://stackoverflow.com/comment/33605405
score: 0
has comment: http://stackoverflow.com/comment/33605368
accepted answer: http://stackoverflow.com/a/22147037
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33605715
has comment: http://stackoverflow.com/comment/33605535
has body: I am writing webApp that use jsp file to call java class directly to get results. The JSP file is like: &lt;% String queryKey = request.getParameter("id"); int jobID = Integer.parseInt(queryKey); out.println(jobID); ArrayList&lt;Integer&gt; myTopList = JobRecByBoWJaccard.topJobsByBoW(jobID); %&gt; In java classes the files are accessed through: BufferedReader br = new BufferedReader(new FileReader("WebContent/StopWords/stop-words-english1.txt")); and private InputStream modelInputT = new FileInputStream("WebContent/OpenNLP_Models/en-token.bin"); The tomcat cannot find the referenced files and someone said use getResourceAsStream, but that is for servlets. I call the java class directly without any servlets. private InputStream modelInputT = = this.getClass().getClassLoader().getResourceAsStream("WebContent/OpenNLP_Models/en-token.bin"); This cause java class cannot find the file as well. Need help and how to make changes to these java classes?
type: Question
has comment: http://stackoverflow.com/comment/33605593
linked to: http://stackoverflow.com/q/2786426
has comment: http://stackoverflow.com/comment/33605752
tagged with: java

http://stackoverflow.com/comment/33464714
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22068341
has text: @JanSchwar see my answer; but literally, you cannot get "unsigned bytes". Some libraries, like Guava, do provide helpers for such cases however.

http://stackoverflow.com/q/22089453
has title: Why do the source folders in package explorer appear in not alphabetical order
upvote count: 3
answer count: 1
favorite count: 0
type: AnsweredQuestion
score: 3
accepted answer: http://stackoverflow.com/a/22089519
downvote count: 0
tagged with: java
has body: I'm looking at a few projects in Eclipse's Package Explorer. I expect to see the items listed in this order: My Awesome Project + src/main/java + src/test/java + src/test/resources The first project in my list meets this expectation, but the second project appears in this order My Less Awesome Project + src/test/java + src/test/resources + src/main/java Is there a setting I can change to get the source folders to appear in the way I expect them to? I'm using Luna-Eclipse
tagged with: eclipse
type: Question
has answer: http://stackoverflow.com/a/22089519

http://stackoverflow.com/a/22022245
has comment: http://stackoverflow.com/comment/33384270
downvote count: 0
answers question: http://stackoverflow.com/q/22022000
has body: You have "/" characters in your query params. Try URL-encoding them as "%2F" (without the quote) using URLEncoder.encode. HttpPost httpPost = new HttpPost("http://ictfox.com/Hafil_Updates/SchoolLocation_Insert.aspx?schoolId="+((MyApplication) mActivity.getApplication()).schoolNum+"&amp;Location_Longitude="+this.txtLag+"&amp;Location_Latitude="+this.txtLat+"&amp;Location_Image="+URLEncoder.encode(imageString)+"&amp;Action_Date="+date2); This should produce: http://ictfox.com/Hafil_Updates/SchoolLocation_Insert.aspx?schoolId=212&amp;Location_Longitude=0&amp;Location_Latitude=0&amp;Location_Image=%2F9j%2F4AAQSkZJRgABAQAAAQABAAD%2F2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB [EDIT] If the image is too big you'll want to submit it in the request body: String url = "http://ictfox.com/Hafil_Updates/SchoolLocation_Insert.aspx"; HttpClient client = HttpClientBuilder.create().build(); HttpPost post = new HttpPost(url); List&lt;NameValuePair&gt; urlParameters = new ArrayList&lt;NameValuePair&gt;(); urlParameters.add(new BasicNameValuePair("schoolId", ((MyApplication) mActivity.getApplication()).schoolNum)); urlParameters.add(new BasicNameValuePair("Location_Longitude", this.txtLag)); urlParameters.add(new BasicNameValuePair("Location_Latitude", this.txtLat)); urlParameters.add(new BasicNameValuePair("Location_Image", imageString)); urlParameters.add(new BasicNameValuePair("Location_Longitude", date2)); post.setEntity(new UrlEncodedFormEntity(urlParameters)); HttpResponse response = client.execute(post);
has comment: http://stackoverflow.com/comment/33384217
type: Answer
has comment: http://stackoverflow.com/comment/33384479
score: 2
upvote count: 2

http://stackoverflow.com/a/22082436
type: Answer
has body: Steps: 1. Download JAD $ jad -o -ddecompiled_sources -sjava *.class 2. Generate the javadoc $ javadoc -d generated_javadoc -sourcepath decompiled_sources -subpackages java -exclude java.net:java.lang 3. Done EDIT: As seen on https://stackoverflow.com/a/8798013/3315914, comments are discarded in the compilation process, so you can generate the javadoc, but without comments.
score: 0
answers question: http://stackoverflow.com/q/22081639

http://stackoverflow.com/comment/33578626
score: 0
type: Comment
type: QuestionComment
has text: Yes it doesn't function, why?
comment on: http://stackoverflow.com/q/22130934

http://stackoverflow.com/comment/33397082
type: AnswerComment
score: 0
has text: I shared constructor and relevant part of main().
type: Comment
comment on: http://stackoverflow.com/a/22029624

http://stackoverflow.com/comment/33533231
type: Comment
score: 2
has text: @stijn26 ahh! Did you forget the `break;` statements in your switch-case?
type: AnswerComment
comment on: http://stackoverflow.com/a/22105786

http://stackoverflow.com/comment/33601487
type: AnswerComment
comment on: http://stackoverflow.com/a/22102290
type: Comment
has text: Thanks, your answer has really helped. My code is working properly.
score: 0

http://stackoverflow.com/comment/33384935
comment on: http://stackoverflow.com/a/22023308
type: AnswerComment
has text: `BitmapFactory.decodeStream()` because *so that I can make a Bitmap of it* :p
score: 0
type: Comment

http://stackoverflow.com/q/22077058
tagged with: java
tagged with: hibernate
has body: I am trying to do this: public List getInventarioNode(){ String sql = "select n.nid, n.nnm, n.nhwtype, n.nstate, n.ipaddress, n.ipaddressrouterid, n.eswversion, u.unhwtype, u.unslot, m.mpos, m.mhwtype from node n, unit u, module m where n.nid*=u.nid and n.nid*=m.nid and u.nid*=m.nid and u.unnr*=m.unnr and n.nhwtype in (10020, 10021, 10022, 10023, 10002, 10017, 10001) and m.mpos not between 11 and 10000"; List resultWithAliasedBean = session.createSQLQuery(sql).setResultTransformer(Transformers.aliasToBean(Node.class)).list(); return resultWithAliasedBean; } But I am getting this error: 11567 [AWT-EventQueue-0] ERROR org.hibernate.property.BasicPropertyAccessor - HHH000123: IllegalArgumentException in class: br.com.model.Node, setter method of property: mpos 11568 [AWT-EventQueue-0] ERROR org.hibernate.property.BasicPropertyAccessor - HHH000091: Expected type: java.lang.Integer, actual value: java.lang.Short Exception in thread "AWT-EventQueue-0" IllegalArgumentException occurred while calling setter for property [br.com.model.Node.mpos (expected type = java.lang.Integer)]; target = [br.com.model.Node@18f6f48], property value = [0] Node Class: //I tried to change the type of mpos and mhwtype to int, but it didnt work because the first row is null. In the database both are smallint, and can be null. private Integer mpos; private Integer mhwtype; public Node(){} public Integer getMpos() { return mpos; } public void setMpos(Integer mpos) { this.mpos = mpos; } public Integer getMhwtype() { return mhwtype; } public void setMhwtype(Integer mhwtype) { this.mhwtype = mhwtype; }
has comment: http://stackoverflow.com/comment/33480909
has comment: http://stackoverflow.com/comment/33481051
upvote count: 1
has comment: http://stackoverflow.com/comment/33481482
type: Question
has comment: http://stackoverflow.com/comment/33480989
has comment: http://stackoverflow.com/comment/33481224
has title: Expected type: java.lang.Integer, actual value: java.lang.Short
has comment: http://stackoverflow.com/comment/33482678
has comment: http://stackoverflow.com/comment/33481167
has comment: http://stackoverflow.com/comment/33480801
downvote count: 0
has comment: http://stackoverflow.com/comment/33481960
has comment: http://stackoverflow.com/comment/33481053
has comment: http://stackoverflow.com/comment/33480920
favorite count: 0
has comment: http://stackoverflow.com/comment/33481117
has comment: http://stackoverflow.com/comment/33480789
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33480788
answer count: 0
score: 1

http://stackoverflow.com/a/22133651
has body: Try this: ack yourfile.txt -o --match '[0-9]{5}(?!.*([0-9]{5}))' What this does is find the last 5 digit number on each line
accepted answer of: http://stackoverflow.com/q/22133506
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22133506
upvote count: 1
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/33584447
has comment: http://stackoverflow.com/comment/33584833
score: 1

http://stackoverflow.com/q/22095869
has answer: http://stackoverflow.com/a/22096040
answer count: 2
favorite count: 0
tagged with: return
has body: I have an array which i want to search and check that if any value has more than one route. For example i want the computer to check the array and see if 0,1 comes up anywhere twice which it doesnt, but mine seems to not work. I want this to work for all the values on the left. So no value in the first column should pair with more than 0 or 1 more than once. e.g 0,1 and 0,1 should never exist twice and if it does the computer should return false but if it doesnt it returns true myArray=new int[][]{ {0, 1}, {0, 0}, {1, 1}, {1, 0}, {2, 0}, {2, 1}, {3, 0}, }; for (int i = 0; i &lt;= myArray.length; i++){ for(int z = 1; z&lt;= myArray.length; z++){ if(myArray[i][1]== myArray[z][1] &amp;&amp; myArray[i][0] == myArray[z][0]){ check = false; } else{ check = true; } } } return check; }
has title: If statement equal twice
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22095942
tagged with: java
downvote count: 2
upvote count: 1
accepted answer: http://stackoverflow.com/a/22095942
type: Question
tagged with: if-statement
possible better answer: http://stackoverflow.com/a/22096040
tagged with: arrays
score: -1

http://stackoverflow.com/q/22156394
tagged with: java
has comment: http://stackoverflow.com/comment/33624031
has body: I'm using JMock &amp; JDave unfinalizer, it was fine with Java 6. but after moving to Java 7 my unit tests that use jdave-unfinalizer fail with such error: java.lang.VerifyError: Expecting a stackmap frame at branch target 49 Exception Details: Location: com/hhi/domain/model/common/DomainAddressTestUF.testEquals()V @42: if_icmpne Reason: Expected stackmap frame at this location. Bytecode: 0000000: b800 2e4c 2b2b b800 a22b 2bb6 00bc b800 0000010: c0bb 0009 592b b700 33b6 0022 4d2b 2cb8 0000020: 00a2 2bb6 00c4 2cb6 00c4 a000 0704 a700 0000030: 0403 b800 c02b 2cb6 00bc b800 c0bb 0009 0000040: 592b b700 3312 c6b6 00ca b600 224e 2b2d 0000050: b800 cd2b 2db6 00bc b800 d0b1 at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2531) at java.lang.Class.getMethod0(Class.java:2774) at java.lang.Class.getMethod(Class.java:1663) at org.junit.internal.builders.SuiteMethodBuilder.hasSuiteMethod(SuiteMethodBuilder.java:20) at org.junit.internal.builders.SuiteMethodBuilder.runnerForClass(SuiteMethodBuilder.java:13) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57) Has anybody used jdave-unfinalizer with Java 7 ?
tagged with: unit-testing
type: Question
has comment: http://stackoverflow.com/comment/33673040
tagged with: jmock
upvote count: 3
has comment: http://stackoverflow.com/comment/33623943
answer count: 1
favorite count: 0
has title: jdave-unfinalizer Java 7 stackmap frame
has answer: http://stackoverflow.com/a/22184148
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/16905947
score: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/33673012

http://stackoverflow.com/q/22009341
tagged with: jsp
has comment: http://stackoverflow.com/comment/33360107
score: 0
has answer: http://stackoverflow.com/a/22009458
has answer: http://stackoverflow.com/a/22009817
answer count: 7
has comment: http://stackoverflow.com/comment/33359824
has answer: http://stackoverflow.com/a/22009479
has answer: http://stackoverflow.com/a/22009442
has answer: http://stackoverflow.com/a/22009643
has body: strSQL = "INSERT INTO emp(NO, EMP_NAME, EMP_TEL)VALUES(088000, 'JIMMY', *****)"; stmt.executeUpdate(strSQL); I have this statement to insert a new employee into the database. What if I want the employee NO to be automatically generated by adding 1 to the previous employee NO? How can this be done in JSP?
has comment: http://stackoverflow.com/comment/33360070
accepted answer: http://stackoverflow.com/a/22009417
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22009541
has title: Assign ID number automatically
tagged with: java
has answer: http://stackoverflow.com/a/22009417
type: Question
possible better answer: http://stackoverflow.com/a/22009442
tagged with: database

http://stackoverflow.com/comment/33639924
comment on: http://stackoverflow.com/a/22048396
has text: I just added my filter code in the question, and i still can't understand what's wrong in it.. :(
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33430991
has text: Probably because you are translating your projection matrix. The [4th column of that matrix](http://www.songho.ca/opengl/files/gl_projectionmatrix_eq24.png) includes some math performed using the `zNear` and `zFar` values, and by translating the matrix you are messing with that.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22047654

http://stackoverflow.com/comment/33419595
score: 1
type: AnswerComment
has text: http://stackoverflow.com/questions/how-to-answer I believe you already know this, however please look at "Provide context for links" paragraph. Otherwise it should rather be a helpful comment.
type: Comment
comment on: http://stackoverflow.com/a/22042869

http://stackoverflow.com/comment/33598160
has text: Wild guess : maybe your system doesn't recognize dot for decimal, rather it recognizes comma? So instead try String val = "9,612771780095113E-25";
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22141930
score: 1

http://stackoverflow.com/comment/33517887
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22097914
score: 0
has text: @Salah probably to display how much data is left in their account

http://stackoverflow.com/comment/33403063
type: QuestionComment
comment on: http://stackoverflow.com/q/22033409
type: Comment
score: 2
has text: @SotiriosDelimanolis The link you provided is about final strings,My code does not have final

opennlp
type: Tag
tag name: opennlp
tags question: http://stackoverflow.com/q/22007197

http://stackoverflow.com/q/22164575
has answer: http://stackoverflow.com/a/22165000
accepted answer: http://stackoverflow.com/a/22165000
has comment: http://stackoverflow.com/comment/33638423
has comment: http://stackoverflow.com/comment/33637858
has comment: http://stackoverflow.com/comment/33638352
has comment: http://stackoverflow.com/comment/33637887
has comment: http://stackoverflow.com/comment/33637864
has comment: http://stackoverflow.com/comment/33637793
has comment: http://stackoverflow.com/comment/33638127
has comment: http://stackoverflow.com/comment/33638004
type: AnsweredQuestion
has title: Passing values from from Servlet to JSP
has answer: http://stackoverflow.com/a/22164736
has comment: http://stackoverflow.com/comment/33638129
tagged with: java
has comment: http://stackoverflow.com/comment/33638018
has comment: http://stackoverflow.com/comment/33638265
type: Question
has body: I am attempting to pass certain values from my servlet to the JSP page and add the values which have been passed to the tag, reading many posts I've got the following code. Use input tage to select files Verify files uploaded invoke upload.java to save uploaded files in WEB-INF of the uploaded file a selected file is saved as my.txt Use buffers to read contents of the file and save them to a variable passing this to the JSP page upload.java After uploading the files, response.setContentType("text/html"); String LINE = " "; String filename = "/WEB-INF/my.txt"; fileTxt = ""; ServletContext context = getServletContext(); InputStream is = context.getResourceAsStream(filename); if (is != null) { InputStreamReader isr = new InputStreamReader(is); BufferedReader reader = new BufferedReader(isr); PrintWriter writer = response.getWriter(); String text = ""; while ((text = reader.readLine()) != null) { fileTxt = text + LINE; } request.setAttribute("File_Text", fileTxt); RequestDispatcher rd = request.getRequestDispatcher("mypage.jsp"); rd.forward(request, response); } mypage.jsp Left File : Right File : Config File : Click to Upload files Now, after doing all this when I click my upload button, it is just not working and the click is not at all being recognized but when I remove the file accessing code the button works fine.. why is this happening? what to do? Is this the right way to accessing values of servlet in JSP? ======================================EDIT======================================= Just to clarify things further, User uploads a file That file is saved as my.txt I am opening this file, reading its contents adding those contents to my ACE editor in
has comment: http://stackoverflow.com/comment/33638364
has comment: http://stackoverflow.com/comment/33638044
tagged with: jsp
tagged with: javascript
has comment: http://stackoverflow.com/comment/33638178
has comment: http://stackoverflow.com/comment/33638327
has comment: http://stackoverflow.com/comment/33638079
score: 0
answer count: 2
possible better answer: http://stackoverflow.com/a/22164736
has comment: http://stackoverflow.com/comment/33638196
has comment: http://stackoverflow.com/comment/33637926
has comment: http://stackoverflow.com/comment/33638233
has comment: http://stackoverflow.com/comment/33638243
has comment: http://stackoverflow.com/comment/33638093
has comment: http://stackoverflow.com/comment/33638098

http://stackoverflow.com/q/22094893
has answer: http://stackoverflow.com/a/22099687
has body: I am stuck in a very bad situation Kindly help. My requirement : In a text area I will be replacing a String with a value Eg.. Original text :James Bond acted in Skyfall I need to change 'James' alone, with a Tag {CTPC-1} then it will be displaying like " {CTPC-1} Bond acted in Skyfall" this is done dynamically.. when I select the next string it will be incremented {CTPC-2} etc.. after replacing it.. the tag "{CTPC-1}" alone should not be editable others i.e "Bond acted in Skyfall"should be in editable format I need to do this in java swings kindly help me
type: AnsweredQuestion
tagged with: java
tagged with: swing
has comment: http://stackoverflow.com/comment/33512627
type: Question
tagged with: jtextarea
accepted answer: http://stackoverflow.com/a/22099687
score: 0
has title: how to make specific text uneditable in JTextarea
answer count: 1
tagged with: swingx
tagged with: netbeans-7
has comment: http://stackoverflow.com/comment/33512813

http://stackoverflow.com/a/24832890
downvote count: 0
answers question: http://stackoverflow.com/q/22158855
has body: First I want to say that I would really recommend using JavaFX for such an application. You can also integrate your JavaFX project in existing swing applications using JFXPanel. However I have heard about MT4j which is a framework for multitouch in Java application which also supports Swing. I have not worked with it. So I can not tell you how good it works.
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/38555073
upvote count: 3

http://stackoverflow.com/a/22143139
has comment: http://stackoverflow.com/comment/33601777
has comment: http://stackoverflow.com/comment/33601057
type: AcceptedAnswer
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/22142979
has body: ＂No Source Found＂occurred when you debug a class without the source file. You should just use F6 to step over when debugging.
accepted answer of: http://stackoverflow.com/q/22142979
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33603456

http://stackoverflow.com/comment/33607149
comment on: http://stackoverflow.com/q/22147626
has text: Are your really sure that you want a Activity for every Question? I would really try to take another approach because this is getting you in real trouble. Try to make one Activity and update the views, store the questions in a database so you can easily add new Questions
score: 1
type: QuestionComment
type: Comment

http://stackoverflow.com/a/22038664
has comment: http://stackoverflow.com/comment/33417484
answers question: http://stackoverflow.com/q/22038608
has body: Please try this. public void print() { //The desktop api can help calling native applications in windows Desktop desktop = Desktop.getDesktop(); try { desktop.print(new File("yourFile.pdf")); } catch (IOException e) { e.printStackTrace(); } } Please Note : This is the easy fix. You can also use java's Print API to achieve the same thing
upvote count: 2
has comment: http://stackoverflow.com/comment/33418423
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/33418567
downvote count: 0

http://stackoverflow.com/q/22114318
downvote count: 0
tagged with: actionform
has title: can we apply declarative validation with DynaActionForm
has body: I am new to Struts framework. I am getting a little confusion if DynaActionForm is not supporting validation why framework introduced this form bean class. As we have so many disadvantages like: The DynaActionForm bloats up the Struts config file with the xml based definition. This gets annoying as the Struts Config file grow larger. The DynaActionForm is not strongly typed as the ActionForm. This means there is no compile time checking for the form fields. Detecting them at runtime is painful and makes you go through redeployment. ActionForm can be cleanly organized in packages as against the flat organization in the Struts Config file. ActionForm were designed to act as a Firewall between HTTP and the Action classes, i.e. isolate and encapsulate the HTTP request parameters from direct use in Actions. With DynaActionForm, the property access is no different than using request.getParameter(some parameters). DynaActionForm construction at runtime requires a lot of Java Reflection machinery that can be expensive.
favorite count: 0
type: UnansweredQuestion
answer count: 0
score: 1
tagged with: java
upvote count: 1
tagged with: struts-1
type: Question

http://stackoverflow.com/q/22046461
has body: I need to return the number of LIS of the array. Pseudocode example: if the arr is int []arr = {2,4,90,-3,-2,-1,-10,-9,-8}; num of LIS is: 3 2,4,90 -3,-2,-1 -10,-9,-8 example 2: arr [] = {2,-3,4,90,-2,-1,-10,-9,-8}; num of LIS is: 4 2,4,90 -3,4,90 -3,-2,-1 -10,-9,-8 I have tried to do this: int [] A = {2,4,90,-3,-2,-1,-10,-9,-8}; int[] dp = new int[A.length]; for (int i = 0; i &lt; A.length; i++) { dp[i] = 1; for (int j = 0; j &lt;= i - 1; j++) { if (A[j] &lt; A[i]) { dp[i] = dp[i] + dp[j]; } } System.out.println(dp[dp.length - 1] ) ; }
tagged with: http://stackoverflow.com/tag/c
has comment: http://stackoverflow.com/comment/33426080
type: Question
duplicate of: http://stackoverflow.com/q/3992697
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/22046560
has comment: http://stackoverflow.com/comment/33427515
has comment: http://stackoverflow.com/comment/33426219
score: -1
tagged with: c++
has comment: http://stackoverflow.com/comment/33426130
type: UnansweredQuestion
tagged with: java
downvote count: 2
upvote count: 1
has comment: http://stackoverflow.com/comment/33427398
has title: Number of Longest increasing subsequence
has comment: http://stackoverflow.com/comment/33426406
tagged with: c#
linked to: http://stackoverflow.com/q/3992697

http://stackoverflow.com/a/22115281
downvote count: 0
answers question: http://stackoverflow.com/q/22111603
has comment: http://stackoverflow.com/comment/86211063
upvote count: 30
has body: All you have to do is deploy the exploded artifacts instead of the .ear/.war. Go back into the Run/Debug Configurations in the deployment tab and change the artifact that your deploying and pick the one that ends with :exploded
type: AcceptedAnswer
score: 30
type: Answer
accepted answer of: http://stackoverflow.com/q/22111603

http://stackoverflow.com/q/22117072
downvote count: 0
tagged with: inheritance
score: 16
linked to: http://stackoverflow.com/q/9560600
favorite count: 0
has title: no enclosing instance of type... in scope
possible better answer: http://stackoverflow.com/a/22117161
tagged with: inner-classes
has answer: http://stackoverflow.com/a/22117161
has answer: http://stackoverflow.com/a/22117102
has body: I investigate java inner classes. I wrote example: public class Outer { public Outer(int a){} public class Inner { public Inner(String str, Boolean b){} } public static class Nested extends Inner{ public static void m(){ System.out.println("hello"); } public Nested(String str, Boolean b , Number nm) { super("2",true); } } public class InnerTest extends Nested{ public InnerTest(){ super("str",true,12); } } } I invoke it from main using following string: new Outer(1).new Inner("",true); I see compile error: java: no enclosing instance of type testInheritancefromInner.Outer is in scope Can you explain me this situation? UPDATE
upvote count: 16
type: Question
tagged with: instantiation
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33552853
tagged with: java
has comment: http://stackoverflow.com/comment/33552894
answer count: 2
has comment: http://stackoverflow.com/comment/59192498
accepted answer: http://stackoverflow.com/a/22117102

http://stackoverflow.com/comment/33579310
type: Comment
has text: Kinda. Another way can be `String str = null; while ((str = scanner.nextLine() != null) { ... }`.
comment on: http://stackoverflow.com/a/22131017
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33424946
score: 0
type: QuestionComment
has text: Nope, please re-read the question. I've tried to clarify it with an example. @BrianAgnew
type: Comment
comment on: http://stackoverflow.com/q/22044958

http://stackoverflow.com/comment/33500448
has text: removing "0" or 0 is the same
comment on: http://stackoverflow.com/q/22087863
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22005918
answer count: 1
has comment: http://stackoverflow.com/comment/33373426
favorite count: 0
score: 0
tagged with: nullpointerexception
has comment: http://stackoverflow.com/comment/33374825
tagged with: android
has comment: http://stackoverflow.com/comment/33376613
has comment: http://stackoverflow.com/comment/33376401
tagged with: bundle
has answer: http://stackoverflow.com/a/22019025
has comment: http://stackoverflow.com/comment/33353984
accepted answer: http://stackoverflow.com/a/22019025
has comment: http://stackoverflow.com/comment/33374952
has comment: http://stackoverflow.com/comment/33354832
has comment: http://stackoverflow.com/comment/33373295
has comment: http://stackoverflow.com/comment/33376294
upvote count: 1
has comment: http://stackoverflow.com/comment/33376784
downvote count: 1
type: Question
has body: I am getting a NullPointerException when my code tries to access the value in a key/value pair created by onSaveInstanceState method of Activity class. I set break points and I know for fact my Bundle is not null and it contains references to my key/values. I dont understand why I am getting this runtime error. Here are my codes for onSaveInstanceState @Override protected void onSaveInstanceState(Bundle outState) { int mPoints = winCount; int hPoints = loseCount; String reTextView = resultsTextView.getText().toString(); String pTextView = pointsTextView.getText().toString(); String roTextView = rollTextView.getText().toString(); outState.putInt("MY_POINTS", mPoints); outState.putInt("HOUSE_POINTS", hPoints); outState.putString("RESULTS", reTextView); outState.putString("POINTS", pTextView); outState.putString("ROLL", roTextView); super.onSaveInstanceState(outState); } and here is my code to restore the state on the onCreate method // check if app just started or is being restored from memory if ( savedInstanceState == null ) // the app just started running { winCount = 0; loseCount = 0; } else { winCount = savedInstanceState.getInt("MY_POINTS"); loseCount = savedInstanceState.getInt("HOUSE_POINTS"); resultsTextView.setText(String.valueOf(savedInstanceState.getString("RESULTS"))); pointsTextView.setText(String.valueOf(savedInstanceState.getString("POINTS"))); rollTextView.setText(String.valueOf(savedInstanceState.getString("ROLL"))); } I get the runtime error on line that starts with resultsTextView.setText... and here is contents of the savedInstanceState Bundle retrieved from break points in debug mode Bundle[{RESULTS=Roll Again, MY_POINTS=2, POINTS=Your Point is 8, HOUSE_POINTS=2, android:viewHierarchyState=Bundle[{android:Panels=android.util.SparseArray@421c5560, android:views=android.util.SparseArray@421c5358, android:ActionBar=android.util.SparseArray@421c57f8}], ROLL=You Rolled Easy Four}] as you can see all my strings have a value, the interesting thing is th…
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33376734
tagged with: oncreate
tagged with: java
has comment: http://stackoverflow.com/comment/33376087
has comment: http://stackoverflow.com/comment/33375432
has comment: http://stackoverflow.com/comment/33373873
has title: NullPointerException in savedInstanceState Bundle
has comment: http://stackoverflow.com/comment/33375480
has comment: http://stackoverflow.com/comment/33376225
has comment: http://stackoverflow.com/comment/33376167

http://stackoverflow.com/q/22163397
possible better answer: http://stackoverflow.com/a/42873043
favorite count: 0
has title: Spring: How to get parameters from POST body?
tagged with: spring
upvote count: 27
tagged with: spring-mvc
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33636996
tagged with: java
accepted answer: http://stackoverflow.com/a/22163492
has answer: http://stackoverflow.com/a/33067085
has answer: http://stackoverflow.com/a/42873043
type: Question
has answer: http://stackoverflow.com/a/53293977
has body: Web-service using spring in which I have to get the params from the body of my post request? The content of the body is like:- source=”mysource” &amp;json= { "items": [ { "username": "test1", "allowed": true }, { "username": "test2", "allowed": false } ] } And the web-service method looks like:- @RequestMapping(value = "/saveData", headers="Content-Type=application/json", method = RequestMethod.POST) @ResponseBody public ResponseEntity&lt;Boolean&gt; saveData(@RequestBody String a) throws MyException { return new ResponseEntity&lt;Boolean&gt;(uiRequestProcessor.saveData(a),HttpStatus.OK); } Please let me know how do I get the params from the body? I can get the whole body in my string but I don't think that would be a valid approach. Please let me know how do I proceed further.
answer count: 6
has answer: http://stackoverflow.com/a/22163492
has answer: http://stackoverflow.com/a/22164243
score: 27
tagged with: rest
has answer: http://stackoverflow.com/a/22164585
has comment: http://stackoverflow.com/comment/33636944
downvote count: 0
has comment: http://stackoverflow.com/comment/33637262

http://stackoverflow.com/a/22080001
downvote count: 0
has body: Well the reason that your arrays don't get sorted is that your recursive algorithm keeps recreating the intSorted [] and stringSorted [] with each invocation. Also your recursive method just returns an int (the number of inversions performed). In order of the recursive approach to work each sortAndCount must return it's piece of the array sorted. This makes it difficult to attempt to sort two different arrays in the same algorithm. I have made a few minor tweaks to your code and now it sorts the int[] correctly. If you want to count inversions at the same time that you sort, I would suggest adding a passByReference to a Counter object that does nothing but count inversions (like a visitor pattern). Here is my code: public class Test { private static int[] intSorted; public static void main(String[] args) { //Creates new string to sort //Creates new int to sort int[] intt3 = {1,3,4,6,2,5}; //Calls sortAndCount on int and prints the number of inversions System.out.println(sortAndCount(intt3)); //Turns the int array into a string to print StringBuilder intBuild = new StringBuilder(); for(int i = 0; i &lt; intSorted.length; i++){ if(i+1 == intSorted.length){ intBuild.append(intSorted[i]); } else{ intBuild.append(intSorted[i] + ", "); } } //Turns the string array into a string to print System.out.println(intBuild); } private static int[] sortAndCount(int intToSort[]){ int inversionsLeft; int inversionsRight; int inversionsMerged; if(intToSort.length == 1){ return intToSort; } int m = intToSort.length/2; int[] intLeft = new int[m]; String[] stringLeft = new String[m]; int[] intRight = new int[intToSort.length-m]; String[] stringRight = new String[intToSort.length-m]; for (int i=0; i &lt; m; i++){ intLeft[i] = intToSort[i]; } for (int i = 0;i &lt; intRight.length; i++){ intRight[i] = intToSort[m+i]; } intLeft = sortAndCount(intLeft); intRight = sortAndCount(intRight); intSorted = new int[intToSort.length]; intSorted = mergeAndCount(intLeft, intRight); return intSorted; } p…
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/22079031
score: 1

http://stackoverflow.com/comment/33530015
type: AnswerComment
type: Comment
has text: I can't seem to be able to get `concreteShape`'s class functions.
score: 0
comment on: http://stackoverflow.com/a/22104055

http://stackoverflow.com/comment/33479469
type: QuestionComment
has text: You could do `for (int i : new int[]{1, 2, 3, 4, 5}) System.out.println(i);` or `for (int i : Arrays.asList(1, 2, 3, 4, 5))`
score: 0
comment on: http://stackoverflow.com/q/22076397
type: Comment

storage
tag name: storage
tags question: http://stackoverflow.com/q/22167290
tags question: http://stackoverflow.com/q/22050430
type: Tag
tags question: http://stackoverflow.com/q/22087436
tags question: http://stackoverflow.com/q/22033253

http://stackoverflow.com/comment/33434868
score: 1
type: AnswerComment
has text: I have passed null, and got 1 in result, So thats mean its problem in where clause?
comment on: http://stackoverflow.com/a/22051183
type: Comment

http://stackoverflow.com/comment/33637201
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22164265
has text: `getText()` *doesn't* return a string?

oracle11g
tags question: http://stackoverflow.com/q/22077892
tags question: http://stackoverflow.com/q/22060426
type: Tag
tag name: oracle11g

http://stackoverflow.com/a/22088841
type: Answer
upvote count: 4
has comment: http://stackoverflow.com/comment/33504343
downvote count: 0
has comment: http://stackoverflow.com/comment/33504531
accepted answer of: http://stackoverflow.com/q/22088820
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22088820
score: 4
has body: You should replace this Spinner fSpinner = (Spinner)findViewById(R.id.fSpinner); Spinner phSpinner = (Spinner)findViewById(R.id.phSpinner); With Spinner fSpinner = (Spinner)alertView.findViewById(R.id.fSpinner); Spinner phSpinner = (Spinner)alertView.findViewById(R.id.phSpinner); And also change if EditText comes from your Custom Dialog layout then EditText phNumber = (EditText)alertView.findViewById(R.id.phNumber);
has comment: http://stackoverflow.com/comment/33504647

http://stackoverflow.com/a/22019323
answers question: http://stackoverflow.com/q/22019254
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33378052
has body: You are not initializing txtInformacion anywhere in your code. You need to initialize it with the appropriate TextView before you can use it in onPreExecute() method of AsyncCallWS
has comment: http://stackoverflow.com/comment/33378191
upvote count: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22019254

http://stackoverflow.com/comment/33594774
type: Comment
type: QuestionComment
has text: Apart from the concrete problem, why are you attempting to save the file to the deploy space..? Do you very well realize that all changes in deploy space are completely lost when you redeploy the WAR?
comment on: http://stackoverflow.com/q/22137643
score: 1

http://stackoverflow.com/comment/33606896
comment on: http://stackoverflow.com/a/22147447
type: AnswerComment
has text: one thing you can try is to add a shutdown/startup hook that send you some notification like http://www.mastertheboss.com/jboss-configuration/intercepting-jboss-shutdown. Again, it's not 100% reliable
type: Comment
score: 1

http://stackoverflow.com/comment/33543303
has text: You have an NPE @ at com.mycontacts.NativeServices.SendPushMsg(NativeServices.java:68)
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22111314

http://stackoverflow.com/q/22043166
has body: I am using Amazon SimpleDB from a desktop java app. Thus my installer needs to ship the aws-sdk jar as well. The issue is, its 11mB and has a whole lot of classes for services that I will not use. Is there an easy way of splitting up the sdk into smaller chunks. Like have all the common code into one jar. And all the service specific code into another jar? Is there something that I could use out of the box? Or do I need to this myself after downloading the code? I am using the typica library. But its not maintained anymore and is not compatible with the latest httpcomponents.
favorite count: 0
type: UnansweredQuestion
score: 6
has answer: http://stackoverflow.com/a/75330868
upvote count: 6
has answer: http://stackoverflow.com/a/22086555
has comment: http://stackoverflow.com/comment/33421016
tagged with: java
has comment: http://stackoverflow.com/comment/33446359
type: Question
answer count: 2
downvote count: 0
tagged with: amazon-web-services
has title: AWS SDK - very big - 11MB. I want to use only the SimpleDB service

http://stackoverflow.com/a/22126415
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33570251
accepted answer of: http://stackoverflow.com/q/22126403
type: Answer
upvote count: 4
answers question: http://stackoverflow.com/q/22126403
downvote count: 0
score: 4
has body: The speed variable should not be static. Otherwise it won't be bound to any of the instances of the DynamicObject class, nor any of it's subclasses instances. If you want to have a different speed value for each of the subclasses, you can do: public class DynamicObject { protected float speed; public DynamicObject(float speed) { this.speed = speed; } public float getSpeed() { return this.speed; } } public class Player extends DynamicObject { /*some code*/ public Player(float speed) { super(speed); } } public class Enemy extends DynamicObject { /*some code*/ public Enemy(float speed) { super(speed); } }

http://stackoverflow.com/comment/33587458
comment on: http://stackoverflow.com/q/22135628
score: 0
type: Comment
type: QuestionComment
has text: Yes that's my consideration

http://stackoverflow.com/comment/33636847
type: Comment
has text: If you make it compilable by transforming `t1.x+" "t2.x` into `t1.x+" "+t2.x`, it compiles fine.
score: 2
comment on: http://stackoverflow.com/q/22164036
type: QuestionComment

http://stackoverflow.com/comment/33456380
score: 0
type: Comment
has text: Are you sure you're pointing to the correct directories? Also, dont remove the ".". That will allow the JVM to find classes starting from the current directory.
type: AnswerComment
comment on: http://stackoverflow.com/a/22063497

http://stackoverflow.com/a/22069883
has comment: http://stackoverflow.com/comment/33467341
has body: You have to include the JAR in your classpath: java -jar yourdriver.jar LoadDriver JARs are filesystems. They should be added to your classpath the same way you add directories. Only classes will be loaded from the classpath you specified.
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33467232
type: Answer
score: 2
answers question: http://stackoverflow.com/q/22069819
upvote count: 2
accepted answer of: http://stackoverflow.com/q/22069819

http://stackoverflow.com/q/22006984
tagged with: jsessionid
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/23373269
linked to: http://stackoverflow.com/q/11349064
upvote count: 7
has answer: http://stackoverflow.com/a/44323758
has comment: http://stackoverflow.com/comment/45225521
has body: Yes, this is another "JSESSIONID in URL" question, but I haven't been able to find an answer. I'm running JBoss AS 7.1.1 Final and this is my web.xml: true <!-- secure>true</secure--> COOKIE 30 appServlet org.springframework.web.servlet.DispatcherServlet contextConfigLocation com.cgi.dk.vias.web.config.WebConfig contextClass org.springframework.web.context.support.AnnotationConfigWebApplicationContext 1 appServlet / Based on internet search and answers here on Stack Overflow (e.g. https://stackoverflow.com/a/11350819/224143), it is my understanding that setting COOKIE should prevent JSESSIONID from being appended to URLs. However, when I browse to my site with a fresh browser window (i.e. no existing cookies or session), all links have JSESSIONID appended in the first response. If i refresh the page, the JSESSIONID disappears, since it goes into the cookie. I understand that I can create a filter to remove it, but I'd rather avoid tampering with the html if possible. My browser supports cookies, of course, and they are enabled. Is my understanding of the element wrong, or is there something else going on that I'm missing?
score: 7
tagged with: java
tagged with: jboss
type: Question
answer count: 2
downvote count: 0
tagged with: servlet-3.0
has comment: http://stackoverflow.com/comment/47836273
has title: JBoss 7 appends JSESSIONID to URL despite tracking-mode cookie
tagged with: jboss7.x
favorite count: 0
has comment: http://stackoverflow.com/comment/47868656

http://stackoverflow.com/comment/33430202
score: 0
comment on: http://stackoverflow.com/a/22048280
type: Comment
has text: I would highly recommend working through a tutorial before going any further.
type: AnswerComment

http://stackoverflow.com/q/22093918
has answer: http://stackoverflow.com/a/22094219
type: Question
has title: Should you use runnable even if the threads are not sharing data?
has comment: http://stackoverflow.com/comment/33511250
has comment: http://stackoverflow.com/comment/33511456
answer count: 1
linked to: http://stackoverflow.com/q/541487
has comment: http://stackoverflow.com/comment/33511185
upvote count: 1
tagged with: runnable
has body: I have been working on writing a multi threaded java program. Before I progress I was thinking how best I can write the program. I read the differences between runnable and thread and what we should use and what we should not. However I have a question. Is it good to follow the runnable implementation to thread even if the threads are not sharing data i.e the same runnable class object? I would end up creating different runnable objects thus occupying memory. Also another idea I have is to pool runnable objects and change the value they hold and assign it to a thread. Thereby having only a set of runnable objects and thus utilizing memory better. Sample Code: public class MrRunnable implements Runnable { private String toFireUrl; MrRunnable(String url){ } @Override public void run() { // do some function here } } public class Main { public static void main(String[] args) { // We will create 500 threads for (int i = 0; i &lt; 500; i++) { Runnable task = new MrRunnable("some new url"); Thread worker = new Thread(task); //start the thread worker.start(); } } } Here I am creating a new instance of runnable objects and my threads don't share data. So is this way justified? Or is it better to create a pool of runnable objects and I let my threads manipulate their content and use it?
favorite count: 0
has comment: http://stackoverflow.com/comment/33510701
tagged with: multithreading
has comment: http://stackoverflow.com/comment/33510962
accepted answer: http://stackoverflow.com/a/22094219
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33511277
downvote count: 0
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33510902

http://stackoverflow.com/comment/33390644
score: 0
type: Comment
has text: Thanks for the example - it helped some. If, at the "what would happen?" line, the code did `toWrite = null`, the compiler isn't smart enough to say "use the value from **before**"? In effect, pass `toWrite` _by value_ to the Runnable? (especially as it gets copied?) Geez, doesn't seem like rocket science there, but I'm not writing the compiler... :-)
type: AnswerComment
comment on: http://stackoverflow.com/a/22025275

http://stackoverflow.com/a/22110077
has body: One example: while thread 1 is putting a value, thread 2 decides to increase hash table capacity. In this case thread 1 may put its value to the old hash table and thread 2 may overwrite this hash table with a new one. Thread 1 put is lost.
score: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22109978
answers question: http://stackoverflow.com/q/22109978
type: Answer

http://stackoverflow.com/comment/33411979
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22038455
type: Comment
has text: @chrylis - Hmm, you may be right. I seem to really be asking "How can I reduce my code's memory footprint?" rather than "How often should I call System/gc?". I'll update the question to reflect that.

http://stackoverflow.com/comment/33633151
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22155658
has text: The example looks right for the question, I think this answer should highlight that its getOptionsfromEnv() method depends on the exported DATASTORE_SERVICE_ACCOUNT and DATASTORE_PRIVATE_KEY_FILE environment variables. About the second question, the GCS StorageSample uses GoogleAuthorizationCodeFlow.Builder which relies on GoogleClientSecrets loaded from a /client_secrets.json, so that software is rather different.

http://stackoverflow.com/comment/33535670
type: QuestionComment
comment on: http://stackoverflow.com/q/22107128
score: 0
type: Comment
has text: does it occurs when you click on the button twice ?

http://stackoverflow.com/comment/33569067
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22125768
score: 0
has text: I agree its not that it is unreadable as I mentioned affects readablity, again which depends on indvidual.

http://stackoverflow.com/q/22150317
type: AnsweredQuestion
tagged with: java
tagged with: lotus-domino
tagged with: apache-camel
type: Question
tagged with: jakarta-mail
has body: I just play with emails recently. An application downloads email from mail server with apache-camel-mail component via IMAP protocol and do some magic with the email body. The problem I observe is about primary email folder name on Lotus notes email server. It supposed to be INBOX but actually it is Inbox. My question is... Is there a specification for IMAP or email in general to define the primary folder as INBOX? Or I can hypothetically used in my fresh new mail server primary inbox name like 1nB0x with no harm and still be compliant to IMAP spec. Thanks
accepted answer: http://stackoverflow.com/a/22150888
answer count: 1
tagged with: imap
score: 0
has title: Is there a specification defines INBOX as the primary folder?
has answer: http://stackoverflow.com/a/22150888

http://stackoverflow.com/q/22159596
duplicate of: http://stackoverflow.com/q/3875184
tagged with: android
has title: app crash when android use sql web service
answer count: 0
has body: ive build in netbeans ws that read and write data on my sql data base. ive checked throw netbeans and the code from there work just fine. i have downloaded the ksoap libary into my eclipse and build there my client. when it try to run the app it crash with the error java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() this is my code, i want to sent the number '1' and get from my sql data base the same id. public class Main_WebService3_3_Activity extends Activity { private static final String NAMESPACE = "http://it.gy.com/"; private static final String URL = "http://10.0.2.2:8080/MyAndroidWs/MyAndroidWs?WSDL"; private static final String SOAP_ACTION = "http://it.gy.com/insertDataToSql"; private static final String METHOD_NAME = "getDataFromSql"; EditText et1; EditText et2; EditText et3; Button btn1; Button btn2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main__web_service3_3_); et1=(EditText) findViewById(R.id.editText1); et2=(EditText) findViewById(R.id.editText2); et3=(EditText) findViewById(R.id.editText3); btn1=(Button) findViewById(R.id.button1); btn2=(Button) findViewById(R.id.button2); btn1.setOnClickListener(btn1Listener); // btn2.setOnClickListener(btn2Listener); } private OnClickListener btn1Listener=new OnClickListener() { @Override public void onClick(View v) { Thread netWorkThread=new Thread(){ public void run() { SoapObject requset=new SoapObject(NAMESPACE,METHOD_NAME); PropertyInfo propInfo=new PropertyInfo(); propInfo.setName("id"); propInfo.setValue(1); propInfo.setType(PropertyInfo.INTEGER_CLASS); requset.addProperty(propInfo); SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.setOutputSoapObject(requset); envelope.dotNet=false; try{ HttpTransportSE ht=new HttpTransportSE(URL); ht.call(SOAP_ACTION, envelope); final SoapPrimitive response=(SoapPrimitive)envelope.getRespon…
tagged with: web-services
type: Question
linked to: http://stackoverflow.com/q/3875184
tagged with: java
tagged with: ksoap2
has comment: http://stackoverflow.com/comment/33662276
tagged with: eclipse
score: 0
has comment: http://stackoverflow.com/comment/33665636
has comment: http://stackoverflow.com/comment/33629552
type: UnansweredQuestion

http://stackoverflow.com/comment/33581156
has text: Read through generics and the javadoc of `Void`. `The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the Java keyword void`
type: Comment
type: QuestionComment
score: 3
comment on: http://stackoverflow.com/q/22132321

jboss6.x
tag name: jboss6.x
type: Tag
tags question: http://stackoverflow.com/q/22168066

http://stackoverflow.com/a/22086343
type: Answer
accepted answer of: http://stackoverflow.com/q/22057636
score: 3
answers question: http://stackoverflow.com/q/22057636
upvote count: 3
has body: This is a tricky case. Here is a solution using nested routers and default routes. BCookieAuthenticator cookieAuth1 = new BCookieAuthenticator(getContext(), false, false); cookieAuth1.setNext(InvoiceInstallmentResource.class); BCookieAuthenticator cookieAuth2 = new BCookieAuthenticator(getContext(), false, false); cookieAuth2.setNext(ChangeStatusResource.class); BBasicAuthenticator basicAuth = new BBasicAuthenticator(getContext(), true, false); basicAuth.setNext(router2); router2.attach("/v1/accounts", AccountsResource.class); router2.attach("/v1/accounts/{id}", AccountResource.class); router2.attach("/v1/items/{id}", ItemResource.class); router2.attach("/v1/items", ItemsResource.class); router1.attach("/v1/invoices/{invoice_id}/installments/{id}", cookieAuth1); router1.attach("/v1/{object_type}/{id}/change-status", cookieAuth2); router1.attachDefault(basicAuth);
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/33465412
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22068749
type: Comment
has text: Try writing it to an absolute path e.g.: output = new Formatter("C:\\Users\\currentUser\\Desktop\\numbers.txt");

http://stackoverflow.com/comment/33529374
comment on: http://stackoverflow.com/a/22103914
score: 0
type: Comment
has text: i think "object" should represent GOval access.
type: AnswerComment

http://stackoverflow.com/comment/33448424
comment on: http://stackoverflow.com/a/22058706
type: Comment
has text: Although this is no longer wrong on the example input, it was just a single example. OP asked "I would like for periods to be ignored during the split." I don't see how this fits that requirement. For example, what about a sentence with an ellipsis...
score: 0
type: AnswerComment

http://stackoverflow.com/q/22047237
has comment: http://stackoverflow.com/comment/33427930
has comment: http://stackoverflow.com/comment/33428029
has answer: http://stackoverflow.com/a/22047421
has comment: http://stackoverflow.com/comment/33427756
has comment: http://stackoverflow.com/comment/33427765
favorite count: 0
upvote count: 0
downvote count: 9
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22048447
has body: I have an assignment where I must convert an int into a string of digits like so, 123: one two three 193: one nine three I can not use the String.valueof() method and then convert to a char array! What other way is there of doing this? Modulus?
tagged with: java
duplicate of: http://stackoverflow.com/q/1720049
type: Question
score: -9
has comment: http://stackoverflow.com/comment/33427870
linked to: http://stackoverflow.com/q/1720049
has title: Converting an int into a string on individual digits in java
has answer: http://stackoverflow.com/a/22047750
answer count: 3

http://stackoverflow.com/q/22030021
has comment: http://stackoverflow.com/comment/33397469
has answer: http://stackoverflow.com/a/22030146
type: Question
upvote count: 2
has answer: http://stackoverflow.com/a/22030162
tagged with: casting
has body: I was asked this on an interview a while back and couldn't figure it out. I wasn't allowed to cast the entire thing at once so my next idea was to just run through the string converting until the point but the guy interviewing me told me he wanted to do something like this: 1 = 1 12 = 1 * 10 + 2 123 = 12 * 10 + 3 1234 = 123 * 10 + 4 The input is convert "1234.567" to a float ie. 1234.567 I honestly have no idea how he meant to do it and I haven't been able to produce good enough code to show you guys all I had was the for cycling to parse each character: for(int i = 0; i &lt; str.length(); i++){ if(!str.charAt(i).equals(".")){ fp = Float.parseFloat("" + str.charAt(i));
tagged with: string
answer count: 6
has comment: http://stackoverflow.com/comment/33397523
favorite count: 0
has comment: http://stackoverflow.com/comment/33397549
has answer: http://stackoverflow.com/a/22030627
accepted answer: http://stackoverflow.com/a/22030627
has title: How to convert a String to a Float character by character using Java?
tagged with: character
has answer: http://stackoverflow.com/a/22030796
possible better answer: http://stackoverflow.com/a/22030162
tagged with: floating-point-conversion
has comment: http://stackoverflow.com/comment/33397550
score: 2
has answer: http://stackoverflow.com/a/22031435
type: AnsweredQuestion
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/22030640

http://stackoverflow.com/a/22121861
score: 2
type: AcceptedAnswer
downvote count: 0
type: Answer
upvote count: 2
has body: I do it that way as well and I didn't run into any problems so far. You need to be careful with the SpriteBatch.begin() and SpriteBatch.end() calls, since you may never know where it was started already, and where it was stopped when it is shared. Same applies for the Camera/ProjectionMatrix. And also for the currently used ShaderProgram in case you are working with shaders. Make sure that you are always fully aware of where you are doing what with your SpriteBatch otherwise you might face weird bugs one day. Stage should not be shared, since it will probably serve different purposes. For different UIs it doesn't make any sense to use only one Stage. ShapeRenderer could be shared, since it kind of works the same like SpriteBatch, but probably you only want to use it in a single place. dispose() should actually work without any problems. You have to make sure that you dispose everything in the correct order so nothing will be left over in the end and cause exceptions.
has comment: http://stackoverflow.com/comment/33563195
answers question: http://stackoverflow.com/q/22121694
accepted answer of: http://stackoverflow.com/q/22121694

http://stackoverflow.com/comment/33456554
score: 0
has text: @RobinJonsson Without a lot more detail than this, the most likely issue is that either he isn't actually using an absolute path or that the path is to a file in a development directory not available on the the deployment machine. I'll update if we get more information.
type: Comment
comment on: http://stackoverflow.com/a/22063739
type: AnswerComment

http://stackoverflow.com/comment/33489075
score: 0
has text: Yay another DBZ fan :D. On topic; thanks for the reply - do you have any sort of link or anything where I can find these sorts of functions? They sure like they could be useful to me.
type: AnswerComment
comment on: http://stackoverflow.com/a/22081267
type: Comment

http://stackoverflow.com/a/22042797
has body: Concurrent Collections means multiple thread could perform add/remove operation on collection same time, No it is not thread safe More Detail: for further please read What&#39;s the difference between ConcurrentHashMap and Collections.synchronizedMap(Map)? Is ConcurrentHashMap totally safe?
upvote count: 2
has comment: http://stackoverflow.com/comment/33419829
answers question: http://stackoverflow.com/q/22042750
has comment: http://stackoverflow.com/comment/33419395
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/a/22131101
score: 3
has body: Can it be like that? <?xml version="1.0" encoding="utf-8"?> <TextView android:id="@+id/simplemessage" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/guess" android:gravity="center" android:textSize="19sp" android:layout_alignParentTop="true"/> <TextView android:id="@+id/textchange" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:text="@string/a" android:textSize="60sp" />
type: AcceptedAnswer
downvote count: 0
upvote count: 3
type: Answer
accepted answer of: http://stackoverflow.com/q/22131013
answers question: http://stackoverflow.com/q/22131013

http://stackoverflow.com/comment/33644181
type: Comment
has text: More on overriding [`getPreferredSize()`](http://stackoverflow.com/q/7229226/230513).
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/22167425

http://stackoverflow.com/comment/33565693
comment on: http://stackoverflow.com/q/22117960
type: QuestionComment
type: Comment
score: 0
has text: another option would be to send the html of the current page state to java through an ajax call. I don't know if that's the kind of answer youre looking for though.

http://stackoverflow.com/comment/33572047
type: Comment
type: QuestionComment
score: 0
has text: recursively and with lots of love. Seriously, where are you stuck? And why can't you just put a list of strings into a file?
comment on: http://stackoverflow.com/q/22127357

http://stackoverflow.com/q/22048357
has title: How to get the email of the logged user with oauth2 service account?
has answer: http://stackoverflow.com/a/22179346
tagged with: java
tagged with: oauth-2.0
tagged with: google-oauth
type: Question
has comment: http://stackoverflow.com/comment/33455813
score: 0
has comment: http://stackoverflow.com/comment/33429808
answer count: 1
has body: I'm trying to get the email of a user in appengine. I can't use the UserService nor , in the web.xml file. I'm using OAuth2 with "Service Account", so that if the domain administrator, gives it high, users should be transparent. Here's the code I'm using, but I can not reach any solution. Because when I request the user email with "Google Plus Service" , return the oauth2 clientID. GoogleCredential credential = new GoogleCredential.Builder().setTransport(HTTP_TRANSPORT) .setJsonFactory(JSON_FACTORY) .setServiceAccountId("Client_ID_Service_Account@developer.gserviceaccount.com") .setServiceAccountScopes(Arrays.asList( "https://www.googleapis.com/auth/plus.me", "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile")) .setServiceAccountPrivateKeyFromP12File( new java.io.File( "WEB-INF/yyyyyyyyyyyyyyyyyy-privatekey.p12")) .build(); Plus plus = new Plus(HTTP_TRANSPORT, JSON_FACTORY, credential); Person profile = plus.people().get("me").execute(); String email=profile.getEmails().get(0); String state = new BigInteger(130, new SecureRandom()).toString(32); String send="https://accounts.google.com/o/oauth2/auth?"+ "scope=https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile&amp;"+ "state=url%3Dhttps%253A%252F%rrrrrrrrrrrrrrr.appspot.com%26security_token%3D"+state+"&amp;"+ "redirect_uri=https://rrrrrrrrrrrrrrrr.appspot.com/vuelta&amp;"+ "response_type=id_token&amp;"+ "login_hint="+email+"&amp;"+ "client_id=Client_ID_for_web_application.apps.googleusercontent.com"; resp.sendRedirect(send); How I could continue? Thanks in advance.
tagged with: google-apps-marketplace
type: UnansweredQuestion

http://stackoverflow.com/a/22088455
has comment: http://stackoverflow.com/comment/33501494
has comment: http://stackoverflow.com/comment/33502803
has comment: http://stackoverflow.com/comment/33502256
score: 0
answers question: http://stackoverflow.com/q/22087938
has body: The class of a deserialized object must be available on the CLASSPATH of the receiver.
type: Answer
has comment: http://stackoverflow.com/comment/33502074
has comment: http://stackoverflow.com/comment/33503643

http://stackoverflow.com/q/22037534
favorite count: 0
has body: i am using a postgresql database. I insert the values to the database from a java class. I have declared the field which is of datatype time without time zone as a String. I am not knowing how to parse and send it to database which matches the data type? How do I do this? public static void User(Form t) { String insertTableSQL = "INSERT INTO DBUSER" + "(USER_ID, USERNAME,CREATED_DATE) VALUES" + "(?,?,?)"; PreparedStatement ps = dbConnection.prepareStatement(insertTableSQL); ps.setString(1, t.getUserID()); ps.setString(2, t.getuserName()); ps.setString(3, t.getTime()); ps.executeUpdate(); } Error: Error: the CREATED_DATE is of time without time zone but expression is of type character varying Hint: try to cast the expression
tagged with: postgresql
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22843553
score: 6
upvote count: 6
has title: Error: the <column-name> is of time without time zone but expression is of type character varying
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33410226
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/33411447

http://stackoverflow.com/comment/39192144
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22119962
has text: Please _do not_ capitalize your method's names.
score: 0

http://stackoverflow.com/q/22158689
linked to: http://stackoverflow.com/q/2107803
type: Question
type: AnsweredQuestion
tagged with: java
tagged with: twitter
score: -1
possible better answer: http://stackoverflow.com/a/22158720
answer count: 3
has comment: http://stackoverflow.com/comment/33628095
downvote count: 1
has body: I'm making a twitter analysis software with java and I want to create two threads that run in parallel: One is to stream the tweets using twitter streaming API and one is to analyze. I'm not sure of how to start .
favorite count: 0
duplicate of: http://stackoverflow.com/q/2107803
has answer: http://stackoverflow.com/a/22158792
has answer: http://stackoverflow.com/a/22158783
accepted answer: http://stackoverflow.com/a/22158783
has answer: http://stackoverflow.com/a/22158720
has comment: http://stackoverflow.com/comment/33628149
upvote count: 0
tagged with: multithreading
has title: How to create two parallel running threads in Java?

http://stackoverflow.com/q/22098660
tagged with: javascript
has body: My programming background is largely in Java, C++, and C#. I've been getting into Javascript and web development recently and I have a basic grasp of using Javascript and JQuery to do things like manipulate DOM elements and whatever else I need on the front end. What I can't seem to wrap my head around, however, is prototyping in JS. I've read several articles and answers about it, but it still doesn't quite make sense to me. I think the best way for me to properly understand it is with some sort of comparison between JS prototypes and C++/Java classes. So my final question is: Coming from a Java/C++ background, what do I need to know to be able to effectively use prototypes in my code? Side note: questions like this talk about the philosophical differences between the two. What I'm really hoping for is an explanation of how to program with prototypes geared towards someone who already understands how to use classes in C++.
score: 4
has comment: http://stackoverflow.com/comment/33519389
tagged with: class
possible better answer: http://stackoverflow.com/a/22099348
has answer: http://stackoverflow.com/a/22099348
has comment: http://stackoverflow.com/comment/33521904
linked to: http://stackoverflow.com/q/816071
favorite count: 0
tagged with: c++
accepted answer: http://stackoverflow.com/a/22099449
linked to: http://stackoverflow.com/q/16063394
has comment: http://stackoverflow.com/comment/33519395
type: AnsweredQuestion
tagged with: java
tagged with: prototype
type: Question
upvote count: 4
answer count: 2
has title: Understanding Javascript's prototypes coming from a Java and C++ background
downvote count: 0
has answer: http://stackoverflow.com/a/22099449

http://stackoverflow.com/q/22148120
type: Question
has comment: http://stackoverflow.com/comment/33610208
has title: ANDROID: KSOAP2 HttpsTransportSE slow response or timeout
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/33611622
tagged with: android
has body: I'm using HttpsTransportSE for calling webservices. Repeatedly calling web service which needs for reply 1-2s. Then there is a call which requires 30-45s or return timeout(set on 45s). This problem occurs only on 3G signal on WIFI works perfectly. public SoapObject CallWS(Object object, ArrayList&lt;Tuples&gt; params, String SOAP_ACTION, String METHOD_NAME, String NAMESPACE, String serviceURL) { SoapObject response = null; //try { // Generate soap object with WS-namespace and WS-method name SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); // Parameters for WS method for (int i = 0; i &lt; params.size(); i++) { request.addProperty(params.get(i).getLeft().toString(), params .get(i).getRight().toString()); } // Create soap envelope SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); envelope.headerOut = new Element[1]; envelope.headerOut[0] = buildAuthHeader(NAMESPACE,"trak8","g3s0"); // Add mapping for complex parameter envelope.addMapping(NAMESPACE, "Object", new Object().getClass()); TrustManagerManipulator.allowAllSSL(); Log.i("NAMESPACE",NAMESPACE); Log.i("METHOD_NAME",METHOD_NAME); Log.i("URL2",serviceURL); //HttpTransportSE aht = new HttpTransportSE(serviceURL, 10000); String[] serviceURLSplit = serviceURL.split("//"); String[] serviceURLSplitMethod = serviceURLSplit[1].split("/"); HttpsTransportSE aht = new HttpsTransportSE(serviceURLSplitMethod[0], 443,"/"+serviceURLSplitMethod[1], 45000); List&lt;HeaderProperty&gt; headerList = new ArrayList&lt;HeaderProperty&gt;(); headerList.add(new HeaderProperty("Connection", "keep-alive")); try { Log.i("StatusCall", "calling ws"+METHOD_NAME); // For debbug only aht.call(SOAP_ACTION, envelope,headerList); response = (SoapObject) envelope.getResponse(); Log.i("StatusCall", "response successfully recived"); // For debbug // only } catch (Exception e) { e.printStackTrace(); } return response; } `
answer count: 0
type: UnansweredQuestion
score: 1
has comment: http://stackoverflow.com/comment/33638057
upvote count: 1
has comment: http://stackoverflow.com/comment/33611289
has comment: http://stackoverflow.com/comment/33638655
tagged with: java
tagged with: ksoap2

http://stackoverflow.com/comment/33600348
comment on: http://stackoverflow.com/q/22143307
has text: @PareshMayani, i not confident with android java yet, how to you mean that i inflate it two times?
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33737705
type: Comment
score: 1
has text: Well apparently you are submitting the username under the key 'username' and you are trying to retrieve it using the key 'txtUsername'. That won't work of course.
type: AnswerComment
comment on: http://stackoverflow.com/a/22202945

http://stackoverflow.com/comment/33524253
comment on: http://stackoverflow.com/q/22100848
has text: This will only generate the correct value if you want big endian... Shorter way to write the same code: `ByteBuffer.allocate(4).putInt(i).array()`
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22124498
type: Question
has title: Initial SessionFactory creation failed.javax.persistence.PersistenceException
accepted answer: http://stackoverflow.com/a/22124531
answer count: 1
tagged with: jpa
has comment: http://stackoverflow.com/comment/33566679
tagged with: jsp
score: 0
linked to: http://stackoverflow.com/q/18829834
tagged with: eclipselink
has body: I am doing web application.I found many questions with same problem Like this question But I didn't get correct answer. My folder structure and class path everything is correct but why this Exception occurring really I don't know. Below is my folder structure. Here persistence.xml file is within META-INF folder of src folder My Persistance.xml: org.hibernate.ejb.HibernatePersistence com.entity.Student <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/reports" /> <property name="javax.persistence.jdbc.user" value="root" /> <property name="javax.persistence.jdbc.password" value="root" /> <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" /> EntityManagerUtil public class EntityManagerUtil { private static final EntityManagerFactory emf; static { try { emf = Persistence.createEntityManagerFactory("jspWithJpa"); } catch (Throwable ex) { System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } } public static EntityManagerFactory getEmf() { return emf; } } Exception Is: Initial SessionFactory creation failed.javax.persistence.PersistenceException: No Persistence provider for EntityManager named jspWithJpa Mar 2, 2014 11:16:08 AM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [com.action.InsertData] in context with path [/jspWithJpa] threw exception [Servlet execution threw an exception] with root cause javax.persistence.PersistenceException: No Persistence provider for EntityManager named jspWithJpa
has comment: http://stackoverflow.com/comment/33566689
has answer: http://stackoverflow.com/a/22124531
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/q/22163700
has body: I have an ArrayList that has 6 values in it. When I click a button I have one of these values deleted then a new value is added to the ArrayList. Everything works perfectly but when I get to the last original item in the ArrayList and try to delete it, the app crashes. Here is an example, My ArrayList contains these variables "1", "2", "3","4", "5", "6" When I push a button the first item of the ArrayList is removed, then another item is added. So, it would look like this, "2", "3","4", "5", "6", "New Value" I keep doing this until I get to the last original item in the ArrayList. It looks like this, "6", "New Value","New Value", "New Value", "New Value", "New Value" When I hit the button to delete the item "6" the app crashes. Here is my ArrayList code, String[] values = new String[] { "1", "2", "3", "4", "5", "6" }; final ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;(); for (int i = 0; i &lt; values.length; ++i) { list.add(values[i]); } final StableArrayAdapter adapter = new StableArrayAdapter(this, R.layout.main_activity_list_item, list); listview.setAdapter(adapter); Here is the code I use to delete and add new ArrayList items, Button.setOnTouchListener(new OnTouchListener(){ public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN : break; case MotionEvent.ACTION_UP : list.add("New Value"); list.remove(0); adapter.notifyDataSetChanged(); break; } return false; } }); This is the StableArrayAdapter, private class StableArrayAdapter extends ArrayAdapter&lt;String&gt; { HashMap&lt;String, Integer&gt; mIdMap = new HashMap&lt;String, Integer&gt;(); public StableArrayAdapter(Context context, int textViewResourceId, List&lt;String&gt; objects) { super(context, textViewResourceId, objects); for (int i = 0; i &lt; objects.size(); ++i) { mIdMap.put(objects.get(i), i); } } @Override public long getItemId(int position) { String item = getItem(position); return mIdMap.get(item); } @Override public boolean hasSt…
has answer: http://stackoverflow.com/a/22163771
tagged with: android-arrayadapter
has comment: http://stackoverflow.com/comment/33636349
has comment: http://stackoverflow.com/comment/33636613
has answer: http://stackoverflow.com/a/22164525
tagged with: arraylist
possible better answer: http://stackoverflow.com/a/22163771
score: 0
answer count: 2
tagged with: android-listview
accepted answer: http://stackoverflow.com/a/22164525
tagged with: android
type: AnsweredQuestion
tagged with: java
type: Question
has title: Android - Deleting item from ArrayList

http://stackoverflow.com/a/53978779
answers question: http://stackoverflow.com/q/22015660
type: Answer
score: 2
downvote count: 0
has body: You may also consider to use this tiny library excelorm
upvote count: 2

http://stackoverflow.com/a/70019096
upvote count: 1
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/22045108
has body: In 2021, the simple answer is to set the placeholderReplacement boolean to false: flyway -placeholderReplacement="false" The configuration parameter placeholderReplacement determines whether placeholders should be replaced. Reference: https://flywaydb.org/documentation/configuration/parameters/placeholderReplacement

http://stackoverflow.com/q/22150454
tagged with: java
has title: java.lang.OutOfMemoryError: Java heap space with array of 100 objects
has comment: http://stackoverflow.com/comment/33612377
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33612350
tagged with: arrays
has comment: http://stackoverflow.com/comment/33612319
has body: (Sorry for any format errors, I'm a very novice programmer and this is my first question). I have a moviearray array with a physical size of 100 and a logical size of 15 (the program is a mock movie store that allows for movies to be added and removed by 'adding' or 'buying'. However, in the following line of code, I have a heap space error: for (int i=0;i&lt;moviearray.length;i++) { while(moviearray[i].getTitle() !=null) { CollTitle.append(moviearray[i].getTitle()+"\n"); } } I am really confused because my array is only 100 at maximum. Thank you in advance.
tagged with: heap-memory
type: Question
tagged with: out-of-memory
has answer: http://stackoverflow.com/a/22150503
has answer: http://stackoverflow.com/a/22150516
possible better answer: http://stackoverflow.com/a/22150503
has answer: http://stackoverflow.com/a/22150513
score: 0
answer count: 3
accepted answer: http://stackoverflow.com/a/22150516

http://stackoverflow.com/a/22058871
has comment: http://stackoverflow.com/comment/33449529
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33449881
has comment: http://stackoverflow.com/comment/33449742
answers question: http://stackoverflow.com/q/22058779
upvote count: 2
has comment: http://stackoverflow.com/comment/33448617
has comment: http://stackoverflow.com/comment/33449627
type: Answer
has comment: http://stackoverflow.com/comment/33449038
has comment: http://stackoverflow.com/comment/33449912
score: 2
has comment: http://stackoverflow.com/comment/33449063
has comment: http://stackoverflow.com/comment/33449796
accepted answer of: http://stackoverflow.com/q/22058779
has comment: http://stackoverflow.com/comment/33448742
has body: Get the sdcard directory using Environment.getExternalStorageDirectory(). Try changing this line in you code: String file = "sdcard/CSCI598.txt"; With: String file = Environment.getExternalStorageDirectory() + "/CSCI598.txt"; Also, as @Yahya mentioned make sure you have this permission in your android manifest file: &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; If this doesn't work. Try reading the file like this: FileReader fr = new FileReader(file); BufferedReader inputReader = new BufferedReader(fr); Then use your while loop as it is right now. Write the file like this FileWriter out = new FileWriter(file, true); out.write(txt + "\n"); out.close();
has comment: http://stackoverflow.com/comment/33449096
has comment: http://stackoverflow.com/comment/33449153
has comment: http://stackoverflow.com/comment/33450014
has comment: http://stackoverflow.com/comment/33449722

http://stackoverflow.com/comment/33569543
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22126035
type: Comment
has text: The new base case is: `SortedLinkedSetNode<T> newNode = new SortedLinkedSetNode<T>(getValue()); newNode.next = this.next; this.next = newNode; value = el;`

android-viewpager
tag name: android-viewpager
tags question: http://stackoverflow.com/q/22041858
type: Tag

http://stackoverflow.com/a/22070053
answers question: http://stackoverflow.com/q/22069254
has body: Personally I would wrap 3rd party classes into implementation of my interface if: the 3rd party library is still evolving (new changes are expected) the 3rd party library is not solving all my issues I don't want to stick with only one provider (of the scientific library) my application is long term project Otherwise I would us the 3rd party classes directly. Introducing unnecessary layers of abstraction at the beginning of the project is very often waste of time.
score: 0
type: Answer

http://stackoverflow.com/q/22133300
has answer: http://stackoverflow.com/a/22133547
tagged with: java
has body: I'm new to the LDAP protocol and servers so please forgive me if I'm asking another trivial question. Let's assume I have the following LDAP DIT with nested groups. dn: dc=example,dc=com objectClass: top objectClass: domain dc: example # Create a place where users are stored dn: ou=Users, dc=example, dc=com ou: Users description: All strongbox users. objectclass: organizationalUnit # Create users dn: uid=tcruise,ou=Users,dc=example,dc=com objectClass: inetOrgPerson objectClass: organizationalPerson objectClass: person objectClass: top uid: tcruise cn: Tom Cruise mail: tcruise@example.com givenName: Tom surname: Cruise userPassword: password dn: uid=sspielberg,ou=Users,dc=example,dc=com objectClass: inetOrgPerson objectClass: organizationalPerson objectClass: person objectClass: top uid: sspielberg cn: Steven Spielberg mail: sspielberg@example.com givenName: Steven surname: Spielberg userPassword: password # Create groups dn: ou=Groups, dc=example, dc=com ou: Groups description: Base group organization unit. objectClass: organizationalUnit # Employees dn: ou=Employees, ou=Groups, dc=example, dc=com ou: Employees cn: Employees description: All employees objectClass: groupOfUniqueNames uniqueMember: cn=NULL # Employees (Actors) dn: ou=Actors, ou=Employees, ou=Groups, dc=example, dc=com ou: Actors cn: Actors description: All actors objectClass: groupOfUniqueNames uniqueMember: uid=tcruise,ou=Users,dc=example,dc=com # Employees (Directors) dn: ou=Directors, ou=Employees, ou=Groups, dc=example, dc=com ou: Directors cn: Directors description: All directors objectClass: groupOfUniqueNames uniqueMember: uid=sspielberg,ou=Users,dc=example,dc=com The users in the example could be assigned to multiple groups and each group has specific authorization level. Therefore I need to get all of the groups the user is assigned to as well as their parent groups (i.e. tcruise - Actors, Employees). At this point I couldn't find any examples addressing this issue. What comes to my mind as a…
type: Question
answer count: 1
tagged with: ldap
downvote count: 0
score: 1
favorite count: 0
type: UnansweredQuestion
upvote count: 1
has title: What is considered to be the right approach to traverse the LDAP DIT?
tagged with: ldap-query

http://stackoverflow.com/q/22144264
has answer: http://stackoverflow.com/a/22144299
has comment: http://stackoverflow.com/comment/33601704
type: AnsweredQuestion
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/33601656
accepted answer: http://stackoverflow.com/a/22144299
type: Question
possible better answer: http://stackoverflow.com/a/22144400
has title: Creating and Using arrays
has answer: http://stackoverflow.com/a/22144400
has comment: http://stackoverflow.com/comment/33601469
tagged with: arrays
answer count: 2
has body: I am new to the concept of arrays in java, and as part of an assignment, I am required to create a 10 row by 3 column integer array and populate it with a for loop. I have the following. public class arrays{ int arr[][][] = new int [10][10][10]; for(int i=0;i&lt;arr.length;++i) { for(int j=0;j&lt;arr[i].length;++j) { System.out.print(arr[i][j] + " "); } System.out.println(); } } am I on the right track?

http://stackoverflow.com/comment/33526783
has text: try checking the brackets as i had mentioned.
type: Comment
comment on: http://stackoverflow.com/a/22102356
score: 0
type: AnswerComment

http://stackoverflow.com/a/22013730
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/22013634
upvote count: 1
score: 1
has body: Did you notice the E8 in your answer? Then the answer is correct :)

http://stackoverflow.com/q/22164693
possible better answer: http://stackoverflow.com/a/22164938
has answer: http://stackoverflow.com/a/22164938
type: AnsweredQuestion
tagged with: java
tagged with: hibernate
type: Question
has answer: http://stackoverflow.com/a/22165013
answer count: 2
has comment: http://stackoverflow.com/comment/33638806
score: 0
has title: Hibernate: Duplicate entries in reference table with unique primary key
has body: I have two tables Employee and Project Table Employee emp_id(PK- assigned) | emp_name | prj_id(FK prj_id of Project table) Table Project prj_id(PK- auto generated) | prj_name I am using many to one relationship between Employee and Project PROBLEM: When I run the below code: Project pro = new Project(); emp.setProject(pro); saveDetails(emp); public void saveEmployeeDetails( final Employee emp) { try { this.hibernateTemplate.saveOrUpdate( emp); } catch (Exception exception) { logger.info( "Unable to save details", exception ); } } It is updating Table Employee and Project but where in Project it is creating new entry for the same proj_name which is already present. It is updating Table Employee's data and. Since there is auto generated primary key for Employee and also i am creating new object for Project every time it is saving the new object. How to avoid duplicate entry ,I am very new to hibernate .I have very less knowledge on it. find the hbm files store details of a project <column length="45" name="emp_id" /> <generator class="assigned" /> <column name="prj_id" not-null="true" /> <column name="prj_id" /> <generator class="identity" /> <column name="prj_name" />
tagged with: sql
accepted answer: http://stackoverflow.com/a/22165013

http://stackoverflow.com/comment/33403901
type: Comment
has text: Note that a changed the title of this question. Representing a date as milliseconds-since-epoch requires a `long` primitive, not an `int`.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22030903

http://stackoverflow.com/q/22023292
tagged with: java
tagged with: android-custom-view
answer count: 0
type: UnansweredQuestion
tagged with: android-canvas
has comment: http://stackoverflow.com/comment/33385021
has title: How to draw Custom View Extending Relative Layout to a canvas
has comment: http://stackoverflow.com/comment/33385458
has comment: http://stackoverflow.com/comment/33385645
type: Question
tagged with: android
has body: I have my main activity which creates an instance of SurfaceView. In the SurfaceView I am creating several simple objects from bitmaps. I pass a canvas element to them (objectX.draw(canvas)...etc) from a render method in the SurfaceView. all of this is working as i would like, however I would like to do the same with a custom RelativeLayout. For example i would like to create a custom class extending RelativeLayout and fill it with various objects such as ImageView etc and then from the SurfaceView call a method which draws this to the canvas. I have been looking for tutorials to help me understand how to do this but cannot find anything. I understand that I have to draw a bitmap of the RelativeLayout and then in turn draw that to my canvas which the surface view is passing in to it. I think a lot of my issues may be coming from the fact that i am not trying to ever add the Custom RelativeLayout to the screen, instead I would like to create it by inflating an xml layout and simply drawing to a passed in canvas.
score: 0

http://stackoverflow.com/q/22141420
has answer: http://stackoverflow.com/a/22225468
has title: WebSphere Issue
type: Question
tagged with: action-mapping
has answer: http://stackoverflow.com/a/34407752
tagged with: struts2
has answer: http://stackoverflow.com/a/26152785
tagged with: websphere
downvote count: 0
tagged with: tomcat
has comment: http://stackoverflow.com/comment/33599737
favorite count: 0
type: UnansweredQuestion
answer count: 4
has comment: http://stackoverflow.com/comment/33601060
has body: I working in an Java application. I am using Struts2 and Hibernate. The application was working fine in Tomcat7 , But when I deployed that On IBM"S Websphere I am getting the following error for the following URL http://localhost:8080/MYAPPS Error 404: There is no Action mapped for action name . http://localhost:8080/MYAPPS/ Error 404: There is no Action mapped for namespace [/] and action name [] associated with context path
score: 1
has answer: http://stackoverflow.com/a/31790230
tagged with: java
upvote count: 1

coding-style
tags question: http://stackoverflow.com/q/22125394
tags question: http://stackoverflow.com/q/22035176
type: Tag
tags question: http://stackoverflow.com/q/22163702
tag name: coding-style

http://stackoverflow.com/comment/33446012
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22057230
type: Comment
has text: `On a side note, try to avoid static if at all possible. Generally speaking, it's bad practice.` How? Statics are a crucial part of programming...

http://stackoverflow.com/comment/33445584
has text: tried http://stackoverflow.com/questions/8737171/velocity-framework-resource-not-found-exception solution. didn't work.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22056967
score: 0

http://stackoverflow.com/comment/107038852
comment on: http://stackoverflow.com/a/22178613
has text: @mertaksu Did you find a solution to this ?
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33486957
comment on: http://stackoverflow.com/q/22079082
score: 0
type: Comment
type: QuestionComment
has text: @ajb the value for lastDie1 and lastDie2 get paired with DIE1_STAT and DIE2_STAT at onSavedInstanceState method and then i used the keys at onCreate to restore the image states

http://stackoverflow.com/q/22036144
tagged with: primefaces
tagged with: java
accepted answer: http://stackoverflow.com/a/22341240
tagged with: mojarra
tagged with: myfaces
type: Question
tagged with: websphere
linked to: http://stackoverflow.com/q/8026082
downvote count: 0
answer count: 1
favorite count: 0
has body: Good day, Right now I'm trying to migrate my currently working application (Primefaces+EJB+JPA + Glassfish 4.0) to WAS 8.5. I tried using mojarra to be able to make Primefaces work. I thought I was already successful but then I stumbled upon this exception in one of the incident report in the SystemOut.log of WAS during startup: FFDC Exception:java.lang.IllegalStateException SourceId:com.ibm.ws.webbeans.services.JCDIWebListener.contextInitialized() ProbeId:104 Reporter:com.ibm.ws.webbeans.services.JCDIWebListener@fa0f39fa java.lang.IllegalStateException: Unsupported JSF Implementation used with JCDI And also when I tried to press a button invoking #{navigationBean.login} I get this exception: javax.el.PropertyNotFoundException: /login.xhtml @45,111 action="#{navigationBean.login}": Target Unreachable, identifier 'navigationBean' resolved to null Further research showed (correct me if I'm wrong) that the CDI Implementation of WAS (Apache OpenWebBeans) works best (or works only?) with MyFaces JSF Implementation. So I'm suspecting that this happened because I used Mojarra instead of MyFaces. So I went on to try to just try and replace also the OpenWebBeans only to find out that I can't change it to Weld CDI Implementation (which is what Glassfish uses). Any suggestions on how I should address this problem? I really would like to be able to use primefaces in websphere. Update: Update: I was able to make my first page (login page using primeface+MyFaces) appear. But when I click the first element with an EL expression (#{navigationBean.login}) pointing to an @Named class NavigationBean, I still get the javax.el.PropertyNotFoundException: /login.xhtml @45,111 action="#{navigationBean.login}": Target Unreachable, identifier 'navigationBean' resolved to null Further more, I also see this exception trace: com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0014E: Uncaught service() exception root cause Faces Servlet: javax.servlet.ServletException: WebBeans context wi…
has answer: http://stackoverflow.com/a/22341240
upvote count: 3
type: AnsweredQuestion
score: 3
has title: Primefaces + MyFaces + CDI (OpenWebBeans) + WAS 8.5

http://stackoverflow.com/comment/33635047
score: 0
type: Comment
type: QuestionComment
has text: For the (new) example you've pasted, get rid of `setLayout(null);`, get rid of `mainPanel.setBounds(0,0,500,500);` and `add(mainPanel);` and simply use `setContentPane(mainPanel)`
comment on: http://stackoverflow.com/q/22162398

http://stackoverflow.com/q/22083514
type: UnansweredQuestion
tagged with: smime
score: 2
has answer: http://stackoverflow.com/a/50842514
tagged with: java
has comment: http://stackoverflow.com/comment/33524523
type: Question
has title: Reading OpenSSL generated, PEM/DER formatted, S/MIME messages in Java
tagged with: openssl
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/33525245
favorite count: 0
has body: I need to be able to read in Java a S/MIME file generated from OpenSSL. The openssl command looks like openssl smime -encrypt -in test_message.txt -out test_out.pem -outform pem certificate.pem This creates a file that looks like -----BEGIN PKCS7----- MIIBkwYJKoZIhvcNAQcDoIIBhDCCAYACAQAxggE+MIIBOgIBADAiMBoxGDAWBgNV [binary] -----END PKCS7----- I am currently using BouncyCastle to try to read in test_out.pem, .... MimeMessage mimeMessage = new MimeMessage(session, new FileInputStream("test_out.pem")); SMIMEEnveloped smimeEnveloped = new SMIMEEnveloped(mimeMessage); ... but I can't figure out how to make it accept a message without the MIME headers, as I get the following error: java.lang.NullPointerException: null at org.bouncycastle.cms.CMSEnvelopedData.&lt;init&gt;(Unknown Source) ~[bcpkix-jdk15on-1.50.jar:1.50.0] at org.bouncycastle.cms.CMSEnvelopedData.&lt;init&gt;(Unknown Source) ~[bcpkix-jdk15on-1.50.jar:1.50.0] at org.bouncycastle.mail.smime.SMIMEEnveloped.&lt;init&gt;(Unknown Source) ~[bcmail-jdk15on-1.50.jar:1.50.0] What would be the best way to read a PEM (or DER) formatted file like this in and be able to decrypt it with a java.security.PrivateKey?
has comment: http://stackoverflow.com/comment/33499849
tagged with: bouncycastle
upvote count: 2

http://stackoverflow.com/a/22116151
score: 2
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/22087566
upvote count: 2
has body: For selecting a good cache, with good in-memory read performance, take a look at the benchmarks at the cache2k benchmark page. It compares EHCache, guava cache, cache2k, and Infinispan. If you don't need eviction, why you need a cache then? Anyway, within cache2k it is possible to switch to eviction implementations that have very low overhead, like this: Cache&lt;String, String&gt; c = CacheBuilder.newCache(String.class, String.class) .source(new CacheSource&lt;String, String&gt;() { @Override public String get(String o) { ... fill code ... } }) .implementation(ClockCache.class) .build(); Another low overhead eviction is org.cache2k.impl.RandomCache, which just selects an eviction candidate by a round robin pointer that walks through the hashtable. The different algorithms are not exposed within the API module, so you need to have cache2k-core.jar within your compile scope. Disclaimer: I work on cache2k...

bluej
tags question: http://stackoverflow.com/q/22163520
tag name: bluej
tags question: http://stackoverflow.com/q/22158954
type: Tag
tags question: http://stackoverflow.com/q/22117738

http://stackoverflow.com/q/22120353
has comment: http://stackoverflow.com/comment/33559049
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33559007
possible better answer: http://stackoverflow.com/a/22120408
downvote count: 0
has answer: http://stackoverflow.com/a/22120475
accepted answer: http://stackoverflow.com/a/22120475
has comment: http://stackoverflow.com/comment/33558930
type: Question
has title: Difference between generic method and non-generic method
score: 3
has comment: http://stackoverflow.com/comment/33558981
has comment: http://stackoverflow.com/comment/33566104
tagged with: java
upvote count: 3
answer count: 2
has answer: http://stackoverflow.com/a/22120408
has body: What is the difference between these two methods? public &lt;T extends Serializable, Y extends List&lt;T&gt;&gt; void foo(Y y, T t); and public void foo(Serializable ser, List&lt;Serializable&gt; list);
tagged with: generics
favorite count: 0
has comment: http://stackoverflow.com/comment/33558999

http://stackoverflow.com/q/22101237
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/22120172
type: Question
tagged with: session
accepted answer: http://stackoverflow.com/a/22120172
tagged with: jstl
downvote count: 0
answer count: 1
has comment: http://stackoverflow.com/comment/33524195
tagged with: jsp
score: 1
has comment: http://stackoverflow.com/comment/33539849
favorite count: 0
has comment: http://stackoverflow.com/comment/33526251
has body: I have been googling and found that I can remove a session attribute using: &lt;c:remove var="foo" /&gt; What I want is to clear all session attributes from a JSP, something like this: &lt;c:forEach var="item" items="${sessionScope}"&gt; &lt;c:remove var="${item }" scope="session"/&gt; &lt;/c:forEach&gt; The problem is that the code from above gives me this warning c:remove doesn't support runtime expression And I can't view the JSP where I put the code. Is it possible? Is it a good practice to do something like this?
type: AnsweredQuestion
has title: JSTL Remove ALL session attributes

arraylist
tags question: http://stackoverflow.com/q/22118237
tags question: http://stackoverflow.com/q/22124816
tags question: http://stackoverflow.com/q/22117741
tags question: http://stackoverflow.com/q/22020224
tags question: http://stackoverflow.com/q/22085954
tags question: http://stackoverflow.com/q/22123987
tags question: http://stackoverflow.com/q/22105679
tags question: http://stackoverflow.com/q/22119725
tags question: http://stackoverflow.com/q/22148184
tags question: http://stackoverflow.com/q/22043119
tags question: http://stackoverflow.com/q/22131029
tags question: http://stackoverflow.com/q/22132761
tags question: http://stackoverflow.com/q/22086624
tags question: http://stackoverflow.com/q/22158954
tags question: http://stackoverflow.com/q/22095941
tags question: http://stackoverflow.com/q/22031012
tags question: http://stackoverflow.com/q/22073619
tags question: http://stackoverflow.com/q/22135628
tags question: http://stackoverflow.com/q/22042794
tags question: http://stackoverflow.com/q/22078983
tags question: http://stackoverflow.com/q/22134952
tags question: http://stackoverflow.com/q/22156605
tags question: http://stackoverflow.com/q/22053412
tags question: http://stackoverflow.com/q/22077021
tags question: http://stackoverflow.com/q/22147491
tags question: http://stackoverflow.com/q/22141981
tags question: http://stackoverflow.com/q/22041300
tags question: http://stackoverflow.com/q/22007696
tags question: http://stackoverflow.com/q/22152060
tags question: http://stackoverflow.com/q/22085350
tags question: http://stackoverflow.com/q/22013786
tags question: http://stackoverflow.com/q/22123608
tags question: http://stackoverflow.com/q/22163700
tags question: http://stackoverflow.com/q/22165106
tags question: http://stackoverflow.com/q/22049931
tags question: http://stackoverflow.com/q/22070234
tags question: http://stackoverflow.com/q/22150886
tags question: http://stackoverflow.com/q/22096824
tags question: http://stackoverflow.com/q/22135824
tags question: http://stackoverflow.com/q/22138278
tags question: http://stackoverflow.com/q/22035970
tags question: http://stackoverflow.com/q/22060290
tags question: http://stackoverflow.com/q/22131154
tags question: http://stackoverflow.com/q/22131437
tags question: http://stackoverflow.com/q/22119470
tags question: http://stackoverflow.com/q/22087863
tags question: http://stackoverflow.com/q/22014805
tags question: http://stackoverflow.com/q/22109958
tags question: http://stackoverflow.com/q/22127510
tags question: http://stackoverflow.com/q/22009068
tags question: http://stackoverflow.com/q/22040675
tags question: http://stackoverflow.com/q/22080660
tags question: http://stackoverflow.com/q/22030851
tags question: http://stackoverflow.com/q/22072233
tags question: http://stackoverflow.com/q/22114928
tags question: http://stackoverflow.com/q/22057604
tags question: http://stackoverflow.com/q/22077071
tags question: http://stackoverflow.com/q/22084104
tags question: http://stackoverflow.com/q/22128154
tags question: http://stackoverflow.com/q/22082079
tags question: http://stackoverflow.com/q/22117585
tags question: http://stackoverflow.com/q/22083518
tags question: http://stackoverflow.com/q/22159803
tags question: http://stackoverflow.com/q/22059018
tags question: http://stackoverflow.com/q/22014970
tags question: http://stackoverflow.com/q/22064144
tags question: http://stackoverflow.com/q/22048819
tags question: http://stackoverflow.com/q/22059271
tags question: http://stackoverflow.com/q/22080304
tags question: http://stackoverflow.com/q/22096247
tags question: http://stackoverflow.com/q/22041400
tags question: http://stackoverflow.com/q/22162062
tags question: http://stackoverflow.com/q/22034500
tags question: http://stackoverflow.com/q/22158613
tags question: http://stackoverflow.com/q/22070903
type: Tag
tags question: http://stackoverflow.com/q/22057540
tags question: http://stackoverflow.com/q/22032877
tags question: http://stackoverflow.com/q/22130261
tags question: http://stackoverflow.com/q/22006446

http://stackoverflow.com/comment/36663309
score: 0
type: AnswerComment
has text: @EJP I did not say or think they were synonyms. I would think that asynchronous and non-blocking are two different things that go hand-in-hand. How to be asynchronous without being non-blocking? Perhaps you can clarity? I know java has `java.nio` but it is the bare bones of selectors. Then you have Netty, Mina, CoralReactor and other frameworks on top of it. By the way I edited my answer to include your suggestion to use a demux / task-buffer. I totally agree.
type: Comment
comment on: http://stackoverflow.com/a/23820460

http://stackoverflow.com/a/22016014
score: 5
has comment: http://stackoverflow.com/comment/33416928
has body: String.split(pattern,resultlength) does it. use: String[] splitted = line.split(" ",2); the ',2' parameter means that the resulting Array maximum size is 2.
downvote count: 0
upvote count: 5
has comment: http://stackoverflow.com/comment/33381464
type: Answer
has comment: http://stackoverflow.com/comment/33371750
answers question: http://stackoverflow.com/q/22015892

http://stackoverflow.com/a/22016681
answers question: http://stackoverflow.com/q/22015228
type: Answer
has body: You could create a little method that simply hunts for such substrings between delimiters sequentially, using (as noted) String.indexOf(string); You do need to decide whether you want all substrings (whether they overlap or not .. which your question indicates), or if you don't want to see overlapping strings. Here is a trial for such code import java.util.Vector; public class FindDelimitedStrings { public static void main(String[] args) { String[] test = getDelimitedStrings("Ron_CR7_MU'RM'_SAF_34'", "_", "'"); if (test != null) { for (int i = 0; i &lt; test.length; i++) { System.out.println(" " + (i + 1) + ". |" + test[i] + "|"); } } } public static String[] getDelimitedStrings(String source, String leftDelimiter, String rightDelimiter) { String[] answer = null; ; Vector&lt;String&gt; results = new Vector&lt;String&gt;(); if (source == null || leftDelimiter == null || rightDelimiter == null) { return null; } int loc = 0; int begin = source.indexOf(leftDelimiter, loc); int end; while (begin &gt; -1) { end = source .indexOf(rightDelimiter, begin + leftDelimiter.length()); if (end &gt; -1) { results.add(source.substring(begin, end)); // loc = end + rightDelimiter.length(); if strings must be // returned as pairs loc = begin + 1; if (loc &lt; source.length()) { begin = source.indexOf(leftDelimiter, loc); } else { begin = -1; } } else { begin = -1; } } if (results.size() &gt; 0) { answer = new String[results.size()]; results.toArray(answer); } return answer; } }
score: 0

http://stackoverflow.com/a/24840876
has body: I think there are lock files locking your database. you must delete them go to your database directory and search for a file with "YourDbName-journal" delete it This should works if it did not work make sure that you have one connection running at a time and make sure you close your connection each time. after catch clause you add this finally{ try{ preparedStatement.close(); connection.close();} catch(Exception e){e.printStackTrace();}} make sure to add this code after each method calling connection because sqlite does not support more than one connection.
type: Answer
answers question: http://stackoverflow.com/q/22150519
score: 0

http://stackoverflow.com/comment/64407700
comment on: http://stackoverflow.com/a/31681921
has text: Could you share which files are needed for IBM Java 6?
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33644260
type: QuestionComment
has text: in WebContent folder.
score: 0
comment on: http://stackoverflow.com/q/22168066
type: Comment

http://stackoverflow.com/a/22050997
type: Answer
answers question: http://stackoverflow.com/q/22050194
has body: Thank you @Eldad, your comment helped me to detect the problem. Under Eclipse IDE : Right click on "X" project > Build Path > Configure Build Path > Project > Check Y > Click on "Remove" Now no error while deploying the X war.
has comment: http://stackoverflow.com/comment/122314695
has comment: http://stackoverflow.com/comment/63962015
upvote count: 35
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/103818338
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22050194
score: 35

http://stackoverflow.com/q/22086982
type: AnsweredQuestion
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/25842661
accepted answer: http://stackoverflow.com/a/25842661
tagged with: collections
type: Question
possible better answer: http://stackoverflow.com/a/34420821
has answer: http://stackoverflow.com/a/44508763
has answer: http://stackoverflow.com/a/34420821
upvote count: 6
has comment: http://stackoverflow.com/comment/56582796
answer count: 3
tagged with: api
favorite count: 0
has body: The API documentation for Android's SparseIntArray opens with: SparseIntArrays map integers to integers. I'm curious, then, why it doesn't implement Map&lt;Integer, Integer&gt;. It seems to me that all that would've been required is a couple of different method names, a few trivial extra methods, and a bit of code to prohibit null keys and values... certainly nothing that an EnumMap doesn't handle with grace. Am I overlooking something? This isn't intended to be a swipe at the designers of the Android API. Normally when I wonder things like this, there turns out to be a good reason, and I learn something about the language or platform.
tagged with: android
score: 6
linked to: http://stackoverflow.com/q/857420
has comment: http://stackoverflow.com/comment/33499083
has title: Why doesn't SparseIntArray implement Map<Integer, Integer>?
has comment: http://stackoverflow.com/comment/56582690

http://stackoverflow.com/q/22149012
has comment: http://stackoverflow.com/comment/33646044
type: Question
has comment: http://stackoverflow.com/comment/33610193
tagged with: android
has comment: http://stackoverflow.com/comment/33610464
tagged with: java
score: 0
has comment: http://stackoverflow.com/comment/33610249
has title: Method called after release() even though I reopen camera
tagged with: camera
has comment: http://stackoverflow.com/comment/33647751
answer count: 0
has body: The following code takes a picture with the camera and works fine. When I pause the application (by going back to the home menu) and restart the app, the camera image does not get saved anymore. Even though I release and re-open the camera on pause/resume, I get the error when calling snapPicture: "Method called after release()". This is my code, and the line 'Log.w("Error message: ", e.getLocalizedMessage());' displays the error. Can anyone help me to solve this problem? camerapreview.java package com.example.testproject; import java.io.IOException; import android.content.Context; import android.hardware.Camera; import android.view.SurfaceHolder; import android.view.SurfaceView; public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback { private SurfaceHolder mSurfaceHolder; private Camera mCamera; // Constructor that obtains context and camera @SuppressWarnings("deprecation") public CameraPreview(Context context, Camera camera) { super(context); this.mCamera = camera; this.mSurfaceHolder = this.getHolder(); this.mSurfaceHolder.addCallback(this); this.mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } @Override public void surfaceCreated(SurfaceHolder surfaceHolder) { try { mCamera.setPreviewDisplay(surfaceHolder); mCamera.startPreview(); } catch (IOException e) { // left blank for now } } @Override public void surfaceDestroyed(SurfaceHolder surfaceHolder) { mCamera.stopPreview(); mCamera.release(); mCamera = null; } @Override public void surfaceChanged(SurfaceHolder surfaceHolder, int format, int width, int height) { // start preview with new settings try { mCamera.setPreviewDisplay(surfaceHolder); mCamera.startPreview(); } catch (Exception e) { // intentionally left blank for a test } } } custom_cameraactivity.java package com.example.testproject; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.sql.Date; …
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33610114

http://stackoverflow.com/a/22150942
answers question: http://stackoverflow.com/q/22150374
has body: You are sending the data too soon. Implement ApplicationListener and send the data when the ContextRefreshedEvent is received.
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33648451
score: 6
type: Answer
upvote count: 6
accepted answer of: http://stackoverflow.com/q/22150374

http://stackoverflow.com/q/22036690
type: UnansweredQuestion
has body: I have a java RMI server which exports itself with UnicastRemoteObject.export. Is there a way to find out the IP address that was embedded in the server stub? and how can i change this ip ?
tagged with: rmi
tagged with: java
type: Question
has title: Not able to get ip of stub
answer count: 2
has answer: http://stackoverflow.com/a/22036877
has answer: http://stackoverflow.com/a/22040559
has comment: http://stackoverflow.com/comment/33408703
score: 0
has comment: http://stackoverflow.com/comment/33415363

http://stackoverflow.com/q/22085706
tagged with: java
tagged with: file
has body: I am trying to delete a folder which has only files but no sub folders without success. Code: File rowFolder = new File(folderPath); String[] files = rowFolder.list(); for (String file : files){ File deleteFile = new File(file); System.out.println("deleting file -"+deleteFile.getName()); deleteFile.delete(); } System.out.println("deleting folder -"+rowFolder.getName()); rowFolder.delete(); Output: deleting file -testing.pdf deleting file -app_json.json deleting file -photo.jpg deleting folder -bundle_folder The code doesn't delete any folder nor any file. Why is that?
type: Question
possible better answer: http://stackoverflow.com/a/22085806
has title: Cannot delete folder using Java
downvote count: 0
tagged with: java-io
has answer: http://stackoverflow.com/a/22085862
has answer: http://stackoverflow.com/a/22085806
tagged with: file-io
has comment: http://stackoverflow.com/comment/33496739
favorite count: 0
has comment: http://stackoverflow.com/comment/33496930
upvote count: 2
has comment: http://stackoverflow.com/comment/33496742
answer count: 4
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22085795
has answer: http://stackoverflow.com/a/22085756
accepted answer: http://stackoverflow.com/a/22085756

pdfbox
tag name: pdfbox
tags question: http://stackoverflow.com/q/22067557
tags question: http://stackoverflow.com/q/22074449
tags question: http://stackoverflow.com/q/22039388
tags question: http://stackoverflow.com/q/22073137
type: Tag
tags question: http://stackoverflow.com/q/22026222

http://stackoverflow.com/a/22131788
type: Answer
has body: You should use mousePosition to determine if that point is within the bounds of any ovals or rectangles. If it is, perform g.setColor(myColor) and fill that shape. Then change g to a normal, non-randomized color, and fill the rest of the shapes.
score: 0
answers question: http://stackoverflow.com/q/22131342

http://stackoverflow.com/comment/33582808
comment on: http://stackoverflow.com/a/22132860
score: 0
has text: when u receive a String that you want to display in TextView ... just copy that code and call setText with that string on textview (in my code above it is //set your text) ... the thing is that you will call UI thread (UI thread can work with user interface, and thats what you want) from another thread that you have implemented for receiving messages ... makes that any sence for you ? :) i am not that good in EN :/
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/33547093
type: Comment
comment on: http://stackoverflow.com/a/22113784
type: AnswerComment
has text: Compare the memory usage of `public static void main(String[] args) { while(true) { if (foo()) break; } }` vs `public static void main(String[] args) { while(true) { if (false) break; } }`. No difference at all on my machine... One obvious reason being that `foo` will get inlined pretty quickly, making the two codes exactly the same at the assembly level. Even without inlining, the call stack in only one level deep at all time and I don't see how that is going to use any significant amount of memory.
score: 0

http://stackoverflow.com/q/22166266
type: UnansweredQuestion
score: -3
has body: I am using SpringFramework. I want to create an excel file using Java. Below is the code in which i failed creating a excel file. public void eventsUpdate(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{ response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-Disposition", "attachment; filename=events123.xls"); HSSFWorkbook hwb = new HSSFWorkbook(); HSSFSheet sheet = hwb.createSheet("new sheet"); }
tagged with: java
downvote count: 3
has title: Creating an excel file in java
type: Question
has answer: http://stackoverflow.com/a/22166408
upvote count: 0
has comment: http://stackoverflow.com/comment/33640770
answer count: 1
favorite count: 0

http://stackoverflow.com/q/22010118
has comment: http://stackoverflow.com/comment/33361252
possible better answer: http://stackoverflow.com/a/22011060
score: -1
has answer: http://stackoverflow.com/a/22011060
has title: Print only the Current Value of an array or array index
downvote count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22010635
tagged with: java
type: Question
answer count: 2
has body: Java Novice: I am using a for loop to iterate an array and check it's values. For example: If the array contains the number 100. Then do something, However if it doesn't then get the current value of the current variable. Is it possible to get the value of the current variable when the check was made? Currently, when I print using the else I get everything printed out. Like this: 1 2 3 Found Something! Please forgive my ignorance. Just experimenting: public class MyArrayExample { private int[] intArray = new int[] {1, 2, 3, 100}; public int[] getArrayValues() { return intArray; } public static void main(String[] args) { MyArrayExample example = new MyArrayExample(); int[] arrayValues = example.getArrayValues(); for(int counter=0; counter&lt;arrayValues.length; counter++) { int current = arrayValues[counter]; if(current == 100) { System.out.println("Found Something!"); } else{ System.out.println(current); } } } }
upvote count: 0
accepted answer: http://stackoverflow.com/a/22010635
favorite count: 0
has comment: http://stackoverflow.com/comment/33361278

http://stackoverflow.com/comment/33526691
type: QuestionComment
has text: I'd say pass a reference to the live one into the archive, and have the archive launch a thread that periodically copies the live one's contents... BUT BEWARE OF THREADSAFETY.
comment on: http://stackoverflow.com/q/22102334
score: 0
type: Comment

http://stackoverflow.com/comment/33437984
type: Comment
comment on: http://stackoverflow.com/a/22052677
has text: Alright, so it may just not be possible to do this because there are so many words then?
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33395560
type: QuestionComment
score: 2
has text: Is this the same `M`? Is this a variable whose value might have changed?
type: Comment
comment on: http://stackoverflow.com/q/22028853

http://stackoverflow.com/comment/33521297
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/22099449
type: Comment
has text: Wow, that's pretty much exactly what I was looking for. It gives me the framework for a basic understanding, and makes it easy for me to build off it. Thanks again!

http://stackoverflow.com/q/22058077
type: Question
tagged with: arrays
possible better answer: http://stackoverflow.com/a/22058116
has title: Trouble understanding this findMinimum array method
has answer: http://stackoverflow.com/a/22058116
answer count: 2
accepted answer: http://stackoverflow.com/a/22058103
favorite count: 0
has body: So I'm sorting arrays in subclasses that inherit a couple of methods from a class with things like swap to switch indexes a method to find the minimum value, method to print etc, however for the findMinimum method, my teacher provided us with a pre-made code, but I'm having a little trouble understanding it, was hoping some of you would be able to help. An array is inserted by the user in a main class public int findMinimum(int[] array, int first){ int minIndex = first; for(int i =0; i&lt;array.length; i++){ if(array[i]&lt;array[minIndex]){ minIndex = i; } } return minIndex; } What I'm having a hard time understanding is since int first is given no initial value isn't it considered null and therefore can't be used to check in the loop? How can int minIndex be set equal to null? Thanks in advance
type: AnsweredQuestion
upvote count: 2
score: 0
tagged with: java
downvote count: 2
has answer: http://stackoverflow.com/a/22058103

http://stackoverflow.com/comment/33403582
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22026019
has text: Does this command work for you? java -cp "*" addition 1 2 -dataType Integer

http://stackoverflow.com/a/22155842
answers question: http://stackoverflow.com/q/22155679
score: 0
has body: Simply put: == compares the references. .equals compares the values. The same is true for String(s) and all other objects.
type: Answer

http://stackoverflow.com/comment/33620659
type: AnswerComment
comment on: http://stackoverflow.com/a/22138486
has text: I know how to print the proper grid; however, the constraint I am under is that I cannot create another method. I must be able to use the GameOfLife constructor method, which must then be able to be printed in the driver class. It seems that I must be able to convert the 2d character array to a String from within the constructor, is this doable? Also, I am a student of Industrial/Systems Engineering as well, living in Seattle. Thanks again for your help!
type: Comment
score: 0

selenium
tags question: http://stackoverflow.com/q/22130540
tags question: http://stackoverflow.com/q/22139498
tags question: http://stackoverflow.com/q/22034583
tags question: http://stackoverflow.com/q/22168004
tags question: http://stackoverflow.com/q/22091979
tags question: http://stackoverflow.com/q/22110282
tags question: http://stackoverflow.com/q/22021031
tags question: http://stackoverflow.com/q/22081270
tags question: http://stackoverflow.com/q/22090464
tags question: http://stackoverflow.com/q/22064853
tags question: http://stackoverflow.com/q/22008715
tags question: http://stackoverflow.com/q/22061096
tags question: http://stackoverflow.com/q/22041981
tags question: http://stackoverflow.com/q/22091892
tags question: http://stackoverflow.com/q/22108605
tags question: http://stackoverflow.com/q/22143465
tags question: http://stackoverflow.com/q/22058872
tags question: http://stackoverflow.com/q/22043119
tags question: http://stackoverflow.com/q/22031582
tags question: http://stackoverflow.com/q/22146950
tag name: selenium
tags question: http://stackoverflow.com/q/22099124
tags question: http://stackoverflow.com/q/22070709
tags question: http://stackoverflow.com/q/22053810
tags question: http://stackoverflow.com/q/22058712
tags question: http://stackoverflow.com/q/22069141
tags question: http://stackoverflow.com/q/22008953
tags question: http://stackoverflow.com/q/22116106
tags question: http://stackoverflow.com/q/22162937
tags question: http://stackoverflow.com/q/22145776
tags question: http://stackoverflow.com/q/22091246
tags question: http://stackoverflow.com/q/22110004
tags question: http://stackoverflow.com/q/22085993
tags question: http://stackoverflow.com/q/22039766
tags question: http://stackoverflow.com/q/22089243
tags question: http://stackoverflow.com/q/22168076
tags question: http://stackoverflow.com/q/22144945
tags question: http://stackoverflow.com/q/22087952
tags question: http://stackoverflow.com/q/22168651
tags question: http://stackoverflow.com/q/22043895
tags question: http://stackoverflow.com/q/22166234
type: Tag
tags question: http://stackoverflow.com/q/22142101
tags question: http://stackoverflow.com/q/22106436
tags question: http://stackoverflow.com/q/22031345
tags question: http://stackoverflow.com/q/22089221

http://stackoverflow.com/comment/33390344
score: 4
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22015992
has text: A simple way of keeping your image size under 100 KB would be to leave it alone. JPEG compression does not support a 1-bit pixel depth, and is useless for this sort of image.

http://stackoverflow.com/q/22131518
downvote count: 5
has body: So as the title says, I have a class, Game and it needs to have an instance of an abstract GameState (which is extended). Game then needs to pass this instance to several Player objects. For Instance: public class PlayGame { public static void main(String[] args) { Player red = new EasyPlayer() Player green = new HardPlayer() Game game = new Game(red, green) game.play(); } } If anyone could help with what code I need to put in Game (including the constructor) it would be very appreciated! Thanks in advance!
tagged with: class
upvote count: 0
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33579881
tagged with: abstract
type: UnansweredQuestion
has title: (JAVA) How to make a class have an instance of another (abstract) class, then to pass instance to multiple objects?
score: -5
tagged with: instance
tagged with: java
has answer: http://stackoverflow.com/a/22131730
type: Question
tagged with: object

http://stackoverflow.com/comment/33569714
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/22126024
type: Comment
has text: @Simple Plan: there it is.

http://stackoverflow.com/comment/33603685
type: Comment
comment on: http://stackoverflow.com/a/22145597
type: AnswerComment
has text: When reading a file, no flushing is required, so you won't even find a flush()method in a Reader kind of class.For all your output files, you might discover that the buffers don’t get flushed, so the file will be incomplete and you may not see the output.
score: 0

http://stackoverflow.com/a/22009015
downvote count: 0
answers question: http://stackoverflow.com/q/22008782
score: 1
has body: You could concatenate client ip + nanosec
upvote count: 1
type: Answer

http://stackoverflow.com/comment/33382864
score: 0
type: AnswerComment
type: Comment
has text: Don't you hate it when you have the same answer and it's a 2 min difference? +1 for having a code example. And for using `ByteArrayOutputStream` cleverly (I didn't know about the `toString()` trick)
comment on: http://stackoverflow.com/a/22021537

http://stackoverflow.com/comment/33413094
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22039199
has text: Isn't that `ENTITY` supposed to be simply `T`?
score: 0

http://stackoverflow.com/a/22084077
score: 0
answers question: http://stackoverflow.com/q/22083104
type: Answer
upvote count: 1
downvote count: 1
has body: Here's one trivial conversion: TreeMap&lt;Integer, ArrayList&lt;Character&gt;&gt; convert(HashMap&lt;Character, Integer&gt; x) { return new TreeMap&lt;&gt;(); } But I suspect there are additional requirements you haven't yet articulated.

http://stackoverflow.com/a/22128538
downvote count: 0
has body: When the StackOverFlow occurs, the JVM will pop down to the catch, freeing the stack. In you example, it get rids of all the stacked foo.
type: Answer
answers question: http://stackoverflow.com/q/22128485
score: 12
upvote count: 12

http://stackoverflow.com/q/22043557
tagged with: filesystems
answer count: 1
tagged with: ubuntu
score: 0
tagged with: linux
has body: I want to use Java 7 WatchService to monitor /proc folder, but that's not working (changes made in the folder are not reported). I've tested other folders such as /home/user/Desktop and /tmp and it works. What could be the reason? Is it because of permissions? /proc is obviously owned by root whereas the other folder is owned by logged in user. The /tmp however is also owned by root, but it works. I'm using this basic implementation to test it. My OS is Ubuntu 13.10 64bit. Oracle Java 1.7.0_51.
type: UnansweredQuestion
has title: Java WatchService doesn't work on some folders
has answer: http://stackoverflow.com/a/23568842
tagged with: java
tagged with: watchservice
type: Question

http://stackoverflow.com/q/22146764
accepted answer: http://stackoverflow.com/a/22146896
answer count: 1
downvote count: 0
tagged with: string
favorite count: 0
tagged with: dictionary
has answer: http://stackoverflow.com/a/22146896
type: AnsweredQuestion
upvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33605494
tagged with: performance
has title: fast static key-value mapping
score: 1
has body: I have a set of unique key-value pairs, both key and value are strings. The number of pairs is very huge and finding the value of a certain string is extremely time-critical. The pairs are computed beforehand and are given for a certain program. So i could just write a method containing: public String getValue(String key) { //repeat for every pair if(key.equals("abc")) { return "def"; } } but i am talking about more than 250,000 pairs and perhaps sorting them could be faster... I am having a class that contains the getValue() method and can use its constructor, but has no connection to any database/file system etc. So every pair has to be defined inside the class. Do you have any ideas that could be faster than a huge series of if-statements? Perhaps using a sorting map that gets the pairs presorted. Perhaps improve constructor-time by deserializing an already created map? I would like your answers to contain a basic code example of your approach, I will comment answers with their corresponding time it took an a set of pairs! Time-frame: for one constructor call and 20 calls of getValue() 1000 milliseconds. Keys have a size of 256 and values have a size &lt; 16
tagged with: java
has comment: http://stackoverflow.com/comment/33605580

http://stackoverflow.com/comment/33428489
has text: @Matt this was fixed, the problem still persists
comment on: http://stackoverflow.com/q/22043846
score: 0
type: Comment
type: QuestionComment

hash-collision
tags question: http://stackoverflow.com/q/22139135
tag name: hash-collision
type: Tag

http://stackoverflow.com/comment/33527708
comment on: http://stackoverflow.com/q/22102703
has text: No deadlocks. Starvation, hmmm, guess you can call the 50-100% IO wait starvation, but 1% CPU does not seem like starvation, and this question is basically about why this thread does not get the CPU. No sync-problems - non of the threads really depends on each other, they all just do a lot of reading and processing on their individual files
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/33538454
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22108684
has text: @Ravinder how do I make sure it does **Not** return null anymore though?
score: 0

http://stackoverflow.com/q/22117512
type: AnsweredQuestion
score: 0
tagged with: java
tagged with: authentication
tagged with: web-services
type: Question
tagged with: jersey
has body: Could anyone explain to me why basic auth is working and the digest isn't working or not showing up in the http headers on the server anyway. public String login(UserDTO user) { ClientConfig clientConfig = new DefaultClientConfig(); clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); Client client = Client.create(clientConfig); // client.addFilter(new HTTPBasicAuthFilter(user.getUsername(), user.getPassword())); client.addFilter(new HTTPDigestAuthFilter(user.getUsername(), user.getPassword())); ClientResponse response = client.resource(url + "user/login").accept("application*json").type("application/json").get(ClientResponse.class); System.out.println(response.toString()); return null; } If I use: client.addFilter(new HTTPBasicAuthFilter(user.getUsername(), user.getPassword())); I get an authorization header on the server: USER LOGIN REQUEST request:uri: /StambomenWebAPI/rest/user/login method: GET QueryString: null Parameters: Headers: Name: accept Value: application*json Name: content-type Value: application/json Name: authorization Value: Basic QXhsOkxvbA== Name: user-agent Value: Java/1.7.0_51 Name: host Value: localhost:8084 Name: connection Value: keep-alive USER AND PASS[XXXXX, XXXXX] But when I use client.addFilter(new HTTPDigestAuthFilter(user.getUsername(), user.getPassword())); I do not get an authorization header field ... :s ? Using jersey with tomcat v7 My regards and thx in advance for any help
has answer: http://stackoverflow.com/a/22129789
answer count: 1
accepted answer: http://stackoverflow.com/a/22129789
has title: Jersey Security Digest vs Basic Auth
tagged with: digest

http://stackoverflow.com/comment/33427370
score: 0
type: Comment
type: QuestionComment
has text: The way you've suggested it's not possible; however, maybe if you tell us *why* you want to do this...
comment on: http://stackoverflow.com/q/22046474

http://stackoverflow.com/comment/33421271
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/22043759
type: Comment
has text: Yup uploading data direct in Service class would freeze the UI thread. I need a separate thread for this, that's why I was thinking to do the uploading in AysncTask.

http://stackoverflow.com/comment/33558194
type: QuestionComment
comment on: http://stackoverflow.com/q/22119962
score: 2
has text: *" I would expect to execute the "Human" method"* Since when null is a `Human` instance?
type: Comment

http://stackoverflow.com/a/22158746
upvote count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33632964
has body: I use a fixed pipeline which is only responsible for decoding/encoding requests/responses (and optional aggregation, compression, static headers, etc). The final handler in the pipeline passes off to a configurable RequestResolver (generic to support types other than HTTP) which looks a little like: public interface RequestResolver&lt;T&gt; { void execute(@Nonnull ChannelHandlerContext ctx, @Nonnull T req); } The request resolver is responsible for deciding how to handle the request (i.e. routing if necessary) and generally passes off to one or more actions that have been registered on it, or returns a 404. It doesn't have anything to do with the pipeline so much, other than it takes a ctx with which to queue responses. I started using Netty 4 right back when it was alpha-01 and there was no routing framework plugins available, so I wrote my own RequestResolver in Java, more recently I've another written in Clojure which re-uses the Clout routing from Compojure.
has comment: http://stackoverflow.com/comment/33634949
answers question: http://stackoverflow.com/q/22152823
type: Answer
score: 2

http://stackoverflow.com/comment/33469076
has text: As i know, cells with formatting is initialised, and same is the column with that style.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22070763

http://stackoverflow.com/comment/33574521
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22128694
type: AnswerComment
has text: try this : System.out.println(" 1 :Usage: ./run.sh [mobile] #"+ args[0] + "#");

http://stackoverflow.com/comment/33430458
type: Comment
score: 0
has text: Thank you very Much for your time, i will try myself Thanks once again :)
type: AnswerComment
comment on: http://stackoverflow.com/a/22048051

http://stackoverflow.com/q/22167910
tagged with: java
tagged with: concurrency
tagged with: java.util.concurrent
type: Question
accepted answer: http://stackoverflow.com/a/22168007
has title: Java executor: Submitting a batch of tasks?
upvote count: 1
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/22168007
has body: Here's what I want to achieve: I want to have some object (probably an executor of some sort) to which I can submit a "batch" of tasks to be executed (say List&lt;Callable&lt;T&gt;&gt;). When all of these tasks have finished running I want to be notified (probably through a value available in a Future object). This "executor" should be able to handle several batches at once. In other words: two (or more) code sites can submit two different batches and each of these sites will be notified only when "his" batch is over. Even better, I want that Future to provide me with a List&lt;T&gt; holding the values that were returned by the various tasks (Callables). Summarizing the above I am looking for something that offers an API that is conceptually identical to: public T Future&lt;List&lt;T&gt;&gt; submitBatch(List&lt;Callable&lt;T&gt;&gt; tasks) What canned constructs from java.util.concurrent can help me the most in achieving that?
type: AnsweredQuestion
downvote count: 0
score: 1

http://stackoverflow.com/q/22016805
tagged with: string
has answer: http://stackoverflow.com/a/22016911
score: 0
has answer: http://stackoverflow.com/a/22016881
accepted answer: http://stackoverflow.com/a/22016881
has answer: http://stackoverflow.com/a/22017867
answer count: 5
tagged with: output
has answer: http://stackoverflow.com/a/22016932
possible better answer: http://stackoverflow.com/a/22016911
type: AnsweredQuestion
tagged with: java
has title: String Tokenizer in Java gives wrong output. Need help (probably an easy solution)
tagged with: stringtokenizer
has body: My code is basically to find the number of words in a string (Yeah, really simple, but it isnt working). I've tried multiple methods and tried altering the code quite a few times. Can anyone explain to my why this code doesnt work and if it's possible to give me a better/working code. StringTokenizer stspace = new StringTokenizer(sent, " .?"); int nTokenSpace = stspace.countTokens(); String mspace[] = new String[nTokenSpace]; for(int i=0;i&lt;nTokenSpace;i++) { mspace[i] = stspace.nextToken(); } for(int i=0;i&lt;nToken;i++) { String k = mspace[i]; int freq = 0; for(int x=0;x&lt;nTokenSpace;x++) { if(k==mspace[x]) { freq++; } } System.out.println(k+"\t"+freq); } The Required output for "My. Name. Is. Anon. Is. Anon." should be My 1 Name 1 Is 2 Anon 2 But I get My 1 Name 1 Is 1 Anon 1 Is 1 Anon 1 I have a feeling there's an obvious mistake here but I just dont see it (need new eyes >.>)
type: Question
has answer: http://stackoverflow.com/a/22016957

http://stackoverflow.com/comment/33621855
type: Comment
has text: I tried that earlier with a loop, but it still didn't work: `while (imageIcon.getImageLoadStatus() != MediaTracker.COMPLETE) {}`
comment on: http://stackoverflow.com/a/22154914
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33513635
comment on: http://stackoverflow.com/a/22063658
score: 0
type: AnswerComment
type: Comment
has text: that would be the case for non-blocking i/o, but blocking connections can often get blocked in an i/o operation effectively making no use of CPU, so generally with blocking i/o one would want more worker threads than CPU cores

minecraft
tags question: http://stackoverflow.com/q/22160617
type: Tag
tag name: minecraft
tags question: http://stackoverflow.com/q/22119642

http://stackoverflow.com/comment/33526079
comment on: http://stackoverflow.com/a/22101772
type: Comment
score: 0
type: AnswerComment
has text: Semaphore also allows fair locking, but ReentrantLock is a better replacement for synchronized.

http://stackoverflow.com/comment/99113239
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/25404917
has text: @kdoteu sure, it is stated in javadoc: https://www.eclipse.org/eclipselink/api/2.7/org/eclipse/persistence/config/PersistenceUnitProperties.html#ALLOW_ZERO_ID

http://stackoverflow.com/q/22109297
has title: How to use a boolean return value from my subprogram in my main
tagged with: boolean
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/22109345
has body: Hey I made a subprogram which returns either true or false. Now in my main I am not able to use it in my if statement. This is how I shaped my if statement: Uniqueyear(year); if (Uniqueyear()) { System.out.println(year + "is unique."); } else { year++; Uniqueyear(year); } } However, when i compile my program it says " method Uniqueyear in class DistinctDigits cannot be applied to given types; required: int found: no arguments reason: actual and formal argument lists differ in length " I am new to programming and cant seem to fix it.I also tried writing " if (Uniqueyear(year)){.. but it messes up my output. This is my subprogram in case there is some problem in my return statement or anything else: public static boolean Uniqueyear(int a) { String year= Integer.toString(a); for (int i=0; i&lt;year.length(); i++) { for(int j = i + 1; j &lt; year.length(); j ++){ if (year.charAt(i) == year.charAt(j)) { return true; } } } return false; Any help will be appreciated. :)
tagged with: return
type: UnansweredQuestion
tagged with: java
type: Question

http://stackoverflow.com/q/22120986
tagged with: proxy
has answer: http://stackoverflow.com/a/22121188
score: 0
has body: I am writing an HTTP proxy in Java which takes malformed HTTP request, corrects them, forwards them to a server, and then forwards the server's response back to the client. However, I'm having a lot of trouble testing it. I am running the proxy on a virtual machine (of which I have root privilages) on a Red Hat server that I am sshing into and listening at port 12345. Then on my machine, in Firefox I am going to Options>Connection Settings>Manual Proxy Configuration and entering the IP address for the virtual machine and port 12345. However, when I run the proxy on my virtual machine and try to go to a site in Firefox nothing happens. Here is my code: package proxy; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; public class WebProxy { public void run() { try { toFromClient(); } catch (IOException e) { e.printStackTrace(); } } public String requestNormalizer(String badRequest) { return badRequest.replace(badRequest.substring(0, badRequest.indexOf(" ")), badRequest.substring(0, badRequest.indexOf(" ")).toUpperCase()); } public void toFromClient() throws IOException { ServerSocket welcome; Socket client; String request; String response; DataOutputStream outputToClient; BufferedReader inputFromClient; boolean listening = true; welcome = new ServerSocket(12345); while (listening) { client = welcome.accept(); inputFromClient = new BufferedReader(new InputStreamReader(client.getInputStream())); request = inputFromClient.readLine(); // request = requestNormalizer(request); response = toFromServer(request); outputToClient = new DataOutputStream(client.getOutputStream()); outputToClient.writeBytes(response); } } public String toFromServer(String request) throws UnknownHostException, IOException { Socket server; String response; DataOutputStream outputToServer; BufferedReader inp…
answer count: 1
has title: Using a Java HTTP proxy with Firefox
type: UnansweredQuestion
tagged with: sockets
tagged with: java
type: Question
tagged with: firefox

http://stackoverflow.com/comment/33641909
type: Comment
comment on: http://stackoverflow.com/a/22166741
has text: The Thread.stop() method is unsafe and thus deprecated. If the thread being stopped was modifying common data, that common data remains in an inconsistent state.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33607319
comment on: http://stackoverflow.com/a/22132928
score: 0
has text: I not understand what is problem handle your exception. I am sorry, i am not familar with java nor with your java library. You also can read library code(it is opensource) and add connection check routine.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/33602971
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22145281
has text: Why not use the default method for Integer? Integer.toHexString(456);
score: 0

http://stackoverflow.com/comment/33442797
comment on: http://stackoverflow.com/q/22055548
score: 2
has text: They teach Flappy Bird cloning in programming classes?!
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33579229
type: Comment
score: 1
comment on: http://stackoverflow.com/q/22131206
has text: What are you using to compile and run, and how are you trying to do that? It looks like it's just a classpath issue...
type: QuestionComment

http://stackoverflow.com/q/22013330
has answer: http://stackoverflow.com/a/22013462
tagged with: java
score: -1
upvote count: 0
answer count: 1
favorite count: 0
accepted answer: http://stackoverflow.com/a/22013462
tagged with: properties
has body: I'm having some trouble when reading from a .config file in a Java application. I have a module, let's call it Configuration_Reader that implements the next interface: Interface int getDelayValue(); int getRepValue(); ... For example, the getDelayValue() implementation is as follows: Implementation InputStream fis = new FileInputStream( new File("").getAbsolutePath()+"/config/config.properties"); props.load(fis); fis.close(); PropertyConfigurator.configure(props); ... public int getDelayValue() { return getIntProperty("delayValue"); } There's no error nor exception when reading the value, but my issue is that if I update the value on the config file and call the getDelayValue() function again, it always returns the original value the property had when I launched the application. So, it is not updating (I assume it is not reading the file again) even if debugging I can see that the function is being called appropriately. Any tips? Thanks in advance
type: AnsweredQuestion
has title: Reading updated values from a .config file
tagged with: file
downvote count: 1
type: Question

http://stackoverflow.com/a/22091154
upvote count: 2
accepted answer of: http://stackoverflow.com/q/22091071
has body: java.sql.Date does not have no-arg constuctor. java.sql.Date change it to java.util.Date cookie = new Cookie("test_cookie", Long.toString(new java.util.Date().getTime()));
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22091071
has comment: http://stackoverflow.com/comment/33506068
type: Answer
has comment: http://stackoverflow.com/comment/33506228
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33505980
has comment: http://stackoverflow.com/comment/33506116

http://stackoverflow.com/comment/33595374
type: QuestionComment
comment on: http://stackoverflow.com/q/22140654
has text: can you check builders which are currently configured on that project. It should have maven builder configured
score: 0
type: Comment

http://stackoverflow.com/comment/33384937
score: 1
has text: No answer abt public & static
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22023158

http://stackoverflow.com/comment/33396947
type: QuestionComment
has text: I understand that @MatejC however the problem still remains and occurs as soon as that For loop is added.
comment on: http://stackoverflow.com/q/22015282
score: 0
type: Comment

http://stackoverflow.com/comment/33550281
score: 0
has text: Maybe you have the key-codes wrong : (VK_KP_UP) is for the up arrow key. In fact, here is the full list (: http://docs.oracle.com/javase/7/docs/api/java/awt/event/KeyEvent.html
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22115419

http://stackoverflow.com/comment/33543123
has text: that's a reasonable persuasion,… it definitely works
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22111280

http://stackoverflow.com/a/22176985
answers question: http://stackoverflow.com/q/22155911
has body: We do this using the maven war overlay feature (read about it here). To do this we simply have a dependency from our web client module onto a war type war , and override what we need to in our module. Maven will take the contents of the dependent war and use its files to provide content for our web client, but if there is a clash on filename it'll take the file from our web client, not from the dependent jar. It's as if it takes the dependent jar and overlays our client on top of it to produce a new war. We do this very simply, without any need for ant run -- in years of using maven I have never had to resort to antrun (I consider it an antipattern). You mention in the comments that you have a separate problem dealing with some xml files. This can be handled by the resource plugin, if you tell it which directory your files are in, and give it a wildcard to define the files you need copying.
has comment: http://stackoverflow.com/comment/33662439
has comment: http://stackoverflow.com/comment/33660992
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/33661426

loops
tags question: http://stackoverflow.com/q/22113241
tags question: http://stackoverflow.com/q/22153033
tags question: http://stackoverflow.com/q/22114565
tags question: http://stackoverflow.com/q/22089027
tags question: http://stackoverflow.com/q/22113359
tags question: http://stackoverflow.com/q/22141413
tags question: http://stackoverflow.com/q/22109874
tags question: http://stackoverflow.com/q/22008532
tags question: http://stackoverflow.com/q/22128437
tags question: http://stackoverflow.com/q/22103786
tags question: http://stackoverflow.com/q/22112212
tags question: http://stackoverflow.com/q/22025590
tags question: http://stackoverflow.com/q/22132288
tags question: http://stackoverflow.com/q/22111465
tags question: http://stackoverflow.com/q/22087039
type: Tag
tags question: http://stackoverflow.com/q/22161684
tags question: http://stackoverflow.com/q/22006177
tags question: http://stackoverflow.com/q/22138851
tags question: http://stackoverflow.com/q/22108369
tags question: http://stackoverflow.com/q/22085224
tags question: http://stackoverflow.com/q/22028894
tags question: http://stackoverflow.com/q/22030908
tags question: http://stackoverflow.com/q/22080190
tags question: http://stackoverflow.com/q/22140624
tag name: loops
tags question: http://stackoverflow.com/q/22061764
tags question: http://stackoverflow.com/q/22051124
tags question: http://stackoverflow.com/q/22056322
tags question: http://stackoverflow.com/q/22075224
tags question: http://stackoverflow.com/q/22051276
tags question: http://stackoverflow.com/q/22102720
tags question: http://stackoverflow.com/q/22095941
tags question: http://stackoverflow.com/q/22059802
tags question: http://stackoverflow.com/q/22106886
tags question: http://stackoverflow.com/q/22153980
tags question: http://stackoverflow.com/q/22092196

http://stackoverflow.com/a/22117820
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22117725
answers question: http://stackoverflow.com/q/22117725
type: Answer
upvote count: 3
has body: Just use optJSONObject(String name) instead getJSONObject(String name): Returns the value mapped by name if it exists and is a JSONObject. Returns null otherwise. And then check returned value.
score: 3
type: AcceptedAnswer

http://stackoverflow.com/a/22063155
has comment: http://stackoverflow.com/comment/33455688
downvote count: 0
answers question: http://stackoverflow.com/q/22062974
has comment: http://stackoverflow.com/comment/33457441
type: Answer
score: 2
upvote count: 2
has body: First close all connection resources properly - use a Java 7 try-with-resources. Here is an simple example: final String email = request.getParameter("email"); final String pass = request.getParameter("pass"); try (final Connection con = DriverManager.getConnection("jdbc:mysql://localhost:8080/student", "root", "root"); final PreparedStatement statement = con.prepareStatement("SELECT COUNT(*) AS count FROM student WHERE email=? AND password=?");) { statement.setString(1, email); statement.setString(2, pass); try (final ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { final int rows = resultSet.getInt("count"); if (rows &gt; 1) { throw new IllegalStateException("More than one row returned!"); } boolean validUser = rows == 1; } } } But really you should hash passwords in the database. Use something like jBcrypt. Your code would then look like: final String email = request.getParameter("email"); final String pass = request.getParameter("pass"); try (final Connection con = DriverManager.getConnection("jdbc:mysql://localhost:8080/student", "root", "root"); final PreparedStatement statement = con.prepareStatement("SELECT pass FROM student WHERE email=?");) { statement.setString(1, email); statement.setString(2, pass); try (final ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { final String hash = resultSet.getString("pass"); final boolean valid = BCrypt.checkpw(pass, hash); } } } Obviously you need to add error checking if there are no rows returned from the query. You also need to check that only one row is returned. But I leave that as an exercise.

http://stackoverflow.com/q/22070903
answer count: 5
has answer: http://stackoverflow.com/a/22072016
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22072016
tagged with: java
has answer: http://stackoverflow.com/a/22070945
has answer: http://stackoverflow.com/a/22071032
has answer: http://stackoverflow.com/a/22070940
type: Question
tagged with: arraylist
score: 0
accepted answer: http://stackoverflow.com/a/22070945
has title: Java - Multiplication not working as expected
has answer: http://stackoverflow.com/a/22070965
has body: the below code gives me -1894967296 as result but this is not expected. What is exactly happening? I can't figure it out. The result has to be 2400000000 as per my calculator :( import java.util.List; import java.util.ArrayList; public class Calculate{ public static void main(String []args){ int result = 1; List&lt;Integer&gt; integer = new ArrayList&lt;Integer&gt;(); integer.add(100); integer.add(200); integer.add(300); integer.add(400); for (Integer value : integer) { result *= value; } System.out.println(result); } } When I debug, it works correctly till the third iteration. Update: As per the answers, the int primitive type range has been exceeded but what will happen to the int variable? It will be defaulted to some value?
tagged with: operators

http://stackoverflow.com/comment/33670130
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22099482
has text: I only see the support to override dependencies versions, note that it is impossible Roo controls all the possible variants to do something, so Roo set up your project in one way only.

http://stackoverflow.com/a/22097174
has comment: http://stackoverflow.com/comment/33517606
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22097049
has comment: http://stackoverflow.com/comment/33523185
type: Answer
has comment: http://stackoverflow.com/comment/33517354
accepted answer of: http://stackoverflow.com/q/22097049
has comment: http://stackoverflow.com/comment/33517574
has body: You could read through the book and learn about the design patterns there, then look through the code to see what patterns look similar. In this way, you might learn something useful about design patterns instead of just putting and answer down on your assignment.
score: 0

http://stackoverflow.com/comment/33585848
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22134928
has text: Question - does the constructor work? Doesn't defining the parameters as x and y override (or is it shadow/hide?) the global class variables? Wouldn't it then be like assigning a variable to itself?

http://stackoverflow.com/comment/33642846
has text: sorry I don' know how to make it go in new line here
comment on: http://stackoverflow.com/q/22167369
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22111852
possible better answer: http://stackoverflow.com/a/22112122
answer count: 2
has answer: http://stackoverflow.com/a/22112122
accepted answer: http://stackoverflow.com/a/22112013
tagged with: android
type: AnsweredQuestion
tagged with: java
has body: @Override public Fragment getItem(int position) { CharacterFragment fragment = new CharacterFragment(); View rootView = fragment.getView(); TextView character = (TextView) rootView.findViewById(R.id.character); character.setText(name[position]); return fragment; } This is my code for changing the fragment in the ViewPager. The fragment just has a single text view. basically, I am just siwping through the alphabets in my name. So, depending on the index, I have to set the text in the TextView of the fragment. With the above code, the programs blows with a NullPointerException because the layout has not been inflated yet, so I presume. What would be the right way to change the content of the Fragment? Is there a callback method that would let me know that it has become visible ?
has title: Changing the text of the Fragment in the ViewPager
type: Question
tagged with: android-fragments
has answer: http://stackoverflow.com/a/22112013
score: 0

hibernate
tags question: http://stackoverflow.com/q/22020652
tags question: http://stackoverflow.com/q/22067239
tags question: http://stackoverflow.com/q/22031128
tags question: http://stackoverflow.com/q/22120536
tags question: http://stackoverflow.com/q/22089861
tags question: http://stackoverflow.com/q/22077058
tags question: http://stackoverflow.com/q/22032045
tags question: http://stackoverflow.com/q/22044264
tags question: http://stackoverflow.com/q/22024153
tags question: http://stackoverflow.com/q/22030448
tags question: http://stackoverflow.com/q/22155328
tags question: http://stackoverflow.com/q/22038786
tags question: http://stackoverflow.com/q/22032260
tags question: http://stackoverflow.com/q/22066946
tags question: http://stackoverflow.com/q/22046211
tags question: http://stackoverflow.com/q/22147219
tags question: http://stackoverflow.com/q/22080407
tags question: http://stackoverflow.com/q/22168348
tags question: http://stackoverflow.com/q/22058662
tags question: http://stackoverflow.com/q/22017347
tags question: http://stackoverflow.com/q/22054464
tags question: http://stackoverflow.com/q/22140906
tags question: http://stackoverflow.com/q/22044364
tags question: http://stackoverflow.com/q/22167659
tags question: http://stackoverflow.com/q/22147507
tags question: http://stackoverflow.com/q/22163158
tags question: http://stackoverflow.com/q/22155244
tags question: http://stackoverflow.com/q/22016604
tags question: http://stackoverflow.com/q/22094071
tags question: http://stackoverflow.com/q/22150678
tags question: http://stackoverflow.com/q/22014912
tags question: http://stackoverflow.com/q/22087628
tags question: http://stackoverflow.com/q/22133073
tags question: http://stackoverflow.com/q/22097873
tags question: http://stackoverflow.com/q/22016971
tags question: http://stackoverflow.com/q/22041587
tags question: http://stackoverflow.com/q/22073871
tags question: http://stackoverflow.com/q/22034262
tags question: http://stackoverflow.com/q/22156424
tags question: http://stackoverflow.com/q/22119567
tags question: http://stackoverflow.com/q/22148410
tags question: http://stackoverflow.com/q/22112448
tags question: http://stackoverflow.com/q/22070465
tags question: http://stackoverflow.com/q/22125823
tags question: http://stackoverflow.com/q/22045779
tags question: http://stackoverflow.com/q/22045572
tags question: http://stackoverflow.com/q/22135683
tags question: http://stackoverflow.com/q/22099336
tags question: http://stackoverflow.com/q/22130564
tags question: http://stackoverflow.com/q/22111177
tags question: http://stackoverflow.com/q/22029798
tags question: http://stackoverflow.com/q/22168486
tag name: hibernate
tags question: http://stackoverflow.com/q/22060686
tags question: http://stackoverflow.com/q/22034158
tags question: http://stackoverflow.com/q/22142920
tags question: http://stackoverflow.com/q/22078386
tags question: http://stackoverflow.com/q/22089288
tags question: http://stackoverflow.com/q/22037125
tags question: http://stackoverflow.com/q/22020500
tags question: http://stackoverflow.com/q/22063273
tags question: http://stackoverflow.com/q/22099901
tags question: http://stackoverflow.com/q/22107384
tags question: http://stackoverflow.com/q/22151183
tags question: http://stackoverflow.com/q/22024016
tags question: http://stackoverflow.com/q/22083666
tags question: http://stackoverflow.com/q/22068871
tags question: http://stackoverflow.com/q/22147309
tags question: http://stackoverflow.com/q/22048194
tags question: http://stackoverflow.com/q/22012233
tags question: http://stackoverflow.com/q/22042903
tags question: http://stackoverflow.com/q/22151698
tags question: http://stackoverflow.com/q/22152346
tags question: http://stackoverflow.com/q/22150190
tags question: http://stackoverflow.com/q/22007703
tags question: http://stackoverflow.com/q/22133787
tags question: http://stackoverflow.com/q/22005115
tags question: http://stackoverflow.com/q/22112068
tags question: http://stackoverflow.com/q/22086082
tags question: http://stackoverflow.com/q/22035445

http://stackoverflow.com/a/22124531
has body: Change your provider tag to in persistence.xml to: org.eclipse.persistence.jpa.PersistenceProvider from your libs i can see that you're using eclipselink as JPA provider, not hibernate.
score: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22124498
downvote count: 0
answers question: http://stackoverflow.com/q/22124498
type: Answer
upvote count: 1

http://stackoverflow.com/q/22103812
upvote count: 1
tagged with: swing
has comment: http://stackoverflow.com/comment/33530017
has title: KeyListener isn't working
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33530162
tagged with: keylistener
has comment: http://stackoverflow.com/comment/33530663
has answer: http://stackoverflow.com/a/22104499
type: Question
has body: I am working on a game and it was quite some time ago that I programmed in java so I have forgoten some things such as how to crate a KeyListener so I read the java docs and came up with this but it the player doesn't move when I press one of the keys. Below is my code. This is in the Player.java class (Player.java extends Entity.java): (speed = 1) public void keyPressed(KeyEvent e){ if(e.getKeyChar() == 'W' | e.getKeyChar() == 'w' | e.getKeyCode() == KeyEvent.VK_UP){ yPos = -speed; } if(e.getKeyChar() == 'S' | e.getKeyChar() == 's' | e.getKeyCode() == KeyEvent.VK_DOWN){ yPos = speed; } if(e.getKeyChar() == 'A' | e.getKeyChar() == 'a' | e.getKeyCode() == KeyEvent.VK_LEFT){ xPos = -speed; } if(e.getKeyChar() == 'D' | e.getKeyChar() == 'd' | e.getKeyCode() == KeyEvent.VK_RIGHT){ xPos = speed; } } public void keyReleased(KeyEvent e){ if(e.getKeyChar() == 'W' | e.getKeyChar() == 'w' | e.getKeyCode() == KeyEvent.VK_UP){ yPos = 0; } if(e.getKeyChar() == 'S' | e.getKeyChar() == 's' | e.getKeyCode() == KeyEvent.VK_DOWN){ yPos = 0; } if(e.getKeyChar() == 'A' | e.getKeyChar() == 'a' | e.getKeyCode() == KeyEvent.VK_RIGHT){ xPos = 0; } if(e.getKeyChar() == 'D' | e.getKeyChar() == 'd' | e.getKeyCode() == KeyEvent.VK_LEFT){ xPos = 0; } } This is in the Entity.java class: public void move(){ x += xPos; y += yPos; } This is in the Entities.java class: KeyAdapter playerAdapter = new KeyAdapter(){ @Override public void keyPressed(KeyEvent e){ player.keyPressed(e); } @Override public void keyReleased(KeyEvent e){ player.keyReleased(e); } }; public void move(){ //Player player.move(); } and this is in the Level.java class (Level.java extends JComponent): In the Level() method: addKeyListener(entities.playerAdapter); In the paintComponent(Graphics g) method: if(entities.player.getState()) g2d.drawImage(entities.player.getImage(), entities.player.getX(), entities.player.getY(), this); and int the run() method: entities.move(); So, what am I doing wrong?
answer count: 1
downvote count: 0
linked to: http://stackoverflow.com/q/13354230
has comment: http://stackoverflow.com/comment/33529837
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33529966
tagged with: input

http://stackoverflow.com/q/22071565
downvote count: 0
has comment: http://stackoverflow.com/comment/33599994
accepted answer: http://stackoverflow.com/a/22271096
favorite count: 0
tagged with: on-the-fly
tagged with: android
has comment: http://stackoverflow.com/comment/33600491
has comment: http://stackoverflow.com/comment/33599891
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33508777
has body: I'm stuck in a problem where I need to set reference of my object being parsed to its child objects during deserialization using Gson and InstanceCreator. To depict the problem, following is the simple representation of classes' structure. public class Workshift { private final transient Context context; private final Visit visit; public Workshift(Context context) { this.context = context; this.visit = new Visit(this); } } public class Visit { private final transient Workshift workshift; public Visit(Workshift ws) { this.workshift = ws; } } With this structure, I am able to set Context in Workshift by providing an InstanceCreator to my GsonBuilder, for example: Gson gson = new GsonBuilder() .registerTypeAdapter(Workshift.class, new InstanceCreator&lt;Workshift&gt;() { @Override public Workshift createInstance(Type type) { return new Workshift(context); } }) .create(); I know, I can add additional InstanceCreator to my GsonBuilder, but I'm not sure how to provide a reference of my Workshift object which is in the process of being parsed (on-the-fly) to Visit object? Any help would be appreciated!
tagged with: java
tagged with: gson
has answer: http://stackoverflow.com/a/22271096
type: Question
has title: Gson - Setting object reference on-the-fly using InstanceCreator
possible better answer: http://stackoverflow.com/a/22238249
has answer: http://stackoverflow.com/a/22238249
has comment: http://stackoverflow.com/comment/33599788
score: 4
upvote count: 4
answer count: 2

http://stackoverflow.com/a/22108428
score: 1
answers question: http://stackoverflow.com/q/22108373
has body: If you need to set all the fields in a row at once, you either need to set them up during construction using int[][] newArray = { {1,2,3}, {2,3,4}, {3,4,5} } or if you want to do this at a later time, you can construct a new one dimensional array and assign that to a row, such as int[] row = {2,3,4}; newArray[1] = row;
upvote count: 1
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/33537945

http://stackoverflow.com/a/22139714
answers question: http://stackoverflow.com/q/22078383
type: Answer
has comment: http://stackoverflow.com/comment/33812644
has comment: http://stackoverflow.com/comment/33625491
score: 5
upvote count: 5
downvote count: 0
has body: Some background -- When you tap on the relative layout, TalkBack generates speech based on the layout's contents. On ICS, this is triggered by a HOVER_ENTER event. On Jelly Bean, it's triggered by an ACCESSIBILITY_FOCUS event. These events are sent automatically by the framework and should, generally speaking, never be sent manually from an app. The same goes for FOCUS events, except in the special case of custom views (see Accessibility talk from Google I/O 2013 for more details). So, back on topic. You can control the speech for SCROLLED events by populating the outgoing event with the text you want read. The down side of this is that you'll need to manually generate the text you want read, and it's very likely that this text will differ from what TalkBack will read if the user touches the layout. viewPager.setAccessibilityDelegate(new AccessibilityDelegate () { @Override public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) { super.onPopulateAccessibilityEvent(host, event); if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) { event.setContentDescription(/** your text */); } } }); Another option is to do nothing and let the user explore the view on their own. This is the preferred interaction model for Android accessibility. Edit: Video URL is broken, Changed.

http://stackoverflow.com/q/22089243
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22090497
favorite count: 0
possible better answer: http://stackoverflow.com/a/22090497
has answer: http://stackoverflow.com/a/22090259
tagged with: selenium-webdriver
score: 4
has answer: http://stackoverflow.com/a/22128514
tagged with: java
has body: I have a test case as shown below . it compares 2 data and returns PASS if both data is identical . the issue is i want this test to fail if there is data mismatch CODE is WebElement TxtBoxContent = driver.findElement(By.id(WebelementID)); String Content = TxtBoxContent.getAttribute("value"); String ExcelData = Generic.getXlCellValue(xlpath, sheetName, rownum, cellnum); Content.equals(ExcelData); Reporter.log(LocationName+" Data Verification -- PASS",true);
tagged with: selenium
upvote count: 4
answer count: 4
has comment: http://stackoverflow.com/comment/33502768
downvote count: 0
has answer: http://stackoverflow.com/a/22089334
has title: How to Make This Test case to Fail
accepted answer: http://stackoverflow.com/a/22128514
type: Question

http://stackoverflow.com/comment/33462803
type: Comment
type: QuestionComment
has text: No problem ! But I am still not able to find why background doesn't work with root ! can you try using `-fx-base: rgb(132, 145, 47); -fx-background: rgb(225, 228, 203);` inside root ?
comment on: http://stackoverflow.com/q/22066799
score: 0

http://stackoverflow.com/q/22025194
possible better answer: http://stackoverflow.com/a/22025278
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22025371
has answer: http://stackoverflow.com/a/22025242
has body: I want to populate an array list with 5 elements randomly from 0 to 4. Lets say my ArrayList randomizer = new ArrayList(); What I have is the following... for (int itter = 0; itter &lt; 5; itter++) { do { random = randInt(0, 4); } while (randomizer.contains(random)); if (randomizer.contains(random)) { } else { randomizer.add(random); } Is there a faster way to randomly add 5 integers to an arraylist? Thanks!
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22025267
type: Question
has comment: http://stackoverflow.com/comment/33388548
has title: Simpler way to populate a list of 5 random ints
has comment: http://stackoverflow.com/comment/33388699
upvote count: 2
accepted answer: http://stackoverflow.com/a/22025264
downvote count: 1
has comment: http://stackoverflow.com/comment/33388656
favorite count: 0
has comment: http://stackoverflow.com/comment/33388593
has answer: http://stackoverflow.com/a/22025264
has answer: http://stackoverflow.com/a/22025278
answer count: 5
has comment: http://stackoverflow.com/comment/33388705

http://stackoverflow.com/q/22143093
has comment: http://stackoverflow.com/comment/33600284
tagged with: java
tagged with: http://stackoverflow.com/tag/json
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/22074192
has comment: http://stackoverflow.com/comment/33599289
linked to: http://stackoverflow.com/q/5173603
has answer: http://stackoverflow.com/a/22143877
tagged with: facebook-graph-api
has title: extracting name and id from json
type: Question
tagged with: facebook
has comment: http://stackoverflow.com/comment/33600118
has comment: http://stackoverflow.com/comment/33600853
has comment: http://stackoverflow.com/comment/33600162
has body: I want to extract id value from this json data. I tried many ways but I don't know what went wrong in my code also I wnt to store id into an array JSONObject json = readurl("https://graph.facebook.com/"+s); System.out.println(json); String json2=json.getString("likes"); {"data":[ { "id":"**********", "name":"skkjghkjhkj" }, { "id":"********", "name":"khkfjhkjf" } ]
score: 0
has comment: http://stackoverflow.com/comment/33599440
answer count: 1

http://stackoverflow.com/a/22124073
upvote count: 1
downvote count: 1
score: 0
answers question: http://stackoverflow.com/q/22123972
type: Answer
has body: public class Car implements Comparable { private int speed; public Car(int s) { speed = s; } public int compareTo(Object o) { Car other = (Car) o; return this.speed - other.speed; } }

http://stackoverflow.com/comment/33638149
has text: class gnu.io.RXTXversion, which is a prt of rtxtcomm.jar ,, it mean this class exist in this jar ??
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22164784

http://stackoverflow.com/q/22075543
favorite count: 0
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22076475
has answer: http://stackoverflow.com/a/43601619
tagged with: java
score: 9
type: Question
possible better answer: http://stackoverflow.com/a/43601619
answer count: 2
upvote count: 9
downvote count: 0
linked to: http://stackoverflow.com/q/21296620
tagged with: tomcat
has body: Am deploying my war file on tomcat(jdk 7) and am seeing following error. Am not sure of whats causing the issue. INFO: OpenSSL successfully initialized (OpenSSL 1.0.1d 5 Feb 2013) Feb 27, 2014 11:02:50 AM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-apr-8081"] Feb 27, 2014 11:02:50 AM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-apr-8009"] Feb 27, 2014 11:02:50 AM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 1588 ms Feb 27, 2014 11:02:50 AM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Feb 27, 2014 11:02:50 AM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.42 Feb 27, 2014 11:02:50 AM org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive D:\Dev\tools\apache-tomcat-7.0.42\webapp s\CollaborationPortal.war Feb 27, 2014 11:03:09 AM org.apache.catalina.startup.TaglibUriRule body INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined Feb 27, 2014 11:03:09 AM org.apache.catalina.startup.TaglibUriRule body INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined Feb 27, 2014 11:03:09 AM org.apache.catalina.core.StandardContext startInternal SEVERE: Error listenerStart Feb 27, 2014 11:03:09 AM org.apache.catalina.core.StandardContext startInternal SEVERE: Context [/CollaborationPortal] startup failed due to previous errors Feb 27, 2014 11:03:09 AM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-apr-8081"] Feb 27, 2014 11:03:09 AM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-apr-8009"] Feb 27, 2014 11:03:09 AM org.apache.catalina.startup.Catalina start INFO: Server startup in 18890 ms
has answer: http://stackoverflow.com/a/22076475
has title: Tomcat 7.0.42 Error listenerStart
tagged with: deployment

http://stackoverflow.com/q/22012067
answer count: 5
possible better answer: http://stackoverflow.com/a/22012796
tagged with: multithreading
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22012299
has answer: http://stackoverflow.com/a/22012200
tagged with: java
has title: How Thread run starts?
type: Question
has body: I was looking a small example on Threads.For creating Threads we can do in 2 ways either by implementing Runnable interface or by extending Thread.I used the 1st way package test; public class test implements Runnable{ public static void main(String args[]) { test t=new test(); t.run();Thread th=Thread.currentThread(); th.start(); } @Override public void run() { // TODO Auto-generated method stub System.out.println("hi"); } } My doubt is when we are calling th.start(); then run() is called.I want to know how.I thought internally there start() may be calling run() so I looked in the documentation of Thread class The following is the start() declaration in Thread class public synchronized void start() { /** * This method is not invoked for the main method thread or "system" * group threads created/set up by the VM. Any new functionality added * to this method in the future may have to also be added to the VM. * * A zero status value corresponds to state "NEW". */ if (threadStatus != 0) throw new IllegalThreadStateException(); /* Notify the group that this thread is about to be started * so that it can be added to the group's list of threads * and the group's unstarted count can be decremented. */ group.add(this); boolean started = false; try { start0(); started = true; } finally { try { if (!started) { group.threadStartFailed(this); } } catch (Throwable ignore) { /* do nothing. If start0 threw a Throwable then it will be passed up the call stack */ } } } As you can see inside start(),run() is not called but when we are calling th.start() then automatically overriden run() is called.Can anybody please throw some light in this
accepted answer: http://stackoverflow.com/a/22012299
has answer: http://stackoverflow.com/a/22012137
downvote count: 0
has answer: http://stackoverflow.com/a/22012796
has comment: http://stackoverflow.com/comment/33364516
has answer: http://stackoverflow.com/a/22012115
favorite count: 0
score: 8
upvote count: 8

http://stackoverflow.com/comment/33544676
comment on: http://stackoverflow.com/q/22112402
score: 1
type: QuestionComment
has text: Did you add `jfxrt.jar` to your project? (this should be in your java bin)
type: Comment

http://stackoverflow.com/q/22047781
favorite count: 0
has comment: http://stackoverflow.com/comment/33464062
has answer: http://stackoverflow.com/a/22132945
has title: @inject doesn't work when the bean is not created via hk2
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33460860
has comment: http://stackoverflow.com/comment/33460788
tagged with: hk2
score: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/33442662
has comment: http://stackoverflow.com/comment/33482589
has comment: http://stackoverflow.com/comment/33429220
tagged with: java
has body: I have been trying to inject a service to a contract: @org.jvnet.hk2.annotations.Contract public interface CategoryDAO{ } @org.jvnet.hk2.annotations.Service public class HibernateCategoryDAO implements CategoryDAO } @org.jvnet.hk2.annotations.Service public class MyCategoryManager implements CategoryManager { @javax.inject.Inject CategoryDAO categoryDAO; } But categoryDAO is null. I tried even to bind it: public class ServiceBinder implements Binder { @Override public void bind(DynamicConfiguration config) { config.bind(BuilderHelper.link(HibernateCategoryDAO.class).to(CategoryDAO.class).build()); } } But still it stays null. I init the MyCategoryManager with Reflections framework like this: Set&lt;?&gt; managers = Reflections.getSubTypesOf(CategoryManager.class);
type: Question
has comment: http://stackoverflow.com/comment/33477325
tagged with: dependency-injection
has comment: http://stackoverflow.com/comment/33478571
has comment: http://stackoverflow.com/comment/33444660
upvote count: 3
answer count: 1

http://stackoverflow.com/comment/33583491
type: Comment
type: QuestionComment
score: 4
comment on: http://stackoverflow.com/q/22133590
has text: You may check what `void` keyword is and when you have to use it. http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html

http://stackoverflow.com/q/22055425
has answer: http://stackoverflow.com/a/22076562
score: 0
tagged with: java
has body: I have this scenario: EJB PROJECT public BussinessException extends Exception {} public MyInterfaceImplementation implements MyInterface {} === EJB PROJECT CLIENT public interface MyInterface { public void foo() throws BussinessException; } but BussinessException is not in EJB PROJECT CLIENT classpath.. how to resolv this issue?
has title: How to import a custom exception from ejb project to ejbclient project??
type: Question
tagged with: ejb
answer count: 1
type: UnansweredQuestion

http://stackoverflow.com/q/22131726
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33580970
has comment: http://stackoverflow.com/comment/33580219
has title: Make JLabel Copyable?
tagged with: swing
tagged with: java
has comment: http://stackoverflow.com/comment/33580335
type: Question
has answer: http://stackoverflow.com/a/22133445
score: 5
has comment: http://stackoverflow.com/comment/33580213
upvote count: 5
downvote count: 0
answer count: 1
favorite count: 0
tagged with: jlabel
has body: I have a question about making JLabels Copyable. I have a drop down menu which takes the imput and displays it as a JLabel, and the label changes when the menu changes. However, I want to make the JLabel copyable. I have heard this is not possible, so i changed the labels to strings and outputted it as a textarea. But when i do this, the string doesnt change when i select a new choice from the drop down menu. Im new to java so be as descriptive as possible please, thank you. Here are some bits of my code. I really just need a way to make the JTextArea/JLabel copyable and have it be able to change String[] players = {"Nearest Player", "All Players", "Random Player"}; JComboBox&lt;String&gt; player = new JComboBox&lt;String&gt;(players); JLabel playernumb = new JLabel ("@p"); JLabel playerprompt = new JLabel("Target Player:"); JTextPane box = new JTextPane(); public static void main(String[] args) { mc frame = new mc(); frame.setVisible(true); } player.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ if (e.getSource() == player){ JComboBox temp1 = (JComboBox)e.getSource(); String playertxt = (String)temp1.getSelectedItem(); switch (playertxt){ case "Nearest Player": playernumb.setText("@p"); break; case "All Players": playernumb.setText("@a"); break; case "Random Player": playernumb.setText("@r"); break; default: break; } } } }); add(playerprompt); add(player); box.insertComponent(playernumb);

http://stackoverflow.com/a/22014929
type: Answer
answers question: http://stackoverflow.com/q/22014805
has body: You haven't call the method PrintDataArray(data) in your main method... public static void main(String args[]) { ArrayList&lt;Data&gt; data = new ArrayList&lt;Data&gt;(); data.add(new Data("Fred", 21)); CS1702_Lab5.PrintDataArray(data); } Note: please read naming conventions in Java and try to use them.
score: 0

http://stackoverflow.com/q/22056223
has comment: http://stackoverflow.com/comment/33445595
type: Question
tagged with: debugging
accepted answer: http://stackoverflow.com/a/22645476
tagged with: intellij-idea
downvote count: 0
has comment: http://stackoverflow.com/comment/33444845
has title: Running IntelliJ debugger with maven-antrun-plugin
has comment: http://stackoverflow.com/comment/33444324
answer count: 1
has body: I have a libGDX project that is built using maven. I use the maven-antrun-plugin to run the project immediately after it's built, to make it so I can test new builds quickly from the IDE. A problem I've encountered though is that I have no idea how to use IntelliJ's debugger with the java program run by the maven-antrun-plugin. Here's the code for the plugin in my pom.xml: maven-antrun-plugin 1.7 integration-test <sysproperty key="java.library.path" value="target/natives"/> <jvmarg value="-ea"/> run And to clarify, what I need to do is attach the IntelliJ debugger to the java program run by this plugin.
favorite count: 0
upvote count: 2
tagged with: maven
has answer: http://stackoverflow.com/a/22645476
type: AnsweredQuestion
score: 2
has comment: http://stackoverflow.com/comment/33445312
tagged with: java

event-handling
tag name: event-handling
tags question: http://stackoverflow.com/q/22154691
tags question: http://stackoverflow.com/q/22036962
tags question: http://stackoverflow.com/q/22102590
type: Tag
tags question: http://stackoverflow.com/q/22023768

http://stackoverflow.com/a/22107711
has comment: http://stackoverflow.com/comment/33536637
score: 0
has body: you should execute B like this: B b=new B(); b.start(); this will execute the run method and continue running simultaneously
type: Answer
answers question: http://stackoverflow.com/q/22107655

http://stackoverflow.com/comment/33729339
type: Comment
has text: Glad to know it is working now. I have updated my answer to fix the type problem, thanks for pointing that out.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22162266

http://stackoverflow.com/comment/33459821
has text: Ok. Thanks. It's working :) The last question: If I want to change the rotation how can I set the new angle?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22065069
score: 0

jar
tags question: http://stackoverflow.com/q/22164784
tags question: http://stackoverflow.com/q/22168396
tags question: http://stackoverflow.com/q/22034967
tags question: http://stackoverflow.com/q/22086273
tags question: http://stackoverflow.com/q/22117927
tags question: http://stackoverflow.com/q/22100991
tags question: http://stackoverflow.com/q/22104405
tags question: http://stackoverflow.com/q/22019886
tags question: http://stackoverflow.com/q/22102686
tags question: http://stackoverflow.com/q/22166319
tags question: http://stackoverflow.com/q/22033686
tags question: http://stackoverflow.com/q/22115644
tags question: http://stackoverflow.com/q/22098950
tags question: http://stackoverflow.com/q/22038801
tags question: http://stackoverflow.com/q/22087950
tags question: http://stackoverflow.com/q/22148093
tags question: http://stackoverflow.com/q/22025253
tags question: http://stackoverflow.com/q/22099944
tags question: http://stackoverflow.com/q/22108467
tags question: http://stackoverflow.com/q/22147507
tags question: http://stackoverflow.com/q/22054629
type: Tag
tags question: http://stackoverflow.com/q/22151968
tags question: http://stackoverflow.com/q/22155095
tags question: http://stackoverflow.com/q/22167518
tags question: http://stackoverflow.com/q/22096909
tags question: http://stackoverflow.com/q/22166048
tags question: http://stackoverflow.com/q/22093274
tags question: http://stackoverflow.com/q/22063690
tags question: http://stackoverflow.com/q/22080686
tags question: http://stackoverflow.com/q/22163692
tags question: http://stackoverflow.com/q/22050741
tags question: http://stackoverflow.com/q/22123692
tag name: jar
tags question: http://stackoverflow.com/q/22155102
tags question: http://stackoverflow.com/q/22142609
tags question: http://stackoverflow.com/q/22007784
tags question: http://stackoverflow.com/q/22110267
tags question: http://stackoverflow.com/q/22034725
tags question: http://stackoverflow.com/q/22121221
tags question: http://stackoverflow.com/q/22015880
tags question: http://stackoverflow.com/q/22064853
tags question: http://stackoverflow.com/q/22015873
tags question: http://stackoverflow.com/q/22050427
tags question: http://stackoverflow.com/q/22061096
tags question: http://stackoverflow.com/q/22164247
tags question: http://stackoverflow.com/q/22130447
tags question: http://stackoverflow.com/q/22133311
tags question: http://stackoverflow.com/q/22064116
tags question: http://stackoverflow.com/q/22085552
tags question: http://stackoverflow.com/q/22041329
tags question: http://stackoverflow.com/q/22095682
tags question: http://stackoverflow.com/q/22015446
tags question: http://stackoverflow.com/q/22006814
tags question: http://stackoverflow.com/q/22071885

http://stackoverflow.com/comment/33466250
comment on: http://stackoverflow.com/q/22068871
type: Comment
has text: @Biohazard401 you must edit your question to add the code.
type: QuestionComment
score: 0

http://stackoverflow.com/q/22042038
tagged with: maven
tagged with: java
tagged with: jboss
has comment: http://stackoverflow.com/comment/33418834
has comment: http://stackoverflow.com/comment/33420391
type: Question
score: 0
has title: Infinite loop on jboss7 when have a database exception
has body: I have a maven project, where I have used ejb6 and jboss 7 application server. When there is an exception related to database activity, the jboss log enters into an infinite loop, as a result the processor and the memory usage increases to 100%. For example, if I try to retrieve one object but there are two objects in the result, I have an exception of unique result, but instead of printing once, the exception continues to be printed. In my github I have my application with this problem.: https://github.com/alanj2diniz/ejb-loop-jboss-7 [Removed, external link has no relevance here]
answer count: 0
type: UnansweredQuestion

http://stackoverflow.com/comment/33519937
comment on: http://stackoverflow.com/a/22079024
score: 0
type: AnswerComment
has text: WarrenT, no, the application is running in an AIX server. It communicates with an AS400 server, retrieving data from a DataQueue on it (KeyedDataQueue) and sends the data to another AIX with a Websphere MQ manager. To one of its queues.
type: Comment

http://stackoverflow.com/comment/33481836
type: Comment
has text: Ok so heres an update, the code gets to if(command.get(0).equals("dt")) line but doesn't enter the loop. Any ideas?
score: 0
comment on: http://stackoverflow.com/q/22076672
type: QuestionComment

http://stackoverflow.com/q/22140080
downvote count: 0
has body: this line of code takes about 2 seconds to execute! ObjectMapper mapper = new ObjectMapper(); since two seconds is a life time when it comes to computing, is there any way to make jackson respond faster? i am using : org.codehaus.jackson jackson-mapper-asl 1.9.13
score: 1
has comment: http://stackoverflow.com/comment/33594727
tagged with: jackson
favorite count: 0
has comment: http://stackoverflow.com/comment/33594420
has comment: http://stackoverflow.com/comment/33594153
has title: How to make json jackson faster?
has comment: http://stackoverflow.com/comment/33594241
has comment: http://stackoverflow.com/comment/33594231
has comment: http://stackoverflow.com/comment/33594217
has comment: http://stackoverflow.com/comment/33594433
upvote count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22141218
tagged with: java
tagged with: http://stackoverflow.com/tag/json
accepted answer: http://stackoverflow.com/a/22141218
type: Question
answer count: 1

http://stackoverflow.com/comment/33510802
comment on: http://stackoverflow.com/q/22092704
score: 0
type: Comment
type: QuestionComment
has text: @Aarav thanks for details so if there are so many strings wouldn't it be easier to keep all those strings in separate table and instead of name have name_fk as foreign key to those strings, finally in a where clause use another select that will check whether name in given strings table or not.

http://stackoverflow.com/q/22091332
has comment: http://stackoverflow.com/comment/33507055
has comment: http://stackoverflow.com/comment/33507920
has title: Not operator in Regular expression for set of values
accepted answer: http://stackoverflow.com/a/22189087
type: Question
has comment: http://stackoverflow.com/comment/33506579
answer count: 2
tagged with: regex
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/33506507
has answer: http://stackoverflow.com/a/22091624
has body: I need to improve my skills on how regex is used in JAVA, I want to basically search if a pattern is found in a string called input. Now this input should return false to anything apart from WO.* Like WO.SYNC : true WO.UPD : true WO.REL : true ACCOUNTS.SYNC : false SC.SYNC : false Below is the sample piece of code which I wanted to use, What is to be done here? Pattern p = Pattern.compile("^(WO.*)"); String input = "WO.SYNC"; Matcher m = p.matcher(input); System.out.println(m.find());
has comment: http://stackoverflow.com/comment/33506540
has answer: http://stackoverflow.com/a/22189087
has comment: http://stackoverflow.com/comment/33507286
has comment: http://stackoverflow.com/comment/33506423
has comment: http://stackoverflow.com/comment/33506290
possible better answer: http://stackoverflow.com/a/22091624
has comment: http://stackoverflow.com/comment/33506610
has comment: http://stackoverflow.com/comment/33506698
type: AnsweredQuestion

http://stackoverflow.com/q/22043667
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33440798
type: Question
has body: In Java, I want to construct a Type object (from java.lang.reflect) that represent a complex type i.e. if I have classes Foo.class and Goo.class I want a Type object that represent Foo&lt;Goo&gt;. I know that in Jackson for example, it is done using constructParametricType() method of org.codehaus.jackson.map.type.TypeFactory class, but it returns a org.codehaus.jackson.type.JavaType and I want a java.lang.reflect.Type.
answer count: 2
has comment: http://stackoverflow.com/comment/33421073
upvote count: 1
has answer: http://stackoverflow.com/a/22043960
favorite count: 0
has answer: http://stackoverflow.com/a/22044424
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33448919
has title: How to construct types in Java?
downvote count: 0
tagged with: reflection

http://stackoverflow.com/comment/33555621
comment on: http://stackoverflow.com/q/22016027
has text: This is the flaw of procedure-based AST systems. Building ASTs (and auxiliary stuff by hard) is really a pain (and fragile: next release of ADT may break your code). Program transformation engines offer an alternative: you can write your code fragment in *source* form, almost exactly as you expressed it in "looks like the following". See http://en.wikipedia.org/wiki/Program_transformation
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22115037
answer count: 3
has answer: http://stackoverflow.com/a/22115095
upvote count: 1
tagged with: eclipse
has answer: http://stackoverflow.com/a/22115232
has answer: http://stackoverflow.com/a/22115115
type: AnsweredQuestion
has title: How do I share classes between two Android projects in Eclipse?
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33549245
favorite count: 0
type: Question
tagged with: android
accepted answer: http://stackoverflow.com/a/22115115
has body: I have 2 Android projects in Eclipse. Now the both need to share one class. As soon as I add a Project to the buildpath of the other, the folder is added but always marked with a red cross. How can I resolve this? Thanks for any help.
possible better answer: http://stackoverflow.com/a/22115095
tagged with: java

http://stackoverflow.com/comment/33366357
comment on: http://stackoverflow.com/a/22013259
score: 0
type: AnswerComment
type: Comment
has text: I understand he's looking for an implementation of both interfaces in each instance, not one or another

http://stackoverflow.com/comment/33580313
comment on: http://stackoverflow.com/q/22131409
score: 0
has text: yes it still old name there , i want to rename it but it return false
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33399857
comment on: http://stackoverflow.com/q/22031319
has text: I want to put the number of times a character/punction/number is used in a file that the user uploads on a graphic display. For instance, 33 or ! there are 3 instances. Or 65 A there are 4354 instances in the file. However I'm having a large problem with getting the counter to count the characters in the word correctly, and even more trouble getting the stored array of numbers of characters to the GUI (g.draw) section of the program
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22099041
has comment: http://stackoverflow.com/comment/33526865
has answer: http://stackoverflow.com/a/22102630
tagged with: infinispan
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/14760367
has title: Infinispan namedCache expiration
score: 1
tagged with: java
upvote count: 1
tagged with: caching
type: Question
accepted answer: http://stackoverflow.com/a/22102630
has comment: http://stackoverflow.com/comment/33521889
answer count: 1
downvote count: 0
tagged with: jboss7.x
has body: I am testing configuration settings for a named cache in infinispan hosted on jboss 7. I am using the REST server API implementation so that I can access the cache from anywhere. Here is my configuration file. &lt;infinispan&gt; &lt;namedCache name="keydata"&gt; &lt;!-- http://infinispan.org/docs/5.2.x/user_guide/user_guide.html#_expiration_2 --&gt; &lt;expiration lifespan="1000" reaperEnabled="true" /&gt; &lt;/namedCache&gt; &lt;/infinispan&gt; Now everything appears to be fine, the instance starts up and my cache is created. I can use the REST API to push new entries to this named cache. My problem is that they never seem to expire. It looks like the reaper wakes up every 60 seconds by default as I see this in my logs when it happens: 09:15:05,920 TRACE [EvictionManagerImpl] (Scheduled-eviction-thread-0) Purging data container of expired entries 09:15:05,920 TRACE [EvictionManagerImpl] (Scheduled-eviction-thread-0) Purging data container completed in 0 milliseconds If I then hit the server with a GET, the cached value comes back. Here is the trace when I do that. 09:17:10,451 TRACE [InvocationContextInterceptor] (http-localhost/127.0.0.1:8280-1) Invoked with command GetKeyValueCommand {key=user123, flags=null} and InvocationContext [org.infinispan.context.SingleKeyNonTxInvocationContext@2b77b3f2] 09:17:10,451 TRACE [EntryFactoryImpl] (http-localhost/127.0.0.1:8280-1) Exists in context? null 09:17:10,451 TRACE [EntryFactoryImpl] (http-localhost/127.0.0.1:8280-1) Retrieved from container ImmortalCacheEntry{key=user123, value=ImmortalCacheValue {value=org.infinispan.remoting.MIMECacheEntry@90c3ab46}} 09:17:10,451 TRACE [CallInterceptor] (http-localhost/127.0.0.1:8280-1) Executing command: GetKeyValueCommand {key=user123, flags=null}. 09:17:10,451 TRACE [GetKeyValueCommand] (http-localhost/127.0.0.1:8280-1) Found value org.infinispan.remoting.MIMECacheEntry@90c3ab46 I'll continue digging, but I'm curious. Has anyone come across this before? Why would a named cache wit…
favorite count: 0

http://stackoverflow.com/comment/33586188
type: QuestionComment
has text: So are you or are you not using UDP? It's possible with the code you showed, but it isn't likely. In any case there's not enough code exhibited here to answer your question.
comment on: http://stackoverflow.com/q/22134456
type: Comment
score: 0

http://stackoverflow.com/comment/33594058
type: Comment
comment on: http://stackoverflow.com/q/22139513
has text: @Youngistan I have built a code only with using the ParentClass. I do not want to change the flow of code since in my program, I am introducing multiple child for the ParentClass and use in different scenario. But each needs the parentClass values. Instead of passing all values, I am sending the parentObject so each child can take what is needed inside.
score: 0
type: QuestionComment

http://stackoverflow.com/comment/33594438
has text: @GGrec: I've updated the answer to react to cut and paste events, and I'm sure you're smart enough to configure this low level key listener based on your own needs.
comment on: http://stackoverflow.com/a/22128716
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33602094
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22144254
has text: @Jakub Kania is it this? `String sql = "SELECT studentno, lastname, firstname, middlename FROM student WHERE lastname LIKE '%" + lastname.getText() + "'%";` ? @AndrewThompson hmm. you mean like all the data in my SQL table will be displayed in my JTable, then filter search from JTable instead of filtering search directly in MySQL table? I haven't thought of that. I'll give it a shot. Thanks! @Alexander_Winter I have tried it and gave me no error, thank you. However, it displayed all the data in my SQL table instead of filtering.

http://stackoverflow.com/a/22050034
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/22049724
accepted answer of: http://stackoverflow.com/q/22049724
score: 1
upvote count: 1
has body: If you don't want to force an exception by closing the listening socket, (which is perfectly fine IME), then set a volatile boolean 'shutdown' flag that that is checked after every accept() return. Then make the accept() call return by opening a localhost client connection.
type: AcceptedAnswer

http://stackoverflow.com/q/22151464
score: 0
tagged with: utf-8
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33614376
has title: couldn't retain utf-8 codes in POJO after converting from JSON string
tagged with: java
tagged with: http://stackoverflow.com/tag/json
type: Question
has comment: http://stackoverflow.com/comment/33615273
has comment: http://stackoverflow.com/comment/33615311
has body: My JSON return string has something like below ** ® in between some string ** I have parsed using jackson parser something like returnedPOJO = objectmapper.readvalues(jsonstring,userdefinedclass); Now the returnedPOJO has values but the problem is ® has been changed to some character like y with some 2 dots top. so how to parse json to POJO without any modification of ®. Please help. see my json below and find the card-name wit utf-8 { "partner-code":"DINERS", "partner":"Diners Club", "issuer":"Diners Club", "url":"http://dinersclub.com.au/travel_card.htm", "mediafile":[ ], "general-terms-and-conditions":" Card products referred to are not Qantas products and not offered or issued by Qantas but by the relevant Card partners. The applicable Card Partner is the credit provider and credit licensee under the National Consumer Credit laws. Points are offered by the relevant Card partner and partner reward program and can only be earned on eligible purchases. Contact the relevant Card Partner for terms and conditions or enquiries. If you are interested in a Card, make sure you check out all its features on the applicable Card Partner's website as Card features are only summarised here. Card features information is based solely on information supplied by the Card Partner. The information is current as at 13 February 2014 and is subject to change. Qantas has made reasonable efforts to confirm with the applicable Card Partner as to the accuracy of information provided on this site but is not responsible for errors or omissions. ", "card-offerings":[ { "sequence-no":"6", **"card-name":"Frequent Flyer Diners Club Card with World MasterCard Card®",** "earning-points":"This charge card lets you earn Qantas Points which are directly credited to your account.", "website":"http://dinersclub.com.au/travel_card.htm", "contact-phone-number":"1300 360 060", "usage-type":"Personal", "card-level":"World", "card-type-01":"Diners Club", "per-dollar-card-type-01":"1.5", "earned-area-card-ty…

http://stackoverflow.com/a/42794426
has comment: http://stackoverflow.com/comment/72713784
has body: Even though the question is old , I am trying my best to explain , since this is a fairly common question for java newbies. Consider Employee class in package p1. package p1; public class Employee{ protected String hireDay = "hireday"; } Manager extends Employee and is in a different package. package p2; public class Manager extends p1.Employee { //now even Manager class has hireDay protected variable that was defined in Employee class. //Since Manager class has protected variable hireDay , for any manager m1 , we can access hireDay as m1.hireDay ONLY within package p2. } Enterprenur class extends Manager and is in package p3. package p3; public class Enterpreneur extends p2.Manager{ //now Enterpreneur class has inherited hireDay protected variable that Employee class had. (see comments in Employee class.) //Since Enterpreneur class has protected variable hireDay , for any Enterpreneur e , we can access hireDay as e.hireDay ONLY within package p3. //the following will work because using Enterpreneur reference e , we can access e.hireday within package p3 , this has nothing to do with //the fact that right now our code is present in Enterpreneur class , like the other answer said. Note the method is static. public static void printhireDay(Enterpreneur e){ System.out.println("hireday is :" + e.hireDay); } //this will work because using this reference we can only access protected variable in the same class(Enterpreneur) or in a subclass. public void printhireDay(){ System.out.println("hireday is :" + this.hireDay); } // This shouldn't work because using manager reference , we can only access protected field within package p2. /* public printhireDay(Manager m){ System.out.println("hireday is :" + m.hireDay) }*/ } Now within the root package , we have this class to test. public class HelloWorld{ public static void main(String []args){ p3.Enterpreneur e = new p3.Enterpreneur(); //both of these work. e.printhireDay(); //printing by passing the reference e. p3.Enterpreneur.…
downvote count: 1
has comment: http://stackoverflow.com/comment/72803760
upvote count: 0
answers question: http://stackoverflow.com/q/22139513
has comment: http://stackoverflow.com/comment/72711707
score: -1
has comment: http://stackoverflow.com/comment/72712967
has comment: http://stackoverflow.com/comment/72712925
type: Answer
has comment: http://stackoverflow.com/comment/75704266

http://stackoverflow.com/q/22068705
has comment: http://stackoverflow.com/comment/33465032
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22068804
possible better answer: http://stackoverflow.com/a/22068737
type: Question
has answer: http://stackoverflow.com/a/22069012
has answer: http://stackoverflow.com/a/22068737
has comment: http://stackoverflow.com/comment/33465080
has answer: http://stackoverflow.com/a/22068776
score: 0
tagged with: java
has body: I have a method, which I use to count the items in a hashmap: public void getAvailable(final Item item) { System.out.println("\n" + "Item's \"" + item.getItemName() + "\" stock"); System.out.println("Name\tPrice\tAmount"); for (Map.Entry&lt;Item, Integer&gt; entry : stockItems.entrySet()) { System.out.println(entry.getKey() + "\t" + entry.getValue()); } } But if I have specified the key item, how can I find the amount of all the items with that key in the hashmap? At the moment it returns me all the items with different keys.
has title: Finding amount of certain item in the hashmap in Java
accepted answer: http://stackoverflow.com/a/22069012
tagged with: hashmap

http://stackoverflow.com/a/22130724
has comment: http://stackoverflow.com/comment/33578473
answers question: http://stackoverflow.com/q/22130558
upvote count: 3
has body: I recently ended up with something like this: object Implicits { implicit class ConvertToOption[T](t: T) { def optional = Option(t) } } Usage: Suppose you have a following Java interface: public interface Fooable { public String getFoo(); } public class Foo implements Fooable { public String getFoo() { return null; } } In your Scala code: import Implicits._ val foo = new Foo() val myOptionalValue = foo.getFoo.optional //returns an Option[String], in this case None because getFoo returns null
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/33578647
downvote count: 0

http://stackoverflow.com/comment/33363068
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22011047
has text: I don't see how this is related to MVC in any way, so retagged as spring-jdbc.

http://stackoverflow.com/comment/33608336
has text: Note that *overwrite* is not terminology. There is *override* and *overload* which are in turn two different things.
comment on: http://stackoverflow.com/q/22147863
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33631509
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22159699
has text: you mean, if I mention src/java inside sourceSets>main>groovy and leave sourceSets>main>java as it's (containing src/java as it's srcDir), then it doesn't work. But, if you mean to move all the java files/with com/../.. folder tree from src/java to src/groovy, then yes it will work as there'll be no .java under src/java then and even mentioning sourceSets>main>java srcDir = "src/java" won't do anything, right?

http://stackoverflow.com/q/22062803
tagged with: java
has title: Correct way to return from inside of for loop in Java?
has answer: http://stackoverflow.com/a/22063015
has comment: http://stackoverflow.com/comment/33454926
type: Question
tagged with: for-loop
has body: So I have this little method which takes an integer argument and checks if an array (which is set as an attribute) contains a certain object. If it does, it returns that object, otherwise it returns null. The problem here is that I get an error when I try to return something. Here it is: myClass.java:33: error: missing return statement } ^ 1 error I do have a return statement and it includes the ternary operator, meaning that it returns something at any cost. Here's my method: public Banesa gjejBanese(int nrBaneses) { for (int i = 0; i &lt; listaBanesave.length; i++) { return (listaBanesave[i].getNrBanesa() == nrBaneses) ? listaBanesave[i] : null; } } What is wrong with it? Why do I get that error?
has answer: http://stackoverflow.com/a/22062967
has answer: http://stackoverflow.com/a/22062927
score: 0
has answer: http://stackoverflow.com/a/22062852
has comment: http://stackoverflow.com/comment/33454901
answer count: 7
possible better answer: http://stackoverflow.com/a/22062852
has comment: http://stackoverflow.com/comment/33454800
has comment: http://stackoverflow.com/comment/33454946
has answer: http://stackoverflow.com/a/22062861
has answer: http://stackoverflow.com/a/22062855
has answer: http://stackoverflow.com/a/22062965
accepted answer: http://stackoverflow.com/a/22062927
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33454988

http://stackoverflow.com/q/22113857
has comment: http://stackoverflow.com/comment/33547722
has title: How to set variable for use in other function?
has answer: http://stackoverflow.com/a/22113901
upvote count: 0
answer count: 1
tagged with: variables
favorite count: 0
has comment: http://stackoverflow.com/comment/33547184
has comment: http://stackoverflow.com/comment/33547866
tagged with: android
score: -3
has body: Why I set Icao = WSSS but OnclickListener call Icao = null don't use = WSSS. Guide to me please. public class MainActivity extends Activity { String ans[] ={"","",""}; String Icao =""; String url = String.format("http://flightxml.flightaware.com/json/FlightXML2/Search?query=-destination%%20%s",Icao); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Icao = "WSSS"; // &lt;&lt;&lt; don't use this value btn1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getInput(url); txt1.setText(ans[0]); } }); }
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22113901
tagged with: java
downvote count: 3
type: Question

http://stackoverflow.com/comment/33569363
score: 0
type: Comment
type: QuestionComment
has text: @StinePike yes it returns the node value's compareTo (which is Integer.compareTo)
comment on: http://stackoverflow.com/q/22125912

http://stackoverflow.com/q/22163922
has answer: http://stackoverflow.com/a/22164033
has answer: http://stackoverflow.com/a/39083779
has comment: http://stackoverflow.com/comment/33648160
has answer: http://stackoverflow.com/a/22163958
tagged with: java
has comment: http://stackoverflow.com/comment/33638379
score: 12
has body: Here are my two classes: public class Firstclass { public static void main(String args[]) throws InterruptedException { System.out.println("Main start...."); Secondclass t1 = new Secondclass(); t1.setName("First Thread"); Secondclass t2 = new Secondclass(); t2.setName("Second Thread"); t1.start(); t2.start(); System.out.println("Main close..."); } } and public class Secondclass extends Thread { @Override public void run() { try { loop(); } catch(Exception e) { System.out.println("exception is" + e); } } public void loop() throws InterruptedException { for(int i = 0; i &lt;= 10; i++) { Thread t = Thread.currentThread(); String threadname = t.getName(); if(threadname.equals("First Thread")) { Thread.sleep(1000); } else { Thread.sleep(1500); } System.out.println("i==" + i); } } } Now when I run Firstclass then the output is: Main start.... Main close... i==0 i==0 i==1 i==1 i==2 i==3 i==2 i==4 i==3 i==5 i==6 i==4 i==7 i==5 i==8 i==9 i==6 i==10 i==7 i==8 i==9 i==10 My question is: Let's consider main method is executed by a thread 'T' in JVM and t1 and t2 are obviously child threads of parent thread T so when T thread that is the main method dies how can T1 and T2 still execute and give us output. Because if parent thread dies or terminates then child thread should also die or terminate.
tagged with: jvm
favorite count: 0
has comment: http://stackoverflow.com/comment/33636757
linked to: http://stackoverflow.com/q/2213340
answer count: 3
has title: How can child threads still execute even after that their parent thread die or terminate?
linked to: http://stackoverflow.com/q/5642802
has comment: http://stackoverflow.com/comment/33638880
upvote count: 12
has comment: http://stackoverflow.com/comment/33641911
downvote count: 0
has comment: http://stackoverflow.com/comment/33636711
type: UnansweredQuestion
tagged with: multithreading
has comment: http://stackoverflow.com/comment/33636959
type: Question

http://stackoverflow.com/q/22088909
tagged with: arrays
downvote count: 0
accepted answer: http://stackoverflow.com/a/22088998
has body: String[] m_cPackageName; int m_size; int j=0; List&lt;ApplicationInfo&gt; installedList = packageManager.getInstalledApplications(PackageManager.GET_META_DATA); m_size = installedList.size(); m_cPackageName=new String[m_size]; for (PackageInfo pi : pkginfoList) { try { m_appinfo = packageManager.getApplicationInfo(pi.packageName, 0); if ((m_appinfo.flags &amp; ApplicationInfo.FLAG_SYSTEM) == 0) { // equal to zoo means system apps, not equal is third party installed apps m_cPackageName[j]=pi.packageName; j++; } } catch (NameNotFoundException e) { Log.d(getClass().getSimpleName(), "Name not found", e); } Here I'm getting total size of installedList is 56..After filling the value in array it display in null values. how can i eliminate the null values.. Any one Help for me.. OUTPUT : m_cPackageName=String[56]; m_cPackageName[0]="Myvalue" m_cPackageName[1]="null" m_cPackageName[2]="null" . . . m_cPackageName[55]="null"
favorite count: 0
has answer: http://stackoverflow.com/a/22088984
has answer: http://stackoverflow.com/a/22088967
tagged with: android
upvote count: 1
has answer: http://stackoverflow.com/a/22088998
has answer: http://stackoverflow.com/a/22089016
has answer: http://stackoverflow.com/a/22088965
type: Question
type: AnsweredQuestion
score: 1
tagged with: java
answer count: 6
possible better answer: http://stackoverflow.com/a/22088936
has answer: http://stackoverflow.com/a/22088936
has title: How to avoid the null values in String array in java..?

http://stackoverflow.com/a/22129902
has body: It's hard to say what the problem is without seeing the source for SortedLinkedSetNode, but you seem to be modifying your original with this statement: copy.firstNode= copy.firstNode.next; This probably advances firstNode to the end of your original linkedset, resulting in the original having one element. Also, confusingly the original is called "copy". You may want to rename it so you can understand your code better. When creating a deep copy, you shouldn't modify the structure you want to copy. In this case, you can just use a temporary variable to store the reference to the current node you are on, without modifying your original data structure. Try this: this.firstNode = firstNode1; // so basically I am chaining elements from "copy" to firstNode1 and then making "this" = to firstNode1. SortedLinkedSetNode currentNode = copy.firstNode; while (currentNode.next !=null) { firstNode1.add(currentNode.next.value); this.firstNode = firstNode1; currentNode = currentNode.next; }
score: 0
has comment: http://stackoverflow.com/comment/33576827
has comment: http://stackoverflow.com/comment/33621220
answers question: http://stackoverflow.com/q/22129809
type: Answer

http://stackoverflow.com/a/22019441
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/22019268
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/33379542
has body: You will need to work with signal strength. You cannot determine lat. &amp; long. with wifi. It appears that a few iPhone apps leverage triangulation of wifi. But for outdoor triangulation , the default is GPS. See this question - Wifi Triangulation Specifically this answer
answers question: http://stackoverflow.com/q/22019268
type: AcceptedAnswer

http://stackoverflow.com/a/22160725
type: Answer
score: 2
downvote count: 0
has body: You need a base case. That is like an exit method for recursion. In your case, the createCircles method repeats infinitely, that is why it gives an overflow exception. Try this. public void createCircles(int x, int y, int rad){ int myX = x/3; int myRad = rad/3; if(rad != 0){ Circle myCircle = new Circle(myX, y, myRad); circles.add(myCircle); createCircles(myX, y, myRad); createCircles(myX, y, myRad); createCircles(myX, y, myRad); } }
answers question: http://stackoverflow.com/q/22160555
upvote count: 2
has comment: http://stackoverflow.com/comment/33632010

http://stackoverflow.com/q/22018305
has answer: http://stackoverflow.com/a/22019448
tagged with: tcp
tagged with: java
has body: I am trying to send data from android app Client class src: import java.io.*; import java.net.Socket; import java.net.UnknownHostException; public class CClient implements Runnable { private Socket socket; private String ServerIP = "10.0.0.14"; public void run() { try { socket = new Socket("10.0.0.14", 16606); } catch(Exception e) { System.out.print("Whoops! It didn't work!:"); System.out.print(e.getLocalizedMessage()); System.out.print("\n"); } } public void Send(String s) { try { PrintWriter outToServer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream())); outToServer.print(s + "\n"); outToServer.flush(); } catch (UnknownHostException e) { System.out.print(e.toString()); } catch (IOException e) { System.out.print(e.toString()); }catch (Exception e) { System.out.print(e.toString()); } } } Use CClient class in activity to create connection and send data. Here is activity code import android.os.Bundle; import android.app.Activity; import android.view.*; import android.widget.*; public class Auth extends Activity { private ProgressBar mProgress; private TextView mTV; private CClient mClient; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_auth); mProgress = (ProgressBar) findViewById(R.id.progressBar1); mTV = (TextView) findViewById(R.id.textView4); mClient = new CClient(); Thread myThready = new Thread(mClient); myThready.start(); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.auth, menu); return true; } public void proc_Login(View v) { for (int i=0; i&lt;5; i++) mClient.Send("asaadsasdasd"); } } Problem: recive only one message from client (C# server, without any errors) and next messages wont sent.
type: UnansweredQuestion
upvote count: 4
downvote count: 0
has title: Send data over TCP from android app
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/22018455
answer count: 2
tagged with: android
score: 4

http://stackoverflow.com/a/22126298
has body: Try this: ... discount *= 100; discount = Math.round(discount); discount /= 100; ...
answers question: http://stackoverflow.com/q/22126278
score: 0
upvote count: 1
has comment: http://stackoverflow.com/comment/33571448
downvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/33570124

http://stackoverflow.com/q/22107128
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33535559
has comment: http://stackoverflow.com/comment/33535816
upvote count: 1
answer count: 1
has comment: http://stackoverflow.com/comment/33535624
tagged with: android
favorite count: 0
tagged with: android-alertdialog
tagged with: android-edittext
has comment: http://stackoverflow.com/comment/33535670
downvote count: 0
has title: alertdialog - removeView has to get called
has answer: http://stackoverflow.com/a/22107270
type: Question
accepted answer: http://stackoverflow.com/a/22107270
has body: I have a alert dialog with a editText area. When I call it a second time, the app crashes with error: 02-28 23:25:08.958: E/AndroidRuntime(11533): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. Here is my code: alert = new AlertDialog.Builder(this); String txt_title = context.getResources().getString(R.string.txt_head_search_coord); String txt_message = context.getResources().getString(R.string.txt_mess_search_coord); alert.setTitle(txt_title); alert.setMessage(txt_message); // Set an EditText view to get user input final EditText input = new EditText(this); alert.setView(input); alert.setPositiveButton(context.getResources().getString(R.string.Accept), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); // Do something with value! dialog.dismiss(); } }); alert.setNegativeButton(context.getResources().getString(R.string.Cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }); //UTM Koordinate suchen btn_search_coord.setOnClickListener(new OnClickListener() { public void onClick(View v) { alert.show(); } }); the alert is defined globally so I can call it in the onClickListener I'm already dismissing my dialog...
type: AnsweredQuestion

http://stackoverflow.com/q/22121918
tagged with: java
accepted answer: http://stackoverflow.com/a/36024874
upvote count: 10
type: Question
tagged with: spring-boot
has answer: http://stackoverflow.com/a/36647741
has answer: http://stackoverflow.com/a/22302787
downvote count: 0
score: 10
has answer: http://stackoverflow.com/a/64610483
has answer: http://stackoverflow.com/a/36024874
favorite count: 0
answer count: 5
tagged with: maven
tagged with: spring
linked to: http://stackoverflow.com/q/52670491
has title: Package a spring boot application including JSPs and static resources
possible better answer: http://stackoverflow.com/a/22125057
tagged with: spring-mvc
type: AnsweredQuestion
has body: I want to package a spring-boot application as jar, and I do so with mvn package. This produces a jar which does not contain any /WEB-INF/jsp nor /src/main/webapp/resources. How can I make sure my jar contains everything needed ? Here my current pom.xml: 4.0.0 org.springframework.boot spring-boot-samples 1.0.0.RC3 jar <main.basedir>${basedir}/../..</main.basedir> <m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot> ${project.groupId} spring-boot-starter-web ${project.groupId} spring-boot-starter-tomcat provided org.apache.tomcat.embed tomcat-embed-jasper provided javax.servlet jstl commons-dbcp commons-dbcp org.springframework spring-jdbc org.apache.tomcat tomcat-jdbc org.springframework spring-tx org.postgresql postgresql 9.3-1101-jdbc41 org.springframework.boot spring-boot-maven-plugin org.apache.maven.plugins maven-surefire-plugin false spring-snapshots http://repo.spring.io/snapshot true spring-milestones http://repo.spring.io/milestone true spring-snapshots http://repo.spring.io/snapshot spring-milestones http://repo.spring.io/milestone com.example.app
has answer: http://stackoverflow.com/a/22125057

http://stackoverflow.com/q/22115913
score: 0
has comment: http://stackoverflow.com/comment/33551115
has comment: http://stackoverflow.com/comment/33550989
tagged with: nullpointerexception
has answer: http://stackoverflow.com/a/22115974
has comment: http://stackoverflow.com/comment/33550916
has comment: http://stackoverflow.com/comment/33551232
answer count: 4
possible better answer: http://stackoverflow.com/a/22115993
has comment: http://stackoverflow.com/comment/33550992
favorite count: 0
has answer: http://stackoverflow.com/a/22115993
upvote count: 1
tagged with: swing
downvote count: 1
has answer: http://stackoverflow.com/a/22116955
has comment: http://stackoverflow.com/comment/33550875
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33551166
has comment: http://stackoverflow.com/comment/33551190
has comment: http://stackoverflow.com/comment/33551037
type: Question
tagged with: graphics
has comment: http://stackoverflow.com/comment/33550962
has answer: http://stackoverflow.com/a/22115972
accepted answer: http://stackoverflow.com/a/22116955
has title: Set Oval throwing error
has comment: http://stackoverflow.com/comment/33550868
has body: I am currently working on a project, I get this error Java.lang.NullPointerException, I undrestand that this error happen when you try to refer to a null object instance, but what I do not know, is how I can fix it. This is my code: public void paint(Graphics g) { g.setColor(Color.red); g.drawOval(150, 150, 10, 10); } /** Main Method **/ public static void main(String [] args) { Run run = new Run(); run.paint(null); } Please help me with a solution and also explain it, so that I learn it. Many thanks in advance. Andre

http://stackoverflow.com/a/22111475
answers question: http://stackoverflow.com/q/22099321
score: 2
has body: You can phrase this as optimizing a function nested inside finding a root. Optimization problem: find max_t normal.compute(foo(t)) where foo(t) parametrizes a circle of radius r centered on (x1, y1), i.e. foo(t) = [x1 + r cos(t), y1 + r sin(t)]. (Use max if normal.compute(x1, y1) is less than z. Otherwise use min.) Root finding problem: find r such that the solution to the optimization problem = z. I got this idea by looking at a contour plot of normal.compute(x, y) and thinking about circles around (x1, y1). The value of normal.compute goes up and down as you walk around the circle. You want the circle such that its highest or lowest point is exactly z. Hope this helps. EDIT: I like this question, so I've constructed a solution. Here is a script for the Maxima [1] computer algebra system. See comments in the code. Have fun. /* solve problem stated in: * http://stackoverflow.com/questions/22099321/calculate-inverse-of-normal-function-that-minimizes-another-function * * copyright 2014 by Robert Dodier * I release this work under terms of the GNU General Public License * * how to: * * (1) assign values to m1, s1, m2, s2, x1, y1, and z0 * (2) batch("foo.mac"); * * example: * * [m1, s1, m2, s2, x1, y1, z0] : [-2, 1.8, 1.3, 2.4, 1.82, -0.24, 0.3]; * batch ("foo.mac"); * =&gt; [x0, y0] = [- .4249300563696112, 0.172672148095035] * * after that, try: * * set_plot_option ([same_xy, true]); * load (implicit_plot); * implicit_plot ([F (x, y) = z0, (x - x1)^2 + (y - y1)^2 = r0^2], [x, -5, 5], [y, -5, 5]), numer; * * should show z0 contour just touching the circle of radius r0 centered on [x1, y1] */ load (distrib); ratprint : false; /* m1, s1, m2, s2 must be assigned values */ F (x, y) := pdf_normal (x, m1, s1) + pdf_normal (y, m2, s2); /* x1, y1 must be assigned values */ G (r, x1, y1) := fmax_circular (lambda ([t], F (x1 + r * cos (t), y1 + r * sin (t)))); fmax_circular (f) := lmax (map (f, fargmax_circular (f))); fargmax_circular (f) := block ([n : 17, u0, u2], map (f, makel…
has comment: http://stackoverflow.com/comment/33604303
downvote count: 0
type: AcceptedAnswer
upvote count: 2
accepted answer of: http://stackoverflow.com/q/22099321
type: Answer
has comment: http://stackoverflow.com/comment/33621652

http://stackoverflow.com/comment/33435916
score: 0
type: Comment
has text: ok I added another same selectable textview..now suppose I have seven to 10 different textviews when I wanna selectable so how can I set the java code for all these selectable textviews? should I repeat the same java code for other textviews as well or I can do it in a single code?
type: AnswerComment
comment on: http://stackoverflow.com/a/22051769

http://stackoverflow.com/a/22178150
has comment: http://stackoverflow.com/comment/33752759
has comment: http://stackoverflow.com/comment/33752959
has comment: http://stackoverflow.com/comment/34246351
score: 0
has body: You're going to have to step through the code a bit (including the DCM4CHE toolkit code). I suspect you are using the default response handler, which just counts the number of completed operations, and doesn't actually store the image data from the get command. Clearly, your for loop, below, is looping over the results of the find operation, not the get (which needs to be handled in the response handler). for(DicomObject dco:result) I expect you will have to override the response handler to write your DICOM files appropriately. See also the DcmRcv class for writing DICOM files from the DicomObject you'll receive. : From your edits above, I assume you are just trying to get the raw DICOM instance data (not the command that stored it). What about a response handler roughly like: List&lt;DicomObject&gt; dataList = new ArrayList&lt;DicomObject&gt;(); @Override public void onDimseRSP(Association as, DicomObject cmd, DicomObject data) { if( shouldAdd(as, cmd) ) { dataList.add( data ) } } Watch out for large lists, but it should get you the data in memory.
type: AcceptedAnswer
type: Answer
has comment: http://stackoverflow.com/comment/33762516
has comment: http://stackoverflow.com/comment/33720298
answers question: http://stackoverflow.com/q/22126774
accepted answer of: http://stackoverflow.com/q/22126774
has comment: http://stackoverflow.com/comment/33983403
has comment: http://stackoverflow.com/comment/34104072

http://stackoverflow.com/q/22095513
score: 0
linked to: http://stackoverflow.com/q/11989261
answer count: 1
has comment: http://stackoverflow.com/comment/33513431
has answer: http://stackoverflow.com/a/22095605
type: UnansweredQuestion
tagged with: java
has body: If there are two strings string1 and string2 contained in string pool referenced to String literals, will System.out.println(string1 + string2) generate additional string object in String pool as string3=string1+string2;? If not, why? Like to add for more clarity how many objects are allocated in pool in such case?
type: Question
has title: Is there be a new string object created for S.O.P?
tagged with: string-concatenation

http://stackoverflow.com/a/22128934
type: Answer
accepted answer of: http://stackoverflow.com/q/22128143
has comment: http://stackoverflow.com/comment/33574952
answers question: http://stackoverflow.com/q/22128143
score: 0
has body: I assume that: the static resources are relative to the JSP on your file system the URLs are relative The browser is going to resolve relative URLs relative to the current URL. You can use the application's context path to provide the correct path: &lt;link rel="stylesheet" href="${pageContext.servletContext.contextPath}/css/foo.css"&gt; Now it doesn't matter what the request URL is or what the application context path is; the links will be resolved correctly. The expression is a bit verbose but you could always shorten it with an application-scoped copy of the string.
type: AcceptedAnswer

http://stackoverflow.com/q/22095853
favorite count: 0
accepted answer: http://stackoverflow.com/a/22096065
has title: GMT in java, simple but not working
answer count: 3
tagged with: datetime
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22096165
possible better answer: http://stackoverflow.com/a/22095992
downvote count: 3
has comment: http://stackoverflow.com/comment/33525847
linked to: http://stackoverflow.com/q/308683
upvote count: 1
has answer: http://stackoverflow.com/a/22095992
type: Question
tagged with: gmt
has answer: http://stackoverflow.com/a/22096065
score: -2
tagged with: java
tagged with: milliseconds
has body: This is both a duplicate and not a duplicate! Just please help me and don't refer me to anywhere else, cause I'm really unable to get the GMT time. The answer seems easy but it doesn't work for me. I don't know are the answers all aver the web wrong, or am I making a mistake? Please take a look at this snippet and the results: Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); long time = cal.getTimeInMillis(); Date date = new Date(time); System.out.println(date); time = System.currentTimeMillis(); date = new Date(time); System.out.println("--\n" + date); result : Fri Feb 28 16:07:12 GMT+03:30 2014 -- Fri Feb 28 16:07:12 GMT+03:30 2014 Both show my local time. I even printed directly the time, cause I thought maybe this is due to Date class but even those are the same (with just about 1 or 2 milliseconds difference).

http://stackoverflow.com/comment/33557841
type: Comment
type: QuestionComment
has text: @TedBigham oh right, sorry. I wasn't thinking clearly in the AMs. For reasons regarding the other code, I can only test it out on the inner for loop. Using `word_list` used 20mb while `word_list/2` used 6mb. Very weird
comment on: http://stackoverflow.com/q/22113578
score: 0

http://stackoverflow.com/comment/33615603
comment on: http://stackoverflow.com/a/22152014
type: AnswerComment
has text: if i use above one also no luck. font size applies to m not for count. if appears like in HTML view source. TEAM A 0 0 77
score: 0
type: Comment

http://stackoverflow.com/comment/33692102
score: 0
type: Comment
type: QuestionComment
has text: as soon as a connection to db established this lock file gets created
comment on: http://stackoverflow.com/q/22150519

http://stackoverflow.com/comment/33605317
comment on: http://stackoverflow.com/a/22146611
score: 0
has text: @MarkoTopolnik As I describe in my question, I need O(1) for insertion/removal to/from both (or at least one) end(s) as well as O(1) for insertion/removal from/to a random index or for a random object (random = unknown a priori).
type: Comment
type: AnswerComment

http://stackoverflow.com/a/22154085
downvote count: 0
answers question: http://stackoverflow.com/q/22152635
has comment: http://stackoverflow.com/comment/33641860
has body: You have to create a content observer in your service and register that observer to listen for changes in contacts database. Here is an example of contacts content observer: ContactsContentObserver contentObserver = new ContactsContentObserver(); private class ContactsContentObserver extends ContentObserver { public ContactsContentObserver() { super(null); } @Override public void onChange(boolean selfChange) { super.onChange(selfChange); // handle change received } } You can register the content observer in service onStart() method: getContentResolver().registerContentObserver (ContactsContract.Contacts.CONTENT_URI, true, contentObserver); And unregister it in service onDestroy() method: getContentResolver().unregisterContentObserver(contentObserver); Hope it helps.
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/60466033
score: 1

http://stackoverflow.com/a/22073372
type: AcceptedAnswer
has body: The problem in this example is that you create the context in your App class but never get a handle to the repository from the application context. You cannot auto wire into the same class that holds the application context. What you can try is the get the instance of the repository from the context (i.e ctx.getBean(SlpRepository.class)).
type: Answer
answers question: http://stackoverflow.com/q/22071301
has comment: http://stackoverflow.com/comment/33474075
accepted answer of: http://stackoverflow.com/q/22071301
score: 0

http://stackoverflow.com/comment/33470086
type: AnswerComment
type: Comment
score: 0
has text: This is what I was looking for. The tearDown group runs after the main ThreadGroup, so it is suitable for my needs.
comment on: http://stackoverflow.com/a/22043926

http://stackoverflow.com/a/22048182
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/22048151
has body: Check for the condition at the beginning: if (!"1".equals(truckType) &amp;&amp; !"2".equals(truckType)) { // it's an invalid option, do something about it }
type: AcceptedAnswer
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/22048151

http://stackoverflow.com/comment/33397140
score: 1
type: AnswerComment
has text: @LuisAlberto it does keep it all in one line. That's why I said it's dev preference. I like to have them separate but I agree it will work and just another way to do it.
type: Comment
comment on: http://stackoverflow.com/a/22029792

http://stackoverflow.com/q/22024464
has title: Search in a file with good performance
has comment: http://stackoverflow.com/comment/33387620
has answer: http://stackoverflow.com/a/22024953
favorite count: 0
tagged with: python-3.x
has answer: http://stackoverflow.com/a/22024754
type: Question
has comment: http://stackoverflow.com/comment/33390656
has comment: http://stackoverflow.com/comment/33387232
upvote count: 1
has comment: http://stackoverflow.com/comment/33414270
has comment: http://stackoverflow.com/comment/33387328
score: 0
tagged with: java
answer count: 3
downvote count: 1
has comment: http://stackoverflow.com/comment/33387448
has answer: http://stackoverflow.com/a/22024510
type: UnansweredQuestion
has body: I'm trying to implement a search in a 200,000 text files whose size may vary from 50kb to 5 mb which comes to a total of 1.7GB. I'm planning to develop a search engine(Just a sample one). The process is: 1) Extract words from each file and store them in a separate file(40,000,000 words) 2) Search each word in each file ( 40,000,000(words) X 200,000(Files) = 8 X 10^12 searches) 3) Generate boolean Index(650Mb). So, most of the operation involved here will be searching in document(s) or file(s). In which 2nd step takes a lot of time.(4+ hours) This is the program I've written for searching a word in JAVA. count = 0; BufferedReader reader = new BufferedReader(new FileReader('fileName.txt')); while ((text = reader.readLine()) != null) { if( text.indexOf(searchString) != -1 ) { if( text.equals(searchString)) { System.out.print('Word Found in line number '+count); break; } } count++; } Program in PYTHON: count = 0 file = open(filePath) with file as f : for line in f: count += 1 if(line.index(searchWord)) print("Word found in line number"+count) Output is perfect, but it takes lot of time. Language is not a considering criteria for me. I'm looking for a better performance. Is there any way that I can make it out of it. As most of it is searching process, is there any perfect way coz it is searching large pieces of small chunks. (My PC Config: 8GB RAM, i7 4th Generation)

http://stackoverflow.com/comment/33660181
type: Comment
comment on: http://stackoverflow.com/a/22162150
has text: @user2789240 try this.orderList = _(NameOfMainClass)_.orderList;
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33604819
type: AnswerComment
comment on: http://stackoverflow.com/a/22144744
type: Comment
has text: @sagschni You are using different `tableBean` objects in the `FileDownloadController` and the `FileUploadController` (you call `new TableBean()` in both classes). So, if you set the property in `FileUploadController` it will not be set in `FileDownloadController`, because the two `tableBean` are two different objects in memory.
score: 1

http://stackoverflow.com/a/22167054
has comment: http://stackoverflow.com/comment/33651485
score: 2
has comment: http://stackoverflow.com/comment/33649655
type: AcceptedAnswer
downvote count: 0
has body: Your problem does not match what should happen in practice. Your profile definition sounds about right to me: mvn clean install will enable the db-localhost-mysql (as it is marked as to be activated by default) and it will add mysql-connector-java. The same will happen if you run mvn clean install -Pdb-localhost-mysql mvn clean install -Pdb-localhost-oracle will add the ojdbc6 driver. The mysql profile will not be enabled (as it is triggered only if no profile is explicitly active). That does not mean your current dependency hierarchy hasn't already one of those jars. It might come as a transitive dependency. To isolate this case and know which project needs to be fixed run mvn dependency:tree -Pdb-localhost-oracle to look at your dependencies hierarchy when the mysql profile is not enabled.
has comment: http://stackoverflow.com/comment/33652346
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/33656894
accepted answer of: http://stackoverflow.com/q/22166940
answers question: http://stackoverflow.com/q/22166940
has comment: http://stackoverflow.com/comment/33649612

http://stackoverflow.com/comment/33370156
score: 1
type: AnswerComment
type: Comment
has text: The advantage is that you can deserialize in more than one way should you need to do so one day; as to the disadvantage, I don't see what you mean? If you don't specify a serializer for a type, default serialization will be used...
comment on: http://stackoverflow.com/a/22014693

http://stackoverflow.com/a/22168727
score: 0
has body: /rezsystem/java/jdk1.6.0_21/bin/java -classpath pathToPgSQLDriverJar;pathToYourProgramClassesAndJars attraction.external.viator.DeleteTableData Will this work ? If the jar is not there on that machine, you will have to upload it there. say your postgres driver jar is pg.jar located at usr/darshan/myjars/pg.jar. Your DeleteTableData program is located at folder /usr/darshan/myprogs/attraction/external/viator/DeleteTableData, then your command will look like /rezsystem/java/jdk1.6.0_21/bin/java -classpath /usr/darshan/myjars/pg.jar:/usr/darshan/myprogs attraction.external.viator.DeleteTableData Hope this helps.
has comment: http://stackoverflow.com/comment/33645347
type: Answer
answers question: http://stackoverflow.com/q/22168649

http://stackoverflow.com/a/22140704
answers question: http://stackoverflow.com/q/22138515
has body: Same thing happen to me , and i passed a day to fix this. really this is a stupid error. i am just shearing my experience, may be it would helpful to you . First look carefully when you type this setContentView(R.layout.activity_to_do_list); hear your starting point R.l then eclipse should open a suggestion for you look like this you import the second one not layout-android.R . the second one is created in your project hear com.example.gridtest is the project package name . then focus your imported section in your code ok look this import com.example.gridtest.R; its important . If you already import this android.R then remove it. Thank you hope it works . ( you don't need to do this always but if you face this kinda problem then do this )
score: 0
type: Answer

http://stackoverflow.com/comment/33586012
type: Comment
comment on: http://stackoverflow.com/a/22135008
has text: You can also do this inside the JSP file in old-fashioned JSP-Tags like `<% Stirng arrivaldate = request.getParameter("arrivaldate"); %>` which should save you from creating a new `Servlet` subclass.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33472816
has text: It seems that your file is not XML. 0xb is a vertical tab. Perhaps you have some text in your XML that's not inside a XML element.
type: QuestionComment
comment on: http://stackoverflow.com/q/22072872
score: 1
type: Comment

http://stackoverflow.com/comment/33615279
type: Comment
has text: Well, debuggers are great for some problems, but it may be using a slegdehammer to crack a nut, depending on the scope of what you're trying to investigate. It's a judgement call.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22151785

http://stackoverflow.com/q/22146618
type: Question
answer count: 3
score: 2
tagged with: jpa
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/22146657
upvote count: 2
has body: I am trying to learn JPA. If I do a write and then immediately read before calling close, it works. But if I try to read on its own, it doesn't. Here is my code in User: @Entity @Table(name = "JPA_Users") public class User { @Id @GeneratedValue @Column(name = "user_id") private int id; @Column(name = "username") private String username; @Column(name = "password") private String password; public User(){} public User(String username, String password){ this.username = username; this.password = password; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String toString(){ return Integer.toString(id) + ":" + username + ":" + password; } } And here is the JPA code: public void write(){ EntityManagerFactory emf = Persistence.createEntityManagerFactory("helloworld"); EntityManager em = emf.createEntityManager(); EntityTransaction et = em.getTransaction(); et.begin(); User user = new User("Chris", "123456"); User user2 = new User("Dave", "password"); User user3 = new User("Peter", "asfdfsdf"); em.persist(user); em.persist(user2); em.persist(user3); em.flush(); List users = em.createQuery("SELECT u FROM User u").getResultList(); System.out.println(users.size() + " user(s) found"); for(Object o : users){ User u = (User) o; System.out.println(u.getId()); System.out.println(u.getUsername()); System.out.println(u.getPassword()); System.out.println("--------------------------"); } et.commit(); em.close(); emf.close(); } The above works, and prints out the user details. But if I run the below method on its own, it doesn't work. It prints out "0 user(s) found". I have checked in SQL Developer to see if the table is there and populated, and it is. public void read(){ EntityManagerFactory emf = Persiste…
possible better answer: http://stackoverflow.com/a/22147624
has answer: http://stackoverflow.com/a/22147220
accepted answer: http://stackoverflow.com/a/22146657
has title: New to JPA - can write, but can't read from database
has answer: http://stackoverflow.com/a/22147624
type: AnsweredQuestion
tagged with: java
tagged with: hibernate

http://stackoverflow.com/comment/33629498
type: Comment
comment on: http://stackoverflow.com/a/22158679
has text: thank you for your reply. i was trying to instantiate an abstract class.
type: AnswerComment
score: 0

http://stackoverflow.com/q/22063435
downvote count: 0
has body: I have a Play Framework application (2.2.1) which have to send x-www-form-urlencoded data back. My controller action recovers the data with request().body().asFormUrlEncoded() which return a Map&lt;String, String[]&gt;. In my action, I have to send this data back with this kind of way : WS.url(url).setContentType("application/x-www-form-urlencoded").post(data) (Before, I process operations on the URL). The issue is that post() accepts String, File, and others, but not the Map returned by asFormUrlEncoded(). It's a little annoying. I have to rebuild the data in this way : final Map&lt;String, String[]&gt; body = request().body().asFormUrlEncoded(); StringBuffer postBodyProv = new StringBuffer(""); Set&lt;String&gt; keys = body.keySet(); String result = null; try { for (String key : keys) { postBodyProv.append(URLEncoder.encode(key, "UTF-8") + "="); String value = body.get(key)[0]; postBodyProv.append(URLEncoder.encode(value, "UTF-8")); postBodyProv.append("&amp;"); } result = postBodyProv.substring(0, postBodyProv.length() - 1); // To skip the last "&amp;" } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Is there other (simpler) ways to do ? The values of the Map returned by asFormUrlEncoded() are arrays of Strings, is there cases where the array have more than one element ? In this case, how are they separated ?
favorite count: 0
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22065189
tagged with: playframework-2.0
upvote count: 3
tagged with: java
tagged with: http
type: Question
score: 3
has title: Play Framework / Java : A good way to send x-www-form-urlencoded data back
has answer: http://stackoverflow.com/a/22065189
tagged with: playframework
answer count: 1

http://stackoverflow.com/a/22096077
has comment: http://stackoverflow.com/comment/33523328
has comment: http://stackoverflow.com/comment/33536165
has comment: http://stackoverflow.com/comment/33519854
type: Answer
has comment: http://stackoverflow.com/comment/33515328
answers question: http://stackoverflow.com/q/22095854
has comment: http://stackoverflow.com/comment/33515801
has body: The goal of hibernate is mapping database entities to java objects. This kind of complex queries are not entities themselves. This is against the spirit of hibernate. If this query generates an entity in your application logic, I recommend putting the results into a table and applying Hibernate queries to that table. If this query generates some kind of aggregation or summary, there are two possible ways: One way is you compute this aggregation/summary in your application after retrieving entities from iostatus table with hibernate. If this query has nothing to do with your application logic then you can use Native SQL interface of Hibernate and execute the query directly. (You can even use JPA if you are willing to manipulate two database connections.) If you absolutely need to convert it to HQL, you need to eliminate the partition function. If the order of iostatusId is identical to the order of gpsdate, you can do it similar to SELECT i2.* FROM iostatus i1 INNER JOIN iostatus i2 ON i1.iostatusId = i2.iostatusId - 1 AND i1.io1 &lt;&gt; i2.io1 AND i1.mstrackid = i2.mstrackid WHERE i2.mtstrackid = 'redcar' AND i2.gpsdate between '2014-02-28 00:00:00' and '2014-02-28 23:59:59' If gpsdate is no way related to iostatusId then you need something like SELECT i2.* FROM iostatus i1 INNER JOIN iostatus i2 ON i1.gpsdate &lt; i2.gpsdate AND i1.io1 &lt;&gt; i2.io1 AND i1.mstrackid = i2.mstrackid WHERE i2.mtstrackid = 'redcar' AND i2.gpsdate between '2014-02-28 00:00:00' and '2014-02-28 23:59:59' AND NOT EXISTS (SELECT * FROM iostatus i3 WHERE i3.gpsdate &gt; i1.gpsdate AND i2.gpsdate &gt; i3.gpsdate AND i3.io1 = i1.io1 AND i1.mstrackid = i3.mstrackid) I guess both of the queries can be converted to HQL, but I'm not positively sure. By the way I must warn you that, these methods might not perform better then finding the changes in your application, because they involve joining the table onto itself, which is an expensive operation; and the second query involves a nested query a…
has comment: http://stackoverflow.com/comment/33516329
score: 0

http://stackoverflow.com/comment/33554145
comment on: http://stackoverflow.com/a/22109336
type: Comment
has text: Thanks for your answer. I'll have a test on it on my system. But, yet I haven't add any intermediate certificate. Is it necessary? I am not planning to ship my app to Apple Store. Just would like to have users seeing that the application is signed from a trusted developer
score: 0
type: AnswerComment

http://stackoverflow.com/q/22128298
has answer: http://stackoverflow.com/a/22128335
has title: How to make List in java without using collection?
score: 1
tagged with: java
has body: I am trying to find out a java interview answer to the question interviewer asked me was: Question is: How can we make a java.util.List without using collection? Any help would be greatly appreciated.
type: Question
has answer: http://stackoverflow.com/a/22128332
answer count: 3
has comment: http://stackoverflow.com/comment/33575546
downvote count: 0
has comment: http://stackoverflow.com/comment/33573688
favorite count: 0
has comment: http://stackoverflow.com/comment/33573685
has answer: http://stackoverflow.com/a/22128707
has comment: http://stackoverflow.com/comment/33574855
type: UnansweredQuestion
upvote count: 1
tagged with: collections

http://stackoverflow.com/comment/33537331
comment on: http://stackoverflow.com/q/22108097
score: 0
type: Comment
has text: Did you check the values of `first` and `second`?
type: QuestionComment

http://stackoverflow.com/q/22058416
has comment: http://stackoverflow.com/comment/33499688
score: 4
has body: I am trying to connect to Orient DB running in Distributed mode and I am getting following error Exception in thread "main" com.orientechnologies.orient.core.exception.OSerializationException: Error on unmarshalling field 'members' in record #-1:-1 with value: I am using : OrientDB Version: orientdb-community-1.7-rc and JDBC Version: OrientDB JDBC Driver 1.7-rc2-SNAPSHOT ALL Below is my code: public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName("com.orientechnologies.orient.jdbc.OrientJdbcDriver"); Connection connection = (OrientJdbcConnection) DriverManager.getConnection("jdbc:orient:remote:localhost/VANET", "root", "*****"); } database "VANET" as per the DB connection String above, is present in OrientDB and I able to access and create classes in VANET using OrientDB Studio. I have already referred to and tried code as per. But no luck yet. Please help me resolve this issue. A little more details about the error I am getting Exception in thread "main" com.orientechnologies.orient.core.exception.OSerializationException: Error on unmarshalling field 'members' in record #-1:-1 with value: at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at com.orientechnologies.common.log.OLogManager.exception(OLogManager.java:162) at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerSchemaAware2CSV.fromString(ORecordSerializerSchemaAware2CSV.java:543) at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerStringAbstract.fromStream(ORecordSerializerStringAbstract.java:80) at ... * &lt;I removed these lines &gt;* ... at com.orientechnologies.orient.jdbc.OrientJdbcConnection.&lt…
tagged with: jdbc
has comment: http://stackoverflow.com/comment/33498584
favorite count: 0
has title: Error in connecting to Orient DB via JDBC Drivers
type: UnansweredQuestion
tagged with: orientdb
answer count: 0
tagged with: java
type: Question
upvote count: 4
has comment: http://stackoverflow.com/comment/33462132
downvote count: 0

http://stackoverflow.com/comment/33493250
type: QuestionComment
type: Comment
score: 2
comment on: http://stackoverflow.com/q/22082770
has text: Holy crap you should submit this to CodeReview.

custom-component
tags question: http://stackoverflow.com/q/22031274
tags question: http://stackoverflow.com/q/22131286
type: Tag
tag name: custom-component

http://stackoverflow.com/comment/33498400
has text: I can't think of a better way than that given the details.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22086583

http://stackoverflow.com/q/22096083
has title: Loop not working and produces IndexOutOfBoundsException
type: Question
has comment: http://stackoverflow.com/comment/33514698
downvote count: 0
has answer: http://stackoverflow.com/a/22096230
has comment: http://stackoverflow.com/comment/33514609
has comment: http://stackoverflow.com/comment/33514627
accepted answer: http://stackoverflow.com/a/22096230
has comment: http://stackoverflow.com/comment/33514792
answer count: 1
has comment: http://stackoverflow.com/comment/33514907
favorite count: 0
has comment: http://stackoverflow.com/comment/33514865
has comment: http://stackoverflow.com/comment/33515142
has comment: http://stackoverflow.com/comment/33514778
upvote count: 1
has comment: http://stackoverflow.com/comment/33514545
has comment: http://stackoverflow.com/comment/33514743
type: AnsweredQuestion
has body: Why is the first one working and the other not? for (int v=0; v&lt; student1.size();v++) { readLine = student1.get(v); if (readLine.contains(sbB)){ while(!(readLine1.contains(sbA) || readLine1.contains(sbC) || readLine1.contains(sbD) )){ readLine1 = student1.get(ii); if(readLine1.contains("Homework ")){ String[] tokens = readLine1.split(": "); st1marksHwB.add(tokens[1]);summHw = summHw + Integer.parseInt(tokens[1]);} if (readLine1.contains("Exam ")){ String[] tokens = readLine1.split(": "); st1marksExB.add(tokens[1]);summEx = summEx + Integer.parseInt(tokens[1]);;} ii++;}}} double avSt1B = summHw*0.2 + summEx*0.8; summHw=0;summEx=0; //Stundent 1 Subject C--------------------------------------------------- for (int v=0; v&lt; student1.size();v++) { readLine = student1.get(v); if (readLine.contains(sbC)){ while(!(readLine1.contains(sbA) || readLine1.contains(sbB) || readLine1.contains(sbD) )){ readLine1 = student1.get(ii); if(readLine1.contains("Homework ")){ String[] tokens = readLine1.split(": "); st1marksHwC.add(tokens[1]);summHw = summHw + Integer.parseInt(tokens[1]);} if (readLine1.contains("Exam ")){ String[] tokens = readLine1.split(": "); st1marksExC.add(tokens[1]);summEx = summEx + Integer.parseInt(tokens[1]);;} ii++;}}} double avSt1C = summHw*0.2 + summEx*0.8; summHw=0;summEx=0;
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33514817
has comment: http://stackoverflow.com/comment/33514705

http://stackoverflow.com/q/22113808
has comment: http://stackoverflow.com/comment/33547150
score: -1
has answer: http://stackoverflow.com/a/22113971
answer count: 1
favorite count: 0
type: UnansweredQuestion
tagged with: swing
tagged with: java
downvote count: 1
has comment: http://stackoverflow.com/comment/33547261
type: Question
has title: Making 3D Buttons using swing
upvote count: 0
has body: I have the following code which contains two buttons: My requirement is to change the font and color of the buttons and give them a 3D look. import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.Border; import javax.swing.table.DefaultTableModel; import java.beans.*; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Properties; import java.util.Random; @SuppressWarnings("serial") public class UserGui extends JPanel implements ActionListener, PropertyChangeListener { static UserGui currentObj; private JProgressBar progressBar; private JButton generateButton; private JButton exceptionButton; private JTextArea taskOutput; private Task task; DefaultTableModel model; JTable table; JScrollPane spane; int currentRow=-1; class Task extends SwingWorker&lt;Void, Void&gt; { /* * Main task. Executed in background thread. */ @Override public Void doInBackground() { Random random = new Random(); int progress = 0; //Initialize progress property. setProgress(0); while (progress &lt; 100) { //Sleep for up to one second. try { Thread.sleep(random.nextInt(1000)); } catch (InterruptedException ignore) {} //Make random progress. progress += random.nextInt(10); setProgress(Math.min(progress, 100)); } return null; } /* * Executed in event dispatching thread */ @Override public void done() { Toolkit.getDefaultToolkit().beep(); generateButton.setEnabled(true); setCursor(null); //turn off the wait cursor taskOutput.append("Done!\n"); } } public UserGui() { // super(null); JLabel headerLabel = new JLabel("", JLabel.LEADING); headerLabel.setText("TEST APPLICATION"); headerLabel.setFont(new Font("Calibri",Font.ITALIC,25)); //Create the demo's UI. generateButton = new JButton("button1"); generateButton.setActionCommand("generate"); generateButton.addActionListener(this); exceptionButton = new JButton("button2")…

http://stackoverflow.com/comment/33384110
has text: @JBNizet.. The casting will sure fail at runtime, but compiler shouldn't complain, which is what OP is claiming.
type: AnswerComment
comment on: http://stackoverflow.com/a/22022814
score: 0
type: Comment

http://stackoverflow.com/a/22017153
score: 2
has comment: http://stackoverflow.com/comment/33375274
downvote count: 0
has comment: http://stackoverflow.com/comment/33375563
has comment: http://stackoverflow.com/comment/33374973
has body: The problem (or at least one of them) is that you have an if statement inside a switch block. It's almost at the end of the code: if (c.isAutoButton(actionButtonId)) c.assignAutocast(actionButtonId); You can't have code directly as a "child" of a switch statement, it must be placed inside a case block.
accepted answer of: http://stackoverflow.com/q/22016586
has comment: http://stackoverflow.com/comment/33375169
answers question: http://stackoverflow.com/q/22016586
upvote count: 2
has comment: http://stackoverflow.com/comment/33377035
has comment: http://stackoverflow.com/comment/33374264
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33374227
type: Answer
has comment: http://stackoverflow.com/comment/33374498

http://stackoverflow.com/a/22072026
has body: If you want the percentage passed, you need to divide by the total, not the number failed. float percentPassed = (((float) numPass) / (numPassed + numFailed)) * 100;
upvote count: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22071959
downvote count: 0
answers question: http://stackoverflow.com/q/22071959
type: Answer
score: 1

http://stackoverflow.com/comment/33584755
score: 0
has text: @libik Yes, that is the correct way to implement that strategy.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22134211

http://stackoverflow.com/a/22165047
has comment: http://stackoverflow.com/comment/33639265
has comment: http://stackoverflow.com/comment/33638701
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/33673447
has body: Firstly, you can go on https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/ link and follow the instruction for creating the sandbox account. After creating account you can get a credential.
answers question: http://stackoverflow.com/q/22164918
has comment: http://stackoverflow.com/comment/33638772

http://stackoverflow.com/comment/33631861
type: Comment
type: QuestionComment
score: 2
has text: @d_ominic: why are you recommending a class that even Oracle recommends that you not use? You almost always would use `String#split(String regex)` instead.
comment on: http://stackoverflow.com/q/22161025

http://stackoverflow.com/comment/33594910
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22069254
has text: If they update the standard, will your interfaces not be deprecated as well? Either the new features or removed features in the standard will have to be reflected in your interfaces I would assume.
score: 0

http://stackoverflow.com/q/22069821
tagged with: rest
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22073709
has comment: http://stackoverflow.com/comment/33476663
has comment: http://stackoverflow.com/comment/33470349
type: Question
tagged with: apache-httpcomponents
has comment: http://stackoverflow.com/comment/33467297
has title: Apache HTTPClient 4.3.3 execute method for a GET request blocks and never returns
tagged with: java
score: 10
upvote count: 10
accepted answer: http://stackoverflow.com/a/22073709
has comment: http://stackoverflow.com/comment/33476833
answer count: 1
downvote count: 0
has body: Facing this weird issue since morning, I am making a REST call to a particular endpoint which gives responses in pages so i need to make calls again and again until all pages are completed. My code works fine and dandy until the last page after the last page the next request I make (which should return a blank page) by httpClient.execute(httpGet); is blocked permanently and never comes back or neither throws any exception. If I set connection request time out then the last call is not blocked and fails saying timeout but I am not getting why that last call is not working If I make the same last call from firefox RESTClient it works. Kindly help. I also tried adding different log levels like System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); and other logs to debug but no luck. Below is my code. private static Servers fetchServers(String token,String endpoint) throws Exception{ JsonReader jreader = null; InputStreamReader isr = null; CloseableHttpClient httpClient = null; try{ URI uri = new URI(endpoint); /** accepting all certificates */ httpClient = getSecuredHttpClient(); uri = new URIBuilder(uri) .setParameter("limit", "1")//Page limit, for testing have kept just 1 since i have only 2 records. .build(); HttpGet httpGet = new HttpGet(uri); httpGet.setHeader(HTTP.CONTENT_TYPE, "application/json"); httpGet.setHeader("X-Auth-Token", token); httpGet.setHeader("accept", "application/json"); httpGet.setHeader(HTTP.USER_AGENT, "python-neutronclient"); Servers cloudServers = new Servers(); cloudServers.setServers(new ArrayList&lt;Server&gt;()); boolean nextPage = false; do { HttpResponse resp = httpClient.execute(httpGet);//this is where it gets blocked for last page. if(resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK){ isr = new InputStreamReader(resp.getEntity().getContent()); jreader = new JsonReader(isr); Gson gson = new GsonBuilder().registerTypeAdapter(Address.class, new AddressAdapter()).create(); Servers ser…
favorite count: 0
tagged with: apache-httpclient-4.x

http://stackoverflow.com/comment/33479970
type: Comment
score: 2
comment on: http://stackoverflow.com/a/22076492
has text: doStuff() maybe doTooMuch()? I'm sure this would be trivial to solve with a bit of context.
type: AnswerComment

http://stackoverflow.com/a/22030878
downvote count: 0
score: 1
type: Answer
answers question: http://stackoverflow.com/q/22030798
upvote count: 1
has body: You might either look at the source code for String.equals(String arg) ; or run through a debugger in Eclipse where you have attached the source. My quick check appears to show that the strings are compared character by character.

http://stackoverflow.com/comment/33464062
type: QuestionComment
comment on: http://stackoverflow.com/q/22047781
has text: I mean to just create a no-args constructor for HibernateCategoryDAO with Thread.dumpStack(). Either that or create a no-args constructor and set a break-point on it in the debugger, just to see who is actually creating the object
score: 0
type: Comment

messaging
tags question: http://stackoverflow.com/q/22112718
tag name: messaging
type: Tag
tags question: http://stackoverflow.com/q/22137411

http://stackoverflow.com/a/22016359
has body: Use a query with AliasToEntityMapResultTransformer; is verbose but should works with Hibernate property definition and not with JavaBean definition (they can differ). Map&lt;String,Object&gt; aliasToValueMap = session.createCriteria(User.class) .add(Restrictions.idEq(userID)) .setProjection(Projections.projectionList() .add(Projections.id().as("id")) // Add others properties ) .setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE) .uniqueResult(); A worse approch can be write a custom ResultTransformer that introspect ClassMetadata and try to extract values... class IntrospectClassMetadata extends BasicTransformerAdapter { PassThroughResultTransformer rt = PassThroughResultTransformer.INSTANCE; public Object transformTuple(Object[] tuple, String[] aliases) { final Object o = rt.transformTuple(tuple, aliases); ClassMetadata cm = sf.getClassMetadata(o.getClass()); List&lt;String&gt; pns = new ArrayList&lt;String&gt;(Arrays.asList(cm.getPropertyNames())); Map&lt;String, Object&gt; m = new HashMap&lt;String, Object&gt;(); for(String pn : pns) { m.put(pn, cm.getPropertyValue(o, pn)); } m.put(cm.getIdentifierPropertyName(), cm.getIdentifier(o)); return m; } } and use Map&lt;String,Object&gt; aliasToValueMap = session.createCriteria(User.class) .add(Restrictions.idEq(userID)) .setResultTransformer(new IntrospectClassMetadata()) .uniqueResult(); Last chance: Map&lt;String,Object&gt; map = (Map&lt;String,Object&gt;)s.createSQLQuery("select * from user where id = :id") .setParameter("id",p.id) .setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE) .uniqueResult(); but this doesn't map list,bags and other mapped object, but only raw column names and values...
has comment: http://stackoverflow.com/comment/33409017
upvote count: 7
has comment: http://stackoverflow.com/comment/33402547
type: Answer
has comment: http://stackoverflow.com/comment/33408324
accepted answer of: http://stackoverflow.com/q/22016152
has comment: http://stackoverflow.com/comment/33415638
has comment: http://stackoverflow.com/comment/33407054
answers question: http://stackoverflow.com/q/22016152
has comment: http://stackoverflow.com/comment/33414528
has comment: http://stackoverflow.com/comment/33403944
score: 7
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33372708

http://stackoverflow.com/q/22101933
tagged with: sorting
tagged with: visualization
upvote count: 1
has comment: http://stackoverflow.com/comment/33525578
favorite count: 0
has comment: http://stackoverflow.com/comment/33525537
type: UnansweredQuestion
tagged with: merge
has title: Visualisation of merge sort java?
answer count: 0
downvote count: 0
score: 1
tagged with: java
has body: Hello folks I would like to do the visualisation of merge sort algorithm in java. I've already written the program in java. Where should I exactly begin for the visualisation? Are there any predefined libraries for visualisation in java?
type: Question

abstract-data-type
tags question: http://stackoverflow.com/q/22116028
type: Tag
tag name: abstract-data-type

http://stackoverflow.com/a/22064321
has body: Your problem is that String JSON = "http://www.json-generator.com/j/cglqaRcMSW?indent=4"; is not JSON. What you want to do is open an HTTP connection to "http://www.json-generator.com/j/cglqaRcMSW?indent=4" and parse the JSON response. String JSON = "http://www.json-generator.com/j/cglqaRcMSW?indent=4"; JSONObject jsonObject = new JSONObject(JSON); // &lt;-- Problem here! Will not open a connection to the site and retrieve the content.
upvote count: 18
type: Answer
score: 17
accepted answer of: http://stackoverflow.com/q/22062056
type: AcceptedAnswer
downvote count: 1
answers question: http://stackoverflow.com/q/22062056

http://stackoverflow.com/comment/33401636
comment on: http://stackoverflow.com/q/22032567
score: 0
type: Comment
type: QuestionComment
has text: Short Answer: There is no such method available, at present.

http://stackoverflow.com/q/22157574
answer count: 4
accepted answer: http://stackoverflow.com/a/22157657
has title: Passing data between threads, all can produce, all should consume (Java)
has answer: http://stackoverflow.com/a/22157717
linked to: http://stackoverflow.com/q/2332537
has body: I am working on a broadcast server where all clients should be able to send a broadcast message to all clients, and all clients should receive a broadcast from any client. I'm trying to figure out what the best way would be to implement this on the server side. I've run across a BlockingQueue, but my understanding is that when one thread calls take(), it removes the item so that the other threads can't get the data, and that each client is either a producer or a consumer. What would the best way be to implement this? Each client will have a thread on the server side. Thanks!
score: 1
has answer: http://stackoverflow.com/a/22158086
tagged with: java
tagged with: multithreading
linked to: http://stackoverflow.com/q/20663988
upvote count: 1
possible better answer: http://stackoverflow.com/a/22157717
type: Question
has comment: http://stackoverflow.com/comment/33625809
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22157727
has answer: http://stackoverflow.com/a/22157657
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/22036381
has body: The problem is with this line : String[][] info = new String[size][0] The second dimension is empty so when you access info[b][a] you will get the exception since the 2nd dimension will always be out of bounds. What you need to do is initialize the array with the required size for the 2nd dimension as well for example : String[][] info = new String[size][2]; // As in your case you access indicies 0 and 1 in the 2nd dimension
answers question: http://stackoverflow.com/q/22036233
score: 4
upvote count: 4
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/22036233

http://stackoverflow.com/q/22037658
has answer: http://stackoverflow.com/a/22041971
tagged with: modal-dialog
tagged with: jdialog
answer count: 1
favorite count: 0
has title: setModal issue with 2 Jdialogs within a Jframe
tagged with: jframe
type: UnansweredQuestion
tagged with: swing
score: 2
downvote count: 0
has body: I am facing issues when I set my first JDialog modal and the second one non-modal. This is the functionality I am trying to implement: On click of "Test the dialog!" button, a JDialog with name Custom Dialog Main will open. If click "yes" option in Custom Dialog Main, another JDialog named Custom Dialog Search will open. If click "yes" option in Custom Dialog Search, then Custom Dialog Main should come front. And I should be able to select any JDialog. For example if I select Custom Dialog Search, the other dialog should go back and vice versa. Problem I am facing is when I click "yes" in Custom Dialog Main, then Custom Dialog Search is displayed behind the main dialog. This is happening because I am setting Custom Dialog Search non-modal. If I this dialog modal it is displayed correctly but after I click "yes" Custom Dialog Main doesn't come front. I even tried to set CustomDialogSearch's parent to be CustomDialog the behaviour still not correct. Below is the example code I am testing. import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JButton; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.ActionEvent; import java.awt.Dimension; public class TestTheDialog implements ActionListener { JFrame mainFrame = null; JButton myButton = null; public TestTheDialog() { mainFrame = new JFrame("TestTheDialog Tester"); mainFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) {System.exit(0);} }); myButton = new JButton("Test the dialog!"); myButton.addActionListener(this); mainFrame.setLocationRelativeTo(null); mainFrame.getContentPane().add(myButton); mainFrame.pack(); mainFrame.setVisible(true); } public void actionPerformed(ActionEvent e) { if(myButton == e.getSource()) { System.err.println("Opening dialog."); CustomDialog myDialog = new CustomDialog(mainFrame, true, "Custom Dialog Main?"); System.err.println("After opening dialog."); if(myDialog.getAnswer()) { Sys…
tagged with: java
type: Question
upvote count: 2

http://stackoverflow.com/comment/33571998
has text: I think you need to pass -Djava.library.path=[whatever] when you start the JVM rather than using System.setProperty(...). After that, you tried exactly this: System.loadLibrary("vlc") ?
type: QuestionComment
comment on: http://stackoverflow.com/q/22103110
type: Comment
score: 1

http://stackoverflow.com/q/22023333
favorite count: 0
tagged with: windows
type: UnansweredQuestion
tagged with: javafx
upvote count: 1
has answer: http://stackoverflow.com/a/22189358
score: 1
has body: My goal is to have a java application running, when the camera is plugged in or already plugged in, the program can auto detect the camera. After writing that sentence it doesn't seem possible in distinguishing between the USB drives on windows. Can someone help me with pointing me in the right direction with allowing the user to specify the camera location? If the camera location is specified i should be able to auto-generate some sort of list of jpeg files on it correct? My overall goal is to have a user enter a "job number", then from the camera (auto-detected or user location specified), the program automatically takes all the photos that exist on it, dump them into a folder named after the job number, then erase the photos on the camera. It's like an auto photo storage dump pretty much. I'm currently working with Eclipse and the JavaFX plug-in with using SceneBuilder.
tagged with: java
tagged with: scenebuilder
tagged with: eclipse
type: Question
has title: Is there a way to auto detect a camera (USB) on windows with Java/JavaFX?
answer count: 1
downvote count: 0

http://stackoverflow.com/comment/33452883
type: Comment
type: QuestionComment
has text: @JonSkeet True, especially since the linked code will most likely be gone, whilst this question will remain here for others to review.
comment on: http://stackoverflow.com/q/22061488
score: 0

jpanel
tags question: http://stackoverflow.com/q/22166549
tags question: http://stackoverflow.com/q/22155234
tags question: http://stackoverflow.com/q/22057731
tags question: http://stackoverflow.com/q/22029595
tags question: http://stackoverflow.com/q/22021425
tags question: http://stackoverflow.com/q/22115502
tags question: http://stackoverflow.com/q/22086827
type: Tag
tags question: http://stackoverflow.com/q/22013918
tags question: http://stackoverflow.com/q/22162656
tags question: http://stackoverflow.com/q/22135477
tags question: http://stackoverflow.com/q/22162398
tags question: http://stackoverflow.com/q/22138131
tags question: http://stackoverflow.com/q/22030854
tags question: http://stackoverflow.com/q/22110160
tags question: http://stackoverflow.com/q/22076183
tags question: http://stackoverflow.com/q/22161179
tags question: http://stackoverflow.com/q/22079260
tags question: http://stackoverflow.com/q/22168669
tag name: jpanel
tags question: http://stackoverflow.com/q/22072796
tags question: http://stackoverflow.com/q/22026606
tags question: http://stackoverflow.com/q/22075483
tags question: http://stackoverflow.com/q/22100667
tags question: http://stackoverflow.com/q/22052709

http://stackoverflow.com/comment/99388223
type: QuestionComment
has text: Possible duplicate of [Why am I getting Unknown error in line 1 of pom.xml?](https://stackoverflow.com/questions/56142369/why-am-i-getting-unknown-error-in-line-1-of-pom-xml)
comment on: http://stackoverflow.com/q/22053213
score: 0
type: Comment

http://stackoverflow.com/q/22152089
tagged with: eclipse
tagged with: grails
type: Question
upvote count: 2
has comment: http://stackoverflow.com/comment/33703234
has comment: http://stackoverflow.com/comment/50320290
favorite count: 0
has comment: http://stackoverflow.com/comment/33616277
has title: Unable to evaluate Groovy in Eclipse (GGTS) when debugging
tagged with: groovy
answer count: 0
downvote count: 0
type: UnansweredQuestion
has body: I'm using GGTS for Groovy project and during debug in some cases it's impossible to evaluate the the value of some expressions. The expressions I'm trying to evaluate are simple as a variable value, but when I try it shows an exception like this: See error log: (Groovy) Complete snippet: /////start package adminsite; import grails.converters.JSON; import modules.arteplastico.ArticleObraPlasticaTmp; import modules.arteplastico.dto.ArticleObraPlasticaDTO; import com.google.gson.JsonObject; params.accion /////end (Groovy) An exception ocurred during evaluation Evaluation snippet: Any suggestion? Edit: I've find out something more in Eclipse logs: Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: ____Eval.groovy: 8: unable to resolve class core.ArticleTmpStatus @ line 8, column 13. import core.ArticleTmpStatus; ^ ____Eval.groovy: 5: unable to resolve class modules.arteplastico.dto.ArticleObraPlasticaDTO @ line 5, column 33. import modules.arteplastico.dto.ArticleObraPlasticaDTO; ^ ____Eval.groovy: 9: unable to resolve class core.BaseDTO @ line 9, column 13. import core.BaseDTO; ^ ____Eval.groovy: 4: unable to resolve class modules.arteplastico.ArticleObraPlasticaTmp @ line 4, column 29. import modules.arteplastico.ArticleObraPlasticaTmp; ^ ____Eval.groovy: 10: unable to resolve class core.CoreController @ line 10, column 13. import core.CoreController; ^ ____Eval.groovy: 11: unable to resolve class core.ModuleIfce @ line 11, column 13. import core.ModuleIfce; ^ ____Eval.groovy: 7: unable to resolve class core.ArticleTmp @ line 7, column 13. import core.ArticleTmp; ^ The strange thing is I'm running this code with no problems and at runtime all this classes work properly. The thing is that in Eclipse neither (Ctrl+Space) nor the Debugger are able to find this classes.
has comment: http://stackoverflow.com/comment/33691881
has comment: http://stackoverflow.com/comment/45284300
score: 2
has comment: http://stackoverflow.com/comment/33681419
tagged with: java

http://stackoverflow.com/comment/33503590
has text: what do you mean? I'm using a BufferedReader to read client's input, whenever my client sends a command my server receives it as a whole using the readLine() method, why do I even need to check the length of the string?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22089456

http://stackoverflow.com/a/22044949
score: 1
has comment: http://stackoverflow.com/comment/33452018
downvote count: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22043335
has body: Spring AOP can only intercept method executions, so if you catch the exception in the method it won't reach the interceptor. You can advise exceptions being thrown in AspectJ, I believe (using the handler() pointcut designator).
answers question: http://stackoverflow.com/q/22043335
type: Answer
upvote count: 1

http://stackoverflow.com/q/22096587
answer count: 3
tagged with: android
has comment: http://stackoverflow.com/comment/33516028
has answer: http://stackoverflow.com/a/22096955
type: UnansweredQuestion
has title: Android: Customized List view with varying image views
has answer: http://stackoverflow.com/a/22096710
tagged with: java
has body: I would like to know if the following is possible with custom list views/adapters I want to create the following row for a list view IV -> IV -> IV -> CHECKBOX However, my problem is that the amount of Image views will vary. For example in one row there could be 3 IV but another row may have 1 or 2. So basically the contents of each row can vary. IV -> IV -> CHECKBOX IV -> CHECKBOX I would like some advice if this is possible please
type: Question
score: 0
has comment: http://stackoverflow.com/comment/33515448
has answer: http://stackoverflow.com/a/22096734

http://stackoverflow.com/a/22059890
has comment: http://stackoverflow.com/comment/33527920
has comment: http://stackoverflow.com/comment/33494561
has comment: http://stackoverflow.com/comment/33528097
has comment: http://stackoverflow.com/comment/33529321
has comment: http://stackoverflow.com/comment/33490537
has body: Java date/time is a major piece of headaches. Anyway, the trick is that I used, and seem to work, both xml calendar parser combine with SimpleDateFormat. I also posted this a while back on my blog: a simple trick for date format and may be something there you can use too. But anyway, here is the answer. Simply take this method and make a few small tweet and plug in (replace) the deserializeToDate() method on that DateTypeAdapter class: private Date deserializeToDate(/*JsonElement*/String json) /*Json*/ParseException { Date d = null; String date = json; // json.getAsString(); try { d = javax.xml.bind.DatatypeConverter.parseDateTime(date).getTime(); } catch (Exception e) {} // ignore if (d == null) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); d = dateFormat.parse(date); } return d; } @Test public void shouldParseXmlDateTime() { String date1 = "2013-12-18T00:41:38-0500"; String date2 = "2013-10-25T15:00:00+08:00"; try { System.out.println(deserializeToDate(date1)); } catch (Exception e ) { System.out.println(e); } try { System.out.println(parse(date2)); } catch (Exception e ) { System.out.println(e); } } and this should produce: Wed Dec 18 00:41:38 EST 2013 Fri Oct 25 03:00:00 EDT 2013
score: 0
has comment: http://stackoverflow.com/comment/33458729
type: Answer
answers question: http://stackoverflow.com/q/22056204

http://stackoverflow.com/a/22008612
type: Answer
answers question: http://stackoverflow.com/q/22006161
score: 0
has body: java.time In Java 8 If your question is really about how to format a date (as stated in your last line), and not really about HashMap, here's how to do it with the new java.time package in Java 8. The java.time package is inspired by Joda-Time and defined by JSR 310. Notice that you can easily localize to various languages and their various customs such as different number of characters in the abbreviation of the month name. I'm showing formatting for France as output, but you can switch to Locale.US. String input = "September 25, 2013"; DateTimeFormatter formatterInput = DateTimeFormatter.ofPattern( "MMMM d, yyyy" ).withLocale( java.util.Locale.ENGLISH ); LocalDate localDate = LocalDate.parse( input, formatterInput ); //DateTimeFormatter formatterOutput = DateTimeFormatter.ofPattern( "MMM" ).withLocale( Locale.CANADA_FRENCH ); DateTimeFormatter formatterOutput = DateTimeFormatter.ofLocalizedDate( FormatStyle.MEDIUM ).withLocale( Locale.FRANCE ); String output = formatterOutput.format( localDate ); Dump to console… System.out.println( "localDate: " + localDate ); System.out.println( "output: " + output );); When run… localDate: 2013-09-25 output: 25 sept. 2013

http://stackoverflow.com/comment/34144690
score: 0
comment on: http://stackoverflow.com/a/22141825
type: Comment
has text: Instead of a regular Lock, use ReadWriteLock. Type I should use lock.getReadLock().lock(), and type II should use lock.getWriteLock().lock().
type: AnswerComment

http://stackoverflow.com/a/22057728
upvote count: 1
has comment: http://stackoverflow.com/comment/33447105
score: 1
answers question: http://stackoverflow.com/q/22057332
has comment: http://stackoverflow.com/comment/33447118
downvote count: 0
has comment: http://stackoverflow.com/comment/33446936
has body: You could try checking the state of the KeyEvent modifiers, for example... addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { int mods = e.getModifiers(); System.out.println(mods); if ((mods &amp; KeyEvent.BUTTON1_MASK) != 0) { System.out.println("Button1 down"); } } }); I should also point out, you can do... int ext = e.getModifiersEx(); if ((ext &amp; KeyEvent.BUTTON1_DOWN_MASK) != 0) { System.out.println("Button1_down_mask"); } Which, as I've just discovered, produces results for other mouse buttons...
type: Answer
has comment: http://stackoverflow.com/comment/33447050

http://stackoverflow.com/comment/33411249
type: Comment
has text: What operating system are you using?
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22038239

http://stackoverflow.com/a/22036706
accepted answer of: http://stackoverflow.com/q/22036531
answers question: http://stackoverflow.com/q/22036531
downvote count: 0
score: 1
upvote count: 1
type: AcceptedAnswer
has body: I think you're missunderstanding some basic concepts about Threads. Your threads, as you defined them, seem (moreless) ok, they are not blocking your UI as they're running in the background. What is blocking your UI is the while (!display) {} loop. You're waiting here until your thread modifies that value, which I guess is not what you're trying to achieve. You'd need to define some other way of doing this, like for example, append the while (!display) content code block to the Thread.
type: Answer

http://stackoverflow.com/comment/57856057
comment on: http://stackoverflow.com/a/22166421
has text: @Mishax You need to have `org.eclipse.ui.ide` in your plugin's dependencies, but you normally do not need to use `FileEditorInput`.
type: AnswerComment
type: Comment
score: 7

http://stackoverflow.com/a/22048591
answers question: http://stackoverflow.com/q/22048044
type: Answer
score: 0
has body: Once you have included a widget (in your case an ImageView) into the xml layout, it gets bound to that view. It is easier (and good practice) to dynamically add widgets when you need to move/remove/replace them during run time. For example you could keep your RelativeLayout container empty in your layout file and add this ImageView in your onCreate() method using RelativeLayout.addView().

http://stackoverflow.com/q/22133497
favorite count: 0
type: UnansweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33602944
upvote count: 1
has answer: http://stackoverflow.com/a/22133592
downvote count: 1
type: Question
tagged with: jakarta-ee
tagged with: jpa
score: 0
answer count: 1
has title: Does EJB create new transaction
has body: Does EJB(glassfish) create new transaction when i am executing a read only query using jpa(eclipselink).

http://stackoverflow.com/comment/33376314
type: Comment
type: QuestionComment
has text: My guess is that the generated `.class` file of `clicker` will be replaced by `Clicker` and will not be available at run time, though it was compiled at first. So follow @TylerAndFriends comment and change class name.
comment on: http://stackoverflow.com/q/22018260
score: 0

http://stackoverflow.com/comment/33370649
comment on: http://stackoverflow.com/a/22015608
type: Comment
has text: As long as you're putting `FLAG_CANCEL_CURRENT` flag, then it knows to match and cancel / update.
type: AnswerComment
score: 0

normalization
tags question: http://stackoverflow.com/q/22005722
tag name: normalization
type: Tag

http://stackoverflow.com/comment/33355810
has text: hey i tried this but value of password is not getting inserted but only string passWord is getting inserted.... I want the value of passWord to be inserted.. cos i have auto generated password
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22006764

http://stackoverflow.com/comment/33421620
comment on: http://stackoverflow.com/q/22025386
has text: The file isn't particularly large, the issue I was having is that it is a two pass process, where the second pass has to use state (in the form of a map) from the first. The two pieces logically go together, and pig is certainly necessary for all the other processing, before and after.. I was hoping to not need to seperate the pig script, and I was surprised that so far out of the documentation i've seen, you can only execute a UDF as part of a foreach iterative statement
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22103217
has body: If you pass 1 to the NioEventLoopGroup and share the instance between the bootstraps only one client will be used.
answers question: http://stackoverflow.com/q/22090824
type: Answer
accepted answer of: http://stackoverflow.com/q/22090824
score: 2
upvote count: 2
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/26132942
answers question: http://stackoverflow.com/q/22133500
score: 0
has body: When you call start() on the AsyncContext you give it an implementation of the Runnable. Call the complete() on the AsyncContext in the finally clause inside Runnable. Foe example: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ AsyncContext aContext = request.startAsync(); //Provide Runnable implementation to start method aContext.start(() -&gt;{ try{ PrintWriter out; try { Thread.currentThread().sleep(3000); // Emulate a 3-second process HttpServletResponse resp = (HttpServletResponse) aContext.getResponse(); out = resp.getWriter(); out.println("Hello from Async servlet"); } catch (IOException e) { e.printStackTrace(); } }catch( InterruptedException e){ e.printStackTrace(); }finally{ aContext.complete(); // close the response obj } }); }
type: Answer
has comment: http://stackoverflow.com/comment/42811999

http://stackoverflow.com/q/22139262
has answer: http://stackoverflow.com/a/22142867
has answer: http://stackoverflow.com/a/22144545
score: 8
tagged with: eclipse
accepted answer: http://stackoverflow.com/a/22144545
answer count: 2
has comment: http://stackoverflow.com/comment/33600751
type: AnsweredQuestion
downvote count: 0
favorite count: 0
has title: JSF Code formatter or Eclipse XML Editor, each tag for new line?
upvote count: 8
type: Question
tagged with: code-formatting
has comment: http://stackoverflow.com/comment/33601128
linked to: http://stackoverflow.com/q/4527474
tagged with: jsf
tagged with: java
possible better answer: http://stackoverflow.com/a/22142867
has body: How to format JSF code in eclipse? I already try as the following : Format XML code in Eclipse My XML Editor Configuration Setting is : Line width 120 Split multiple attributes each on a new like Checked Align final bracket in mulit-line element tags Checked Clear all blank lines Checked If I do Ctrl + Shif + F, eclipse format the code as below. &lt;tr&gt; &lt;td&gt;&lt;h:outputText value="#{label['MANAGE_USER_TITLE']}" styleClass="table-title" /&gt;&lt;/td&gt; &lt;/tr&gt; My expectation format is, after Ctrl + Shif + F &lt;tr&gt; &lt;td&gt; &lt;h:outputText value="#{label['MANAGE_USER_TITLE']}" styleClass="table-title" /&gt; ▲ This line may be wrap base on line size. &lt;/td&gt; &lt;/tr&gt; How can I do for that? Is there any plugin? I already try HTML Tidy, I can only format HTML, not JSF code. Update Picture -1 Eclipse Setting for Picture-1 Picture - 2 (I want)

http://stackoverflow.com/a/29893119
has body: We have to modify Registry value to be able to manipulate pop-up blocker in IE. Registry information is given below: Registry Location: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\New Windows Registry Value Name: PopupMgr Registry Value Data: no [Turn off pop-up blocker] and yes [Turn on pop-up blocker] If you are with Java and want to achieve it programmatically, following code snippet will surely help you: String cmd = "REG ADD \"HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\New Windows\" /F /V \"PopupMgr\" /T REG_SZ /D \"no\""; try { Runtime.getRuntime().exec(cmd); } catch (Exception e) { System.out.println("Error ocured!"); } Hope it helps!
upvote count: 2
score: 2
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22012076
answers question: http://stackoverflow.com/q/22012076
type: Answer

http://stackoverflow.com/q/22032689
has answer: http://stackoverflow.com/a/22032709
tagged with: java
upvote count: 1
accepted answer: http://stackoverflow.com/a/22032709
downvote count: 1
has answer: http://stackoverflow.com/a/22032861
type: Question
has comment: http://stackoverflow.com/comment/33401804
has body: I need to sort a 2 dimensional array in increasing order. Example: Before: 5.1 3.3 6.3 4.8 4.9 6.9 7.4 5.2 3.6 7.4 After: 3.6 3.3 4.9 4.8 5.1 5.2 6.3 6.9 7.4 7.4
tagged with: sorting
has title: How to Sort a 2Dimensional array?
score: 0
answer count: 3
tagged with: arrays
favorite count: 0
has answer: http://stackoverflow.com/a/22033868
possible better answer: http://stackoverflow.com/a/22033868
type: AnsweredQuestion

http://stackoverflow.com/a/22162266
answers question: http://stackoverflow.com/q/22133900
has body: It looks like you are missing a call to app_message_register_callbacks in your handle_init method. Adding this should do the trick: app_message_register_callbacks(&amp;messageCallBacks); You are still using SDK 1.x which is now deprecated. I strongly recommend that you upgrade to SDK 2.0. The development and debugging tools are much nicer. You will also have way more APIs to play with.
has comment: http://stackoverflow.com/comment/33723834
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33729339
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/33727128
accepted answer of: http://stackoverflow.com/q/22133900
upvote count: 1

http://stackoverflow.com/comment/33527141
comment on: http://stackoverflow.com/q/22102077
type: QuestionComment
score: 0
has text: Library is closed source third party. I've got it to give me a new error message "Can't find dependent libraries". I'll have to contact the third party to find out what those are.
type: Comment

http://stackoverflow.com/comment/33515879
has text: Oh, someone voted for my question, I get more reputation! I can finally vote now~~~~ :D
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22096379

http://stackoverflow.com/comment/33535183
comment on: http://stackoverflow.com/q/22106980
has text: Use `String`'s `equals` method to compare string contents, not the `==` operator.
type: Comment
type: QuestionComment
score: 2

http://stackoverflow.com/comment/33421079
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22043652
has text: Why not try it yourself and find out? If it doesn't work, then come to SO for help.
score: 0

http://stackoverflow.com/q/22081809
type: Question
has comment: http://stackoverflow.com/comment/33491301
accepted answer: http://stackoverflow.com/a/22082674
has comment: http://stackoverflow.com/comment/33490341
answer count: 2
has comment: http://stackoverflow.com/comment/33489933
has answer: http://stackoverflow.com/a/22082403
has comment: http://stackoverflow.com/comment/33490081
downvote count: 0
tagged with: pom.xml
favorite count: 0
linked to: http://stackoverflow.com/q/6625752
possible better answer: http://stackoverflow.com/a/22082403
tagged with: maven
upvote count: 1
has answer: http://stackoverflow.com/a/22082674
has title: Adding repository to pom, dependency still can't be resolved
has body: I'm still new at maven, but I'm attempting to add a new repository to resolve a dependency in my project with no luck. I've added the following to my POM: com.mvnrepository mvnrepository.com default http://repo1.maven.org/maven2 false org.apache.jmeter ApacheJMeter_parent 2.10 I tried switching layout from default to legacy in the off chance that my maven3 had some conflict with the maven2 repository, but that yielded nothing. If anyone could tell me what I'm not doing correctly, I'd appreciate it. UPDATE: I feel really stupid now, here's the output of my terminal. It looks like maven is attempting to resolve the dependency through our corporate repository. I suppose the questions should now be, how do I add this additional repository despite the fact I have a company repository defined in my settings.xml? [ERROR] Failed to execute goal on project jmeter-analyzer: Could not resolve dependencies for project <Project name here> Failure to find org.apache.jmeter: ApacheJMeter_parent:jar:2.10 in http://<our internal corporate repo-url here> was cached in the local repository, resolution will not be reattempted until the update interval of <Company mirror name here> has elapsed or updates are forced -> [Help 1] UPDATE: It looks like it is definitely defined in my settings.xml file under: <mirrors>, <profiles>, and even <pluginGroups>. This shouldn't completely prevent me from adding a third party repo to this single project should it?
type: AnsweredQuestion
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33489951

http://stackoverflow.com/q/22053810
type: AnsweredQuestion
has body: I searched for this for some days now and haven't found a good resource. I want to set up two tasks for the Selenium Grid to work "with just one click" in ConEmu. I added a task and set up a startup dir (where the Selenium Grid jar is located). According to http://code.google.com/p/selenium/wiki/Grid2 I need to start two instances of that jar with different parameters: java -jar selenium-server-standalone-2.14.0.jar -role hub and java -jar selenium-server-standalone-2.14.0.jar -role node -hub http://localhost:4444/grid/register I wanted to have two tasks in ConEmu to start those two instances of Selenium. I tried to set up a task with -new_console:d:D:\Downloads\Programming\Selenium java -jar selenium-server-standalone-2.14.0.jar -role hub This always leads me to following output in ConEmu Error: Unable to access jarfile selenium-server-standalone-2.14.0.jar Current directory: C:\Program Files\ConEmu\ConEmu Command to be executed: "C:\Windows\system32\java.exe" -jar selenium-server-standalone-2.14.0.jar -role hub ConEmuC: Root process was alive less than 10 sec, ExitCode=1. Press Enter or Esc to close console... With the jar in the task it won't open the source path. When deleting the jar with parameters in the task, a new console opens and navigates to the correct folder. I am totally lost here - how do I have to set up a task to run the Selenium grid automatically? Edit 1: I added a screenshot from the current setup (-> http://tinyurl.com/q2mgkmx [as I do not have enough reputation, I altered the stackoverflow url with tinyurl; nothing to fear here ;) ]). I know this is wrong, as every entry in a new line opens a new tab in ConEmu. But I thought that the ">" parameter would mark the tab as "current tab" ... Edit 2: Just for completeness: I do run the 64bit client on Windows 7.
tagged with: java
tagged with: selenium
has comment: http://stackoverflow.com/comment/33484662
tagged with: conemu
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/33478308
possible better answer: http://stackoverflow.com/a/22079547
has answer: http://stackoverflow.com/a/22079547
has title: How to set up ConEmu task for Selenium Grid
score: 0
has answer: http://stackoverflow.com/a/22081070
tagged with: windows
accepted answer: http://stackoverflow.com/a/22081070
has comment: http://stackoverflow.com/comment/33440872
has comment: http://stackoverflow.com/comment/33478695
tagged with: 64-bit

http://stackoverflow.com/comment/33536033
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22107268
type: QuestionComment
has text: please post the class

http://stackoverflow.com/a/22029837
has comment: http://stackoverflow.com/comment/33397326
has body: A StringReader is a Reader. And a Reader's .read() method can throw an IOException. You need to change your method declaration to: public static void readstring(String a) throws IOException { // code here } (edit: or use try/catch, as mentioned in comments; if you do so however, please avoid the classical .printStackTrace() with nothing else)
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/22029790
type: Answer
accepted answer of: http://stackoverflow.com/q/22029790
score: 2
has comment: http://stackoverflow.com/comment/33397240
upvote count: 2
has comment: http://stackoverflow.com/comment/33397191

http://stackoverflow.com/q/22019069
favorite count: 0
has answer: http://stackoverflow.com/a/22019232
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33378132
linked to: http://stackoverflow.com/q/10942427
upvote count: 0
has comment: http://stackoverflow.com/comment/33377887
type: Question
has comment: http://stackoverflow.com/comment/33377194
score: -2
tagged with: java
has comment: http://stackoverflow.com/comment/33378189
has comment: http://stackoverflow.com/comment/33377627
has comment: http://stackoverflow.com/comment/33378062
has body: I made an applet with a chess game but now I want to be able to play against somebody else on another computer. I found alot about serverlets but I don't have a server to run it on. Does anybody knows how I send data from an applet to another instance of that applet on an other computer?
downvote count: 2
tagged with: communication
answer count: 1
tagged with: applet
has title: communication between applets on different computers

int
tags question: http://stackoverflow.com/q/22110401
tags question: http://stackoverflow.com/q/22050474
tags question: http://stackoverflow.com/q/22120325
tags question: http://stackoverflow.com/q/22010948
type: Tag
tags question: http://stackoverflow.com/q/22139036
tag name: int
tags question: http://stackoverflow.com/q/22142456
tags question: http://stackoverflow.com/q/22145281

http://stackoverflow.com/q/22019896
tagged with: android
tagged with: mapsforge
has title: NoClassDefFoundError on Android project
has body: I have this problem that i can't understand how to solve. i have imported a maps forge project in eclipse using maven, but if try to load the project on device, i get this error. But i know that that class is in the project. How can i solve this problem? I am working with the Mapsforge rescue 4.0 library. I have used the same method to import Mapsforge 0.31 and everything works fine. 02-25 16:46:03.202: E/AndroidRuntime(6370): java.lang.NoClassDefFoundError: org.mapsforge.map.android.graphics.AndroidGraphicFactory This is the pom.xml of the app. <?xml version="1.0" encoding="UTF-8"?> http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.mapsforge mapsforge 0.4.0-SNAPSHOT ../../../pom.xml Samples apk ../../../ 1.6 com.jayway.maven.plugins.android.generation2 android-maven-plugin -Xmx512M true org.apache.maven.plugins maven-eclipse-plugin false bin/classes <additionalBuildcommands> com.android.ide.eclipse.adt.ResourceManagerBuilder com.android.ide.eclipse.adt.PreCompilerBuilder com.android.ide.eclipse.adt.ApkBuilder org.eclipse.jdt.core.javabuilder </additionalBuildcommands> <additionalProjectnatures> org.eclipse.jdt.core.javanature com.android.ide.eclipse.adt.AndroidNature </additionalProjectnatures> org.eclipse.jdt.launching.JRE_CONTAINER com.android.ide.eclipse.adt.ANDROID_FRAMEWORK com.android.ide.eclipse.adt.LIBRARIES com.android.ide.eclipse.adt.DEPENDENCIES com.google.android:android org.apache.httpcomponents:httpclient org.apache.httpcomponents:httpcore commons-codec:commons-codec commons-logging:commons-logging org.json:json org.khronos:opengl-api xerces:xmlParserAPIs xpp3:xpp3 org.mapsforge mapsforge-map-android apklib ${project.version} android android 4.4.2_r2 provided com.jayway.android.robotium robotium-solo 5.0.1 test com.google.android support-v4 r7
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33380332
type: Question
has comment: http://stackoverflow.com/comment/33379403
has comment: http://stackoverflow.com/comment/33392496
tagged with: java
has comment: http://stackoverflow.com/comment/33380006
has comment: http://stackoverflow.com/comment/33380130
tagged with: eclipse
score: 0
has comment: http://stackoverflow.com/comment/33378681
has answer: http://stackoverflow.com/a/25866994
answer count: 1
has comment: http://stackoverflow.com/comment/33379830

http://stackoverflow.com/a/22604692
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22064853
type: Answer
answers question: http://stackoverflow.com/q/22064853
downvote count: 0
score: 1
has body: Since your javac worked, you have testng.jar in the classpath correctly. Then the program has dependency on other libraries selenium etc. It will be correct to use individual jars instead of wild cards. java -cp "C:\Program Files\Java\selenium&lt;version&gt;.jar;OneReports.jar;testng.jar" test.TestngTestSuiteUsingXML This may give more classnotfound exception. Add only those to your classpath. Note that you are referring other jars too by relative path (OneReports.jar or testng.jar). This can get pretty messy. Consider using ant/maven/gradle to do this part of the work. They would form the classpath more reliably.
upvote count: 1

http://stackoverflow.com/a/22036877
upvote count: 0
has comment: http://stackoverflow.com/comment/33410645
has comment: http://stackoverflow.com/comment/33410089
score: -1
has comment: http://stackoverflow.com/comment/33410668
has comment: http://stackoverflow.com/comment/33415235
has comment: http://stackoverflow.com/comment/33410382
has comment: http://stackoverflow.com/comment/33410168
downvote count: 1
has comment: http://stackoverflow.com/comment/33409941
has body: You would have to use third variant of UnicastRemoteObject.export method whitch is exportObject(Remote obj, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) here you would have to implement and provide own socket factories where you could specify all socket parameters you would need.
has comment: http://stackoverflow.com/comment/33410364
type: Answer
has comment: http://stackoverflow.com/comment/33413181
answers question: http://stackoverflow.com/q/22036690
has comment: http://stackoverflow.com/comment/33410845

http://stackoverflow.com/comment/33375274
has text: case 24017 @SeanDuggan
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22017153

http://stackoverflow.com/comment/33511935
has text: It's all very well saying just do this, but I have no idea, I'm really stuck, I've tried JLabels before I couldn't get anything to display - is there a block of code that I can put in to get it to display? I've spent hours and hours on this and its just making my head hurt
comment on: http://stackoverflow.com/q/22093313
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/33638689
comment on: http://stackoverflow.com/q/22164674
type: Comment
has text: I checked these sites before itself they all show with two radio buttons.Mine is with multiple radio buttons and I wanted to radiogroup them with changing the alignment.
score: 0
type: QuestionComment

http://stackoverflow.com/a/22142409
downvote count: 0
answers question: http://stackoverflow.com/q/22142350
type: Answer
has comment: http://stackoverflow.com/comment/33601834
upvote count: 1
has body: You must include mysql JDBC jar into your class path first. Get it here http://dev.mysql.com/downloads/connector/j/5.0.html
accepted answer of: http://stackoverflow.com/q/22142350
score: 1
has comment: http://stackoverflow.com/comment/33601240
has comment: http://stackoverflow.com/comment/33605125
has comment: http://stackoverflow.com/comment/33602980
type: AcceptedAnswer

http://stackoverflow.com/q/22016926
type: UnansweredQuestion
downvote count: 1
type: Question
has title: 3 line read from txt file
tagged with: java
score: -1
has answer: http://stackoverflow.com/a/22017001
upvote count: 0
answer count: 1
has body: txt file read and 1~3 line is send Mesaage and 3~6 line read message send but 1~3 read after send, next Again 1~3 line read after send... I want 3 line read Repeat from txt file test.txt 1|11221234|c1|c2|c3|c4 2|11221234|c1|c2|c3|c4 3|11221234|c1|c2|c3|c4 4|11221234|c1|c2|c3|c4 5|11221234|c1|c2|c3|c4 6|11221234|c1|c2|c3|c4 7|11221234|c1|c2|c3|c4 8|11221234|c1|c2|c3|c4 9|11221234|c1|c2|c3|c4 9|11221234|c1|c2|c3|c4 10|11221234|c1|c2|c3|c4 11|11221234|c1|c2|c3|c4 12|11221234|c1|c2|c3|c4 13|11221234|c1|c2|c3|c4 while ((s = in.readLine()) != null) { cnt++; Element record = new Element("RECORD"); String[] arr = s.split("│"); if (arr.length == tableInfoMap.size()) { for (int i = 0; i &lt; arr.length; i++) { int j = i + 1; String fieldName = (String) tableInfoMap .get("COLUMN" + j); Element field = new Element(fieldName); field.addContent(new CDATA(arr[i])); record.addContent(field); } } else { throw new ArrayIndexOutOfBoundsException(" "); } rootElement.addContent(record); if (cnt &gt;= 3) { sendMsg(srcTblName, tgtTblName, classPath, className, doc, comm, sndAgency, rcvAgency, cnt); cnt = 0; } } if (cnt &gt; 0) { boolean isSend = sendMsg(srcTblName, tgtTblName, classPath, className, doc, comm, sndAgency, rcvAgency, cnt); in.close(); if (isSend == true) { File f = new File(file); if (f.delete() == true) { logger.info("Send File Success: " + file); logger.debug(f.getPath()); } else { logger.warn("Send File Fail: " + file); logger.debug(f.getPath()); } } }
favorite count: 0
has comment: http://stackoverflow.com/comment/33373842
tagged with: io
tagged with: readline

http://stackoverflow.com/comment/33500538
type: QuestionComment
has text: where is your startActivityForResult();
comment on: http://stackoverflow.com/q/22087828
score: 0
type: Comment

http://stackoverflow.com/q/22028317
tagged with: fibonacci
possible better answer: http://stackoverflow.com/a/22052127
tagged with: arrays
has answer: http://stackoverflow.com/a/22051794
accepted answer: http://stackoverflow.com/a/22051794
score: 0
answer count: 2
has body: From my homework, I need to have the user enter a number in numeric form, and convert it to the simultaneous fibonacci number from the sequence, while using recursion. My question is how can I make the sequence through an array but not store it, so the array can be the size of the number the user entered... Here's some starting code I have: import java.util.Scanner; public class ReverseUserInput1 { //a recursive method to reverse the order of user input public static void main(String[] args) { Scanner in = new Scanner(System.in); ReverseUserInput1 reverseIt = new ReverseUserInput1(); //creates new object System.out.print("Program to convert a number to a fibonacci number,"); System.out.print(" - press Enter after each number. "); System.out.println("- type \'0 or 1\' to finish the program."); System.out.print(" --Enter a number: "); int aNum = in.nextInt(); reverseIt.reverseInput(aNum); //invokes reverseInput() method } public static int reverseInput() { if(aNum == 0) { return aNum; } else if(aNum == 1) { return aNum; } else { reverseInput(); } System.out.println(aNum); } }
has answer: http://stackoverflow.com/a/22052127
has title: Determine Fibonacci Number from User Input using Recursion
has comment: http://stackoverflow.com/comment/33435827
has comment: http://stackoverflow.com/comment/33394976
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33394833
type: Question
tagged with: recursion

http://stackoverflow.com/q/22155038
tagged with: hashmap
answer count: 1
tagged with: optimization
score: 0
has answer: http://stackoverflow.com/a/22155706
has body: i've got a question. I'm making a sort of addon for a game and i need to create a data structure for store informations with this organization: Data &nbsp;&nbsp; - Player &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- items &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- item1 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- item2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - item3 &nbsp;&nbsp;- logs &nbsp;&nbsp;&nbsp;&nbsp;- log1 &nbsp;&nbsp;&nbsp;&nbsp;- log2 &nbsp;&nbsp;&nbsp;&nbsp;- log3 &nbsp;&nbsp;- Buildings &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- monuments &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- monument1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - monument2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - monument3 &nbsp; - cities &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- city1 &nbsp;&nbsp;&nbsp;&nbsp; - city2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- city3 [...] I did a complex hashmap public Save&lt;HashMap&lt;String,HashMap&lt;String,HashMap&lt;String,List&lt;String&gt;&gt;&gt;&gt;&gt; data; Where Save is public class Save&lt;T&gt; { public final T object; public Save(T object){ this.object = object; } } In this hierarchy there will be only strings and it will be loaded at start and saved in intervals of 5 minutes. My question is if there is a more confortable and manaegable(it is very closed) way to do this Thanks
has comment: http://stackoverflow.com/comment/33621024
type: UnansweredQuestion
has title: Saving hashmap structure java
tagged with: java
type: Question

http://stackoverflow.com/q/22127992
upvote count: 1
tagged with: plot
tagged with: waveform
tagged with: java
type: UnansweredQuestion
has body: I want to plot the waveform of an mp3 file (like we see in various media players). I guess the amplitude is plotted against time. I want to do this using Java. I have Googled a lot about this but did not come up with a proper solution. However, I came across something called "PCM" and "FTT" (about which I have no idea and seemingly too complex). I did get some help on another post on plotting a wav file. However, I cannot plot an mp3 file. Could you be kind enough to help me out (if possible with an actual code). Thank you !
has title: plot mp3 file as waveform in Java
tagged with: http://stackoverflow.com/tag/mp3
has comment: http://stackoverflow.com/comment/33573547
answer count: 0
downvote count: 0
score: 1
favorite count: 0
type: Question
has comment: http://stackoverflow.com/comment/33573479

http://stackoverflow.com/comment/33874947
type: AnswerComment
type: Comment
score: 1
comment on: http://stackoverflow.com/a/22246471
has text: Thank you for your reply, but I need this position to add other elements, not for onClick method

http://stackoverflow.com/q/22016978
score: 0
tagged with: java
has title: How to display messages in jsp according to class errors
has body: here's my Form Class: public ArrayList&lt;ForbesData&gt; loadData(HttpServletRequest request) throws Exception { ActionErrors errors = new ActionErrors(); ..... try { ...... } catch (NullPointerException e) { errors.add("fich", new ActionMessage("error.file.required")); } catch (IndexOutOfBoundsException e) { errors.add("crap", new ActionMessage("error.crapull.required")); } catch (InvalidFormatException e) { errors.add("exc", new ActionMessage("error.excell.required")); } Here's my ApplicationResource.properties: error.fich.required= folder doesn't exist! error.crapull.required=folder isn't crapull! error.excell.required=folder isn't excel! here's my struts-config: &lt;struts-config&gt; &lt;form-beans&gt; &lt;form-bean name="UserForm" type="net.cacib.struts.UserForm" /&gt; &lt;/form-beans&gt; &lt;action-mappings&gt; &lt;action input="/" name="UserForm" path="/userAction" scope="session" validate="true" type="net.cacib.struts.UserAction"&gt; &lt;forward name="success" path="/index.jsp" /&gt; &lt;/action&gt; &lt;action path="/Welcome" forward="/welcomeStruts.jsp" /&gt; &lt;/action-mappings&gt; &lt;message-resources parameter="/WEB-INF/ApplicationResource" /&gt; in my jsp: &lt;html:errors property="crap" /&gt; &lt;html:errors property="fich" /&gt; &lt;html:errors property="exc" /&gt; what I want to do is display error messages to the user each time an exception is thrown. Do you have any idea what I need to change my code to achieve this goal. thank you
has answer: http://stackoverflow.com/a/22017105
tagged with: jsp
type: UnansweredQuestion
tagged with: struts
type: Question
tagged with: jsp-tags
answer count: 1

http://stackoverflow.com/comment/33523483
type: QuestionComment
comment on: http://stackoverflow.com/q/22100555
has text: @Durandal Yes I get that but what I dont know is how do I do that or what is an example of what I would put in there
score: 0
type: Comment

http://stackoverflow.com/comment/33536034
type: Comment
score: 0
comment on: http://stackoverflow.com/q/22107359
type: QuestionComment
has text: Why is this tagged `java` since this is obviously C/C++?

http://stackoverflow.com/comment/33588144
type: Comment
comment on: http://stackoverflow.com/a/22135919
has text: I knew this, however I was looking to automate the start/stop time, not the total time. Sorry if this was not clear.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33502482
comment on: http://stackoverflow.com/q/22089078
has text: You could use regular expressions to accomplish this task. Check http://en.wikipedia.org/wiki/Regular_expression.
type: Comment
type: QuestionComment
score: 1

http://stackoverflow.com/q/22078687
has comment: http://stackoverflow.com/comment/33483924
favorite count: 0
has comment: http://stackoverflow.com/comment/33484063
has title: Print digits in decreasing fashion and then print factorials for number up to n
has comment: http://stackoverflow.com/comment/33485347
has comment: http://stackoverflow.com/comment/33485547
type: AnsweredQuestion
tagged with: java
has body: I want to take an integer n from the user and use it to print n-0, n-1, n-2, and so on down to zero (one number per line) and then back from from 0! to n!. Recursively. But I'm pretty much totally lost as my understanding of recursion is shoddy at best (being generous). Here's my meager code thus far: static void p(int n) { if (n == 0) { System.out.println(n); } else { System.out.println(n); p(n-1); } } Thanks for reading!
type: Question
tagged with: recursion
has comment: http://stackoverflow.com/comment/33484295
has answer: http://stackoverflow.com/a/22078798
accepted answer: http://stackoverflow.com/a/22078798
has comment: http://stackoverflow.com/comment/33483973
has comment: http://stackoverflow.com/comment/33484005
upvote count: 3
score: 0
downvote count: 3
has comment: http://stackoverflow.com/comment/33484002
answer count: 1

http://stackoverflow.com/comment/33608114
comment on: http://stackoverflow.com/q/22148159
has text: I highly advise you to use buttons instead of textfields. Then using a field variable you can auto populate whether it was X turn or O turn. As far as the second class, you will need to have a reference to the first class. What you can do is give it a class variable such as `logic.game = game`. Then you can use logic.game anywhere in logic class.
type: Comment
type: QuestionComment
score: 2

http://stackoverflow.com/a/22077454
has comment: http://stackoverflow.com/comment/33483934
has comment: http://stackoverflow.com/comment/33482098
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33484393
has comment: http://stackoverflow.com/comment/33482726
has body: Try this : public static void main(String[] args) { FlightTickets ticket = new FlightTickets("Caledonia", "South &lt;bKorea", "10:00", "5:00", "15000"); ticket.v.add(ticket); } Remember that you cannot access a non-static variable from a static method. BTW, as the Vector class is a generic type it's better to define 'v' like this : Vector&lt;TestClass&gt; v = new Vector&lt;TestClass&gt;(); As a response to your comment I provide a rather complete implementation for more details: import java.util.Iterator; import java.util.Vector; public class TestClass { String Origin; String destination; String departure; String arrival; String amount; Vector&lt;TestClass&gt; v = new Vector&lt;TestClass&gt;(); public TestClass(String Origin, String destination, String departure, String arrival, String amount) { this.Origin = Origin; this.destination = destination; this.departure = departure; this.arrival = arrival; this.amount = amount; } public static void main(String[] args){ TestClass ticket = new TestClass("Caledonia", "South Korea", "10:00", "5:00", "15000"); ticket.v.add(ticket); Iterator&lt;TestClass&gt; it = ticket.v.iterator(); while(it.hasNext()) System.out.println(it.next().Origin); } }
score: 0
has comment: http://stackoverflow.com/comment/33482859
has comment: http://stackoverflow.com/comment/33484520
accepted answer of: http://stackoverflow.com/q/22077253
type: Answer
answers question: http://stackoverflow.com/q/22077253
has comment: http://stackoverflow.com/comment/33483613
has comment: http://stackoverflow.com/comment/33483428
has comment: http://stackoverflow.com/comment/33483826
has comment: http://stackoverflow.com/comment/33482939

http://stackoverflow.com/comment/33381048
type: QuestionComment
has text: I was actually asking in general. I came across this question when I was referring the docs: [Byte Streams](http://docs.oracle.com/javase/tutorial/essential/io/bytestreams.html)
comment on: http://stackoverflow.com/q/22021140
score: 0
type: Comment

http://stackoverflow.com/q/22113962
downvote count: 0
has comment: http://stackoverflow.com/comment/33547481
type: UnansweredQuestion
tagged with: stream
score: 3
has comment: http://stackoverflow.com/comment/33547514
has comment: http://stackoverflow.com/comment/33547389
tagged with: java
has title: ObjectInputStream does not work with Sockets
type: Question
answer count: 1
has body: a few days ago, I started to code a little multiplayer game, in wich I use ObjectInputStreams and ObjectOutputStreams in order to exchange data with a server. But for some reason, the server does not recieve anything. So I searched for some help, but everything I found was, that I have to flush the ObjectOutputStream. Of course I did this, but it is not the solution for my problem. So I wrote a tiny test application, that does the same as my game. But there is still the same problem: The InputStream does not recieve anything. So here's my code for the test app: Server application: try { ServerSocket srvr = new ServerSocket(12975); Socket client = srvr.accept(); ObjectInputStream in = new ObjectInputStream(client.getInputStream()); ObjectOutputStream out = new ObjectOutputStream(client.getOutputStream()); out.flush(); System.out.println("server ready!"); String line = ""; while(!line.equalsIgnoreCase("exit")){ while(in.available() &lt;= 0){} line = in.readObject().toString(); System.out.println("&gt;&gt;&gt; recieved: " + line); } client.close(); srvr.close(); System.exit(0); } catch (IOException e) { System.err.println("ERROR: " + e.getMessage()); e.printStackTrace(); System.exit(1); } catch (ClassNotFoundException e) { e.printStackTrace(); } And here's the client application: try { Socket client = new Socket("localhost", 12975); ObjectOutputStream out = new ObjectOutputStream(client.getOutputStream()); out.flush(); ObjectInputStream in = new ObjectInputStream(client.getInputStream()); System.out.println("client ready!"); BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); String line = ""; while(!line.equalsIgnoreCase("exit")){ System.out.print("&gt; "); line = input.readLine(); out.writeObject(line); out.flush(); } client.close(); System.exit(0); } catch (IOException e) { System.err.println("ERROR: " + e.getMessage()); e.printStackTrace(); System.exit(1); } I tried to do this to both sides: Server->Client and Client->Server, but both Socke…
has answer: http://stackoverflow.com/a/22114197
favorite count: 0
linked to: http://stackoverflow.com/q/22114510
upvote count: 3
tagged with: sockets
tagged with: input

http://stackoverflow.com/a/22019798
answers question: http://stackoverflow.com/q/22019624
type: Answer
score: 1
upvote count: 1
has body: A NullPointerException triggered by your write method is likely to be caused by a null argument of type Item, specifically on: item.getFileName(); --> invoking method of null Object. It could also be caused by: new File(invFilename) --> initializing new File with null argument (if item is not null, but item.getFileName() is). ... etc. Nothing to do with the fact that Item is an abstract class. Note As mentioned by others in the comments, String contents comparison is done by equals, not the == operator.
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22019624
type: AcceptedAnswer

http://stackoverflow.com/comment/33630276
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22159699
score: 0
has text: Does it work if you use the default settings, but move your Java files into `src/main/groovy`?

http://stackoverflow.com/q/22149683
type: Question
tagged with: dependency-injection
tagged with: guice
has answer: http://stackoverflow.com/a/22196592
upvote count: 1
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33612302
has body: I saw this line in Nexus OSS code ... @Inject public ReleaseRemoverTask( final ReleaseRemover releaseRemover ) { this.releaseRemover = checkNotNull( releaseRemover ); } the above is found in https://github.com/sonatype/nexus-oss/blob/master/components/nexus-core/src/main/java/org/sonatype/nexus/maven/tasks/ReleaseRemoverTask.java But ReleaseRemover.java is an interface . There is no use in interface here , so only the implementation should be passed during runtime ..This only makes sense .. So I confirmed it by debugging , that the implementation is called .The implementation class was DefaultReleaseRemover.java . To support my argument I wrote a plugin for nexus and I wrote an implementation for ReleaseRemover . Even that was picked up ... How is this done ? Internally they are using Google Guice .. Is Guice doing this job of passing the implementations inside this function ? Is this the property of frameworks like Google Guice ? If all implementations are passed like this , can I prevent an implementation from being passed ?
tagged with: nexus
type: UnansweredQuestion
has title: Will all implementations be passed automatically ? Who does this?
tagged with: inject
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33611399
tagged with: java

http://stackoverflow.com/q/22084424
favorite count: 0
tagged with: exponential
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
has title: Trying to estimate e^x with loops
type: Question
accepted answer: http://stackoverflow.com/a/22084484
tagged with: for-loop
has answer: http://stackoverflow.com/a/22084484
tagged with: while-loop
upvote count: 1
has comment: http://stackoverflow.com/comment/33494466
answer count: 1
has body: I've been staring at this for a few hours, and I can't seem to figure out why my outputs are coming out too small. My outputs do what you'd expect, level off, they just level off to the wrong value. I'm very certain the error lies within the while loop of my main method, or the nested for loop, but I'll go ahead and post everything incase it is hiding somewhere else. The purpose of this program is to estimate the value of e^x by summing 1 + x + x^2/2! + x^3/3! + ... + x^n/n!. It needs to output the sum for n take to each value between 1 and 10, along with the values of 50 and 100. So 12 outputs all together. import java.io.*; import java.text.DecimalFormat; public class Ch3Ex7 { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static double x = 0; static DecimalFormat df = new DecimalFormat("0.00"); public static void main (String[] args) { mainMenu(); int counter = 1; double heldx = x; double holderx = 0; double denom = 1; double printx = 0; double f = 1; while (counter != 100) { x = x*heldx; denom++; for(int i = 2; i&lt;=denom; i++) { f = f*i; } holderx = holderx + x/f; if ((counter &gt; 0 &amp;&amp; counter &lt;= 10) || (counter == 50)) { printx = 1 + heldx + holderx; System.out.println(df.format(printx)); } counter++; } System.out.println(df.format(printx)); f = 0; x = 0; counter = 1; denom = 1; callMain(); } public static void mainMenu() { try { System.out.println("Requesting user input, press 0 to leave"); x = Integer.parseInt(br.readLine()); space(); if (x == 0) { System.exit(0); } } catch(IOException ioe) {} } public static void callMain() { String[] x = {"A" , "B"}; Ch3Ex7.main(x); } public static void space() { System.out.println(); } }

http://stackoverflow.com/comment/33492403
has text: For some reason , only first IP adddress is executing and loop is not executing other IP addresses, am i incrementing the variable at the right place?
comment on: http://stackoverflow.com/a/22061645
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33395347
has text: Do you have root access on the device ?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22028729
score: 0

http://stackoverflow.com/comment/33617324
type: Comment
has text: I think this is a nice solution and a bit overlooked :)
score: 1
comment on: http://stackoverflow.com/a/22152923
type: AnswerComment

http://stackoverflow.com/comment/33511811
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22093619
score: 1
has text: It's not free, is it? This is out of the box feature that should work, I'd prefer at first try to work with it

http://stackoverflow.com/comment/33624200
has text: Sounds like it could be your best chance.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22108605
type: Comment

spring
tags question: http://stackoverflow.com/q/22065501
tags question: http://stackoverflow.com/q/22024016
tags question: http://stackoverflow.com/q/22035553
tags question: http://stackoverflow.com/q/22080807
tags question: http://stackoverflow.com/q/22048511
tags question: http://stackoverflow.com/q/22043335
tags question: http://stackoverflow.com/q/22050277
tags question: http://stackoverflow.com/q/22056189
tags question: http://stackoverflow.com/q/22061324
tags question: http://stackoverflow.com/q/22130432
tags question: http://stackoverflow.com/q/22121918
tags question: http://stackoverflow.com/q/22143742
tags question: http://stackoverflow.com/q/22012625
tags question: http://stackoverflow.com/q/22037725
tags question: http://stackoverflow.com/q/22138185
tags question: http://stackoverflow.com/q/22079080
tags question: http://stackoverflow.com/q/22062311
tags question: http://stackoverflow.com/q/22077206
tags question: http://stackoverflow.com/q/22011767
tags question: http://stackoverflow.com/q/22097646
tags question: http://stackoverflow.com/q/22128150
tags question: http://stackoverflow.com/q/22006829
tags question: http://stackoverflow.com/q/22093018
tags question: http://stackoverflow.com/q/22168620
tags question: http://stackoverflow.com/q/22060972
tags question: http://stackoverflow.com/q/22093149
tags question: http://stackoverflow.com/q/22154337
tags question: http://stackoverflow.com/q/22028115
tags question: http://stackoverflow.com/q/22112653
tags question: http://stackoverflow.com/q/22087259
tags question: http://stackoverflow.com/q/22157221
tags question: http://stackoverflow.com/q/22017463
tags question: http://stackoverflow.com/q/22081093
tags question: http://stackoverflow.com/q/22069638
tags question: http://stackoverflow.com/q/22168170
tags question: http://stackoverflow.com/q/22167945
tags question: http://stackoverflow.com/q/22072100
tags question: http://stackoverflow.com/q/22027274
tags question: http://stackoverflow.com/q/22039173
tags question: http://stackoverflow.com/q/22081193
tags question: http://stackoverflow.com/q/22068711
tags question: http://stackoverflow.com/q/22130667
tags question: http://stackoverflow.com/q/22163092
tags question: http://stackoverflow.com/q/22032489
tags question: http://stackoverflow.com/q/22036040
tags question: http://stackoverflow.com/q/22010619
type: Tag
tags question: http://stackoverflow.com/q/22010793
tags question: http://stackoverflow.com/q/22059898
tags question: http://stackoverflow.com/q/22103483
tags question: http://stackoverflow.com/q/22030738
tags question: http://stackoverflow.com/q/22041026
tags question: http://stackoverflow.com/q/22064094
tags question: http://stackoverflow.com/q/22107033
tags question: http://stackoverflow.com/q/22034044
tags question: http://stackoverflow.com/q/22074230
tags question: http://stackoverflow.com/q/22038265
tags question: http://stackoverflow.com/q/22043499
tags question: http://stackoverflow.com/q/22073597
tags question: http://stackoverflow.com/q/22066484
tags question: http://stackoverflow.com/q/22155722
tags question: http://stackoverflow.com/q/22006599
tags question: http://stackoverflow.com/q/22051593
tags question: http://stackoverflow.com/q/22087797
tags question: http://stackoverflow.com/q/22070627
tags question: http://stackoverflow.com/q/22080489
tags question: http://stackoverflow.com/q/22124769
tags question: http://stackoverflow.com/q/22102119
tags question: http://stackoverflow.com/q/22156696
tags question: http://stackoverflow.com/q/22078568
tags question: http://stackoverflow.com/q/22014123
tags question: http://stackoverflow.com/q/22167662
tags question: http://stackoverflow.com/q/22164871
tags question: http://stackoverflow.com/q/22118975
tags question: http://stackoverflow.com/q/22089861
tags question: http://stackoverflow.com/q/22148197
tags question: http://stackoverflow.com/q/22152859
tags question: http://stackoverflow.com/q/22031119
tags question: http://stackoverflow.com/q/22042855
tags question: http://stackoverflow.com/q/22155328

http://stackoverflow.com/comment/33558322
type: QuestionComment
score: 0
has text: @LeosLiterak: they most likely have two columns of Strings -- a color name followed by a String representation of a color int hex String. i.e., `Red 0xffff0000`. This is my guess anyway.
comment on: http://stackoverflow.com/q/22119950
type: Comment

http://stackoverflow.com/comment/33378156
type: Comment
has text: And in addition to using `==` to compare strings being wrong, it pretty much guarantees no item will be created, hence it'll be null, hence an NPE. You have a path through your code where you'll always try to write a null item. Check it for null, etc.
type: QuestionComment
comment on: http://stackoverflow.com/q/22019624
score: 0

http://stackoverflow.com/comment/33558665
has text: You absolutely nailed it with the reason the radio buttons were not working. UGH! Now I can go back trying to get a hashmap working on this bad boy.
comment on: http://stackoverflow.com/a/22120004
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/q/22067696
upvote count: 5
has answer: http://stackoverflow.com/a/35972089
answer count: 5
tagged with: onactivityresult
type: UnansweredQuestion
tagged with: android
linked to: http://stackoverflow.com/q/12714701
has comment: http://stackoverflow.com/comment/33463601
downvote count: 0
tagged with: java
linked to: http://stackoverflow.com/q/3750903
has title: using onActivityResult in Fragments
has comment: http://stackoverflow.com/comment/33464083
has answer: http://stackoverflow.com/a/22068234
type: Question
has answer: http://stackoverflow.com/a/22067848
has body: Hi in fragment I want to pick a phone number from contacts and inset it into EditText but its not working in fragment I use it in activity and it works. Please could you help me how I should change it&lt; thanks public class Encrypt extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.encrypt, null); phoneNumberDisplay = (EditText) v.findViewById(R.id.editTextPhoneNumber); contactsButton=(Button)v.findViewById(R.id.buttonContacts); contactsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if(v==contactsButton){ Intent intent=new Intent(Intent.ACTION_PICK,Contacts.CONTENT_URI); intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE); startActivityForResult(intent, 1); } } }); @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { Uri ur = data.getData(); Cursor c = managedQuery(ur, null, null, null, null); if (c.moveToFirst()) { String s = c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); phoneNumberDisplay.setText(s); } } } return v; } errors: RESULT_OK cannot be resolved to a variable The method managedQuery(Uri, null, null, null, null) is undefined for the type new View.OnClickListener(){}
has answer: http://stackoverflow.com/a/22068214
score: 5
has comment: http://stackoverflow.com/comment/33463117
linked to: http://stackoverflow.com/q/6147884
has answer: http://stackoverflow.com/a/22067843
favorite count: 0

http://stackoverflow.com/comment/33452031
has text: Yes in case of null. I have following code of main class which gives me error in eclipse. public class MainClass { public static void main(String args[]) { SubClass s = new SubClass(null); } }
comment on: http://stackoverflow.com/q/22060994
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22053689
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/22057042
score: 0
has title: how to set parameters to server from android application?
has comment: http://stackoverflow.com/comment/33445234
tagged with: android
has answer: http://stackoverflow.com/a/22056377
has body: I have the following code to connect from my android application to zappos api server and search for some stuff. But It either returns error 404 or We are unable to process the request from the input feilds given. When I execute the same query it works on the web browser. The query is: http://api.zappos.com/Search&amp;term=boots&amp;key=&lt;my_key_inserted_here&gt; Code: HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://api.zappos.com/Search"); NameValuePair keypair = new BasicNameValuePair("key",KEY); NameValuePair termpair = new BasicNameValuePair("term",data); List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(2); params.add(keypair); params.add(termpair); post.setEntity(new UrlEncodedFormEntity(params)); HttpResponse response = client.execute(post); String str; StringBuilder sb = new StringBuilder(); HttpEntity entity =response.getEntity(); if (entity != null) { DataInputStream in = new DataInputStream(entity.getContent()); while (( str = in.readLine()) != null){ sb.append(str); } in.close(); } Log.i("serverInterface","response from server is :"+sb.toString()); What am I doing wrong?
type: UnansweredQuestion
tagged with: request
tagged with: http
has comment: http://stackoverflow.com/comment/33439718
has comment: http://stackoverflow.com/comment/33439588
tagged with: java
linked to: http://stackoverflow.com/q/5769549
tagged with: response

http://stackoverflow.com/comment/33528260
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22103195
score: 0
has text: No Chris, It is serial driver exception Thrown by interface CommonUsbSerialDriver

http://stackoverflow.com/q/22140589
has title: Unable to get the card index
type: Question
has answer: http://stackoverflow.com/a/23897100
score: 0
answer count: 1
tagged with: google-glass
type: UnansweredQuestion
has body: I am trying to get the index of the card which is active on the screen with this code. import java.util.ArrayList; import java.util.Arrays; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import com.google.android.glass.app.Card; import com.google.android.glass.touchpad.Gesture; import com.google.android.glass.touchpad.GestureDetector; import com.google.android.glass.widget.CardScrollAdapter; import com.google.android.glass.widget.CardScrollView; import com.google.api.services.mirror.model.TimelineItem; public class MainActivity extends Activity { private GestureDetector mGestureDetector; String identifysource; int cardindex; private static ArrayList&lt;Card&gt; sourceCard = new ArrayList&lt;Card&gt;(); private ArrayList&lt;String&gt; sourceText = new ArrayList&lt;String&gt;(Arrays.asList("PCWorld", "TechCrunch")); protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); for(int i=0;i&lt;sourceText.size();i++) { System.out.println("whats up"); Card card = new Card(this); identifysource=sourceText.get(i); card.setText(identifysource); sourceCard.add(card); } System.out.println(this); mGestureDetector = createGestureDetector(this); CardScrollView csvCardsView = new CardScrollView(this); csaAdapter cvAdapter = new csaAdapter(); csvCardsView.setAdapter(cvAdapter); csvCardsView.activate(); setContentView(csvCardsView); cardindex=csvCardsView.getSelectedItemPosition(); } private static class csaAdapter extends CardScrollAdapter { @Override public int findIdPosition(Object id) { return -1; } @Override public int findItemPosition(Object item) { return sourceCard.indexOf(item); } @Override public int getCount() { return sourceCard.size(); } @Override public Object getItem(int position) { return sourceCard.get(position); } @Override …
tagged with: java

http://stackoverflow.com/comment/33499221
comment on: http://stackoverflow.com/q/22086827
score: 1
type: QuestionComment
type: Comment
has text: This sounds like a job for a Canvas and bufferstrategy. This way your logic and draw code can operate on the same thread.

multithreading
tags question: http://stackoverflow.com/q/22077695
tags question: http://stackoverflow.com/q/22058662
tags question: http://stackoverflow.com/q/22143884
tags question: http://stackoverflow.com/q/22163922
tags question: http://stackoverflow.com/q/22031386
tags question: http://stackoverflow.com/q/22149276
tags question: http://stackoverflow.com/q/22047330
tags question: http://stackoverflow.com/q/22143215
tags question: http://stackoverflow.com/q/22124538
type: Tag
tags question: http://stackoverflow.com/q/22095983
tags question: http://stackoverflow.com/q/22125055
tags question: http://stackoverflow.com/q/22026616
tags question: http://stackoverflow.com/q/22162738
tags question: http://stackoverflow.com/q/22028115
tags question: http://stackoverflow.com/q/22098982
tags question: http://stackoverflow.com/q/22054867
tags question: http://stackoverflow.com/q/22013353
tags question: http://stackoverflow.com/q/22048535
tags question: http://stackoverflow.com/q/22087609
tags question: http://stackoverflow.com/q/22149909
tags question: http://stackoverflow.com/q/22102703
tags question: http://stackoverflow.com/q/22155957
tags question: http://stackoverflow.com/q/22168098
tags question: http://stackoverflow.com/q/22104097
tags question: http://stackoverflow.com/q/22047209
tags question: http://stackoverflow.com/q/22117689
tags question: http://stackoverflow.com/q/22106154
tags question: http://stackoverflow.com/q/22036531
tags question: http://stackoverflow.com/q/22039466
tags question: http://stackoverflow.com/q/22051438
tags question: http://stackoverflow.com/q/22112469
tags question: http://stackoverflow.com/q/22055829
tags question: http://stackoverflow.com/q/22133214
tags question: http://stackoverflow.com/q/22070894
tags question: http://stackoverflow.com/q/22116479
tags question: http://stackoverflow.com/q/22007644
tags question: http://stackoverflow.com/q/22079080
tags question: http://stackoverflow.com/q/22110205
tags question: http://stackoverflow.com/q/22066469
tags question: http://stackoverflow.com/q/22008803
tags question: http://stackoverflow.com/q/22156155
tags question: http://stackoverflow.com/q/22101118
tags question: http://stackoverflow.com/q/22016572
tags question: http://stackoverflow.com/q/22020915
tags question: http://stackoverflow.com/q/22049289
tags question: http://stackoverflow.com/q/22023768
tags question: http://stackoverflow.com/q/22129955
tags question: http://stackoverflow.com/q/22037211
tags question: http://stackoverflow.com/q/22067533
tags question: http://stackoverflow.com/q/22005859
tags question: http://stackoverflow.com/q/22155671
tags question: http://stackoverflow.com/q/22095660
tags question: http://stackoverflow.com/q/22030630
tags question: http://stackoverflow.com/q/22109978
tags question: http://stackoverflow.com/q/22157813
tags question: http://stackoverflow.com/q/22093918
tags question: http://stackoverflow.com/q/22102828
tags question: http://stackoverflow.com/q/22058092
tags question: http://stackoverflow.com/q/22087212
tags question: http://stackoverflow.com/q/22068772
tags question: http://stackoverflow.com/q/22063268
tags question: http://stackoverflow.com/q/22151347
tags question: http://stackoverflow.com/q/22065837
tags question: http://stackoverflow.com/q/22123608
tags question: http://stackoverflow.com/q/22101371
tags question: http://stackoverflow.com/q/22012067
tags question: http://stackoverflow.com/q/22146899
tags question: http://stackoverflow.com/q/22063249
tags question: http://stackoverflow.com/q/22147265
tags question: http://stackoverflow.com/q/22147861
tags question: http://stackoverflow.com/q/22058151
tags question: http://stackoverflow.com/q/22053125
tags question: http://stackoverflow.com/q/22106428
tags question: http://stackoverflow.com/q/22027496
tags question: http://stackoverflow.com/q/22036788
tags question: http://stackoverflow.com/q/22069334
tags question: http://stackoverflow.com/q/22144038
tags question: http://stackoverflow.com/q/22048651
tags question: http://stackoverflow.com/q/22065841

http://stackoverflow.com/a/22112524
score: 15
has comment: http://stackoverflow.com/comment/33545783
has comment: http://stackoverflow.com/comment/33545607
type: Answer
accepted answer of: http://stackoverflow.com/q/22112469
has comment: http://stackoverflow.com/comment/102572511
has comment: http://stackoverflow.com/comment/119653819
has body: It's very simple - in essence the Threads sleep, waiting to be woken by a task - they run that task and then sleep again. public static void main(final String[] args) throws Exception { final BlockingQueue&lt;Runnable&gt; blockingQueue = new LinkedBlockingDeque&lt;&gt;(); final Thread t = new Thread(new Runnable() { @Override public void run() { while (true) { try { blockingQueue.take().run(); } catch (InterruptedException ex) { return; } } } }); t.start(); blockingQueue.add(new Runnable() { @Override public void run() { System.out.println("Task 1"); } }); blockingQueue.add(new Runnable() { @Override public void run() { System.out.println("Task 2"); } }); } The BlockingQueue will block a Thread while it is empty. When I add an item, and Thread(s) currently blocked are awoken and one will take the task (LinkedBlockingDeque is thread safe). When the Thread is done with the task it goes back to sleep. The JavaDoc for ThreadPoolExecutor describes the logic in detail. All of the constructors for ThreadPoolExecutor take a BlockingQueue&lt;Runnable&gt; - this should give you a hint as so how the logic works. NB: This is not the same as busy waiting. A BlockingQueue uses wait and notify to suspend and wake Threads, this means that the Threads in the pool are not doing any work when they are not processing tasks. A busy wait based approach would not work because the Threads would block up all the CPU cores with their polling not allowing the program to proceed (or at least severely impairing it).
has comment: http://stackoverflow.com/comment/102570848
upvote count: 15
has comment: http://stackoverflow.com/comment/119648118
answers question: http://stackoverflow.com/q/22112469
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/102570876

http://stackoverflow.com/comment/33685645
has text: Thank you so much for your help. Now it's clear to me if what was the missing piece after i followed the steps in your edited answer. I forgot to add classpath in my directory which would produce "could not find or load main class". It took me 2 days to solved this problem of not figuring out if what was the root caused. If only I could give you +10 for your effort in helping me. thanks again.=)
type: Comment
comment on: http://stackoverflow.com/a/22161621
score: 1
type: AnswerComment

http://stackoverflow.com/comment/33377887
comment on: http://stackoverflow.com/q/22019069
type: Comment
type: QuestionComment
has text: Well, you don't need a server or another machine to develop a multiplayer application. You can have 3 JVMs on your local machine that act respectively as Player 1, Server and Player 2.
score: 0

http://stackoverflow.com/comment/33532864
score: 0
type: Comment
type: QuestionComment
has text: put a log inside the `if` statement I bet it never resolves to `true`
comment on: http://stackoverflow.com/q/22105203

http://stackoverflow.com/q/22090815
tagged with: deserialization
score: 1
linked to: http://stackoverflow.com/q/11106053
favorite count: 0
tagged with: serialization
type: Question
upvote count: 1
has comment: http://stackoverflow.com/comment/33505847
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has comment: http://stackoverflow.com/comment/33506344
answer count: 0
type: UnansweredQuestion
tagged with: jackson
has comment: http://stackoverflow.com/comment/33505638
has title: Custom Jackson Serializer for Top Level Map Type
has body: I have a "java" map that I would like to serialize with my own custom serialization logic. Note that java map itself is the top-level object. I want to output it as a collection rather than map only for above parameterized map type. All other map types should work as default (i.e. MyCustomObject could have Map which should work as usual). I want to omit certain key/value from serialization based on some property value inside MyCustomObject. MyCustomObject is already given to me and is not in my control. Is there anyway to achieve this in jackson? Also, what about deserialization - in this case, I will want a map back rather than collection.
downvote count: 0

http://stackoverflow.com/comment/33372651
has text: I can put the entire code in if you would like to see. Editing now.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22016586

http://stackoverflow.com/q/22061723
has answer: http://stackoverflow.com/a/22062471
favorite count: 0
type: Question
tagged with: android
linked to: http://stackoverflow.com/q/5465375
linked to: http://stackoverflow.com/q/2149680
tagged with: regex
upvote count: 98
duplicate of: http://stackoverflow.com/q/2149680
score: 97
has comment: http://stackoverflow.com/comment/139689205
has comment: http://stackoverflow.com/comment/33453306
downvote count: 1
has body: what is the regex for the date format yyyy-mm-dd? I want to validate the email from edittext and check if it matches the regex.
has answer: http://stackoverflow.com/a/22061800
tagged with: java
has answer: http://stackoverflow.com/a/22061799
type: UnansweredQuestion
tagged with: date
has comment: http://stackoverflow.com/comment/33453028
has answer: http://stackoverflow.com/a/22061879
answer count: 4
tagged with: validation
has title: Regex date validation for yyyy-mm-dd

http://stackoverflow.com/q/22034250
upvote count: 1
has answer: http://stackoverflow.com/a/26741774
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/22034626
linked to: http://stackoverflow.com/q/109383
tagged with: java
has comment: http://stackoverflow.com/comment/33405199
has answer: http://stackoverflow.com/a/22034379
has title: Java program to find the character that appears the most number of times in a String?
answer count: 8
has answer: http://stackoverflow.com/a/22035109
tagged with: for-loop
tagged with: arrays
has body: So here's the code I've got so far... import java.util.Scanner; class count{ public static void main(String args[]){ Scanner s=new Scanner(System.in); System.out.println("Enter a string"); String sent=s.nextLine(); int len = sent.length(); int arr[]=new int[len]; int count=1; char ch[] = new char[len]; for(int i = 0; i &lt;= len-1; i ++) { ch[i] = sent.charAt(i); } for(int j= 0;j&lt;=len-1;j++){ for(int k=0;k&lt;=len-1;k++){ if(ch[j]==ch[k]){ arr[j]= count++; } } } int max=arr[0]; for(int z=1;z&lt;=len-1;z++){ if(count&gt;max) max=count; } System.out.println(max); System.out.println("The character that appears the most number of times is " +arr[max]); } } I get count to display the number of times each character appears in the string, I'm not able to compare it with the rest of the elements in the array. The number of appearances is stored in array 'arr[]' how do I find the largest integer in this array? And Also, how do I display the character that has appeared the maximum number of times? The logic of the code isn't working after, int max=arr[0]; Any ideas as to what to do?
tagged with: string
has answer: http://stackoverflow.com/a/22105390
favorite count: 0
tagged with: logic
has answer: http://stackoverflow.com/a/22035061
score: 0
has answer: http://stackoverflow.com/a/22034527
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22034332

http://stackoverflow.com/q/22005940
has title: Heap,Non heap and stack ..intricacies of garbage collection
has answer: http://stackoverflow.com/a/22006170
possible better answer: http://stackoverflow.com/a/22006390
type: AnsweredQuestion
tagged with: java
tagged with: garbage-collection
type: Question
has comment: http://stackoverflow.com/comment/33354325
has body: I have been going through the garbage collection in java(jdk 6 hot spot JVM).I have few questions which I hope the community will help me to resolve. What I understand: 1)Heap is divided into a)Young generation -Eden and Survivor :New objects and arrays are created into the young generation.Minor garbage collection will operate in the young generation. Objects, that are still alive, will be moved from the eden space to the survivor space. b)Old generation/Tenured Generation:Major collection will move the still alive objects from young generation to old generation. 2)Non Heap is divided into a)Code Cache b)Perm generation. What I want to know: 1)what if survivor gets full..how will minor garbage collection work. 2)When and how is the perm generation garbage collected. 3)Also what happens to the stack..where is it stored or residing?How is its size controlled?
tagged with: performance
accepted answer: http://stackoverflow.com/a/22006170
has answer: http://stackoverflow.com/a/22653747
score: 4
upvote count: 4
answer count: 3
tagged with: jvm-hotspot
downvote count: 0
has comment: http://stackoverflow.com/comment/33354084
favorite count: 0
has answer: http://stackoverflow.com/a/22006390

http://stackoverflow.com/comment/33354494
type: Comment
score: 0
has text: thanks for replying... for pt 2 unloaded of classes will happen only if the application is undeployed?Am I right ?I was checking in one of my application where in perm genration graph captured by jconsole is zigzag kind of graph...how do you explain that...can it be because of string interns which also reside in perm gen
type: AnswerComment
comment on: http://stackoverflow.com/a/22006170

http://stackoverflow.com/comment/33385023
type: AnswerComment
score: 0
type: Comment
has text: Haha, yeah I agree, she is a bit lazy about stuff like that, but I know myself not to do it, I like things neat and correct.
comment on: http://stackoverflow.com/a/22022924

http://stackoverflow.com/q/22044486
tagged with: java
has body: I currently use this class to put text into a 'log' JTextArea: public void appendOutput(String output) { textPane.setText(textPane.getText() + "\n " + output); } This works pretty well except for the fact that a text wrapping JTextArea will cut words in half. Is there a good/easy fix for this?
accepted answer: http://stackoverflow.com/a/22044552
type: AnsweredQuestion
answer count: 1
type: Question
tagged with: word-wrap
has answer: http://stackoverflow.com/a/22044552
score: 0
has title: Propper JTextArea Text Wrappping
tagged with: swing
tagged with: jtextarea

http://stackoverflow.com/comment/33586531
comment on: http://stackoverflow.com/a/22135126
score: 0
type: AnswerComment
type: Comment
has text: @EJP: A function is defined as mapping from a single input (the preimage) to a single output (the image). The OP links to the Wikipedia article, which you seem to be quoting from, but you're quoting rather selectively; the very first sentence says that "each input is related to exactly one output". (The article is inconsistent about this, for the simple reason that mathematicians are flexible about the term "function" and let context imply the generalization being used; but the basic definition implies one input and one output, and both can be generalized.)

http://stackoverflow.com/comment/33596867
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22141582
has text: Yes, as simple as that...

http://stackoverflow.com/q/22078516
accepted answer: http://stackoverflow.com/a/22091617
tagged with: amazon-s3
has body: I am using the following code to download an s3. This code is from my Android app. public void downloadFile(String baseDir, String imageName) throws IOException { this.s3Client = new AmazonS3Client(new BasicAWSCredentials(accessKey,secretKey)); String s3key = baseDir + "/" + imageName ; Log.d(tag, "downloading S3 file with key = " + s3key); S3ObjectInputStream content = null; try { content = s3Client.getObject(bucketName,s3key).getObjectContent(); } catch(RuntimeException ex) { Log.e(tag, "error while downloding S3 file with key = " + s3key ,ex); throw new IOException(ex); } When I execute this code I get the following exception: 02-28 00:48:53.589: D/s3dao(4078): downloading S3 file with key = level1/2_3.jpg 02-28 00:48:54.800: I/AmazonHttpClient(4078): Unable to execute HTTP request: fourpicstest.s3.amazonaws.com 02-28 00:48:54.800: I/AmazonHttpClient(4078): java.net.UnknownHostException: fourpicstest.s3.amazonaws.com 02-28 00:48:54.800: I/AmazonHttpClient(4078): at java.net.InetAddress.lookupHostByName(InetAddress.java:512) 02-28 00:48:54.800: I/AmazonHttpClient(4078): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:300) 02-28 00:48:54.800: I/AmazonHttpClient(4078): at java.net.InetAddress.getAllByName(InetAddress.java:259) 02-28 00:48:54.800: I/AmazonHttpClient(4078): at com.amazonaws.org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45) 02-28 00:48:54.800: I/AmazonHttpClient(4078): at com.amazonaws.org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:278) 02-28 00:48:54.800: I/AmazonHttpClient(4078): at com.amazonaws.org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:162) 02-28 00:48:54.800: I/AmazonHttpClient(4078): at com.amazonaws.org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294) 02-28 00:48:54.800: I/AmazonHttpClient(4078): at com.amazonaws.org.apa…
has comment: http://stackoverflow.com/comment/33503893
tagged with: java
upvote count: 1
answer count: 1
has comment: http://stackoverflow.com/comment/33483904
tagged with: amazon-web-services
has comment: http://stackoverflow.com/comment/33483905
has answer: http://stackoverflow.com/a/22091617
type: AnsweredQuestion
downvote count: 0
has comment: http://stackoverflow.com/comment/33485039
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33483923
linked to: http://stackoverflow.com/q/9723169
type: Question
tagged with: android
has title: java.net.UnknownHostException for bucketname.s3.amazonaws.com
has comment: http://stackoverflow.com/comment/33484368
has comment: http://stackoverflow.com/comment/33484076

http://stackoverflow.com/a/22162451
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33637713
has comment: http://stackoverflow.com/comment/33671412
upvote count: 2
answers question: http://stackoverflow.com/q/22152925
has body: I really don't recommend using rectangles. Instead, what I did in my own game is: In Tiled, assignate your wall tiles as blocked. To do so, just add a property called block to each individual tile. In the code, when you process the player movement, write something like this pseudo code: try { cell = collisionLayer.getCell((int) (x / collisionLayer.getTileWidth()), (int) (y / collisionLayer.getTileHeight())); } catch (Exception e) { e.printStackTrace(); } if (cell.getTile().getProperties().containsKey("blocked")) { blocked = true; } where x and y are the position of the cell you want to check. And then if blocked = true, do not move the player. If blocked = false, move the player. I might have been unclear in this answer, if I was, please don't hesitate to send me a message or check this awesome tutorial by dermetfan.
type: Answer

http://stackoverflow.com/a/22130434
score: -2
answers question: http://stackoverflow.com/q/22130261
has comment: http://stackoverflow.com/comment/33577593
has comment: http://stackoverflow.com/comment/33577540
has body: You can get the length of the string element using the length method e.g. list.get(0).length() This should return the size of the string Good Luck
downvote count: 2
type: Answer
upvote count: 0

http://stackoverflow.com/a/22203815
upvote count: 9
answers question: http://stackoverflow.com/q/22141060
has body: As noted in the comments this is a reported bug that has been listed as corrected for 2.4.9: http://code.opencv.org/issues/3387 http://code.opencv.org/issues/3477 That said, the project is open source, and looking at the code change that corrects this, it is a simple fix. You could just implement that bug fix and build it yourself to use until 2.4.9 is released. The associated revision is here: In the VideoCapture.cpp file: REVISION 5f88e2b4 Lines 332->335: Replace: return env-&gt;NewStringUTF(u.name); With: // VideoCapture::get can return 0.0 or -1.0 if it doesn't support // CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING if (u.prop != 0.0 &amp;&amp; u.prop != -1.0) return env-&gt;NewStringUTF(u.name);
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/22141060
score: 9

http://stackoverflow.com/q/22096891
type: Question
tagged with: canvas
answer count: 1
has body: I'm trying to create some pixels with a random color by passing the color into the constructor as I'm creating the object. I can't seem to do it no matter what I try. Here is my code.. Object to be drawn public class Particle extends View{ private int locationX; private int locationY; private int sizeX; private int sizeY; private Paint color; private Rect rect; public Particle(Context context, int locationX, int locationY, int sizeX, int sizeY, Paint color) { super(context); // TODO Auto-generated constructor stub this.locationX = locationX; this.locationY = locationY; this.sizeX = sizeX; this.sizeY = sizeY; this.color = color; rect = new Rect(); color = new Paint(); } @Override protected void onDraw(Canvas canvas){ super.onDraw(canvas); rect.set(0,0, sizeX, sizeY); color.setStyle(Paint.Style.FILL); //this is where it fails, the color defaults to black. //will not take color = new Paint(Color.RED); from MainActivity //as parameter. color.set(color); canvas.drawRect(rect, color); } } My MainActivity public class MainActivity extends Activity { private Particle particle; private Paint color; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); color = new Paint(Color.RED); particle = new Particle(this, 0, 0, 450, 120, color); setContentView(particle); } @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; } }
accepted answer: http://stackoverflow.com/a/22097202
score: 0
tagged with: android
has title: How can I pass a Paint or Color to my new object that is using the onDraw() method from an activity?
has answer: http://stackoverflow.com/a/22097202
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/a/22151031
answers question: http://stackoverflow.com/q/22150886
has body: Yes, why not. I guess your doubt is because it seems like the thread is 'committing suicide' by removing the reference to itself. But there is no special behaviour when passing 'this' in as a function argument...it is just an object in the list like any other.
type: Answer
score: 0

http://stackoverflow.com/comment/33597813
comment on: http://stackoverflow.com/q/22142145
score: 0
has text: ahhh figured it out. The problem was that there was a hidden compile error. The result class had a compile error in it, so it screwed up the method return.
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22126278
duplicate of: http://stackoverflow.com/q/11701399
upvote count: 1
has body: I am trying to get a discount of an amount given lets say: amount = "1.2" and discountPercentage = "17.3" Code: orig = Double.parseDouble("amount"); discount = orig*(discountPercentage/100); discount = Math.round(discount); discountedprice = orig - discount; On the code above: when I round the discount using Math.round(0.2076) i am getting Zero(0) result. What I want to happen is like this: 0.2076 = should get 0.21 when rounded up
has answer: http://stackoverflow.com/a/22126368
favorite count: 0
linked to: http://stackoverflow.com/q/153724
answer count: 5
linked to: http://stackoverflow.com/q/11701399
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22126298
has title: Java round decimal numbers
tagged with: java
has answer: http://stackoverflow.com/a/22126491
type: Question
has answer: http://stackoverflow.com/a/22126514
tagged with: rounding
score: -2
accepted answer: http://stackoverflow.com/a/22126368
has answer: http://stackoverflow.com/a/22126298
tagged with: decimal
has answer: http://stackoverflow.com/a/22126806
downvote count: 3

http://stackoverflow.com/comment/33684970
type: QuestionComment
comment on: http://stackoverflow.com/q/22167302
score: 0
has text: @vefthym I found out the answer, i'll post it as an answer. Thank you very much for you help!
type: Comment

http://stackoverflow.com/comment/33601290
type: QuestionComment
has text: I am not getting how to use JMX is above code. I would appreciate if you could give me some piece of code. Thanks
score: 0
comment on: http://stackoverflow.com/q/22143807
type: Comment

http://stackoverflow.com/q/22132134
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22132246
tagged with: java
accepted answer: http://stackoverflow.com/a/22132246
has body: I use java and avaje ebean 2.8.1. I want do specific query for a method. For Example: select * from children where removed=false order by born_date @Entity public class Client { @Id private Long id; @OneToMany private List&lt;Child&gt; children; //this return all, include removed=true public List&lt;Child&gt; getChildren(){ return children; }
type: Question
has comment: http://stackoverflow.com/comment/33581310
has comment: http://stackoverflow.com/comment/33580902
has comment: http://stackoverflow.com/comment/33581415
tagged with: entity
score: 0
answer count: 1
tagged with: ebean
has title: how can I add order by clause to a java entity?

http://stackoverflow.com/q/22032908
type: Question
linked to: http://stackoverflow.com/q/5621338
score: 0
answer count: 1
tagged with: nullpointerexception
has body: I got the following exception when i tried to do frame.setvisible(true); java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.myapp.GeneralEventProc.cmdProc(GeneralEventProc.java:43) at tcl.lang.Parser.evalObjv(Parser.java:810) at tcl.lang.Parser.eval2(Parser.java:1209) at tcl.lang.Interp.eval(Interp.java:2042) at tcl.lang.Interp.eval(Interp.java:2071) at javaapps.JScriptProcessor.processCurrentScript(JScriptProcessor.java:389) at javaapps.JScriptProcessor.processQueuedScripts(JScriptProcessor.java:632) at javaapps.JSPThread.run(JSPThread.java:43) Caused by: java.lang.NullPointerException at java.awt.FlowLayout.layoutContainer(Unknown Source) at java.awt.Container.layout(Unknown Source) at java.awt.Container.doLayout(Unknown Source) at java.awt.Container.validateTree(Unknown Source) at java.awt.Container.validateTree(Unknown Source) at java.awt.Container.validateTree(Unknown Source) at java.awt.Container.validateTree(Unknown Source) at java.awt.Container.validateTree(Unknown Source) at java.awt.Container.validateTree(Unknown Source) at java.awt.Container.validateTree(Unknown Source) at java.awt.Container.validate(Unknown Source) at java.awt.Window.show(Unknown Source) at java.awt.Component.show(Unknown Source) at java.awt.Component.setVisible(Unknown Source) at java.awt.Window.setVisible(Unknown Source) at com.myapp.mylist.makeList(Unknown Source) at com.myapp.mylist.show(MyList.java:144) The source code is : public void makeList() { synchronized (initLock) { System.out.println(" locking... makeList"); if (_myFrame != null) { initiateList(); _myFrame .setVisible(true); } else { System.out.println("myframe is null"); } } } private void initiateList() { _myFrame.getContentPane().setLayout(null); _myFrame.getContentPane().removeAll…
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22033010
linked to: http://stackoverflow.com/q/17874717
tagged with: java
has title: Getting NullpointerException on JFrame setvisible(true)
tagged with: swing

http://stackoverflow.com/comment/33569594
type: Comment
comment on: http://stackoverflow.com/a/22126035
type: AnswerComment
score: 0
has text: You might want to add some temporary debugging prints to show the actions your code is taking. What order are you inserting elements in?

http://stackoverflow.com/a/22159502
downvote count: 0
has comment: http://stackoverflow.com/comment/37021800
accepted answer of: http://stackoverflow.com/q/22156931
answers question: http://stackoverflow.com/q/22156931
score: 7
has comment: http://stackoverflow.com/comment/37021918
has body: As it turns out HttpServletRequest#setCharacterEncoding(String) which CharacterEncodingFilter uses Overrides the name of the character encoding used in the body of this request. This method must be called prior to reading request parameters or reading input using getReader(). Otherwise, it has no effect. Which is no good for you since you aren't getting the parameters from the body, but rather from the query string. If you are using Tomcat, however, you are in luck. Tomcat has a special Connector attribute which, when set (it's unset by default), will use that same character encoding for the query string. That attribute is useBodyEncodingForURI. If you open up your Tomcat servet.xml file, you will find an element like (without the attribute) &lt;Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" useBodyEncodingForURI="true"&gt; &lt;/Connector&gt; Add the attribute and it will work as intended. Make sure you are setting it for the appropriate Connector, HTTP in this case. Other Servlet containers probably have some similar configuration.
has comment: http://stackoverflow.com/comment/37023666
has comment: http://stackoverflow.com/comment/37023826
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/37023612
upvote count: 7
type: Answer

http://stackoverflow.com/comment/33456192
has text: Done export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 Still getting the same error.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22063390
type: Comment

http://stackoverflow.com/comment/33395687
has text: My list is empty when last = null.
type: Comment
comment on: http://stackoverflow.com/a/22028871
type: AnswerComment
score: 0

http://stackoverflow.com/a/46346822
type: Answer
answers question: http://stackoverflow.com/q/22104584
has body: The SoapUI OpenSource (free) will show you the SOAP XML for both the client and the server side. With this tool you will absolutely see the response SOAP XML from the server side. Download the zip archive version if you just want to try it out. (I launch the ZIP version of SoapUI by setting JAVA_HOME and clicking on SoapUI/bin/soapui.bat Here is a quick start to see your web service in action.. 1. Open SoapUI 2. Create a Project 3. Provide the path to your WSDL file. (If well-formed you will see the operations in your new project a tree control). 4. Open the tree node to an operation and create a SoapUI request template a. Select the operation 1) Right->Click "New Request" b. Name the Request (new node for Request appears in tree) 5. Run a test for your operation. a. Use the property editor below the tree 1) Provide any arguments 2) Provide any authentication b. Right-Click on the Request 1) "Show Request Editor" 5. Ponder your SOAP request envelope XML (on left) 6. Click on the run arrow a. Ponder your SOAP response (on right)
score: 0

http://stackoverflow.com/q/22112477
type: Question
has title: SQL select rows from two different tables with different column names
tagged with: sql
upvote count: 1
answer count: 1
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/22112732
accepted answer: http://stackoverflow.com/a/22112732
tagged with: oracle-database
type: AnsweredQuestion
score: 1
tagged with: java
tagged with: hibernate
has body: I want to select rows from two different tables(TABLE_A and TABLE_B). I'm using oracle db and hibernate. Here are my tables: Here is TABLE_A +----+--------+---------+-----------+---------------------+---------------------+ | ID | AMOUNT | BALANCE | STATUS | CREATE_DATE | END_DATE | +----+--------+---------+-----------+---------------------+---------------------+ | 1 | 5 | 5 | FINISHED | 2014-02-27 15:10:20 | 2014-02-27 15:10:20 | | 2 | 12 | 17 | TIMED_OUT | 2014-02-27 15:10:20 | 2014-02-27 15:10:20 | | 3 | 21 | 38 | COMMITED | 2014-02-27 15:10:20 | 2014-02-27 15:10:20 | +----+--------+---------+-----------+---------------------+---------------------+ Here is TABLE_B +----+----------------+---------------+----------------+---------------------+ | ID | PAYMENT_AMOUNT | TOTAL_BALANCE | PAYMENT_STATUS | REQUEST_TIMESTAMP | +----+----------------+---------------+----------------+---------------------+ | 1 | 3 | 23 | FAILED | 2014-02-27 15:10:20 | | 2 | 12 | 11 | FULFILLED | 2014-02-27 15:10:20 | | 3 | 2 | 9 | TIMED_OUT | 2014-02-27 15:10:20 | +----+----------------+---------------+----------------+---------------------+ What I want to do is that I need to get a result like the following with a single query: +--------+---------+-----------+---------------------+---------------------+ | AMOUNT | BALANCE | STATUS | DATE | END_DATE | +--------+---------+-----------+---------------------+---------------------+ | 5 | 5 | FINISHED | 2014-02-27 15:10:20 | 2014-02-27 15:10:20 | | 12 | 17 | TIMED_OUT | 2014-02-27 15:10:20 | 2014-02-27 15:10:20 | | 21 | 38 | COMMITED | 2014-02-27 15:10:20 | 2014-02-27 15:10:20 | | 3 | 23 | FAILED | 2014-02-27 15:10:20 | null | | 12 | 11 | FULFILLED | 2014-02-27 15:10:20 | null | | 2 | 9 | TIMED_OUT | 2014-02-27 15:10:20 | null | +--------+---------+-----------+---------------------+---------------------+ The results are ordered by DATE. Column descriptions are the following: AMOUNT = TABLE_A.AMOUNT or TABLE_B.PAYMENT_AMOUNT BALANCE = TABLE_A.BALANC…

http://stackoverflow.com/comment/33567626
score: 0
type: Comment
has text: Hey! i'm not using any IDE ,i'm compiling it from cmd,now what should i do ? Please don't say that an IDE is necessary for javafx.
type: QuestionComment
comment on: http://stackoverflow.com/q/22112402

http://stackoverflow.com/comment/33569158
type: Comment
type: QuestionComment
has text: @mKorbel: If I am not mistaken, isn't `DefaultTableModel` use to consider every input as a `String` value? Or can we modify it too, to make it work like an `AbstractTableModel`?
score: 0
comment on: http://stackoverflow.com/q/22125720

http://stackoverflow.com/q/22022737
has title: FTP Login Cracker
answer count: 1
has body: I am currently developing a program that will eventually do "dictionary attacks", this is a university project, so it not for illegal purposes. Okay So far I have manage to achieve this: public class Cracker { public static void main(String [] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new FileReader("/bin/a.txt")); StringBuffer stringBuffer = new StringBuffer(); String line = null; while((line =bufferedReader.readLine())!=null) { stringBuffer.append(line).append("\n"); } System.out.println(stringBuffer); } } So what this does it reads from a *.txt file and print out every line of it. I am not too familiar with connection in Java, so I was wondering how I can implement this same concept and use it to try each line for the password of the FTP server. The lectures have provided the user so there is no need to do it for the user. Thanks in advance for everyone who helps.
favorite count: 0
has comment: http://stackoverflow.com/comment/33384328
downvote count: 2
accepted answer: http://stackoverflow.com/a/22023369
tagged with: ftp
type: AnsweredQuestion
tagged with: java
upvote count: 1
type: Question
score: -1
has answer: http://stackoverflow.com/a/22023369

http://stackoverflow.com/comment/33517217
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22096516
has text: @user3364497 3/19/20, 03-19-20, 2007, Feb. 19, etc. There's no way to tell how you should exactly split your date. But I'm guessing you would want to eliminate any commas, slashes, etc. and then retrieve only the number values for month, day, and year. Then process that, assuming you're going to use a Gregorian calendar, to determine whether it's a valid date. Oh and you'd have to take into account of leap years, but of course that would be part of the process of determining if that is a valid date or not.
score: 0

http://stackoverflow.com/comment/33410319
score: 0
has text: This is not going to solve your problem you may get some idea.http://stackoverflow.com/questions/18725601/android-drag-and-drop-functionality/18725921#18725921
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22037326

http://stackoverflow.com/comment/33564801
type: QuestionComment
has text: `Component`s already have a concpept of position and size, I'd recommend against this approach and instead using a single `JPanel` which would act as the painter and then devise some kind of "Paintable" class which knew how to paint itself. You would then add these paintable objects to the panel and have the panel paint them via the `paintComponent` method
score: 0
comment on: http://stackoverflow.com/q/22123233
type: Comment

http://stackoverflow.com/comment/33469294
comment on: http://stackoverflow.com/a/22070945
score: 0
type: AnswerComment
has text: If the range is exceeded, what will happen to the variable? It will be defaulted to some value?
type: Comment

http://stackoverflow.com/a/22019750
accepted answer of: http://stackoverflow.com/q/22017994
answers question: http://stackoverflow.com/q/22017994
type: AcceptedAnswer
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/33423936
downvote count: 0
has body: Your problem is, that you set the same cam to the stage and the rest of your game. A libgdx Stage has its own camera. You should use this, as this camera won't move arround. So you have your camera and your SpriteBatch to render the game and the Stages cam and SpriteBatch to render the UI over it. Just make sure you call spriteBatch.end(); before calling stage.draw(), because if two SpriteBatches are active it will mess up things.
upvote count: 2
has comment: http://stackoverflow.com/comment/33424649

http://stackoverflow.com/a/22028049
score: 0
type: Answer
answers question: http://stackoverflow.com/q/22026539
has body: change your layout from linear to be framelayout, and attach your fragment in activity . getSupportFragmentManager().beginTransaction() .add(R.id.your_fragment_container, fragment).commit();

http://stackoverflow.com/q/22039528
has body: How would I write a recursive static method that uses an (n+1) term MacLaurin series to compute e^x, called e(x,n), by using the following recursive formulation: e(x,0)= 1 e(x,n)= e(x,n-1) + x^n/n!, if n&gt;0 Also, my method signature needs to use the following: public static double eTwo(double x, long n) Been stuck for a while, any thoughts guys?
accepted answer: http://stackoverflow.com/a/22039713
has title: Use recursive method that uses MacLaurin series to compute e^x
answer count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33413511
favorite count: 0
has answer: http://stackoverflow.com/a/22039713
possible better answer: http://stackoverflow.com/a/46126743
tagged with: recursion
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/46126743
score: 1
tagged with: java
upvote count: 1
has comment: http://stackoverflow.com/comment/33413623
type: Question

http://stackoverflow.com/q/22035066
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33405940
has comment: http://stackoverflow.com/comment/33431566
has comment: http://stackoverflow.com/comment/33406040
answer count: 0
score: 1
tagged with: urlclassloader
tagged with: java
upvote count: 1
has comment: http://stackoverflow.com/comment/33431538
type: Question
has title: Java Class Loader not loading classes imported in a class
has body: I am trying to load a class using ClassLoader as follows ClassLoader loader = ClassLoader.getSystemClassLoader(); // urls contains the urls for all the jars loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), loader); Class&lt;?&gt; main = loader.loadClass("Example"); If Example class imports some other class. Will that class be loaded automatically by JVM?? Because It is throwing me an error NoClassDefFoundError that there is another class Example2 which is imported in class Example and cannot be loaded. I seriously don't know what is happening. Thanks in advance
tagged with: dynamic-class-loaders
downvote count: 0
tagged with: jvm
favorite count: 0
tagged with: classloader

http://stackoverflow.com/comment/33452916
score: 0
type: AnswerComment
has text: I wanted to know what should I put under the button.
type: Comment
comment on: http://stackoverflow.com/a/22059079

http://stackoverflow.com/q/22049033
type: AnsweredQuestion
tagged with: maven
type: Question
tagged with: java
tagged with: apache-axis
has title: how do i create a debuggable axis2 project in eclipse using maven?
has comment: http://stackoverflow.com/comment/33432388
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33431835
score: 0
has comment: http://stackoverflow.com/comment/33432308
has answer: http://stackoverflow.com/a/22050160
accepted answer: http://stackoverflow.com/a/22050160
answer count: 1
has body: I followed the tutorial at this link to create a axis2 webservice project using maven and eclipse. However, this setup doesn't allow me to debug my code. Can someone point me to a link which will allow me to use maven to build my axis2 webservice and debug the code inside eclipse?
has comment: http://stackoverflow.com/comment/33432216

http://stackoverflow.com/a/22120876
has body: The best practice is to maintain both sides of the association. That makes sure you aren't working with an inconsistent graph of objects. It can, however, decrease the performance of the service, especially if all it does is creating a new Phone, linked to an Employee. Indeed, it will load the state of the employee and of all its existing phones. Note that JPA only cares about the owner side of the association: setting the employee of the new Phone is sufficient to have the association created in database. If you choose to go with the second solution, you shouldn't create a fake Employee object though. You should instead get an Employee reference from the EntityManager: Employee e = em.getReference(Employee.class, employeeId); Phone phone = new Phone(); phone.setEmployee(e); em.persist(phone); getReference() doesn't generate any SQL query. It returns an uninitialized proxy, which is all you need. The advantage is that if the method ends up being more complex, and calls any method of the employee, then the actual state of the employee will be loaded.
accepted answer of: http://stackoverflow.com/q/22120782
type: AcceptedAnswer
downvote count: 0
score: 4
answers question: http://stackoverflow.com/q/22120782
has comment: http://stackoverflow.com/comment/33568485
has comment: http://stackoverflow.com/comment/33561801
type: Answer
has comment: http://stackoverflow.com/comment/33572333
has comment: http://stackoverflow.com/comment/33571709
upvote count: 4

http://stackoverflow.com/comment/33355552
comment on: http://stackoverflow.com/q/22006814
score: 0
has text: @M D: No my jar file is not in lbs folder..Only in Referenced Libraried...
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33494186
type: AnswerComment
score: 0
type: Comment
has text: No dice :( I'll have to play around with it in an hour, my eyes are killing after staring at this all day. I really appreciate your pointers, I'll have to check out those tutorials. I'm sure I'm just missing something so easy.
comment on: http://stackoverflow.com/a/22084199

http://stackoverflow.com/comment/33500160
type: Comment
comment on: http://stackoverflow.com/a/22087679
score: 0
type: AnswerComment
has text: Okay, so you would say that `setEnabled(false)` guarantees that there will be no invocation of any ActionListener after it has been called, not even 1 event after it? Well, I'd say that too, but because Java has disappointed me with some of these _contracts_ already, I'm not so sure about them anymore.

http://stackoverflow.com/q/22043451
upvote count: 5
tagged with: java
possible better answer: http://stackoverflow.com/a/22043755
tagged with: base64
tagged with: character-encoding
has answer: http://stackoverflow.com/a/22043599
score: 5
downvote count: 0
tagged with: string
has comment: http://stackoverflow.com/comment/136684000
favorite count: 0
has answer: http://stackoverflow.com/a/22043836
has comment: http://stackoverflow.com/comment/33464489
linked to: http://stackoverflow.com/q/13109588
has body: I have been trying to reduce the length of the way. I represent some integer ID's in my program. For Example 2 3 15 26 63 ... 151564852 I would like them to be represented as such (0-9A-Za-z only) 2 3 F Q z ... vDF25a //For example The approach I thought of is to have 63 if statements which each of the mappings from 0-63 to 0-z respectively and for anything above 64 do a recursion on the value minus 63. Needless to say, I think my approach is very flawed and impractical. What would be a more appropriate way of doing it? Update: Following fge's suggestion I've got the encoder to work correctly, however my decode function only works for up-to length 2 strings, in cases where the string is larger the sum becomes erroneous. For example for 3840 to 3845 this is the output // Encoded zw x zy zz 100 // Decoded 3840 3841 3842 3843 124 //Invalid decoding Here is my code for the decode function public static int decode(String value) { String revStr = new StringBuilder(value).reverse().toString(); int sum = 0; for (int i=1; i &lt; revStr.length(); i++) { for (int j=0; j &lt; ALPHABET.length; j++) { if (ALPHABET[j] == revStr.charAt(i)) { sum += (ALPHABET.length * j) * i; break; } } } for (int j=0; j &lt; ALPHABET.length; j++) { if (ALPHABET[j] == revStr.charAt(0)) { sum += j; break; } } return sum; }
has title: How to convert integers to base64 (0-9A-Za-z)
has answer: http://stackoverflow.com/a/74422059
answer count: 4
has comment: http://stackoverflow.com/comment/33464835
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33420858
tagged with: compression
accepted answer: http://stackoverflow.com/a/22043836
has answer: http://stackoverflow.com/a/22043755
type: Question

http://stackoverflow.com/a/22046028
has comment: http://stackoverflow.com/comment/33427346
has comment: http://stackoverflow.com/comment/33432646
upvote count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33428128
has body: The Toolkit.getImage() have 2 methods, you should use the second one with URL as parameter and use your ClassLoader to get the resource and pass it on // I am assuming that your picture is in klassid/Pictures folder inside the jar file Image pic = Toolkit.getDefaultToolkit().getImage(this.getClass().getClassLoader().getResource("klassid/Pictures/mario.png")); I like to do thing step by step, so, first test the class loader to see if you can get the image separate from the Toolkit by: URL imgUrl = this.getClass().getClassLoader().getResource("klassid/Pictures/mario.png"); and simply do the System.out.println(this.getClass().getClassLoader().getResource("")) to see the root path and follow that to your image/resources. One thing that you should understand about getResource() is that it is as a mean to get resource at runtime relative to the class path. In eclipse is what you set either bin or bin/classes. And in the .jar file it is the top of the file structure.
type: Answer
has comment: http://stackoverflow.com/comment/33426638
has comment: http://stackoverflow.com/comment/33428399
has comment: http://stackoverflow.com/comment/33427514
answers question: http://stackoverflow.com/q/22045718
has comment: http://stackoverflow.com/comment/33427958
score: 2
has comment: http://stackoverflow.com/comment/33428059
has comment: http://stackoverflow.com/comment/33427687
has comment: http://stackoverflow.com/comment/33426661

http://stackoverflow.com/comment/33532448
has text: Thanks a lot and i figured out what the problem was, thank you all
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22102053

gmail
type: Tag
tags question: http://stackoverflow.com/q/22130540
tag name: gmail

http://stackoverflow.com/comment/33658346
type: QuestionComment
comment on: http://stackoverflow.com/q/22165966
score: 0
has text: If you are not using a framework then 'j_security_check' is the wrong way. You can find information about tomcat basic auth here: http://stackoverflow.com/q/2014619/1686330 and here: http://www.tomcatexpert.com/ask-the-experts/basic-auth-configuration-tomcat-7-https
type: Comment

http://stackoverflow.com/comment/35549159
comment on: http://stackoverflow.com/q/22090510
score: 0
type: QuestionComment
type: Comment
has text: @NaveenRamawat I generated the Java classes using the xjc.exe included in the JDK, and I did not get any error. Also, the header of the class generated from eclipse specifies

http://stackoverflow.com/a/22018430
type: Answer
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/22018385
has body: It should work. List&lt;Person&gt; PersonTypes = new ArrayList&lt;Person&gt;()
upvote count: 2

http://stackoverflow.com/comment/33467838
type: Comment
has text: @Marco13 This is a new laptop (ThinkPad T440)
comment on: http://stackoverflow.com/q/22058987
score: 0
type: QuestionComment

http://stackoverflow.com/q/22005516
tagged with: java
has answer: http://stackoverflow.com/a/22005562
has answer: http://stackoverflow.com/a/22006273
has comment: http://stackoverflow.com/comment/33353337
type: Question
has comment: http://stackoverflow.com/comment/33354264
has answer: http://stackoverflow.com/a/22006051
downvote count: 0
has comment: http://stackoverflow.com/comment/33353527
has comment: http://stackoverflow.com/comment/33354581
answer count: 6
has comment: http://stackoverflow.com/comment/33354649
favorite count: 0
possible better answer: http://stackoverflow.com/a/22006089
tagged with: nullpointerexception
has answer: http://stackoverflow.com/a/22006089
tagged with: android
has comment: http://stackoverflow.com/comment/33353732
has answer: http://stackoverflow.com/a/22006090
has answer: http://stackoverflow.com/a/22006169
has comment: http://stackoverflow.com/comment/33354177
has comment: http://stackoverflow.com/comment/33354064
tagged with: textview
has comment: http://stackoverflow.com/comment/33353922
accepted answer: http://stackoverflow.com/a/22006090
upvote count: 3
has title: Can't change the text of a TextView with string passed through intent
has body: I'm doing a very simple login screen where the user inputs their username and password, clicks the login button, and then the inputs are displayed on the next screen. I get a NullPointerException every time I try to change the textview values. I've been googling for a long time and come up with nothing, and it has to be something simple that I'm just completely missing. Following is my code: public class LoggedIn extends Activity{ String username = ""; String password = ""; TextView name; TextView pwd; Button infoDisp; protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.logged_in); Intent intent = getIntent(); name = (TextView)findViewById(R.id.username); pwd = (TextView)findViewById(R.id.password); username = intent.getStringExtra("nameInfo"); password = intent.getStringExtra("passInfo"); name.setText(username); pwd.setText(password); } } Edit: I changed the bundle to an intent above, also here's the rest of the code (The first activity) public class LoginActivity extends Activity { Button loginBtn; Button registerBtn; EditText username; EditText pword; static String name; static String pass; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); username = (EditText) this.findViewById(R.id.username); pword = (EditText) this.findViewById(R.id.password); loginBtn = (Button) this.findViewById(R.id.loginBtn); loginBtn.setOnClickListener(new OnClickListener() { public void onClick(View arg0){ Intent intent = new Intent(LoginActivity.this, LoggedIn.class); name = username.getText().toString(); pass = pword.getText().toString(); intent.putExtra("nameInfo", name); intent.putExtra("passInfo", pass); startActivity(intent); } }); } } I have no error checking for if the value is null on purpose because this was supposed to be just a quick run and done thing. I figure as long as I input something in each EditText, then the strings can…
type: AnsweredQuestion
score: 3
has comment: http://stackoverflow.com/comment/33353970
has comment: http://stackoverflow.com/comment/33354368

http://stackoverflow.com/q/22076358
has comment: http://stackoverflow.com/comment/33479394
tagged with: regex
answer count: 4
accepted answer: http://stackoverflow.com/a/22076391
has comment: http://stackoverflow.com/comment/33479483
score: -4
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33479863
tagged with: java
has body: Does anybody know what this means in java: testNumber.matches("^800[25-9][2-9].*$") I am mainly confused with [25-9].
has title: Java matches regular expression
type: Question
downvote count: 4
has answer: http://stackoverflow.com/a/22076437
possible better answer: http://stackoverflow.com/a/22076401
upvote count: 0
has answer: http://stackoverflow.com/a/22076401
has answer: http://stackoverflow.com/a/22076505
has comment: http://stackoverflow.com/comment/33479438
favorite count: 0
has answer: http://stackoverflow.com/a/22076391

http://stackoverflow.com/q/22144076
answer count: 3
has answer: http://stackoverflow.com/a/22144308
has comment: http://stackoverflow.com/comment/33601023
has comment: http://stackoverflow.com/comment/33600852
type: UnansweredQuestion
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33601071
has comment: http://stackoverflow.com/comment/33600825
has comment: http://stackoverflow.com/comment/33601056
has title: Java - Illegal Start of Expression
has body: so I did a few searches for this error and found a few results. However, none of them seem to be an answer. I'm sure the problem is simple and that I'm just too tired to figure it out, but I dunno what my mistake is. The methods are meant to be mutator methods to increase or decrease the volume. Television.java:94: error: illegal start of expression public int increaseVolume() ^ Television.java:94: error: ';' expected public int increaseVolume() ^ Television.java:103: error: illegal start of expression public int decreaseVolume() ^ Television.java:103: error: ';' expected public int decreaseVolume() ^ Television.java:106: error: reached end of file while parsing } ^ 5 errors Here is the end of the code where the errors are occuring: public class Television { private String MANUFACTURER = "None"; // This represents the manufacturer of the TV set. private int SCREEN_SIZE = 0; // This represents the size of screen of the TV set. private boolean powerOn; // This represents the state the TV is in (On or Off) private int channel; // This represents the channel the TV set is on. private int volume; // This represents the volume value of the TV set. public static void main(String[] args) { } /** Constructor @param brand The manufacturer brand of the TV set. @param size The screen size of the TV set. */ public Television(String brand, int size) { MANUFACTURER = brand; SCREEN_SIZE = size; powerOn = false; volume = 20; channel = 2; } /** The getVolume method gets the volume of the TV set. @return The current volume on the TV set as an integer. */ public int getVolume() { return volume; } /** The getChannel method gets the channel of the TV set. @return The current channel on the TV set as an integer. */ public int getChannel() { return channel; } /** The getScreenSize method gets the screen size of the TV set. @return The screen size as an integer. */ public int getScreenSize() { return SCREEN_SIZE; } /** The getManufacturer method gets the brand manufacturer of the TV set. @r…
has comment: http://stackoverflow.com/comment/33602189
has comment: http://stackoverflow.com/comment/33600810
has answer: http://stackoverflow.com/a/22144382
has answer: http://stackoverflow.com/a/22144317
score: 0

http://stackoverflow.com/q/22085350
has comment: http://stackoverflow.com/comment/33496164
has comment: http://stackoverflow.com/comment/33496173
possible better answer: http://stackoverflow.com/a/22085571
tagged with: java
has title: How can I assign an arraylist that i got from a method into another arraylist?
has answer: http://stackoverflow.com/a/22085571
answer count: 2
has comment: http://stackoverflow.com/comment/33496108
tagged with: arraylist
score: 0
has body: private List&lt;Product&gt; itemList; public List&lt;Product&gt; getItemList() { return itemList; } And then try to recieve like this... public void doMySearch (String query){ System.out.println("bikaMiden"); List&lt;Product&gt; searchResult = new ArrayList&lt;Product&gt;(); List&lt;Product&gt; result = new ArrayList&lt;Product&gt;(); System.out.println("bikagamwwwwwwwww"); result= adapter.getItemList(); System.out.println("bikaMIA"); for (Product product : result) { System.out.println("bika"); if (product.getProductName().contains(query)) { searchResult.add(product); System.out.println("vrika" + product); } } adapter.setItemList(searchResult); adapter.notifyDataSetChanged(); } I have tried 50 different aproaches it always crashes at the assign to the result command please if u know help me... 02-27 21:51:58.847: D/AndroidRuntime(3194): Shutting down VM 02-27 21:51:58.857: W/dalvikvm(3194): threadid=1: thread exiting with uncaught exception (group=0x41465700) 02-27 21:51:58.897: E/AndroidRuntime(3194): FATAL EXCEPTION: main 02-27 21:51:58.897: E/AndroidRuntime(3194): java.lang.RuntimeException: Unable to start activity ComponentInfo{uk.ac.kent.jhp20.shopper/uk.ac.kent.jhp20.shopper.ProductListActivity}: java.lang.NullPointerException 02-27 21:51:58.897: E/AndroidRuntime(3194): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211) 02-27 21:51:58.897: E/AndroidRuntime(3194): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 02-27 21:51:58.897: E/AndroidRuntime(3194): at android.app.ActivityThread.access$600(ActivityThread.java:141) 02-27 21:51:58.897: E/AndroidRuntime(3194): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 02-27 21:51:58.897: E/AndroidRuntime(3194): at android.os.Handler.dispatchMessage(Handler.java:99) 02-27 21:51:58.897: E/AndroidRuntime(3194): at android.os.Looper.loop(Looper.java:137) 02-27 21:51:58.897: E/AndroidRuntime(3194): at android.app.ActivityThread.main(ActivityThre…
has comment: http://stackoverflow.com/comment/33496249
has comment: http://stackoverflow.com/comment/33496154
has answer: http://stackoverflow.com/a/22085463
tagged with: android
has comment: http://stackoverflow.com/comment/33496135
has comment: http://stackoverflow.com/comment/33496421
accepted answer: http://stackoverflow.com/a/22085463
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33496646
type: Question

http://stackoverflow.com/comment/33399373
type: Comment
comment on: http://stackoverflow.com/q/22031114
type: QuestionComment
score: 1
has text: your class should not be called "SumMultiples.java"

http://stackoverflow.com/q/22128363
has answer: http://stackoverflow.com/a/22129958
has title: I/O exception (java.net.SocketException) caught when connecting to the target host: Too many open files
downvote count: 0
type: UnansweredQuestion
favorite count: 0
type: Question
has body: I am using Apache Jmeter for testing our application but suddenly most of the errors that Jmeter displayed was java.net.SocketException: Too many open files at java.net.Socket.createImpl(Socket.java:447) at java.net.Socket.getImpl(Socket.java:510) at java.net.Socket.setSoTimeout(Socket.java:1101) at org.apache.http.conn.scheme.PlainSokcetFactory.connectSocket(PlainSocketFactory.java:126) as I searched on the internet most of the comments about this error is because of the open limit of the machine, and then there was an answer that said Entities should be consume and when I tried on consuming the Entities the number of errors were reduced but not that many. are there any other ways to handle this kind of error?
score: 1
answer count: 2
upvote count: 1
has answer: http://stackoverflow.com/a/22128435
tagged with: jmeter
tagged with: java

mapping
tags question: http://stackoverflow.com/q/22141433
tags question: http://stackoverflow.com/q/22078156
tags question: http://stackoverflow.com/q/22053414
tags question: http://stackoverflow.com/q/22047201
tag name: mapping
tags question: http://stackoverflow.com/q/22108369
type: Tag
tags question: http://stackoverflow.com/q/22116377
tags question: http://stackoverflow.com/q/22070465

http://stackoverflow.com/q/22166956
type: Question
tagged with: windows
has comment: http://stackoverflow.com/comment/33643297
has comment: http://stackoverflow.com/comment/33642600
type: UnansweredQuestion
has title: java open web page without focus
answer count: 0
score: 0
tagged with: java
has body: I made a small program in java is like a rss checker but when find something I launch this, java.awt.Desktop.getDesktop().browse(URI.create(relHref)); But now I have a problem, every time this event trigger i lose focus on the page/program. I wanna open the page without loosing it. Is this possible? For instance: If I'm watching a movie and the event start i get the focus on the page and I have to stop/restart the movie. This is almost the same problem i have Java open html in background but is without a solution :-(
linked to: http://stackoverflow.com/q/9717509
tagged with: google-chrome

http://stackoverflow.com/comment/33423772
comment on: http://stackoverflow.com/q/22045036
has text: That's not a pointer. Being hexadecimal doesn't mean it's a memory address. Hexadecimal is just another way of writing a number value.
type: QuestionComment
type: Comment
score: 2

http://stackoverflow.com/comment/33566815
type: Comment
type: QuestionComment
has text: What processes are locking the data in the first place? Note that some factors may force the optimizer to lock rows _outside_ of what's going to be updated (index/storage page, or the entire table!). If this is a human-interacting process, be prepared to have it be locked over lunch/vacation. How are you accessing this? It may be difficult to retain/rejoin the lock if you're doing web services (where you may not even talk to the same application server!). What's the plan for statement timeout?
score: 0
comment on: http://stackoverflow.com/q/22106570

http://stackoverflow.com/a/22082078
upvote count: 1
has comment: http://stackoverflow.com/comment/33524481
downvote count: 0
has body: Try RemoteLoggingService to send the logs from client to server side. Here is a sample code: web.xml: remoteLogServlet com.x.y.z.server.servlet.GwtRemoteLogging remoteLogServlet /context_path/remote_logging GwtRemoteLogging.java: import java.util.logging.Level; import java.util.logging.LogRecord; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import com.google.gwt.logging.server.StackTraceDeobfuscator; import com.google.gwt.logging.shared.RemoteLoggingService; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import org.apache.log4j.Logger; /** * The Class GwtRemoteLogging. */ @SuppressWarnings("serial") public class GwtRemoteLogging extends RemoteServiceServlet implements RemoteLoggingService { /** The Constant logger. */ private StackTraceDeobfuscator deobfuscator = null; private final static Logger logger = Logger.getLogger("logger_name"); @Override public void init(ServletConfig config) throws ServletException { super.init(config); } /** * Logs a Log Record which has been serialized using GWT RPC on the server. * * @return either an error message, or null if logging is successful. */ public final String logOnServer(LogRecord lr) { try { if (lr.getLevel().equals(Level.SEVERE)) { logger.error(lr.getMessage(),lr.getThrown()); } else if (lr.getLevel().equals(Level.INFO)) { logger.info(lr.getMessage(),lr.getThrown()); } else if (lr.getLevel().equals(Level.WARNING)) { logger.warn(lr.getMessage(),lr.getThrown()); } else if (lr.getLevel().equals(Level.FINE)) { logger.debug(lr.getMessage(),lr.getThrown()); } else { logger.trace(lr.getMessage(),lr.getThrown()); } } catch (Exception e) { logger.error("Remote logging failed", e); return "Remote logging failed, check stack trace for details."; } return null; } /** * By default, this service does not do any deobfuscation. In order to do server side * deobfuscation, you must copy the symbolMaps files to a directory visible to the server and * set the directory using this method. * * @param…
type: Answer
score: 1
answers question: http://stackoverflow.com/q/22049560

http://stackoverflow.com/a/22107685
downvote count: 0
answers question: http://stackoverflow.com/q/22107602
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/33536715
score: 1
has body: You call newRectangleOutput += "Rect-" + ... which is equivalent to newRectangleOutput = newRectangleOutput + "Rect-" + ... So you add the output of the new rectangle the the old ones. Replace += by =, that is what you want.

http://stackoverflow.com/a/22148719
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22148533
answers question: http://stackoverflow.com/q/22148533
has body: An improvement could be to execute only one for statement, which will make it faster. Take into account that this is only useful if you previously know (as it looks like in this case) the number of tables you have. If not, you should add a nested for. Object [][] table= new Object[10][10]; for(int j=0; j&lt;3;j++) { table[j][0]=table1[j]; table[j][1]=table2[j]; table[j][2]=table3[j]; } The representation of the table is a method that can be called later without having to build the table again so you could create a new method called public showTable() { for(int k=0; k&lt;3;k++) { for(int j=0; j&lt;3;j++) { System.out.println("table["+k+"]["+j+"]="+table[k][j]); } } } If you will never want to display the table again you can create the table and at the same time display it using the nested for of the method showTable()
type: Answer
score: 0

http://stackoverflow.com/comment/33424087
type: QuestionComment
comment on: http://stackoverflow.com/q/22045036
type: Comment
has text: I was for some reason under the impression that the "0x" preceding the hex value was a declaration of a pointer.
score: 0

http://stackoverflow.com/comment/37933342
type: AnswerComment
comment on: http://stackoverflow.com/a/24498827
has text: I can't see any relations between Kind name and this error. The reason for this happening is that MBS trying to write all subscriptions into one property. By default MBS uses only one subscription for GCM that is always less than 500 characters limit. Error occurrs when more then one SubscriptionID trying to write into one property. I guess you've changed not only Kind name "Guestbook" but you've also modified some code which adds additional SubscriptionIDs. For example `Scope.FUTURE` and `Scope.FUTURE_AND_PAST` in your query adding more subscriptions.
type: Comment
score: 0

http://stackoverflow.com/q/22146950
has comment: http://stackoverflow.com/comment/33608249
has answer: http://stackoverflow.com/a/22147243
favorite count: 0
has answer: http://stackoverflow.com/a/39506989
type: Question
has comment: http://stackoverflow.com/comment/33609898
score: 12
tagged with: http://stackoverflow.com/tag/html
has answer: http://stackoverflow.com/a/22147301
tagged with: java
tagged with: selenium
has title: Clicking on text in between SPAN tags using Selenium Webdriver (java)
possible better answer: http://stackoverflow.com/a/22153685
has answer: http://stackoverflow.com/a/22153685
upvote count: 12
accepted answer: http://stackoverflow.com/a/22147301
answer count: 5
has body: HTML code looks like this: &lt;td id="id26a" class="doclisting-name link" style="width: 319px; min-width: 319px;"&gt; &lt;span id="id26b" title="Document"&gt; &lt;span class="ie-fallback-marker"&gt; words &lt;/span&gt;&lt;/span&gt;&lt;/td&gt; I cannot search for Element ID, as it changes all the time. I cannot search for the element's class, as there are multiples which could change locations. I want to be able to click on "WORDS" in between the SPAN tags. Is this at all possible? This is what I used so far, but neither seems to work: //string document is words. public void testscenario123(String document) throws Throwable { Thread.sleep(3000); driver.findElement(By.linkText(document)).click(); } or //string document is words. public void testscenario124(String document) throws Throwable { Thread.sleep(3000); driver.findElement(By.xpath("//*[contains(@span,'"+document+"')]")).click(); }
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22149190
downvote count: 0

http://stackoverflow.com/a/22074629
score: 0
answers question: http://stackoverflow.com/q/22074361
type: Answer
has body: I guess 'user' is a database keyword and cannot be used! You must change your mapping to use a different column name.

http://stackoverflow.com/comment/33451881
type: Comment
score: 0
type: AnswerComment
has text: OMG, I've just found an exception, you're right the code doesn't work right, and probably the logic of your code is wrong.
comment on: http://stackoverflow.com/a/22060633

http://stackoverflow.com/comment/33441931
has text: @DavidWallace He copy-pasted OP's code. I don't see why he should have fixed it :p
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22055040
type: Comment

http://stackoverflow.com/comment/33535585
type: QuestionComment
has text: It's offen called "command", so in your example you could use " CustomerCommand".
comment on: http://stackoverflow.com/q/22107033
score: 0
type: Comment

http://stackoverflow.com/comment/48351251
comment on: http://stackoverflow.com/a/29948481
score: 0
type: AnswerComment
has text: Thanks Dennis, I had similar problem with luna in ubuntu 64 and clearing the socks entry in network proxy of the system works like a charm. :)
type: Comment

http://stackoverflow.com/a/22101475
has body: int and char aren't functions, but are primitives. str1[i]=char(int(str1[i])-num1[x])+26) You're trying to use int as a function. What do you expect from it?
type: Answer
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/22101359
downvote count: 0

http://stackoverflow.com/comment/33455173
score: 0
type: AnswerComment
has text: Where? If in the `for` loop it means your array has null elements in it; you didn't mention that in the question ;)
type: Comment
comment on: http://stackoverflow.com/a/22062927

http://stackoverflow.com/a/22032338
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33495554
type: Answer
answers question: http://stackoverflow.com/q/22031701
has body: sun.audio is undocumented Like other sun.* packages, it is undocumented and it might disappear. Java Media Framework is old It's an optional package, not part of the SE and hasn't been updated in a long time. Oracle has a page on it and it's still available but, well, who knows what will happen to it. javax.sound is part of the SE This is the current Java sound implementation, it is part of the SE and the tutorial for it can be found here. If you want to use audio in Java this is what you should learn because it's official, it works, it gets updated sometimes and it is well-documented. javax.sound does not play mp3 Why is that? Despite being ubiquitous in file systems, mp3 has a history of licensing and patent issues. Mp3 is a minefield and this may be why Sun/Oracle has not put effort in to supporting it. (If this is why, I don't blame them.) If you really want to play mp3 there are some third-party decoders floating around on the web. There is no point in recommending one because all of them will read mp3. JavaFX does play mp3 Use a javafx.scene.media.MediaPlayer. See javafx.scene.media/Supported Media Types. JavaFX is part of the JRE/JDK as of Java 8 (and new versions of Java 7) and will (probably) eventually supersede several SE APIs like javax.sound and javax.swing.
has comment: http://stackoverflow.com/comment/33401709
upvote count: 10
score: 10
accepted answer of: http://stackoverflow.com/q/22031701
has comment: http://stackoverflow.com/comment/115340279

http://stackoverflow.com/a/22158111
downvote count: 0
has body: When constructing the set, use a sorted set with a case insensitive comparator. For example: Set&lt;String&gt; s = new TreeSet&lt;&gt;(String.CASE_INSENSITIVE_ORDER); s.addAll(Arrays.asList("one", "two", "three")); //Returns true System.out.println("Result: " + s.contains("One"));
answers question: http://stackoverflow.com/q/22158018
score: 13
upvote count: 13
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/22158018

http://stackoverflow.com/q/22087863
has body: So i currently have : List&lt;String&gt; lineList = new ArrayList&lt;String&gt;(); String thisLine = reader.readLine(); while (thisLine != null) { lineList.add(thisLine); thisLine = reader.readLine(); } System.out.println(lineList); Which basically is reading a text file and returning the numbers in the text file. The output im getting is [0 6 13 0 0 75 33 0 0 0 4 29 21 0 86 0 32 66 0 0] which seems to be correct. However what I have to do is remove all the zeros without creating a new array. But will i have to convert this string arraylist to an integer array list to be able to do so? How could I only remove the zeros? Thanks!
answer count: 4
has answer: http://stackoverflow.com/a/39610559
type: UnansweredQuestion
downvote count: 3
has answer: http://stackoverflow.com/a/22087917
upvote count: 1
has answer: http://stackoverflow.com/a/22087920
has comment: http://stackoverflow.com/comment/33500448
linked to: http://stackoverflow.com/q/8777217
has comment: http://stackoverflow.com/comment/33500429
has title: Removing all zeros from an array list?
tagged with: java
has comment: http://stackoverflow.com/comment/39518532
type: Question
score: -2
tagged with: arrays
has answer: http://stackoverflow.com/a/22088024
favorite count: 0
has comment: http://stackoverflow.com/comment/33500447
tagged with: arraylist
tagged with: file-io

http://stackoverflow.com/q/22128631
score: 1
tagged with: java
linked to: http://stackoverflow.com/q/1158159
upvote count: 1
type: Question
has body: I know this has been asked a lot on SO, but they don't offer solutions to my problem: I'm using a project with JPA, cloned from someone else with the exact same settings (same OS, same IDE, same database name, also in MAMP) Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named persistentie at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54) at DatabaseTest.main(DatabaseTest.java:29) My persistence.xml (both in folder /META-INF/ and /WEB-INF/classes/META-INF/, as suggested on multiple other questions on SO): <?xml version="1.0" encoding="UTF-8"?> org.eclipse.persistence.jpa.PersistenceProvider Domein.Student Domein.Onderzoeksdomein Domein.Promotor Domein.Gebruiker Domein.Campus Domein.Presentatie Domein.Dag Domein.Lokaal <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/Project2-DB?zeroDateTimeBehavior=convertToNull"/> <property name="javax.persistence.jdbc.password" value="root"/> <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> <property name="javax.persistence.jdbc.user" value="root"/> <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/> This line is where it gets the Exception: EntityManagerFactory emf = Persistence.createEntityManagerFactory("persistentie"); There's no code before this, it's the first line of the main. I'm using MAMP, NetBeans 7.4 with Persistence (JPA 2.1) and OS X. I'm completely lost here... As I didn't change anything from my friend's code, this should work right? Also I checked out the source of javax.persistence.Persistence.createEntityManagerFactory(String name) and I found that resolver.getPersistenceProviders() returns an empty List. I don't have the experience in JPA to know what this means though.
tagged with: mamp
answer count: 2
possible better answer: http://stackoverflow.com/a/42274104
tagged with: jpa
downvote count: 0
has comment: http://stackoverflow.com/comment/33574614
has comment: http://stackoverflow.com/comment/43196730
has comment: http://stackoverflow.com/comment/33574981
has answer: http://stackoverflow.com/a/42274104
has title: no Persistence provider for EntityManager named ***
favorite count: 0
tagged with: netbeans
has answer: http://stackoverflow.com/a/22130913
accepted answer: http://stackoverflow.com/a/22130913
type: AnsweredQuestion

http://stackoverflow.com/comment/51338486
comment on: http://stackoverflow.com/a/22140057
has text: Your answer is here : http://stackoverflow.com/questions/5120116/how-to-create-rounded-jbutton-in-java/31699716#31699716
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33554660
type: Comment
comment on: http://stackoverflow.com/a/22112216
has text: As I am new in android can you please elaborate
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33447242
score: 0
type: AnswerComment
type: Comment
has text: I see that you are new here.. Can you vote my answer up and accept it if it helped?
comment on: http://stackoverflow.com/a/22058012

http://stackoverflow.com/comment/33501441
comment on: http://stackoverflow.com/a/22088131
score: 0
type: Comment
has text: i tried your code But it is not returning any text at all it is just showing : Printing : there is no text after that please help - the text content is in text box i need to fetch the text
type: AnswerComment

http://stackoverflow.com/q/22101371
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22101978
has body: When multiple thread try to acquire the lock on synchronized when lock is already acquired by one thread. My understanding was that lock will be given in order of acquire lock request. But as per the book O'Reilly Java threads lock will be given that is best for platform. Thats very abstract statement.I think platform mainly meant OS here. My question what is the criteria based on which JVM decides what is best for platform and how developer accounts it while doing programming? Update:- i know i can use Lock object with fairness argument. But just want to know how does it work with synchronized locks?
has comment: http://stackoverflow.com/comment/33524539
answer count: 3
has comment: http://stackoverflow.com/comment/33526114
has comment: http://stackoverflow.com/comment/33525146
downvote count: 0
has title: synchronized lock grant order when multiple thread ask for it?
favorite count: 0
has answer: http://stackoverflow.com/a/22101772
type: AnsweredQuestion
tagged with: multithreading
upvote count: 1
type: Question
accepted answer: http://stackoverflow.com/a/22101772
has answer: http://stackoverflow.com/a/22102013
possible better answer: http://stackoverflow.com/a/22101978

http://stackoverflow.com/comment/33547984
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22114161
has text: I dont have a code after loading image. I want to know what attributes from android library shall i use to achieve this. Is there any inbuilt functions that can achieve this task?

http://stackoverflow.com/comment/33642574
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22167192
score: 0
has text: what is your android os version?

http://stackoverflow.com/comment/33603013
type: AnswerComment
comment on: http://stackoverflow.com/a/22145001
type: Comment
score: 1
has text: Thanks guys! I implemented exactly what Ross Drew and Dominic advised, and now everything is working properly. I really appreciate you taking the time to teach me.

http://stackoverflow.com/comment/33414267
score: 0
comment on: http://stackoverflow.com/q/22039952
type: Comment
type: QuestionComment
has text: Well, you're probabilly launching your application using as main function the one in the write class. So the main function in the New_string class is never called, hence the New_string.S1 field is null. The fact that you have two main methods in two different classes does not mean that EACH of the is called when you launch your program unsing ONE of them. Your main method inside write should first call New_string.main(null), before expecting to have a chance at a non-null value inside New_string.S1

http://stackoverflow.com/comment/33359436
type: Comment
comment on: http://stackoverflow.com/a/22009157
has text: Thanks for replying, I get the same error though: Invalid XPath expression: //*/substring-before(@att, ' ') Expected node-type
score: 0
type: AnswerComment

http://stackoverflow.com/q/22076188
has title: Programming Web Services for WebLogic Server
answer count: 1
type: UnansweredQuestion
tagged with: java
has body: I was trying to execute a simple Web Service example from a book: package com.alsb.hello; import javax.jws.WebMethod; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import weblogic.jws.WLHttpTransport; import weblogic.jws.WSDL; @WebService @WSDL(exposed=true) @WLHttpTransport(portName="HelloWorldSoapPort", serviceUri = "HelloWorldService", contextPath = "business/hello") @SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.WRAPPED) public class HelloWorld { @WebMethod public String hello(String arg) { return arg + "z"; } } But when i start the server (Weblogic 10.3.6) it happens the following error: Errors: The annotation weblogic.jws.WSDL is not allowed on com.alsb.hello.HelloWorld because it is a JAX-WS type web service. The same happens with the annotation @WLHttpTransport. Could someone figure out where's the problem?
tagged with: web-services
type: Question
tagged with: weblogic
has answer: http://stackoverflow.com/a/22076903
score: 0

http://stackoverflow.com/comment/33620044
has text: Can you give some example for those case? At least the base class methods?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22154572

http://stackoverflow.com/comment/33500855
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22088071
score: 0
has text: This is not clear, you want some method to transform `{"product_tags":"xxxxxxxx,yin yang"}` into "xxxxxxxx"?

http://stackoverflow.com/a/22133047
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22128766
downvote count: 0
answers question: http://stackoverflow.com/q/22128766
has comment: http://stackoverflow.com/comment/33704971
type: Answer
upvote count: 3
has comment: http://stackoverflow.com/comment/33706286
score: 3
has body: I would go with something like that: import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; import java.util.Arrays; @RunWith(Parameterized.class) public class Foo { @Rule public ExpectedException expectedException = ExpectedException.none(); @Parameter public Class&lt;?&gt; input; /** * Test of isCompramised method, of class MyClass. */ @Test public void testIsCompramised() { this.expectedException.expect(IllegalArgumentException.class); final MyClass instance = new MyClass(); instance.isCompramised(input); } @Parameters(name = "test for {0}") public static Iterable&lt;Object[]&gt; data() { return Arrays.asList(new Object[][] { {null}, {Object.class} }); } } (or two test methods, one for null and one for Object) EDIT: some complements (see comments) The methods annotated with @Parameters returns an Iterable containing Object[]. Each of those Object[] is bound to a @Parameter annotated field (using the value of @Parameter as index [default: 0]). JUnit Parameterized runner will iterate over the @Parameters data and for each array, set fields values and then run every tests in the class. See also: Parameterized javadoc

http://stackoverflow.com/comment/33605593
has text: @robermann I don't have any classes in web-inf and the en-token.bin is located in a folder within WebContent... How to make changes...
comment on: http://stackoverflow.com/q/22146598
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/33403283
type: Comment
comment on: http://stackoverflow.com/a/22033416
type: AnswerComment
has text: it does not run i get command not found error when trying to run server.sh. Do you mean writing command as bash -x ./server.sh 8000?
score: 0

http://stackoverflow.com/comment/33638911
type: AnswerComment
comment on: http://stackoverflow.com/a/22073487
type: Comment
has text: I've added more edits; are you saying I can call and execute Java code from javascript?
score: 0

http://stackoverflow.com/a/22168909
has body: Try this to select the date: driver.findElement(By.id("give id")).click(); WebElement selectElement = (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.className("ui-datepicker-year"))); Select select = new Select(selectElement); select.selectByValue("2012"); Thread.sleep(6000); WebElement dateWidget = driver.findElement(By.id("ui-monthpicker-div")); List&lt;WebElement&gt; columns011=dateWidget011.findElements(By.tagName("td")); for (WebElement cell: columns011){ //Select Month if (cell.getText().equals("Feb")){ cell.findElement(By.linkText("Feb")).click(); break; } }
score: 0
has comment: http://stackoverflow.com/comment/33930769
type: Answer
has comment: http://stackoverflow.com/comment/33731751
answers question: http://stackoverflow.com/q/22149626
has comment: http://stackoverflow.com/comment/33731692

http://stackoverflow.com/a/22164407
has comment: http://stackoverflow.com/comment/33637481
type: AcceptedAnswer
downvote count: 0
has body: 3827367453723784675745843783623672348745389734268374687 is too large for a long as well. Use BigInteger, which allows arbitrary large integer numbers.
upvote count: 11
accepted answer of: http://stackoverflow.com/q/22164328
type: Answer
answers question: http://stackoverflow.com/q/22164328
score: 11

http://stackoverflow.com/q/22117353
tagged with: jna
has body: I have been programming a Java version of the FaceRecognizer library. I can successfully initialize a new FaceRecognizer (with Fisherface as default) in my Java OpenCV project. I used JNA to accomplish this. But recently, I found out that the "train" method has bugs so I decided to do the entire recognition in the DLL file and return a double value at last. But when I made a new FaceRecognizer like this: Ptr&lt;FaceRecognizer&gt; model = Algorithm::create&lt;FaceRecognizer&gt;("FaceRecognizer.Fisherfaces"); or Ptr&lt;FaceRecognizer&gt; model = createFisherFaceRecognizer(); it does compile and build successfully! But when I use them to train like this: model-&gt;train(libList,idList); (libList is vector and idList is vector) the JVM (through JNA to my Java OpenCV project). It says : A fatal error has been detected by the Java Runtime Environment: EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x60b2510b, pid=31264, tid=13256 Problematic frame: C [opencv_core248.dll+0x510b] I am guessing it is something to do with reference or pointer because even if I run model-&gt;name(); it also crashes. Seems like it is a problem with "model". I truly appreciate all of your help! Thank you very much! This is the logged file: --------------- T H R E A D --------------- Current thread (0x0008bc00): JavaThread "main" [_thread_in_native, id=13256, stack(0x01070000,0x010c0000)] siginfo: ExceptionCode=0xc0000005, reading address 0x00000000 Registers: EAX=0x010bf098, EBX=0x00000000, ECX=0x00000000, EDX=0x08da0174 ESP=0x010bf08c, EBP=0x010bf0a4, ESI=0x010bf0b0, EDI=0x010bf3e4 EIP=0x60b2510b, EFLAGS=0x00010286 Top of Stack: (sp=0x010bf08c) 0x010bf08c: bdaf0099 010bf0b0 00000000 010bf3e4 0x010bf09c: 60c941e9 ffffffff 010bf3f0 61e42598 0x010bf0ac: 010bf198 bdac87d8 010bf490 00000000 0x010bf0bc: 00000000 010bf148 010bf148 010bf120 0x010bf0cc: 010bf120 cccccccc 00000000 cccccccc 0x010bf0dc: cccccccc 42ff0000 00000000 00000000 0x010bf0ec: 00000000 00000000 00000000 00000000 0x010bf0fc: 00000000 …
has comment: http://stackoverflow.com/comment/33554693
has comment: http://stackoverflow.com/comment/33568144
tagged with: c++
accepted answer: http://stackoverflow.com/a/22123886
type: AnsweredQuestion
upvote count: 1
has title: Opencv JNA&C++ FaceRecognizer Causes JVM to crash
type: Question
tagged with: opencv
tagged with: java
has comment: http://stackoverflow.com/comment/33564386
has comment: http://stackoverflow.com/comment/33553608
has answer: http://stackoverflow.com/a/22123886
answer count: 1
downvote count: 0
score: 1
tagged with: jvm
favorite count: 0

http://stackoverflow.com/a/22124067
has body: It's hard to tell just what you're trying to do, but this cannot be right: public ActivityPerformed(Activity a, double hours){ a = new Activity(name, calories); this.hours = hours; this.name = name; this.calories = calories; } You have to pass an Activity to the constructor when you create a new ActivityPerformed; to do that, you must have created a new Activity already. Instead, the above code throws that Activity away, creates another new Activity, and then assigns that new Activity into the parameter a, where it will also become useless (a is passed by value; therefore assigning to it will not affect anything outside the method). If you want an ActivityPerformed to refer to an Activity, you'll need to decare a field in the ActivityPerformed to refer to it. Then assign it in the constructor: public class ActivityPerformed { Activity activity; double hours; public ActivityPerformed(Activity a, double hours) { activity = a; // sets up the reference to the Activity this.hours = hours; //this.name = name; I don't know what this would have done, since "name" // and "calories" weren't parameters to the constructor. Most likely, // this was a useless statement that assigned a field to itself. Do you // need to store these fields in the ActivityPerformed, or do you just // want to use the "activity" reference to get to them? //this.calories = calories; Anyway, there's a lot of info missing and I can't figure out what you're trying to do. But this should be a start. It probably won't fix everything.
has comment: http://stackoverflow.com/comment/33566100
score: 0
answers question: http://stackoverflow.com/q/22123987
type: Answer

http://stackoverflow.com/comment/33375073
score: 0
type: Comment
type: QuestionComment
has text: I understand why your variables are final, but why are they static?
comment on: http://stackoverflow.com/q/22018043

http://stackoverflow.com/comment/33633474
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22161724
type: Comment
has text: As you reduce "rad" in each recursion, you just need to make a darker shade for your colour and pass that on. Just like you reduce "rad" by 1/3, you increase shade and use the new colour shade to make the 3 createCircles() call.

http://stackoverflow.com/comment/33432691
type: AnswerComment
score: 0
has text: doah... you beat me :-)
type: Comment
comment on: http://stackoverflow.com/a/22049998

http://stackoverflow.com/a/22010071
has comment: http://stackoverflow.com/comment/33361179
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33361550
upvote count: 1
has body: Try this: Map&lt;String,Integer&gt; map = new HashMap&lt;&gt;(); for (int i = 65; i &lt;= 90; i++) { map.put(Character.toString((char) i), 0); }
has comment: http://stackoverflow.com/comment/33361587
answers question: http://stackoverflow.com/q/22009900
has comment: http://stackoverflow.com/comment/33361446

http://stackoverflow.com/q/22045831
type: Question
has answer: http://stackoverflow.com/a/22046352
tagged with: actionlistener
has answer: http://stackoverflow.com/a/22046357
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/22046544
has body: I Have two classes, I am using ActionListeners, the thing is that i want to receive an int value in the First class from the Second One... THE FIRST CLASS is this one: public class PanelCotizacion extends javax.swing.JPanel implements ActionListener { private int numCotizacion = 0; public PanelCotizacion() { initComponents(); } public void actionPerformed(ActionEvent e) { System.out.println("HERE IS WHERE I WANT TO RECEIVE THE VALUE"); this numCotizacion = ""; //THE VALUE THAT I WANT TO RECEIVE FROM THE OTHER jFRAME //TRIGGERED BY THE EVENT OF THE BUTTON (action performed) } } This is the Second One, where i want to send the int value: public class BusquedaCotizacionGUI extends javax.swing.JFrame { private int numCotizacion = 0; public BusquedaCotizacionGUI() { initComponents(); this.setLocationRelativeTo(null); PanelCotizacion pC = new PanelCotizacion(); this.cmdOK.addActionListener(pC); } private void cmdOKActionPerformed(java.awt.event.ActionEvent evt) { this.numCotizacion = Integer.parseInt(this.txtNumCotizacion.getText()); //Here is where I WANT TO PASS THE VARIABLE "numCotizacion" tho the other class //Can Somebody Help Me this.dispose(); } } Can you help me guys to do this, Thanks a lot!
has title: Passing int value from one jFrame to another jFrame using ActionListener
type: UnansweredQuestion
tagged with: swing
tagged with: java

http://stackoverflow.com/comment/59192498
type: Comment
comment on: http://stackoverflow.com/q/22117072
type: QuestionComment
has text: See http://stackoverflow.com/questions/9560600/java-no-enclosing-instance-of-type-foo-is-accessible
score: 0

http://stackoverflow.com/comment/33511250
type: QuestionComment
has text: @m0skit0 - i am definitely not thinking of optimizing here yet , i am just wondering what is the right way to do it. Dont want to start off writing code in a crappy way , trying to adhere some rules might help me later as i am trying to write a program that needs to scale i.e have less memory footprint and run a number of process in parallel.
comment on: http://stackoverflow.com/q/22093918
score: 0
type: Comment

http://stackoverflow.com/comment/33445859
has text: Which one engien are you using?, how many graphysc you need draw?. Por example, this game http://www.youtube.com/watch?v=nOJ-EBnA1AM cannot get the minimun 22 FPS with old devices of few resources. It need draw many sprites for them.
comment on: http://stackoverflow.com/a/22028242
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/comment/123090406
comment on: http://stackoverflow.com/a/22029761
type: Comment
has text: In case some one is struggling with setting the default value inline. Please note that the value is what comes after the hyphen, e.g. if my default path is `/var/log/myfile.log`, then I would write `${sys:oauthLoginLogPath:-/var/log/myfile.log}`
score: 0
type: AnswerComment

http://stackoverflow.com/a/22127815
answers question: http://stackoverflow.com/q/22126862
score: 0
type: Answer
has body: Therefore the two Threads can cancel each other. But is this the optimal solution? Is there a better and safer way to do this? The best solution is to set a volatile flag which is being checked regularly to see if the thread should stop running. If you are blocking on a Stream, you can close the stream and cause it to trigger an IOException (like AsynchronousCloseException for Channels) If you really have no choice, you can use thread.stop(); This will cause the thread to throw a ThreadDeath Error which should trigger it to unwind the stack (and any locks) and cause your thread to die. This should only be used as a last resource and it could leave data in an inconsistent state. i.e. the error could be thrown on any line. Note: If you catch Throwable, or Error or ThreadDeath, this will catch this error, just like any other and the thread won't die.

http://stackoverflow.com/a/22048683
accepted answer of: http://stackoverflow.com/q/22047468
answers question: http://stackoverflow.com/q/22047468
type: Answer
has comment: http://stackoverflow.com/comment/33455058
downvote count: 0
has comment: http://stackoverflow.com/comment/33433311
score: 1
has comment: http://stackoverflow.com/comment/33433218
has body: Your XML has a namespace. DOM4J returns null because it won't find your nodes. To make it work, you first have to register the namespaces you are using. You will need a prefix. Any one. And you will have to use that prefix in your XPath. You could use tns for "target namespace". Then you have to create a xpath object with it like this: XPath xpath = new DefaultXPath("/tns:epp/tns:response/tns:result"); To register the namespaces you will need to create a Map, add the namespace with the prefix you used in the xpath expression, and pass it to the setNamespaceURIs() method. namespaces.put("tns", "urn:ietf:params:xml:ns:epp-1.0"); xpath.setNamespaceURIs(namespaces); Now you can call selectSingleNode, but you will call it on your XPath object passing the document as the argument: Node nodeStatus = xpath.selectSingleNode(xmlDoc); From there you can extract the data you need. getText() won't give you the data you want. If you want the contents of the result node as XML, you can use: nodeStatus.asXML() Edit: to retrieve just the code, change your XPath to: /tns:epp/tns:response/tns:result/@code And retrieve the result with nodeStatus.getText(); I replaced the double slash // (which means descendant-or-self) with / since the expression contains the full path and / is more efficient. But if you only have one result node in your whole file, you can use: //result/@code to extract the data. It will match all descendants. If there is more than one result, it will return a node-set.
has comment: http://stackoverflow.com/comment/33466319
has comment: http://stackoverflow.com/comment/33466472
upvote count: 1
type: AcceptedAnswer

http://stackoverflow.com/q/22166799
upvote count: 2
tagged with: size
linked to: http://stackoverflow.com/q/40480
downvote count: 1
has answer: http://stackoverflow.com/a/22166980
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22166852
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/22166980
type: Question
answer count: 2
tagged with: arrays
has body: This is my first post here, so please be friendly! :) Let's say I have this code: public static void reassign (int[] nums) { int[] A = {10,11,22}; A = nums; } public static void main(String[] args) { int[] nums = {0,2}; reassign(nums); System.out.println(nums[1]); } Why is my answer 2, and not 11? Does it have something to do with the relative sizes of the arrays?
has title: Why can't I reassign the size of an array by replacing the variable with an array of different size?
has answer: http://stackoverflow.com/a/22166852
favorite count: 0
duplicate of: http://stackoverflow.com/q/40480

http://stackoverflow.com/comment/33490195
comment on: http://stackoverflow.com/q/22081817
has text: Dear Franz I read the javadoc and I didn't find the answers. It's better to help me instead of giving -1. -1 does not solve my problem.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33869067
comment on: http://stackoverflow.com/a/22139634
has text: it was very useful what rajshree said above and it works correctly
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33500840
type: QuestionComment
has text: The main advantage of using a `builder pattern` is that it returns an `immutable instance` of the class and makes the code more readable and easy to understand. it allows the object chaining. read more at this [thread](http://stackoverflow.com/questions/328496/when-would-you-use-the-builder-pattern)
score: 1
comment on: http://stackoverflow.com/q/22087849
type: Comment

http://stackoverflow.com/comment/33376646
type: QuestionComment
score: 3
has text: give it a shot, then come back w your issues/code
comment on: http://stackoverflow.com/q/22018910
type: Comment

http://stackoverflow.com/q/22082224
has title: hibernate - delete element in mysql from selected list
score: 0
has body: I have small issue I want to delete element in db (mysql), which is in selected list: List&lt;PsProductAttribute&gt; psProductAttributes = sessionShop.getNamedQuery(PsProductAttribute.GetByProductId) .setInteger("idProduct", psProduct.getIdProduct()) .list(); for (PsProductAttribute psProductAttribute : psProductAttributes) { ... sessionShop.getNamedQuery(PsProductAttribute.DeleteByAttributeId) .setParameter("idProduct", psProductAttribute.getIdProduct()) .executeUpdate(); } After this i get: ERROR: org.springframework.scheduling.support.TaskUtils$LoggingErrorHandler - Unexpected error occurred in scheduled task. org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 I understand that i want to delete element, which is in previously selected List. But how to delete element ?
has comment: http://stackoverflow.com/comment/33491569
has comment: http://stackoverflow.com/comment/33491205
answer count: 0
type: UnansweredQuestion
tagged with: java
tagged with: hibernate
has comment: http://stackoverflow.com/comment/33492367
type: Question

http://stackoverflow.com/comment/33579399
score: 0
comment on: http://stackoverflow.com/q/22131044
has text: @prathmesh.kallurkar: The name of the system call is _clone_, not _fork_.
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22138642
tagged with: centos
accepted answer: http://stackoverflow.com/a/22316977
upvote count: 6
type: AnsweredQuestion
tagged with: java
has title: jsvc 1.0.15 installation on CentOS 6.x
score: 6
type: Question
has answer: http://stackoverflow.com/a/22316977
possible better answer: http://stackoverflow.com/a/37140447
has answer: http://stackoverflow.com/a/37140447
tagged with: centos6
answer count: 2
has body: After some google search, it seems that I can only install apache jsvc jsvc-1.0.1-8.9.el6 on CentOS 6.x. It's the latest version for CentOS. See from: http://pkgs.org/search/?query=jsvc&amp;type=smart http://rpmfind.net/linux/rpm2html/search.php?query=jsvc However jsvc 1.0.1 doesn't support some stardard JVM args such as "-javaagent" which I'm currently depend on. How can I install an newer version, e.g.the latest 1.0.15 on my CentoS instance?
tagged with: apache
downvote count: 0
tagged with: jsvc
favorite count: 0

http://stackoverflow.com/q/22059000
type: Question
has comment: http://stackoverflow.com/comment/33449155
has body: I need to align two DNA sequences (they are strings). The matching characters have to be aligned with a vertical line | and the mismatches with a space. Here is my code, the whole thing works well I just can't seem to find a way to align the strings. //Variable List Scanner keyboard = new Scanner(System.in); String s_one, s_two, aligner = " "; int len_one = 0, len_two = 0, a = 0, total_pos = 0, total_neg = 0, total_score = 0; char char_one = ' ', char_two = ' ', compare = ' '; //End Variable List System.out.println("Enter the first DNA sequence: "); s_one = keyboard.next().toUpperCase(); System.out.println("Enter the second DNA sequence: "); s_two = keyboard.next().toUpperCase(); len_one = s_one.length(); len_two = s_two.length(); while(len_one &gt; a &amp;&amp; len_two &gt; a){ char_one = s_one.charAt(a); char_two = s_two.charAt(a); a++; if(char_one == char_two){ total_pos += 2; aligner = "|"; System.out.println(aligner); }else if(char_one != char_two){ total_neg -= 1; aligner = " "; System.out.println(aligner); } } //Output total_score = total_pos + total_neg; System.out.println(s_one); System.out.println(s_two); System.out.println("The total score is: " + total_score); do{//Ask the user if they want to re-enter another DNA sequence System.out.println("Would you like to re-enter another DNA sequence? Y/N"); compare = keyboard.next().charAt(0); if(compare == 'y' || compare == 'Y'){ System.out.println("Enter the first DNA sequence: "); s_one = keyboard.next().toUpperCase(); System.out.println("Enter the second DNA sequence: "); s_two = keyboard.next().toUpperCase(); len_one = s_one.length(); len_two = s_two.length(); while(len_one &gt; a &amp;&amp; len_two &gt; a){ char_one = s_one.charAt(a); char_two = s_two.charAt(a); a++; if(char_one == char_two){ total_pos += 2; }else if(char_one != char_two){ total_neg -= 1; } } //Output total_score = total_pos + total_neg; System.out.println(s_one); System.out.println(); System.out.println(s_two); System.out.println("The total…
has answer: http://stackoverflow.com/a/22059108
has title: Global sequence alignment
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/22059038
type: UnansweredQuestion
tagged with: java

http://stackoverflow.com/q/22118685
has title: How to import in Java?
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/33555994
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33555960
has comment: http://stackoverflow.com/comment/33556126
has comment: http://stackoverflow.com/comment/33556711
has comment: http://stackoverflow.com/comment/33555838
type: Question
has body: So, this is one question my professor asked in the review package she gave us. Suppose the CLASSPATH is set to ~/2013/tests currently i'm in directory ~/2013/DEMOS/myClasses and editing the file Subject.java How to import class Figure in ~/2013/tests/Projects/Final/Figure.java ? Also, can any of you tell me how exactly CLASSPATH works?

http://stackoverflow.com/q/22085107
favorite count: 0
has comment: http://stackoverflow.com/comment/33495648
has comment: http://stackoverflow.com/comment/33495651
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22085108
tagged with: aes
has comment: http://stackoverflow.com/comment/33495649
has comment: http://stackoverflow.com/comment/33495647
score: 1
tagged with: java
upvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33495650
tagged with: des
downvote count: 0
answer count: 1
has title: perl CBC DES equivalent in java
has body: We are migrating some code from perl to java/scala and we hit a roadblock. We're trying to figure out how to do this in Java/scala: use Crypt::CBC; $aesKey = "some key" $cipher = new Crypt::CBC($aesKey, "DES"); $encrypted = $cipher-&gt;encrypt("hello world"); print $encrypted // prints: Salted__�,%�8XL�/1�&amp;�n;����쀍c $decrypted = $cipher-&gt;decrypt($encrypted); print $decrypted // prints: hello world I tried a few things in scala but didn't really get it right, for example something like this: val secretKey = new SecretKeySpec("some key".getBytes("UTF-8"), "DES") val encipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); encipher.init(Cipher.ENCRYPT_MODE, secretKey) val encrypted = encipher.doFinal(bytes) println("BYTES:" + bytes) println("ENCRYPTED!!!!!!: " + encrypted) println(toString(encrypted)) Any help or direction in Java/scala would very much be appreciated

permissions
tag name: permissions
type: Tag
tags question: http://stackoverflow.com/q/22137928
tags question: http://stackoverflow.com/q/22016669
tags question: http://stackoverflow.com/q/22018657
tags question: http://stackoverflow.com/q/22033377

http://stackoverflow.com/q/22099264
has body: I have this class and wants to create a mock to return and verify the return value "50": QAService.java: @Path("/QAService") public class QAService { @GET() //@Path("/") @Produces("text/plain") public String getServiceInfo() { return "50"; } My understanding of mock by defintion is that I can create a fake object of an implementation class and mock functions yet to be developed so I can test the interface. Still I am creating this test to test mocking without having an interface. How do I verify it?: QAServiceTest.java: public class QAServiceTest { @Test public void getserviceTest () { QAService qasmock = mock(QAService.class); when(qasmock.getServiceInfo()).thenReturn("50"); String expected = "50"; assertEquals(expected, qasmock.getServiceInfo()); } }
has comment: http://stackoverflow.com/comment/33521054
has comment: http://stackoverflow.com/comment/33520993
has comment: http://stackoverflow.com/comment/33520653
tagged with: unit-testing
has comment: http://stackoverflow.com/comment/33520895
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22099858
has comment: http://stackoverflow.com/comment/33520598
tagged with: java
has comment: http://stackoverflow.com/comment/33520795
has comment: http://stackoverflow.com/comment/33520522
type: Question
score: 20
answer count: 2
tagged with: mocking
upvote count: 20
tagged with: mockito
downvote count: 0
possible better answer: http://stackoverflow.com/a/22104166
has answer: http://stackoverflow.com/a/22104166
favorite count: 0
accepted answer: http://stackoverflow.com/a/22099858
has title: Mockito Mocking a return value and verify it

http://stackoverflow.com/a/22170700
type: Answer
accepted answer of: http://stackoverflow.com/q/22163320
answers question: http://stackoverflow.com/q/22163320
has body: If are you using GWT 2.6 , then below 2.6 versions of GWT doesn't support java7. Java7 support added in GWT 2.6 version. Make sure that the GWT version and Java version matching or not.
type: AcceptedAnswer
score: 0

http://stackoverflow.com/q/22008707
has answer: http://stackoverflow.com/a/22008932
score: 0
tagged with: android
has answer: http://stackoverflow.com/a/22009833
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/15469942
type: Question
has body: I have start point,intermediate point and destination point. start point and destination point is same now i want to cover all points and reach to same destination point on Google map in Android so, how it will be possible. Thank you in Advanced....
tagged with: java
answer count: 2
tagged with: google-maps
has title: how to draw route from start point to destination point with intermediate points on google map in android?

http://stackoverflow.com/comment/33405195
comment on: http://stackoverflow.com/q/22034500
has text: just for code convention: please do not start variable names with capital letters. only the classname should! so it should be `arr[i]=....`
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33402153
type: QuestionComment
type: Comment
has text: i am using terminal to compile from linux deepin
score: 0
comment on: http://stackoverflow.com/q/22032765

http://stackoverflow.com/q/22039466
has answer: http://stackoverflow.com/a/22083681
has comment: http://stackoverflow.com/comment/33425704
has answer: http://stackoverflow.com/a/22039777
has body: Firstly, i know that it seems like this question has been asked before, and it did but i didn't get any good answer so i will ask again more clearly. This code may cause deadlock if the notify happens when no other thread is currently waiting while (!checkPreConditions()){ synchronized(lock){ lock.wait(); } } doWork(); synchronized(lock) { lock.notifyAll(); } I'v tried putting a counter for the number of threads notifying while no threads are waiting but this solution was a bit cumbersome.. another idea was to timeout the wait but then the program may wait for no reason. is there a common solution / pattern for that problem?
tagged with: java
has comment: http://stackoverflow.com/comment/33425776
tagged with: concurrency
upvote count: 1
linked to: http://stackoverflow.com/q/17811794
downvote count: 1
has comment: http://stackoverflow.com/comment/33447075
type: Question
has title: avoiding deadlock when using wait and notify
has comment: http://stackoverflow.com/comment/33425835
has answer: http://stackoverflow.com/a/22948339
has comment: http://stackoverflow.com/comment/33414017
has comment: http://stackoverflow.com/comment/33413930
has comment: http://stackoverflow.com/comment/33422269
tagged with: deadlock
score: 0
has comment: http://stackoverflow.com/comment/33428299
answer count: 3
tagged with: synchronization
favorite count: 0
type: UnansweredQuestion
tagged with: multithreading
has comment: http://stackoverflow.com/comment/33425934

sensors
type: Tag
tag name: sensors
tags question: http://stackoverflow.com/q/22016101

http://stackoverflow.com/comment/33562574
comment on: http://stackoverflow.com/q/22121915
type: Comment
type: QuestionComment
has text: In render only are super(); and in PantallaJuego : render is good.
score: 0

http://stackoverflow.com/a/22167250
has body: you have not implemnt this..,just implement OnHeadlineSelectedListener public class MainActivity extends FragmentActivity implements OnHeadlineSelectedListener {
downvote count: 0
type: Answer
upvote count: 3
answers question: http://stackoverflow.com/q/22167165
score: 3
has comment: http://stackoverflow.com/comment/33644838

http://stackoverflow.com/q/22134406
type: AnsweredQuestion
score: 3
tagged with: java
has comment: http://stackoverflow.com/comment/33584955
tagged with: comparator
answer count: 3
has answer: http://stackoverflow.com/a/22134613
has comment: http://stackoverflow.com/comment/33585312
downvote count: 0
tagged with: string
possible better answer: http://stackoverflow.com/a/22135006
favorite count: 0
has answer: http://stackoverflow.com/a/22135006
tagged with: initialization
has title: How to correctly initialize a Comparator?
accepted answer: http://stackoverflow.com/a/22134613
has body: I need to write a static method in a class MinTester that computes the "smallest" string from an ArrayList collection using a comparator object: public static String min(ArrayList&lt;String&gt; list, Comparator&lt;String&gt; comp) I cannot use the Collections class to compute the minimum. Here is what I have so far. public class MinTester { public static String min(ArrayList&lt;String&gt; list, Comparator&lt;String&gt; comp) { String shortest = list.get(0); for(String str : list) { if ( comp.compare(str, shortest) &lt; 0) { shortest = str; } } return shortest; } } I am not getting any errors here from the method, So I try to test it in Main with this. I get this error when trying to pass comp: Variable comp may not have been initialized public static void main(String[] args) { // TODO code application logic here MinTester s = new MinTester(); Comparator&lt;String&gt; comp; ArrayList&lt;String&gt; list = new ArrayList&lt;&gt;(); list.add("a"); list.add("ab"); list.add("abc"); list.add("abcd"); String a = s.min(list,comp);//Error: Variable comp may not have been initialized System.out.println(a); } Heres where I run into my problem. I try Comparator&lt;String&gt; comp = new Comparator&lt;&gt;();//Error:Comparator is abstract, cannot be instantiated Comparator&lt;String&gt; comp = new MinTester();//Error: MinTester cannot be converted to Comparator&lt;String&gt; Can anyone tell me the proper way to handle this Comparator? Im not sure if Im just trying to initialize it incorrectly, or if I'm missing something in my MinTester class.
upvote count: 3
has answer: http://stackoverflow.com/a/22134669
type: Question

http://stackoverflow.com/q/22074230
favorite count: 0
type: Question
tagged with: jdbc
has comment: http://stackoverflow.com/comment/33476590
upvote count: 2
has answer: http://stackoverflow.com/a/22083282
linked to: http://stackoverflow.com/q/10062328
tagged with: spring
tagged with: jdbctemplate
answer count: 1
tagged with: java
has body: So just for simplicity, I wrote up a little example of what I am trying to do. I haven't been able to find a solution for this but I'm sure there is a solution. I am trying to batch insert a list of objects into a table that contains an id for some other object. Confusing to explain but if you look at the code it should be easy to see what I am trying to do: public class Person{ private Long id; private String firstName; private String lastName; private Animal animal; ... {getters/setters} } public class Animal{ private Long id; private String species; private String name; ... {getters/setters} } Somewhere in my code: List&lt;Person&gt; people = someList; personsRepository.save(people); My repository: public class PersonsRepository{ @Autowired(required=true) private NamedParameterJdbcTemplate namedParameterJdbcTemplate; public void save(List&lt;Person&gt; people) { String sql = "insert into PERSONS(ID, FIRST_NAME, LAST_NAME, ANIMAL_ID) VALUES(:id, :firstName, :lastName, {{ animal.id }})"; SqlParameterSource[] parameterSource = SqlParameterSourceUtils.createBatch(people.toArray()); namedParameterJdbcTemplate.batchUpdate(sql, parameterSource); } } You will notice in my repository, I need to insert the ANIMAL_ID. How can I do that with a batch insert? I am using an oracle db in prod, but hsql (with oracle syntax) locally.
accepted answer: http://stackoverflow.com/a/22083282
has title: NamedJDBCTemplate batch insert with object members
score: 2
type: AnsweredQuestion
downvote count: 0

http://stackoverflow.com/comment/33546404
type: Comment
type: QuestionComment
has text: I see no loop at all in your code, although your question is about writing and reading multiple persons.
comment on: http://stackoverflow.com/q/22113310
score: 0

http://stackoverflow.com/a/22158056
has body: In Java7 you can do this: File theFile = new File("c:/foobar.txt"); Path file = theFile.toPath(); Files.setAttribute(file, "dos:archive", false);
score: 4
upvote count: 4
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22157901
answers question: http://stackoverflow.com/q/22157901
type: Answer

http://stackoverflow.com/comment/33434851
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22051235
has text: Why not try compiling it and see for yourself?
score: 14

spring-security
tags question: http://stackoverflow.com/q/22071599
tags question: http://stackoverflow.com/q/22006599
tags question: http://stackoverflow.com/q/22167045
tags question: http://stackoverflow.com/q/22032045
tags question: http://stackoverflow.com/q/22060474
tags question: http://stackoverflow.com/q/22127344
tags question: http://stackoverflow.com/q/22046180
tags question: http://stackoverflow.com/q/22115493
type: Tag
tags question: http://stackoverflow.com/q/22048511
tags question: http://stackoverflow.com/q/22011767
tags question: http://stackoverflow.com/q/22160711
tags question: http://stackoverflow.com/q/22093018
tags question: http://stackoverflow.com/q/22153339
tags question: http://stackoverflow.com/q/22010619
tags question: http://stackoverflow.com/q/22111146
tags question: http://stackoverflow.com/q/22154240
tags question: http://stackoverflow.com/q/22091540
tags question: http://stackoverflow.com/q/22167784
tag name: spring-security

http://stackoverflow.com/comment/33445573
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22057083
has text: It's `%` followed by 2 hex characters.
score: 4

http://stackoverflow.com/q/22118846
tagged with: java
has title: Array Index Out of Bounds Exception - RMI DynamicClient
type: Question
score: 0
has comment: http://stackoverflow.com/comment/33556636
has comment: http://stackoverflow.com/comment/33578107
has comment: http://stackoverflow.com/comment/33559842
has comment: http://stackoverflow.com/comment/33578048
answer count: 0
has comment: http://stackoverflow.com/comment/33558554
type: UnansweredQuestion
has body: import java.rmi.Naming; import java.rmi.Remote; import java.rmi.RMISecurityManager; import java.rmi.server.RMIClassLoader; import java.util.*; import java.lang.reflect.Constructor; public class DynamicClient { public DynamicClient (String[] args) throws Exception { Properties p = System.getProperties(); String url = p.getProperty("java.rmi.server.codebase"); Class ClasseClient = RMIClassLoader.loadClass(url,"ClientDistant"); Constructor [] C = ClasseClient.getConstructors(); C[0].newInstance( new Object[] {args} ); } public static void main (String[] args) { System.setSecurityManager( new RMISecurityManager() ); try { DynamicClient cli = new DynamicClient(args); } catch (Exception e) { System.out.println(e.toString()); } } } This code is supposed to dynamically charge the class ClientDistant from a web server and execute the treatment, however it displays an error message: C:\Users\DELL\Desktop&gt;java -Djava.security.policy=client.policy -Djava.rmi.serv er.useCodebaseOnly=false -Djava.rmi.server.codebase=http://localhost:8080/RMI/ DynamicClient java.lang.ArrayIndexOutOfBoundsException: 0 where RMI is a directory's in the java web application named RMI ( I m using GlassFish server). Any solutions to load ClientDistant and execute its treatment?
has comment: http://stackoverflow.com/comment/33556352
tagged with: rmi

http://stackoverflow.com/q/22147309
type: AnsweredQuestion
has title: Hibernate OneToMany Relation
tagged with: jsf
score: 1
tagged with: java
tagged with: hibernate
tagged with: hibernate-onetomany
accepted answer: http://stackoverflow.com/a/22147511
type: Question
has body: I got a problem with hibernate OneToMany relation. For some reason hibernate has problems saving the Relation in the right way. Here are the two classes: @Entity @Table public class Project { @Id @GenericGenerator(name = "generator", strategy = "increment") @GeneratedValue(generator = "generator") @Column(unique = true, nullable = false) private int projectId; @Column(unique = true, nullable = false) private String name; @ManyToMany(fetch = FetchType.EAGER, mappedBy = "projects", targetEntity = User.class) private Set&lt;User&gt; users; @OneToMany(fetch = FetchType.EAGER, mappedBy = "project", cascade = CascadeType.ALL, targetEntity = WorkingPackage.class) private Set&lt;WorkingPackage&gt; workingPackages; /** * Default Constructor. Creates an empty object. */ public Project() { // nothing to do here! } /** * Convenience Constructor. Use this constructor to create a new {@link Project} object. * * @param name The name of the project. May not be null. */ public Project(String name) { this.name = name; } /** * The id is the unique identifier for the {@link Project} in the database. DO NOT set the * id manually since it will be generated by Hibernate. * * @return The unique identifier for the project. */ public int getProjectId() { return projectId; } /** * The id is the unique identifier for the {@link Project} in the database. DO NOT set the * id manually since it will be generated by Hibernate. * * @param projectId The unique identifier for the project. */ public void setProjectId(int projectId) { this.projectId = projectId; } /** * Refers to the name of the {@link Project}. * * @return The name of the project. */ public String getName() { return name; } /** * Refers to the name of the {@link Project}. * * @param name The name of the project. */ public void setName(String name) { this.name = name; } /** * Gets the working packages. * * @return the working packages */ public Set&lt;WorkingPackage&gt; getWorkingPackages() { return workingPackages; } /** * Sets the wor…
has comment: http://stackoverflow.com/comment/33606504
answer count: 1
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/22147511
tagged with: one-to-many
upvote count: 1

http://stackoverflow.com/a/22113070
downvote count: 0
has body: Encryption operations are always quite slow. Anyway, if you are using a fixed salt generator, jasypt 1.9.2 includes an optimization that saves some initialization calls and might improve your performance: http://jasypt.org/changelogs/jasypt/ChangeLog.txt As for iterations, note that iteration in PBE encryption (two-way) is only performed in order to obtain the encryption key (it is obtained by applying a hash function on the password, which is not a byte[] encryption key but an unlimited-strength String). The amount of iterations performed on the hash function that obtains the key can be configured in most encryptor objects by means of a keyObtentionIterations property (and if not, javadoc will explain the value chosen). Disclaimer, per stackoverflow rules: I'm jasypt's author.
upvote count: 2
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22085170
type: Answer
answers question: http://stackoverflow.com/q/22085170
has comment: http://stackoverflow.com/comment/45688727
score: 2

http://stackoverflow.com/comment/33631232
comment on: http://stackoverflow.com/a/22160426
type: AnswerComment
score: 0
type: Comment
has text: @HovercraftFullOfEels So a JFrame doesn't actually execute the code until it is closed? But a JDialog will do so as it gets the input?

http://stackoverflow.com/a/22144234
answers question: http://stackoverflow.com/q/22106680
type: Answer
has body: Well firstly , i do not see the need for recursive calling. It will just make your code more complex. You can have two methods , one method to check if the URL exists in the db and based on that the logic to insert or go ahead. Another method to fetch data from the page. So i would write it something like this: public class htmlCrawler{ public static db_Connection db = new db_Connection(); public htmlCrawler(String url){ getLinksFromPage(url); } public boolean checkInDb(String url){ //your data base logic here } public boolean getLinksFromPage(String url){ //your jsoup thing //the loop Elements questions = doc.select("a[href]").getAll(); for(Element link: questions){ { String link = link.attr("abs:href"); checkInDb(link); } } } Let me know if u need more help.
has comment: http://stackoverflow.com/comment/33692447
accepted answer of: http://stackoverflow.com/q/22106680
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33694053

http://stackoverflow.com/comment/33398271
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22030143
has text: Using JNI like this (which is a cool idea) would preclude you adding any Java based components to the window ...
type: AnswerComment

http://stackoverflow.com/q/22035592
score: 0
has comment: http://stackoverflow.com/comment/33406790
has title: extracting comments from facebook
type: UnansweredQuestion
tagged with: facebook
has comment: http://stackoverflow.com/comment/33407544
has body: I want to extract the details of persons who like a particular page. I'm trying it but now I'm trying to extract the comments/posts from a page based on the keyword I specify. I works but doesn't works good since only for some pages it shows output and shows some exceptions for all other keyword that I specify. Here is my sample code. How can I get the information abou users who liked a particular page? Facebook facebook = new FacebookFactory().getInstance(); ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); facebook.setOAuthAppId("", ""); configurationBuilder .setOAuthPermissions("id, name, first_name, last_name,likes"); String accessTokenString = "*****"; AccessToken at = new AccessToken(accessTokenString); configurationBuilder.setOAuthAppId("1466708753544336"); configurationBuilder.setOAuthAppSecret("*****"); facebook.setOAuthAccessToken(at); @SuppressWarnings("resource") Scanner sc=new Scanner(System.in); String s=sc.nextLine(); ResponseList&lt;Post&gt; posts=facebook.getPosts(s,new Reading().limit(100)); StringBuilder str = new StringBuilder(); ResponseList&lt;Post&gt; res =facebook.getPosts(s); for(Post post :res) { //str.append(post.getMessage()); for(int i=0;i&lt;post.getComments().size();i++) { str.append(post.getComments().get(i).getMessage()); str.append(post.getComments().get(i).getId()); } } System.out.println(str); }//try catch(Exception e) { e.printStackTrace(); } It shows this type of exception for some keywords when I enter "Ice-Cream". I don't know what's wrong with this. Any kind of help will be appreciated Ice-Cream FacebookException{statusCode=400, response= HttpResponse{statusCode=400, responseAsString='&lt;!DOCTYPE html PUBLIC "-// W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" id="facebook"&gt; &lt;head&gt; &lt;title&gt;Facebook | Error&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=…
answer count: 0
has comment: http://stackoverflow.com/comment/33407304
tagged with: java
has comment: http://stackoverflow.com/comment/33407655
type: Question
has comment: http://stackoverflow.com/comment/33408469
has comment: http://stackoverflow.com/comment/33407236
has comment: http://stackoverflow.com/comment/33406950

http://stackoverflow.com/comment/33397070
comment on: http://stackoverflow.com/a/22029624
type: AnswerComment
score: 0
type: Comment
has text: actually I have a feeling that you have some other M in a superclass :-) let me wait for more code to come :-)

http://stackoverflow.com/q/22068368
has title: AspectJ: polymorphic logging of methods. Pointcut signature issues
type: Question
tagged with: aspectj
has comment: http://stackoverflow.com/comment/33605669
downvote count: 0
has comment: http://stackoverflow.com/comment/33605930
has comment: http://stackoverflow.com/comment/33508763
has answer: http://stackoverflow.com/a/22104152
answer count: 1
score: 1
favorite count: 0
upvote count: 1
has body: I'm having issues with a few pointcut signatures inside my aspect. 1.. Messages are entering our system via 2 exposed interfaces(IIncoming, IOutgoing) and then they are processed by a PartsManager component like: PartsManager pmanager = new PartManagerImpl(); pmanager.process(message); public class PartManagerImpl implements PartsManager{ public boolean process(Message message){ //do some messsage processing.. return true; } } 2.. All processed messages are then logged via the following aspect. @Aspect public class OldMessageLogging { private static final Logger LOGGER = Logger.getLogger(OldMessageLogging.class); @Before("execution(* org.company.PartManagerImpl.process(..))") public void processMessageCalled(final JoinPoint joinPoint) throws Throwable { LOGGER.info("Message processed."); return; } } 3.. But, now I want to log processed messages but with one additional information. Instead of Message processed. I want the log entry to become Incoming message processed. or Outgoing message processed. 4.. So, I have defined two additional interfaces and changed PartManagerImpl.java like this: public class PartManagerImpl implements PartsManager, IncommingMessageProcessor, OutgoingMessageProcessor { public boolean process(Message message){ //do some messsage processing.. return true; } } public interface IncommingMessageProcessor { boolean process(Message message); } public interface OutgoingMessageProcessor { boolean process(Message message); } 5.. Now, message processing is performed like this: IncommingMessageProcessor inProcessor = new PartManagerImpl(); inProcessor.process(message); OutgoingMessageProcessor outProcessor = new PartManagerImpl(); outProcessor.process(message); 6.. A new aspect was created to reflect my new logging needs. @Aspect public class NewMessageLogging { private static final Logger LOGGER = Logger.getLogger(NewMessageLogging.class); @Before("execution(* org.company.IncommingMessageProcessor.process(..))") public void processIncomingCalled(fina…
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22104152
tagged with: java

http://stackoverflow.com/q/22125055
has comment: http://stackoverflow.com/comment/33567734
upvote count: 5
tagged with: java
score: 5
downvote count: 0
answer count: 1
favorite count: 0
has body: So, the following, very basic example of threading isn't compiling if i remove the import statement. However, earlier I didn't have to import the Thread class. Has anyone been through this, please assist me. import java.lang.Thread; class Test { public static void main(String args[]) { Thread t = Thread.currentThread(); System.out.println("current thread is "+t); t.setName("amar"); System.out.println("after name change "+t); try { for(int n=5;n&gt;0;n--) { System.out.println(n); Thread.sleep(1000); } }catch(InterruptedException e) { System.out.println("main interrupted"); } } }
has comment: http://stackoverflow.com/comment/33567791
has comment: http://stackoverflow.com/comment/33567772
has comment: http://stackoverflow.com/comment/33567764
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33567741
has comment: http://stackoverflow.com/comment/33567748
tagged with: compiler-errors
has answer: http://stackoverflow.com/a/22125150
tagged with: multithreading
has comment: http://stackoverflow.com/comment/33567809
has comment: http://stackoverflow.com/comment/33583050
type: Question
accepted answer: http://stackoverflow.com/a/22125150
has title: Do I need to import the Thread class explicitly?

http://stackoverflow.com/comment/33676271
comment on: http://stackoverflow.com/a/22161571
has text: Sorry, only just logged back in :P
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33406938
score: 0
has text: i tried a java class called app-bundler.jar but that didnt work :(
type: Comment
comment on: http://stackoverflow.com/a/22035339
type: AnswerComment

http://stackoverflow.com/comment/33607083
has text: Unfortunately I haven't found the right mechanism to find this in the Google Drive SDK. You can see my update, I try update.getLastStatusCode(), but its returning -1, while the error message contains a 404.
type: Comment
comment on: http://stackoverflow.com/a/22147354
score: 0
type: AnswerComment

http://stackoverflow.com/a/22118540
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/22103451
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/22103451
has body: I am not sure whether it is simplest solution, but I think that you can do it in this way: Create new List implementation Write serializer for new type Use this type in your POJO classes New Java class which extends ArrayList: @JsonSerialize(using = JacksonListSerializer.class) class JacksonList&lt;E&gt; extends ArrayList&lt;E&gt; { private static final long serialVersionUID = 1L; } Serializer for above class: class JacksonListSerializer extends JsonSerializer&lt;JacksonList&lt;?&gt;&gt; { @Override public void serialize(JacksonList&lt;?&gt; list, JsonGenerator generator, SerializerProvider provider) throws IOException, JsonProcessingException { generator.writeStartArray(); if (list != null) { for (Object item : list) { generator.writeObject(item); } } generator.writeEndArray(); } } Now, you can use this list in your example: public static void main(String[] args) throws IOException { ObjectMapper om = new ObjectMapper(); List&lt;Common&gt; list = new JacksonList&lt;Common&gt;(); list.add(new A()); list.add(new B()); om.addMixInAnnotations(A.class, AMixIn.class); om.addMixInAnnotations(B.class, BMixIn.class); System.out.println(om.writeValueAsString(list)); System.out.println(om.writeValueAsString(new A())); } Above example prints: [{"type":"CODE"},{"type":"CODE"}] {"type":"CODE"}
type: AcceptedAnswer

http://stackoverflow.com/q/22132283
has comment: http://stackoverflow.com/comment/33581061
tagged with: lazy-initialization
score: 4
upvote count: 4
has body: I am defining default-lazy-init="true" in the spring context file inside beans tag but when I start tomcat, I see my beans are getting instantiated. here is what it shows in log - org.springframework.beans.factory.support.DefaultListableBeanFactory (DefaultListableBeanFactory.java:555) - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@ac6fb1: defining beans [dataSource,my other beans in app....... Am I missing something ?
answer count: 1
downvote count: 0
favorite count: 0
type: UnansweredQuestion
tagged with: spring
tagged with: java
has title: Spring default-lazy-init does not seems to work, i see Pre-instantiating of singletons
has answer: http://stackoverflow.com/a/22132364
type: Question

http://stackoverflow.com/comment/33657868
type: QuestionComment
has text: @Uluk Biy So when if I were to midify ENTITY and add something like DELTA_ACTION. It would be appended into the list automatically without me adding explicitly coding it into the list.
comment on: http://stackoverflow.com/q/22158087
score: 0
type: Comment

http://stackoverflow.com/q/22013206
tagged with: android
linked to: http://stackoverflow.com/q/16596064
accepted answer: http://stackoverflow.com/a/22017733
upvote count: 2
tagged with: java
tagged with: android-ndk
type: Question
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/12864778
has answer: http://stackoverflow.com/a/22017733
score: 2
has title: shared memory in android ndk
answer count: 1
downvote count: 0
favorite count: 0
has body: I wanted to transfer large data from one process/app to another process/app in Android, but some how creating shared memory using Memory File in Java layer doesn't work. So then tried to create shared Memory in android native, somewhere I read ashmem_create_region API can be used. But looks like this API is not accessible or open. It is inside libcutils.so. which is at android-ndk-r9c/platforms/android-19/arch-arm/usr/lib/rs/libcutils.so Q1. How to access this library in android native code. Q2. If it is not possible to access then what is purpose of giving this in ndk tool. Q3. If somehow I linked libcutils.so and able to create shared Memory in native using libcutils.so Then can I use this fd to map with MemoryFile in Java layer so it will avoid application native copy to write for each data transaction.

http://stackoverflow.com/q/22165436
has answer: http://stackoverflow.com/a/27249196
tagged with: jakarta-ee
tagged with: java
type: Question
answer count: 1
has title: Server Oracle WebLogic Server 11gR1 PatchSet 1 at localhost failed to start
score: 0
tagged with: weblogic-10.x
has body: I am using portal1032_win32.exe file to install the weblogic server in my local. After following basic installation by providing password and choosing the folder names and selected jdk which comes through installation. Also created domain by providing the defalut configurationd and chooses adminserver alone. I have opened the eclipse IDE comes through this and started. Added the server by choosing base_domain. I have started the server. here is my problem It is taking more time and finally displaying following message "Server Oracle WebLogic Server 11gR1 PatchSet 1 at localhost failed to start."
type: UnansweredQuestion

http://stackoverflow.com/comment/33365835
type: QuestionComment
has text: Have you read the Java API spec on them?
comment on: http://stackoverflow.com/q/22012998
score: 0
type: Comment

http://stackoverflow.com/q/22140242
type: UnansweredQuestion
tagged with: maven
has comment: http://stackoverflow.com/comment/33594486
has comment: http://stackoverflow.com/comment/33594590
tagged with: java
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/33594463
downvote count: 0
has body: I have a batch file to make my life easy. I want to build a maven project then copy the distribution from the target folder to another folder, then unzip them and followed by few copy replace instructions. This works perfectly fine when there is no issue with the code. If there is any issue with the build and build fails then I want to stop the batch execution. I am not able to figure it out. ::Kill all the java processs taskkill /f /im "java.exe" ::Take the sprint number form the user set /p sprintNumber=Enter the sprint number:%=% :: Navigate to the code path cd D:\Sprint-%sprintNumber% call D: :: Build the code ::@echo ###############BUILDING#################### ::call mvn clean install ::cd .. ::Remove the distribution IF EXIST "D:\Distribution\Sprint-%sprintNumber%\" ( rmdir "D:\Distribution\Sprint-%sprintNumber%\" /s /q ) ::Few more instructions I want to stop my execution if maven install fails. Please provide any suggestion to acheive this task.
has answer: http://stackoverflow.com/a/78638526
tagged with: batch-file
has answer: http://stackoverflow.com/a/22142235
favorite count: 0
score: 2
has title: How to stop batch execution when maven build fails
upvote count: 2

http://stackoverflow.com/comment/33507092
type: Comment
type: AnswerComment
has text: @mKorbel thx for info. Meta and the MCVE are useful resources. Updated answer to refer to MCVE rather than SSCCE.
comment on: http://stackoverflow.com/a/22089747
score: 0

http://stackoverflow.com/a/22196592
type: Answer
has comment: http://stackoverflow.com/comment/33696156
has body: you question is not clear for me. What do you want to achieve? What means can I prevent an implementation from being passed ? what you want to pass instead? Null or your implementation? You are right about that Nexus OSS uses Google Guice as Dependency injection framework. To bind an implementation to some interface you have to create modules where you say something like this: bind(ReleaseRemover.class).to(DefaultReleaseRemover.class); As you see in DefaultReleaseRemover there are another injections and they very likely stuck up. So the injected implementation in DefaultReleaseRemover contains another injections and so on. The DefaultReleaseRemover is annotated as @Singleton which means there is only one instance of DefaultReleaseRemover class for whole injector. Well, you have your interface and implementation and your module with bindings. Now you need to create Guice Injector and use it to create all objects for you. For Nexus OSS you can find Guice Injection entry point at https://github.com/sonatype/nexus-oss/blob/de6a606372349283f78aeaa498e9a70d4dd967b1/components/nexus-webapp/src/main/java/org/sonatype/nexus/webapp/WebappBootstrap.java line 118 Guice.createInjector(your modules...); See, you will provide all modules you want to install to the Guice Injector. Be aware there could be some sub modules installed inside modules. You dont have to explicitly pass it into createInjector function. So, if you want to change some Guice bindings it's good start to dig from there. UPDATE: I don't know the mechanics. But you have to bind your implementation in some Module.configuration() as bind(ReleaseRemover.class).annotathedWith(Names.named("custom")).to(MyCustomReleaseRemover.class); The module should be not PrivateModule:) Then you will pass you CustomReleaseRemover as @Inject public ReleaseRemoverTask( final @Named("custom") ReleaseRemover releaseRemover ) I would direct you more straight forward, but I have no idea how it works inside Nexus OSS. Maybe somebody could…
score: 0
answers question: http://stackoverflow.com/q/22149683
has comment: http://stackoverflow.com/comment/33695293

http://stackoverflow.com/a/22066467
type: Answer
accepted answer of: http://stackoverflow.com/q/22009372
has body: Installing e(fx)clipse and adding the JAVA FX SDK Library to the build path of the project works as a workaround.
type: AcceptedAnswer
score: 0
answers question: http://stackoverflow.com/q/22009372

http://stackoverflow.com/comment/33374129
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22014601
type: QuestionComment
has text: A very straightforward null pointer exception. This question is unlikely to help anyone in the future.

http://stackoverflow.com/q/22038359
type: Question
has title: Reload static fields in a java class
has body: I have a class in java which has a number of static final strings and one static Locale variable. These Strings are basically keys to a messagebundle which return the translated Strings using the locale. i.e., public static Locale locale = Locale.getDefault(); public static String MSG1 = Translator.get(locale, "MSG1"); //Similar Strings. This locale variable is set at runtime based on the browser locale. But since these are static variables, they are already initialized with the default locale and changes to the locale variable does not have any effect. Is there a way to "reload" these strings everytime the localevariable is changed? I don't want to make the obvious change(making all the strings non static and initializing locale in constructor/method) because this class has a lot of messages(250+) and is used in too many places.
upvote count: 6
has answer: http://stackoverflow.com/a/22038715
tagged with: java
answer count: 3
accepted answer: http://stackoverflow.com/a/22038715
has comment: http://stackoverflow.com/comment/33411420
score: 6
has comment: http://stackoverflow.com/comment/33411439
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22038400
has comment: http://stackoverflow.com/comment/33411947
downvote count: 0
has answer: http://stackoverflow.com/a/22038429
has answer: http://stackoverflow.com/a/22038400
favorite count: 0
tagged with: static

http://stackoverflow.com/comment/33562550
has text: One is enough, or less `Math.log((n1+1.0)/(n2+n3))/Math.log(2)` the use of a `1.0` turns it into a double.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22122171
score: 0

http://stackoverflow.com/a/22012027
accepted answer of: http://stackoverflow.com/q/22010955
answers question: http://stackoverflow.com/q/22010955
score: 0
type: AcceptedAnswer
has body: Finds every "data-segment" by using regex, then splits it with # as delimiter and prints it: File blub = new File("blub.txt"); Scanner scanner = null; try { scanner = new Scanner(blub); } catch (FileNotFoundException e){} while(scanner.hasNext("((\\S*)#){6}(\\w)")) { String buffer = scanner.next("((\\S*)#){6}(\\w)"); for(String value : buffer.split("#")) System.out.print(value + " "); System.out.println(); } Output: Adams Marilyn 8233331109 0 0 01012014 C Anderson John 5025559980 20 15 12152013 M Baker-Brown Angelica 9021329944 0 3 02112014 C Note: You can use any whitespace character to separate each data-segment in the input file, so even spaces are okay or tabs(or crazy mix with empty lines and so on). For farther use of data: you could add your data in an arraylist since buffer.split("#") gives you an array of the data-segment, so you can output it easier with your desired changes to each value.(or in a different order)
type: Answer

http://stackoverflow.com/comment/33531187
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22104521
has text: Is there a way to Add Screen Shot for new user?

http://stackoverflow.com/a/22064657
has comment: http://stackoverflow.com/comment/33458446
has comment: http://stackoverflow.com/comment/33458183
has comment: http://stackoverflow.com/comment/33458034
has comment: http://stackoverflow.com/comment/33462747
score: 1
upvote count: 2
has body: First you should change the int max = score[0][0]; into as int max = Integer.MIN_VALUE; as it might produce not valid result. And the second is that you need to swap the index while compare if (score[j][i] &gt; max) { max = score[j][i]; }
answers question: http://stackoverflow.com/q/22064558
downvote count: 1
type: Answer

http://stackoverflow.com/comment/33404895
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22034158
has text: @ShoaibChikate I tried with session.close(), but still was getting same result. Also session.close() was throwing an error where I am reading CURSOR from a procedure as ResultSet is closed.
score: 0

http://stackoverflow.com/a/22035347
answers question: http://stackoverflow.com/q/22035054
has body: Inner join: select * from entityA inner join entityB on entityA.field1 = entityB.field2 Left outer join: select * from entityA left outer join entityB on entityA.field1 = entityB.field2 Change entities and use left join again instead of right join: select * from entityB left outer join entityA on entityA.field1 = entityB.field2 Useful posts: http://chrisiecorner.blogspot.com/2012/12/jpa-and-outer-joins.html, RIGHT JOIN in JPQL So better way is criterion query, see: Querying Relationships Using Joins
type: Answer
score: 0

http://stackoverflow.com/comment/33699177
comment on: http://stackoverflow.com/q/22032462
score: 0
has text: you havent tried my previous comment, and you havent said whether what you see is on dev server or real
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22151785
has comment: http://stackoverflow.com/comment/33615209
has body: I'm going to assume you have access to the code for fio and can rebuild it. One mechanism you could use would be to have fio output the local variable state you are interested in to one of the output streams (stdout or stderr) that you are handling, and parse the values out of it as messages whenever it changes and fio outputs an updated value. That keeps the communication fairly simple. If you have a lot of complex data, you might want to consider creating a separate communication channel (shared memory, for example, or named pipes, or a socket based connection) for shared state. If you are just interested in some cheap debugging, I'd just go with the first approach by outputting something like DBG{var1}=&lt;value&gt; to stderr whenever a value of interest changes, and have your stderr stream handler in Java record the state for use wherever you need it.
has comment: http://stackoverflow.com/comment/33615279
has comment: http://stackoverflow.com/comment/33615076
downvote count: 0
type: Answer
score: 2
answers question: http://stackoverflow.com/q/22151547
upvote count: 2

http://stackoverflow.com/comment/33369977
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22015242
has text: You may be interested in http://stackoverflow.com/questions/7295604/how-to-set-an-alarm-in-android-java
score: 0

http://stackoverflow.com/comment/33360986
comment on: http://stackoverflow.com/q/22009679
has text: One thing, you need to mark and reset the buffer if you decide you need to wait for the next pass due to not having a full frame. See my decode here - https://github.com/basho/riak-java-client/blob/develop/src/main/java/com/basho/riak/client/core/netty/RiakMessageCodec.java#L40 (not saying it'll solve your issue, but noticed you hadn't done so)
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22079808
answers question: http://stackoverflow.com/q/22079763
downvote count: 0
has body: There is no return where you have the recursive call to searchBin
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/a/27174629
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22158923
score: 37
type: Answer
has body: For me it was similar error. I solved it simply by inserting SetJavaHome /usr/lib/jvm/java-7-openjdk-amd64/ into ~/.sqldeveloper/4.0.0/product.conf file.
has comment: http://stackoverflow.com/comment/101869462
has comment: http://stackoverflow.com/comment/117112736
has comment: http://stackoverflow.com/comment/120444738
upvote count: 37
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/101865750
answers question: http://stackoverflow.com/q/22158923

http://stackoverflow.com/a/22133720
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33584068
has comment: http://stackoverflow.com/comment/33583861
accepted answer of: http://stackoverflow.com/q/22133615
type: Answer
has comment: http://stackoverflow.com/comment/33583775
downvote count: 4
has comment: http://stackoverflow.com/comment/33583894
answers question: http://stackoverflow.com/q/22133615
has comment: http://stackoverflow.com/comment/33583939
has comment: http://stackoverflow.com/comment/33583978
upvote count: 8
has comment: http://stackoverflow.com/comment/33584102
has comment: http://stackoverflow.com/comment/33584179
score: 4
has body: I add it here in case someone really need it or want to study from it: public static void main(String[] args) { String webapple = "webapple"; String apple = "apple"; char[] webappleArray = webapple.toCharArray(); char[] appleArray = apple.toCharArray(); System.out.println(isPresent(appleArray, webappleArray)); } public static boolean isPresent(char[] apple, char[] webapple) { for (int i = 0; i &lt; webapple.length - apple.length+1; i++) { for (int j = 0; j &lt; apple.length; j++) { if (webapple[i + j] == apple[j]) { if (j == apple.length - 1) { return true; } } else { break; } } } return false; }

http://stackoverflow.com/comment/33564605
comment on: http://stackoverflow.com/q/22123317
has text: Oh I see, it was because the value was -30 in the String. Thanks
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/33539459
has text: Is the TextView that you are updating still visible/declared? I would debug the updateTextView and try to if something is null there.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22098121

http://stackoverflow.com/comment/33625807
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22157525
has text: I will double check and confirm. I got it to work using this.address=address and a redirect but I am not sure how this will work in production. For example if multiple requests are sent does each one have an instance or will one instance overwrite another.
score: 0

http://stackoverflow.com/comment/38622471
score: 1
has text: Yes, `Expectations(Calendar.class)` will work the same, except that you'll have *strict* expectations, so keep that in mind. Both tests above *partially* mock the `Calendar` class, since we only want to make `getInstance()` return (unmocked) calendar objects. For more information and examples, please refer to the [online documentation](http://jmockit.github.io/tutorial.html).
type: AnswerComment
comment on: http://stackoverflow.com/a/22229338
type: Comment

http://stackoverflow.com/q/22006190
tagged with: java
has answer: http://stackoverflow.com/a/22006571
type: Question
answer count: 2
has title: Returning an enum as an Object type
has comment: http://stackoverflow.com/comment/33354437
accepted answer: http://stackoverflow.com/a/22006427
score: 0
has body: I am trying to set the value of a Field programmatically by parsing through an xml document to find the values. My structure is somewhat like this: value = parseXml(); field.set(myObject, value); private Object parseXml() { String value = getValueFromXmlNode(); if (type.isInstance(Enum.class)) { return Enum.valueOf(((Class&lt;Enum&gt;) type), value); } else { return value; } } This works fine for most cases. However, in the case that the field expects an Enum, this no longer works. Because I set the return type of my method as Object, the enum gets casted to a String instead. Then the field.set() call fails. What's the proper way to have a method return a generic type that could possibly be an Enum? With primitive types there are Object wrappers that autobox and unbox, does Enum have something like that?
possible better answer: http://stackoverflow.com/a/22006571
has answer: http://stackoverflow.com/a/22006427
has comment: http://stackoverflow.com/comment/33354605
has comment: http://stackoverflow.com/comment/33354556
has comment: http://stackoverflow.com/comment/33354515
type: AnsweredQuestion
tagged with: enums
tagged with: reflection

http://stackoverflow.com/comment/33473113
type: Comment
type: QuestionComment
has text: Sorry I'm trying to ask my question as best I can with my limited knowledge. Basically, what is `70` in `byte[0]`? Is it a character, a number, or something else? I don't have a strong understanding of data structures, so that is probably why I don't really get it.
comment on: http://stackoverflow.com/q/22072698
score: 0

http://stackoverflow.com/q/22127178
tagged with: cookies
tagged with: java
has comment: http://stackoverflow.com/comment/33571706
type: Question
tagged with: httpsession
has comment: http://stackoverflow.com/comment/33571859
tagged with: servlets
has body: As for the subject: Are USERLANGUAGE and JSESSIONID cookies implicitly part of HttpServletRequest? Even without declaring any httpsession? protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // HttpSession session = req.getSession(true); Cookie[] cookies = req.getCookies(); ServletOutputStream out = resp.getOutputStream(); out.println("&lt;html&gt;"); out.println("&lt;head&gt;"); out.println("&lt;/head&gt;"); out.println("&lt;body&gt;"); for (Cookie cookie : cookies) { out.println(cookie.getName()+": "+ cookie.getValue()); } out.println("&lt;/body&gt;"); out.println("&lt;/html&gt;"); } In the above code reported for example even though I do not declare any httpSession I get USERLANGUAGE and JSESSIONID as part of the Cookies array. Should not I have got null instead?
score: 0
has title: Are USERLANGUAGE and JSESSIONID cookies implicit?
has comment: http://stackoverflow.com/comment/33572380
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33571885
answer count: 0

http://stackoverflow.com/q/22071959
tagged with: math
tagged with: java
has answer: http://stackoverflow.com/a/22072026
has comment: http://stackoverflow.com/comment/33471151
type: Question
downvote count: 0
answer count: 7
favorite count: 0
has answer: http://stackoverflow.com/a/22072095
accepted answer: http://stackoverflow.com/a/22072026
has title: Getting infinity when should be getting percent
linked to: http://stackoverflow.com/q/18542536
has answer: http://stackoverflow.com/a/22072031
has comment: http://stackoverflow.com/comment/33471122
has answer: http://stackoverflow.com/a/22072017
has answer: http://stackoverflow.com/a/22072531
has answer: http://stackoverflow.com/a/22072079
score: 1
has body: Here is the output I'm getting "1 student(s) passed: Infinity" when I should be getting 100% instead of Infinity. Any insight on this issue would be greatly appreciated! public class PassFailCount { public static void main(String[] args) { char grade; int numFails = 0; int numPass = 0; float percentFailed; float percentPassed; do { System.out.print("Enter a grade: "); grade = 'A'; if (grade == 'A' || grade == 'B' || grade == 'C' || grade == 'D') { numPass++; } else { numFails++; } grade = 'Z'; } while (grade != 'Z'); percentPassed = (float) numPass * 100 / numFails; System.out.println(numPass + " student(s) passed: " + percentPassed); } }
upvote count: 1
possible better answer: http://stackoverflow.com/a/22072051
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22072051
has comment: http://stackoverflow.com/comment/33471425

http://stackoverflow.com/a/22071883
downvote count: 0
type: Answer
has body: You have to be careful to distinguish between boolean and Boolean in Java. boolean is a primitive and cannot be null, but Boolean which you are asking about is an object, and can be null (not set). Thus, when dealing with Booleans, it's necessary to check whether the object is null before accessing one of its methods.
accepted answer of: http://stackoverflow.com/q/22071785
answers question: http://stackoverflow.com/q/22071785
score: 2
upvote count: 2
type: AcceptedAnswer

http://stackoverflow.com/comment/64913664
comment on: http://stackoverflow.com/q/22009475
has text: We had something but I think it was not a good solution, cause I changed the logic fully to calculate it in the shader.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33456579
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22063768
has text: Is your app self signed ?
type: Comment

http://stackoverflow.com/comment/33407330
type: Comment
has text: After adding this you cleaned your project and rebuilt it right?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22035894

while-loop
tags question: http://stackoverflow.com/q/22093349
type: Tag
tags question: http://stackoverflow.com/q/22076688
tags question: http://stackoverflow.com/q/22067933
tags question: http://stackoverflow.com/q/22077535
tags question: http://stackoverflow.com/q/22133297
tags question: http://stackoverflow.com/q/22153033
tags question: http://stackoverflow.com/q/22020224
tags question: http://stackoverflow.com/q/22084424
tags question: http://stackoverflow.com/q/22102720
tags question: http://stackoverflow.com/q/22033962
tags question: http://stackoverflow.com/q/22095941
tags question: http://stackoverflow.com/q/22087708
tags question: http://stackoverflow.com/q/22137526
tags question: http://stackoverflow.com/q/22037198
tags question: http://stackoverflow.com/q/22049467
tag name: while-loop
tags question: http://stackoverflow.com/q/22080190

http://stackoverflow.com/q/22054966
has comment: http://stackoverflow.com/comment/33441830
score: 0
answer count: 3
upvote count: 1
tagged with: swing
downvote count: 1
accepted answer: http://stackoverflow.com/a/22055319
tagged with: java
has comment: http://stackoverflow.com/comment/33441696
has comment: http://stackoverflow.com/comment/33441625
has comment: http://stackoverflow.com/comment/33442008
has answer: http://stackoverflow.com/a/22055031
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22055031
has answer: http://stackoverflow.com/a/22055040
has title: How can I duplicate my code simply?
has body: I have the code below; I want it also want the code in the 'action performed' to happen when it is hovered over. Instead of copy and pasteing the code again and have twice as many times, Is there a way to set it easily? The code: private void btnGreenActionPerformed(java.awt.event.ActionEvent evt) { Color btnGrn = new Color(159, 191, 143); //Sets the colour to a class Color txtGrn = new Color(201, 255, 191); //Sets the colour to a class Color txtGry = new Color(89, 89, 89); //Sets the colour to a class this.getContentPane().setBackground(new java.awt.Color(127,191,95)); //Sets background color to green btnConvert.setBackground(btnGrn); //Changes the colors to green btnReset.setBackground(btnGrn); //Changes the colors to green btnClose.setBackground(btnGrn); //Changes the colors to green btnInfo.setBackground(btnGrn); //Changes the colors to green txtIncome.setBackground(txtGrn); //Changes the colors to green txtPayable.setBackground(txtGrn); //Changes the colors to green txtStatus.setBackground(txtGrn); //Changes the colors to green txtIncome.setForeground(txtGry); //Changes the colors to grey txtPayable.setForeground(txtGry); //Changes the colors to grey txtStatus.setForeground(txtGry); //Changes the colors to grey } Note: I have 7 buttons that are all the same except for the color values.
favorite count: 0
has comment: http://stackoverflow.com/comment/33441919
has comment: http://stackoverflow.com/comment/33441627
type: Question
has answer: http://stackoverflow.com/a/22055319

http://stackoverflow.com/q/22161519
upvote count: 1
has comment: http://stackoverflow.com/comment/33713540
has comment: http://stackoverflow.com/comment/33691420
has title: app engine entitymanager.close() causes npe in google app engine
favorite count: 0
has comment: http://stackoverflow.com/comment/33696931
has comment: http://stackoverflow.com/comment/33634913
has body: I am trying to update an entity in the datastore but when mgr.close gets called, the entity manager is null. I don't set the entity manager to null anywhere in the code. I don't think that app engine is setting the entity manager to null for me either, it just seems like the entity manager may have crashed or something on its own. Does the entity manager have a life cycle or something I am not aware of? Is there something I could be doing in the code to make the entity manager close prematurely? While waiting on this question to be answered I noticed that my update method (generated by cloud endpoints and then altered by myself) didn't have the contains method that checks to see if the object is already present in the datastore. I edited the method and got the same error except it occurred inside the contains method. The code is displayed below. @ApiMethod(name = "updateParty") public Party updateParty(Party party) { EntityManager mgr = getEntityManager(); //update party with serving url try { if (!containsParty(party)) { throw new EntityNotFoundException("Object does not exist"); } if (party.getFlyerServingUrl() == null &amp;&amp; party.getFlyerStr() != null) { blob = new BlobKey(party.getFlyerStr()); options = Builder.withBlobKey(blob); servingUrl = imagesService.getServingUrl(options); party.setFlyerServingUrl(servingUrl); } mgr.persist(party); } finally { mgr.close(); } return party; } contains method: private boolean containsParty(Party party) { EntityManager mgr = getEntityManager(); boolean contains = true; try { if(party.getId() == null){ contains = false; }else{ Party item = mgr.find(Party.class, party.getId()); if (item == null) { contains = false; } } } finally { mgr.close(); } return contains; } EDIT *updated DEBUG level stack trace for the second set of methods:* 2014-03-05 10:20:40.484 /_ah/spi/com.mastermindcode.theincrowd.PartyEndpoint.updateParty 500 15ms 0kb Google-HTTP-Java-Client/1.16.0-rc (gzip) module=default version=1 75.108.229.93 - - [05/Mar…
tagged with: google-cloud-endpoints
answer count: 0
type: UnansweredQuestion
tagged with: google-app-engine
has comment: http://stackoverflow.com/comment/33685642
has comment: http://stackoverflow.com/comment/33713221
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33634053
tagged with: java
type: Question
tagged with: datanucleus

http://stackoverflow.com/q/22065494
has comment: http://stackoverflow.com/comment/33459765
has answer: http://stackoverflow.com/a/22065829
type: UnansweredQuestion
tagged with: regex
has answer: http://stackoverflow.com/a/22065594
has comment: http://stackoverflow.com/comment/33460365
answer count: 4
has body: i want to count the number of zeros in a N-range of numbers starting from 0. If the N is 100 means,then the range should starts from 0 to 100 then and the count should be 12. Below code works till some 10^6 private static int calcZeros(String input){ int count = 0; int n = Integer.parseInt(input); for(int i = 0;i&lt;=n;i++){ count += String.valueOf(i).replaceAll("[a-zA-Z_1-9]","").trim().length(); } return count; } If the N exceeds 10^6, it hangs,Obiviously, for loop runs for long duration. My Question here is ,this is right approach to find the zeros count? Suggest me some fastest way to do the count.
tagged with: java
linked to: http://stackoverflow.com/q/20614288
type: Question
has answer: http://stackoverflow.com/a/22089543
has answer: http://stackoverflow.com/a/22066385
has title: Count zeros in the series of N numbers - Java
score: 0

http://stackoverflow.com/comment/33389973
score: 1
comment on: http://stackoverflow.com/q/22025924
type: Comment
type: QuestionComment
has text: "Now I have a warning of MyComparator<Employee> and error of calling the getSalary() instance method." What warning? What error? This looks fine.

http://stackoverflow.com/comment/33406611
comment on: http://stackoverflow.com/q/22035424
score: 0
type: Comment
has text: chanumber is not STring type..u caanot call getByte[]
type: QuestionComment

http://stackoverflow.com/comment/33502361
type: QuestionComment
comment on: http://stackoverflow.com/q/22087849
score: 0
has text: alright.. @JBNizet & fge: I have a scenario wherein i do need them to be mutable. For instance, i get the object details from database, construct the data holder , update it , then again store it in db. In this case, I want the POJO to be mutable. So is there a mutable builder pattern to satisfy the above use case or builder pattern are to be only used for cases where immutability is needed?
type: Comment

http://stackoverflow.com/comment/34577883
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22686537
has text: 1) Its not really a cache, since the objects that sit behind the names, do not get reclaimed when memory is low. But WeakHashMap could neverthless go into the picture, Boris the Spider and I didn't yet figure out how. 2) What gets changed during work, is the state of the object, means inside the synchronized statement as posted in the question, where it is highlighted /* do something exclusively on obj */, the do something means that fields of the object are read and written. Also methods are called. So having immutable objects here wouldn't serve the requirement.
score: 0

http://stackoverflow.com/a/22143590
answers question: http://stackoverflow.com/q/22143510
score: 0
has body: You can create a custom annotation with runtime retention. Check this for example: Java 1.5.0.12 and custom Annotations at Runtime
type: Answer

http://stackoverflow.com/q/22028773
has answer: http://stackoverflow.com/a/22033700
answer count: 1
downvote count: 0
favorite count: 0
has title: JavaFX tooltip on editable cell
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22033700
score: 1
tagged with: java
tagged with: javafx
upvote count: 1
type: Question
has body: I have a TableView with editable cells. I use the recommended JavaFx callback to achieve editable cells. myCol.setCellFactory(TextFieldTableCell.&lt;Student&gt;forTableColumn()); I want to add a tooltip to each of these editable cells, so I have to make my own Callback. Is it possible to extend the above Callback to add functionality for adding a ToolTip or do I have to write my own from scratch?
tagged with: tableview

http://stackoverflow.com/comment/33631547
comment on: http://stackoverflow.com/q/22160693
has text: Are you getting same log every time you run the app? I can see that just after your PlayerSearchActivity started, you got "Completed PlayerSearchActivity.onCreate". Also since the messages are async so you may not get them in correct sequence at times. Try putting break point and see the control. Also with break points log should be in proper sequence.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22128481
possible better answer: http://stackoverflow.com/a/22128723
accepted answer: http://stackoverflow.com/a/22128499
has title: How to match just 1 or 2 chars with regex
upvote count: 1
has comment: http://stackoverflow.com/comment/33574674
type: Question
tagged with: java
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/22128499
favorite count: 0
has body: i want regx to match any word of 2 or 1 characters example ( is , an , or , if, a ) i tried this :- int scount = 0; String txt = "hello everyone this is just test aa "; Pattern p2 = Pattern.compile("\\w{1,2}"); Matcher m2 = p2.matcher(txt); while (m2.find()) { scount++; } but got wrong matches.
has answer: http://stackoverflow.com/a/22128723
has comment: http://stackoverflow.com/comment/33573984
tagged with: regex
type: AnsweredQuestion
score: 1

http://stackoverflow.com/q/22083227
has answer: http://stackoverflow.com/a/22083283
has body: What I have to do is to create a SpanishNumbers application that displays numbers 1 through 10 in Spanish. A method with an int parameter should display the Spanish word for the number passed. A loop structure in the main() method should be used to call the method ten times. The Spanish word equivalents for numbers 1 through 10 are... 1 uno 2 dos, 3 tres, 4 cuatro, 5 cinco, 6 seis, 7 siete, 8 ocho, 9 nueve, 10 diez. I do not know why am I getting this error below https://i.sstatic.net/HLIiI.png Thanks in advanced! import java.util.Scanner; public class SpanishNumberss { public static void spanishNumbers(int num) { String[] numbers = {"uno", "dos", "tres", "cuatro", "cinco", "seis", "siete", "ocho", "nueve", "diez"}; for (int i = 1; i &lt;= num; i++) { System.out.println(numbers[num]); } } public static void main(String args[]) { for (int i = 1; i &lt;= 10; i++) spanishNumbers(i); } }
tagged with: java
accepted answer: http://stackoverflow.com/a/22083273
type: Question
has title: How to Fix Spanish Numbers
score: 0
possible better answer: http://stackoverflow.com/a/22083253
has answer: http://stackoverflow.com/a/22083299
has answer: http://stackoverflow.com/a/22083253
answer count: 7
has comment: http://stackoverflow.com/comment/33492492
has answer: http://stackoverflow.com/a/22083273
has answer: http://stackoverflow.com/a/22083276
has answer: http://stackoverflow.com/a/22083397
has answer: http://stackoverflow.com/a/22083314
type: AnsweredQuestion

http://stackoverflow.com/q/22033377
has comment: http://stackoverflow.com/comment/33403710
has comment: http://stackoverflow.com/comment/33403881
has comment: http://stackoverflow.com/comment/33403332
tagged with: java
has comment: http://stackoverflow.com/comment/33403973
tagged with: chmod
has answer: http://stackoverflow.com/a/22034681
has comment: http://stackoverflow.com/comment/33403419
has body: Here is my executable file: #!/bin/bash JAVA_HOME=/cad2/ece419s/java/jdk1.6.0/ # arguments to GameServer # $1 = port # where GameServer is listening ${JAVA_HOME}bin/java GameServer $1 I run the chmod command as: chmod +x server.sh And then: ./ server.sh 8000 8000 is the port from local computer which my server is listening to. After bash -x server.sh 8000, I got
tagged with: linux
answer count: 3
has comment: http://stackoverflow.com/comment/33404555
has comment: http://stackoverflow.com/comment/33403022
tagged with: permissions
has title: getting permission denied after using chmod +x on Linux while executing Java program
has comment: http://stackoverflow.com/comment/33404634
score: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33403189
has answer: http://stackoverflow.com/a/22034213
has comment: http://stackoverflow.com/comment/33404018
has answer: http://stackoverflow.com/a/22033416
type: Question

http://stackoverflow.com/q/22022751
has comment: http://stackoverflow.com/comment/33384384
has comment: http://stackoverflow.com/comment/33384286
type: AnsweredQuestion
has body: In my code Public class TailList extends SList{ ... } First question: What is different between this two lines: TailList t; and TailList t = new TailList(); And second question is: If i write: SList s = new SList(); t = (TailList) s; // Compile-time Error Why? But, If i write: t = (TailList) s; I my first question state, There is no error!
has comment: http://stackoverflow.com/comment/33384415
has comment: http://stackoverflow.com/comment/33384210
accepted answer: http://stackoverflow.com/a/22022814
type: Question
has title: Object creation/declaration different
tagged with: java
has comment: http://stackoverflow.com/comment/33384050
has comment: http://stackoverflow.com/comment/33384369
score: 0
has comment: http://stackoverflow.com/comment/33384450
tagged with: casting
answer count: 1
tagged with: inheritance
has comment: http://stackoverflow.com/comment/33384470
has answer: http://stackoverflow.com/a/22022814

row
tags question: http://stackoverflow.com/q/22021571
type: Tag
tag name: row

http://stackoverflow.com/q/22166545
has answer: http://stackoverflow.com/a/22182222
tagged with: java
tagged with: logback
type: Question
upvote count: 4
answer count: 1
downvote count: 0
score: 4
has body: In case an appender fails to log a message, I'd like to catch the log and use "fallback appender" instead. Is that possible? Something like this (I know STDOUT wont fail) APPENDER
has title: Create a fallback appender in logback?
favorite count: 0
type: UnansweredQuestion

http://stackoverflow.com/comment/33562873
type: QuestionComment
comment on: http://stackoverflow.com/q/22121915
has text: You need to set a breakpoint and determine which variable exactly is `null`. Are you using an IDE where you can do so, and inspect variables?
score: 0
type: Comment

http://stackoverflow.com/comment/33486056
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22078798
type: AnswerComment
has text: Fascinating. Thanks, everyone. Learning recursion has been frustrating for me but I'll keep hammering away at it. Last question: I'm using netbeans; how do I debug the code and what do I look for to see how it operates?

http://stackoverflow.com/comment/33584202
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22054513
has text: Could you please provide the versions of SonarQube and the Java plugin? Could you also provide the error stack trace?
score: 0

http://stackoverflow.com/comment/33488622
type: Comment
has text: @user3325350: Please edit your question and show the specific code that you are using. Try to show the entire loop, try to show real code, not sort-of code (like your original question has -- ?JFields??), try to describe in even greater details your program's misbehavior, because what you're describing above, calling `someTextField.setText("foo")` changing the size of the field can't really happen.
comment on: http://stackoverflow.com/a/22080497
score: 0
type: AnswerComment

http://stackoverflow.com/q/22069934
tagged with: java
has answer: http://stackoverflow.com/a/22142998
has body: I am using Cordova Version 3.4.0. with CLI. The Concept of the project is to send SMS from phoneGap Application. Below is the command used to create this project. $ cordova create PluginExample com.example.pluginexample PluginExample $ cd PluginExample $ cordova platform add android $ cordova plugin add org.apache.cordova.network-information $ cordova plugin add https://github.com/asanka-x/Phonegap-SMS.git $ cordova run android *** smsplugin.send(number, message, '', success, error); When i click on Send Button the below error message occurs, // Error Message Failed: Class not found In ADT Eclipse, the below message is shown in LogCat PluginManager -> exec() call to unknown plugin: SMSPlugin How to implement this? I have hosted the project in GitHub https://github.com/ideepakrnd/PhoneGapPlugin
type: Question
score: 0
answer count: 1
tagged with: phonegap-plugins
tagged with: android
has title: How to implement SMSPluging in Cordova Application?
tagged with: cordova
type: UnansweredQuestion

http://stackoverflow.com/comment/33451416
score: 0
comment on: http://stackoverflow.com/q/22060601
type: QuestionComment
has text: Use a `Polygon` or some kind of `Shape` and keep adding points together and the paint that instead of squares which represent each point in the line...OR you could draw lines between the points...so instead of `fillRect` you could use `drawLine`...
type: Comment

http://stackoverflow.com/a/22058521
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22058430
type: Answer
answers question: http://stackoverflow.com/q/22058430
has comment: http://stackoverflow.com/comment/33448046
has body: I'm not sure why you are making two new arrays. You only need one... public void addProductToTotalSale(LineItem li) { addItemToSaleList(); lineItem[lineItem.length-1] = li; } public void addItemToSaleList() { LineItem[] tempItemList = new LineItem[lineItem.length + 1]; for (int i = 0; i &lt; tempItemList.length; i++) { tempItemList[i] = lineItem[i]; } lineItem = tempItemList; }
score: 0

http://stackoverflow.com/a/22053036
score: 1
has body: This happens sometimes when your buildpath loses its reference to your JRE. You can fix this by re-adding the JRE System Library to your buildpath. It is an interesting bug in Eclipse that I'm not sure why it happens. The other option is to start new project and copy everything over, but this is tedious and annoying as it looks you have already discovered.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/22052479
upvote count: 1

http://stackoverflow.com/a/22120170
has comment: http://stackoverflow.com/comment/33582398
answers question: http://stackoverflow.com/q/22110675
type: Answer
downvote count: 0
score: 1
has body: If you use Java, that means you are using LDAP to query Active Directory. What you want will not work using the default LDAP port. However, if you query the Global Catalog on port 3268 using LDAP it is possible to retrieve cross-domain memberships. EDIT: If this does not yield any results, either you need a Universal Group (not likely) or the GC needs to be set up properly. EDIT2: Given that you do not have a GC, the only other option is to create a referral object in AD that points to the external domain. See http://support.microsoft.com/kb/241737 how to set this up. You then have to configure your Java LDAP environment to follow referrals like this: env.put(Context.REFERRAL, "follow");.
has comment: http://stackoverflow.com/comment/33572068
upvote count: 1

http://stackoverflow.com/a/22106750
type: Answer
has comment: http://stackoverflow.com/comment/33536330
upvote count: 2
score: 2
has body: com.yammer.dropwizard.config.Bootstrap contains an addCommand method for adding ConfiguredCommand. You will get access to this object when you override initialize method in your service class, eg. public void initialize (Bootstrap&lt;T&gt; configurationBootstrap) { configurationBootstrap.addCommand(yourCommand); }
has comment: http://stackoverflow.com/comment/33540071
answers question: http://stackoverflow.com/q/22106508
downvote count: 0
has comment: http://stackoverflow.com/comment/33536298

http://stackoverflow.com/comment/33474853
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22050158
has text: I have to make a dynamic number of columns, this is apart of an university assignment and it says 'The visual appearance of the bar chart scales in an intelligent manner depending on user input', will it all be created within the dynamic class or will i have to use any others?

http://stackoverflow.com/comment/33541275
score: 0
type: Comment
type: QuestionComment
has text: it appears that my line stack.push(ch) is the one pushing nulls. why is this.
comment on: http://stackoverflow.com/q/22110376

http://stackoverflow.com/comment/33536089
has text: currently it is running every 200 ms (200ms=1min)
comment on: http://stackoverflow.com/q/22107323
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33555616
comment on: http://stackoverflow.com/a/22118528
type: Comment
score: 0
type: AnswerComment
has text: Intents are not Activities

http://stackoverflow.com/comment/33373504
type: Comment
has text: Also note that you need a CCSID on the AS400Text constructor which you can get from a connected AS400 object. If you don't provide one, jt400 will guess. The guess will be wrong at very inconvenient times.
comment on: http://stackoverflow.com/a/22011153
score: 0
type: AnswerComment

http://stackoverflow.com/a/62193950
type: Answer
has body: You could use TreeSet.floor(), which according to the docs Returns the greatest element in this set less than or equal to the given element, or null if there is no such element.
answers question: http://stackoverflow.com/q/22078377
score: 4
upvote count: 4
downvote count: 0

tomcat8
tags question: http://stackoverflow.com/q/22083164
type: Tag
tag name: tomcat8

http://stackoverflow.com/q/22071967
answer count: 3
tagged with: generics
favorite count: 0
has answer: http://stackoverflow.com/a/22072103
has body: This is some code that I hope gives you an understanding of what I want. It does not work of course. public static &lt;T&gt; void foo(Class&lt;? extends T&gt; type, AsyncCallback&lt;T&gt; callback){ /*do something */ } public void MyMethod() { Class a; if (isSomething()) { a = "some class"; } else if (isSomething2()){ a = "some other class"; } /* probably more of this or even a switch*/ useFoo(a); } public void useFoo(Class a){ foo(a.class, AsyncCallback&lt;a&gt; { /* some callback */ }); } Method foo is already there and I need to use it dynamically from MyMethod. Currently there is one useFoo for each different if statement in MyMethod. I want to have only one useFoo that would be called with some parameters. The reason is that the callback is a lengthy piece of code which needs to be repeated in every call for that method. How can I accomplish this without changing foo method? I hope you understand my problem. Thank you.
accepted answer: http://stackoverflow.com/a/22072450
score: 2
type: AnsweredQuestion
downvote count: 0
tagged with: reflection
tagged with: java
has title: Passing Class<? extends T> as a parameter
has answer: http://stackoverflow.com/a/22072450
type: Question
upvote count: 2
has answer: http://stackoverflow.com/a/22072115
possible better answer: http://stackoverflow.com/a/22072103
has comment: http://stackoverflow.com/comment/33471221

http://stackoverflow.com/q/22064108
score: 0
has title: dcm4che2: DcmQR method get(results) does not work
tagged with: dicom
answer count: 1
has body: I've found sample code: public static void main(String[] args) { DcmQR dcmqr = new DcmQR("server"); dcmqr.setCalledAET("server", true); dcmqr.setRemoteHost("213.165.94.158"); dcmqr.setRemotePort(104); dcmqr.setQueryLevel(DcmQR.QueryRetrieveLevel.PATIENT); dcmqr.configureTransferCapability(true); dcmqr.setCFind(true); dcmqr.setCGet(true); List&lt;DicomObject&gt; result=null; try { dcmqr.start(); System.out.println("started"); dcmqr.open(); System.out.println("opened"); result = dcmqr.query(); dcmqr.get(result); System.out.println("List Size = " + result.size()); dcmqr.stop(); dcmqr.close(); } } catch (Exception e) { System.out.println("error: "+e); } System.out.println("done"); } } Everything is fine until I call dcmqr.get(result);. After that I got exception: error: org.dcm4che2.net.NoPresentationContextException: 1.2.840.10008.5.1.4.1.2.1.3/Patient Root Query/Retrieve Information Model - GET not supported by server I use for testing public PACS server (http://www.dicomserver.co.uk/) which accepts C-FIND, C-GET, C-MOVE commands. I tried to do it using CONQUEST pacs - result is the same Does enyone know what's wrong with that?
has answer: http://stackoverflow.com/a/22081838
type: AnsweredQuestion
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/22081838

http://stackoverflow.com/q/22021379
tagged with: authentication
type: Question
has answer: http://stackoverflow.com/a/26286137
score: 3
has body: I'm using Spring LDAP 2.0.0.RELEASE and am getting an error using the new ldapTemplate.authenticate(LdapQuery, password) method with ldap pooling turned on. I get the error: java.lang.UnsupportedOperationException: Not supported for this implementation I only get this error when I have the ldap:pooling tag in my applicationContext.xml When I remove this, the method works successfully. Any idea why authenticate doesn't work with ldap pooling? Pooling seems to work fine with other ldapTemplate methods.
upvote count: 3
answer count: 1
favorite count: 0
type: UnansweredQuestion
tagged with: spring
has title: Spring LDAP authenticate method with Pooling - UnsupportedOperationException
downvote count: 0
tagged with: java

http://stackoverflow.com/comment/33500276
type: Comment
score: 1
comment on: http://stackoverflow.com/q/22086372
has text: since you are recreating the main activity (i suppose you are not saving the state of the main activity) on home pressed, why do you need flags ? if you want the intermediate activities closed, you should explicitly finish them while navigating away from them
type: QuestionComment

http://stackoverflow.com/comment/33361344
comment on: http://stackoverflow.com/q/22009099
score: 0
type: Comment
has text: Okay I believe I just found my issue. I should not be registering and unregistering my receiver every time I start and cancel discovery. I should just register it once in my onCreate and unregister in my onDestroy. Thank you for taking a look at it Hamid, going back and looking for that line made me realize that I was registering it multiple times.
type: QuestionComment

http://stackoverflow.com/comment/33535772
comment on: http://stackoverflow.com/q/22107247
score: 0
type: Comment
type: QuestionComment
has text: usually, you'd use an engine such as androidengine or libgdx to do stuff such as flappy bird.

http://stackoverflow.com/q/22027982
has comment: http://stackoverflow.com/comment/33404733
has answer: http://stackoverflow.com/a/22916771
has title: Is it possible to integrate android annotations with android studio 0.4.6?
answer count: 1
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/33393963
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/33404760
tagged with: android-studio
linked to: http://stackoverflow.com/q/15825081
score: 1
tagged with: java
has body: I tried many options from google and stackoverflow. Android studio 0.4.6 and aa 2.7.1. My build.gradle looks like this buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.7.+' } } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 19 buildToolsVersion "19.0.1" defaultConfig { minSdkVersion 8 targetSdkVersion 19 versionCode 1 versionName "1.0" } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } } ext.daggerVersion = '1.0.0'; ext.androidAnnotationsVersion = '2.7.1'; configurations { apt } dependencies { compile 'com.android.support:appcompat-v7:+' apt "com.googlecode.androidannotations:androidannotations:${androidAnnotationsVersion}" compile "com.googlecode.androidannotations:androidannotations-api:${androidAnnotationsVersion}" apt "com.squareup.dagger:dagger-compiler:${daggerVersion}" compile "com.squareup.dagger:dagger:${daggerVersion}" } I've checked Activities_ in AndroidManifest.xml too. If this quesion were not banned due to other "similar" questions I would prefer answers from people who did it with exacly the same as version. I know there will be next version's and maybe new questions but this looks litle tricky imho. Even though android development with aa is very robust. "sync project with gradle files", clean, rebuild etc brings no effect. EDIT: I tryied with ext.daggerVersion = '1.2.0'; ext.androidAnnotationsVersion = '3.0.1'; but it brings no result. After switching to: classpath 'com.android.tools.build:gradle:0.8.+' and ext.daggerVersion = '1.2.0'; it builds succesfully but outputs with: Default Activity not found I checked Error: Default Activity Not Found with no effect.
upvote count: 1
tagged with: gradle
type: Question
has comment: http://stackoverflow.com/comment/33394137
tagged with: android-annotations

http://stackoverflow.com/a/22030458
has body: Your charValue variable appears to break your logic. You should remove it. This is sufficient: for (int i=0; i&lt;alphabetArray.length; i++) alphabetArray[i] = 0; // set initial values while ((line = inputStream.readLine()) != null) { for(int i=0; i&lt;line.length(); i++) alphabetArray[(int)line.charAt(i)]++; // use the ASCII value of the character as an index } Your alphabet counter also seems to go out of scope. Either (1) make alphabetArray an instance variable of the class, or (2) display its contents before it goes out of scope. I think #1 is preferable. I'd also be concerned about this line: System.out.println(c + " : "+ char.alphabetArray[i]); char is a datatype, and alphabetArray does not exist inside of it (and technically doesn't exist anywhere at this point since it's gone out of scope). c is also undefined. Take advantage of ASCII values! However, be careful printing non-printable characters and such. Your output will look really funky. System.out.println((char)i + " : "+ alphabetArray[i]); Of course, you'd still need to make alphabetArray accessible somehow.
has comment: http://stackoverflow.com/comment/33398239
type: Answer
answers question: http://stackoverflow.com/q/22030424
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33398182
upvote count: 1
has comment: http://stackoverflow.com/comment/33398255

http://stackoverflow.com/comment/33516286
type: AnswerComment
has text: Yes already checked. I have only one java version on computer and its exactly the same as i developed with
type: Comment
comment on: http://stackoverflow.com/a/22097022
score: 0

http://stackoverflow.com/a/22008001
downvote count: 0
has body: You are trying to access the directory. The parameter of the FileOutputStream should be a File/ Path object pointing to a file: FileOutputStream file = new FileOutputStream("path/file.txt"); File -------------------------------^ For more detail take a look on http://docs.oracle.com/javase/7/docs/api/java/io/FileOutputStream.html
type: Answer
answers question: http://stackoverflow.com/q/22007890
accepted answer of: http://stackoverflow.com/q/22007890
upvote count: 20
score: 20
type: AcceptedAnswer

http://stackoverflow.com/a/22098938
score: 2
answers question: http://stackoverflow.com/q/22098884
has comment: http://stackoverflow.com/comment/33520038
has comment: http://stackoverflow.com/comment/33520007
accepted answer of: http://stackoverflow.com/q/22098884
type: AcceptedAnswer
downvote count: 0
type: Answer
upvote count: 2
has body: Suggest passing a stop event type that instructs the loop to break: boolean have_received_stop_event = false; while (!have_received_stop_event) { for(some event) { if(stop-event) { have_received_stop_event = true; break; } if(some event does something i want to capture) { threadPool.submit() } } } Then call shutdown() after main loop exits.

http://stackoverflow.com/comment/33493016
has text: So what would the correction be? I need to extend library in order to for it to access a method that repaints my JFrame named frame. The point of implementing my own ArrayList was to create an observer that whenever an object was added or removed from the list, I would invoke the repaint method in Library that would repaint my frame with an updated list. Inside my framePaint method was frame.repaint()
type: AnswerComment
comment on: http://stackoverflow.com/a/22083563
score: 0
type: Comment

http://stackoverflow.com/comment/33602126
type: Comment
comment on: http://stackoverflow.com/a/22144880
score: 0
type: AnswerComment
has text: I've tested it on http://regex101.com/ ,and it doesn't catch it, and to make sure i've teted in my program as well, same results...

http://stackoverflow.com/q/22068835
has body: Consider the following complete Java program. public class Reflection { static class A { public void useArray( String[] args ) { System.out.println( "Args are " + Arrays.toString( args ) ); } } public static void main( String[] args ) throws Exception { Method m = A.class.getMethod( "useArray", String[].class ); m.invoke( new A(), new String[] { "Hi" } ); } } Trying to run this, you get an error: Exception in thread "main" java.lang.IllegalArgumentException: argument type mismatch If instead of using only one String in the array passed to invoke you pass more than one, then you get: Exception in thread "main" java.lang.IllegalArgumentException: wrong number of arguments So, clearly, because invoke's signature is: invoke(java.lang.Object obj, java.lang.Object... args) when I call invoke using an array, the call is getting "translated" to: m.invoke( new A(), "Hi" ); How to make Java understand that I do want my array to be passed into invoke intact??
upvote count: 3
tagged with: java
accepted answer: http://stackoverflow.com/a/22068882
type: Question
tagged with: arrays
has title: How to call method which takes an array using reflection
answer count: 1
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/22068882
type: AnsweredQuestion
score: 3

http://stackoverflow.com/q/22006161
has answer: http://stackoverflow.com/a/22006296
type: Question
has body: HashMap hm = new HashMap(); hm.put("January", "Jan"); hm.put("Febraury", "Feb"); hm.put("March", "Mar"); hm.put("April", "Apr"); hm.put("May", "May"); hm.put("June", "Jun"); hm.put("July", "Jul"); hm.put("August", "Aug"); hm.put("September", "Sep"); hm.put("October", "Oct"); hm.put("November", "Nov"); hm.put("December", "Dec"); for (int k = 1; k &lt;= 12; k++) { if (Time.contains("January")) { } } Where Time contains like September 25,2013 then expected output is Sep 25,2013 .how can i do like this,thanks in advance
has answer: http://stackoverflow.com/a/22006322
has comment: http://stackoverflow.com/comment/33354829
score: 0
possible better answer: http://stackoverflow.com/a/22006337
has answer: http://stackoverflow.com/a/22006428
has title: How to place all month names in hashmap and replacing January as Jan and Febraury as Feb?
has answer: http://stackoverflow.com/a/22006337
tagged with: hashmap
tagged with: java
answer count: 5
accepted answer: http://stackoverflow.com/a/22006322
has comment: http://stackoverflow.com/comment/33358473
has comment: http://stackoverflow.com/comment/33354414
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33354382
has answer: http://stackoverflow.com/a/22008612

http://stackoverflow.com/comment/33455472
type: AnswerComment
comment on: http://stackoverflow.com/a/22063156
has text: Exactly, 127.0.0.1 is your localhost address. In the Android Emulator, that would translate to the Android devices localhost, and as such the Android copy would attempt to connect to a web server on the Android device, not on your Windows/Linux machine.
type: Comment
score: 0

http://stackoverflow.com/q/22132179
type: Question
accepted answer: http://stackoverflow.com/a/22132209
has body: I am trying to build a jsonobject to be send with a post request. But instead i get the error as shown below: 03-02 13:54:50.340: E/AndroidRuntime(2862): FATAL EXCEPTION: main 03-02 13:54:50.340: E/AndroidRuntime(2862): Process: in.mally.mallys, PID: 2862 03-02 13:54:50.340: E/AndroidRuntime(2862): java.lang.StackOverflowError 03-02 13:54:50.340: E/AndroidRuntime(2862): at java.lang.String._getChars(String.java:908) 03-02 13:54:50.340: E/AndroidRuntime(2862): at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:147) 03-02 13:54:50.340: E/AndroidRuntime(2862): at java.lang.StringBuilder.append(StringBuilder.java:216) 03-02 13:54:50.340: E/AndroidRuntime(2862): at org.json.JSONStringer.beforeValue(JSONStringer.java:412) 03-02 13:54:50.340: E/AndroidRuntime(2862): at org.json.JSONStringer.open(JSONStringer.java:178) 03-02 13:54:50.340: E/AndroidRuntime(2862): at org.json.JSONStringer.object(JSONStringer.java:158) 03-02 13:54:50.340: E/AndroidRuntime(2862): at org.json.JSONObject.writeTo(JSONObject.java:670) The Error seems to a stackoverflow error. I can't quite figure out how that works. The code below attempts to build a jsonObject and puts that Object into another Jsonobject as a value. The format for JsonObject i am trying to make is { "email" : "a@b.com", "user_record" : first_jsonObject } First JsonObject is just a simple key-value pair of strings. Below is the code that i used to acheive it. JSONObject j = new JSONObject(); try { j.put("offer_id", "531328f8616c69133a350000"); j.put("views", "1"); j.put("call_count", "0"); j.put("rating", "3"); } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } JSONObject json = new JSONObject(); try { json.put("email", "a@b.com"); json.put("user_post_records", json); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } JsonObjectRequest r = new JsonObjectRequest(Method.POST,POST_URL, json, new Listener&lt;JSONObject&gt;() { @Override public vo…
answer count: 1
upvote count: 6
favorite count: 0
has answer: http://stackoverflow.com/a/22132209
tagged with: android-volley
tagged with: android
has title: JsonObject Build Stackoverflow error
downvote count: 0
score: 6
type: AnsweredQuestion
tagged with: java
tagged with: http://stackoverflow.com/tag/json

http://stackoverflow.com/comment/33465104
type: QuestionComment
has text: cannot resolve symbol class Scanner
comment on: http://stackoverflow.com/q/22068618
score: 0
type: Comment

http://stackoverflow.com/a/22155141
score: 5
has comment: http://stackoverflow.com/comment/33621403
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/33643089
answers question: http://stackoverflow.com/q/22154785
has body: First a remark: The kind of question you ask smells like a XY problem, see: https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem So maybe some background what you really want to achieve would be good. Taking the question literally, I would do the following: Use a second cache without expiration for the "don't reset counter" accesses. Add a removal listener to the peers cache, to remove the value from the second cache. Maybe just a HashMap is fine, too. The resource usage is actually controlled by the peers cache.
upvote count: 5

http://stackoverflow.com/comment/33377876
has text: Tried but it's like two different screen, I didn't get the player to be near block1.
type: AnswerComment
comment on: http://stackoverflow.com/a/22019435
score: 0
type: Comment

http://stackoverflow.com/a/22132127
answers question: http://stackoverflow.com/q/22132044
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22132044
has comment: http://stackoverflow.com/comment/33580926
type: Answer
has body: What are trying to achieve? Are.you aware that to compute the md5 locally, you will need to download the full file ? There is a special ftp extension that provide a server-side md5 to the client but it'd not generally supported. Some server also implement some similar proprietary functionality; you''ll have to check for your specific server. You may want to have a look at the XCRC or XMD5 or XSHA1 commands, for example.
has comment: http://stackoverflow.com/comment/33581018
score: 0

http://stackoverflow.com/a/22084185
answers question: http://stackoverflow.com/q/22084171
score: 4
upvote count: 4
has body: set timezone in SimpleDateFormat instance instead sdf.setTimezone("America/Los_Angeles");
downvote count: 0
type: Answer

http://stackoverflow.com/q/22148077
has body: I had the Android App which play sound when specific times , I did my code well but when I locked the screen the sound isnot play , I checked my code and I find that the code that I added when user press lock button is the reason of the problem .How to solve this issue ? @Override protected void onPause() { Player.stopAzan(); finish(); super.onPause(); }
has title: The sound stopped when press lock button
favorite count: 0
tagged with: android
has comment: http://stackoverflow.com/comment/33607981
has comment: http://stackoverflow.com/comment/33608139
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/22148297
accepted answer: http://stackoverflow.com/a/22148327
type: Question
possible better answer: http://stackoverflow.com/a/22148297
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33608169
has answer: http://stackoverflow.com/a/22148327
answer count: 2
upvote count: 1

http://stackoverflow.com/q/22161640
tagged with: spring
answer count: 0
score: 1
tagged with: java
type: Question
downvote count: 0
tagged with: tomcat
tagged with: deployment
favorite count: 0
tagged with: jenkins
type: UnansweredQuestion
has body: I just set up Jenkins CI for building web applications(Spring Framework). After job builds with new commits, post action triggered to deploy built .war file to tomcat by deploy plugin. In this case, Is there any way to detect deploy failure? so that I can use command to deal with deploy failure(not build failure)?
has title: How to detect tomcat deploy failure in Jenkins
upvote count: 1

http://stackoverflow.com/comment/33609369
type: QuestionComment
score: 0
has text: Cannot understand.can you please add input and expected ouput
comment on: http://stackoverflow.com/q/22148860
type: Comment

http://stackoverflow.com/a/22039858
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/22039675
downvote count: 0
has body: You can create interfaces as you said in this case it's going to be marker interface. You can read more about that here: http://javarevisited.blogspot.co.uk/2012/01/what-is-marker-interfaces-in-java-and.html
type: Answer

http://stackoverflow.com/q/22092992
has body: The method processExceptions() should call the method BEAN.methodThrowExceptions and handle exceptions: 1.1. if an exception FileSystemException occurs, then log it by calling the method BEAN.log and throw forward 1.2. if an exception CharConversionException or any other IOException occurs, just log it by calling the method BEAN.log Add the class/type of the exception you are forwarding in 2.1. to the processExceptions() method signature. Handle the remaining exception in the method main() and log it. Use try..catch I tried different solutions. It works but not as it should. What is the correct placement of throws in methods. Or maybe i shouldnt use them at all? And if I don't place them I can't make use of throw. Please help, I would really appreciate your time. public class Solution { public static StatelessBean BEAN = new StatelessBean(); public static void main(String[] args) { try{ processExceptions(); } catch (CharConversionException e){ BEAN.log(e); } } public static void processExceptions()throws CharConversionException { try{ BEAN.methodThrowExceptions(); } catch (CharConversionException e){ BEAN.log(e); throw e; } catch (FileSystemException e){ BEAN.log(e); } catch (IOException e){ BEAN.log(e); } } public static class StatelessBean { public void log(Exception exception) { System.out.println(exception.getMessage() + ", " + exception.getClass().getSimpleName()); } public void methodThrowExceptions() throws CharConversionException, FileSystemException, IOException { int i = (int) (Math.random() * 3); if (i == 0) throw new CharConversionException(); if (i == 1) throw new FileSystemException(""); if (i == 2) throw new IOException(); } } }
score: 0
tagged with: java
tagged with: throws
type: Question
has answer: http://stackoverflow.com/a/22094055
answer count: 2
has comment: http://stackoverflow.com/comment/33509633
has comment: http://stackoverflow.com/comment/33509487
has comment: http://stackoverflow.com/comment/33509598
tagged with: exception
tagged with: throw
has title: Exceptions works correct but not how its must
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33509336
has answer: http://stackoverflow.com/a/43497832
tagged with: ioexception

http://stackoverflow.com/comment/33547114
has text: @assylias That's exactly what I thought too, which is why I'm confused. I can't really post a runnable example because I don't even have the input for my function because it's not disclosed on codeeval.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22113578
score: 0

http://stackoverflow.com/a/22061864
upvote count: 2
has body: Ironically the background-color is the foreground-color in POI/Excel. Try it like this: XSSFCellStyle style1 = workbook.createCellStyle(); style1.setFillForegroundColor(new XSSFColor(new java.awt.Color(128, 0, 128))); style1.setFillPattern(CellStyle.SOLID_FOREGROUND); cell.setCellStyle(style1); or in your case simply: stylex.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex()); stylex.setFillPattern(CellStyle.SOLID_FOREGROUND); and don't forget to assign the style to the cells. If you just take the initial style from three different cells, it will probably point to the same style object in the workbook. If you want a new style you have to create it in the workbook and assign it to the cell (see my example).
type: Answer
answers question: http://stackoverflow.com/q/22061790
score: 2
downvote count: 0

http://stackoverflow.com/comment/33499796
has text: mark as a answer, in left side see one tick symbol is there.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22086974
score: 1

http://stackoverflow.com/comment/33401737
type: Comment
has text: Yes, I know. Just wanted to point out the obvious that I definitely have to use something supporting XPath 2.0.
comment on: http://stackoverflow.com/a/22010460
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33492715
has text: So you are actually NOT using newlines, ``"\n"``? Then about using ``" "`` instead of ``"\n"``?
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22083256

http://stackoverflow.com/q/22164716
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22164890
has answer: http://stackoverflow.com/a/22164759
tagged with: inheritance
has title: Java Inheritance and Variables
downvote count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33638078
tagged with: constructor
has answer: http://stackoverflow.com/a/22164866
possible better answer: http://stackoverflow.com/a/22164759
has answer: http://stackoverflow.com/a/22164770
upvote count: 4
accepted answer: http://stackoverflow.com/a/22164770
answer count: 4
has body: I know this is very basic but I am having trouble putting the pieces together in an unfamiliar language. I'm mapping UML into Java code and inheritance is throwing me. I have an ERD like this: Animal ---------------------------- -color: int -weight: int ---------------------------- + getColor() : int + getWeight(): int ---------------------------- ^(Inheritance Triangle) | | ---------------------------- Dog ---------------------------- -breed: string ---------------------------- + getBreed() ---------------------------- So of course a dog IS-A animal, and I can call getColor from a dog class, etc. My problem is about the variables, in particular contructors. When I implement this, I have public class Animal { private int color; private int weight; public Animal(int c, int w) { color = c; weight = w; } ... } public class Dog extends Animal { private string breed; public Dog() { breed = "Shelty"; } } My question is, what is the proper way to use color and weight in the dog class? Looking at the UML, I know I could put color and weight in the dog entity, but I understand that's optional. Would I just also have a private color and weight attribute in the dog class? Would I call the Animal constructor (which throws errors) What is the proper form here?
type: AnsweredQuestion
score: 3

http://stackoverflow.com/comment/33658138
type: Comment
comment on: http://stackoverflow.com/a/22157905
score: 0
type: AnswerComment
has text: Try adding all the parameters to the addressPage controller and then forward it to selectAddress to see if they are Added but it is supposed to be the same request between the two controllers.

deserialization
type: Tag
tags question: http://stackoverflow.com/q/22026719
tags question: http://stackoverflow.com/q/22087938
tag name: deserialization
tags question: http://stackoverflow.com/q/22090815
tags question: http://stackoverflow.com/q/22020334

http://stackoverflow.com/comment/33405241
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22034116
has text: it works, but it does the math wrong. it only outputs to "1" run of the while loop

http://stackoverflow.com/comment/33605193
has text: Ok , I'll change to another one.
comment on: http://stackoverflow.com/q/22146334
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33391672
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22026283
has text: @helderdarocha yes maybe i should migrate the all app using JAXB, It's a pity to waste all the work already done with Xstream, thank you tho for your answer
score: 0

http://stackoverflow.com/comment/33371678
type: QuestionComment
has text: I am afraid you can't predict the size of a compressed image before actually compressing it.
type: Comment
comment on: http://stackoverflow.com/q/22016091
score: 3

http://stackoverflow.com/a/22142810
has comment: http://stackoverflow.com/comment/33625927
has comment: http://stackoverflow.com/comment/33598831
has comment: http://stackoverflow.com/comment/33599134
upvote count: 1
has comment: http://stackoverflow.com/comment/33598766
has comment: http://stackoverflow.com/comment/33605655
has comment: http://stackoverflow.com/comment/33599939
type: Answer
has comment: http://stackoverflow.com/comment/33598801
has body: It would be considered an interpreter, and the compiled code would be byte code. To be a "virtual machine" you'd need to create ways of interacting with "everything" on the PC that it runs. Giving your users/developers a "print to screen" feature is not a virtual machine. http://en.wikipedia.org/wiki/Virtual_machine Edit: You asked: "Also: Conceptually, would you say that a programming language that is only able to create programs that can run inside another program, is still considered a programming language?" That depends on the features of this "other program". If you're asking about the JVM: yes. The wikipedia definition of programming language can be found here: http://en.wikipedia.org/wiki/Programming_language A programming language is an artificial language designed to communicate instructions to a machine And we say that a virtual machine fulfills this property. So yes, Java (and other languages that compile to bytecode run by a proper virtual machine) is a programming language.
has comment: http://stackoverflow.com/comment/33605854
answers question: http://stackoverflow.com/q/22142761
has comment: http://stackoverflow.com/comment/33626011
has comment: http://stackoverflow.com/comment/33602574
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33605234

http://stackoverflow.com/comment/33610344
type: Comment
has text: `ur`? What is this... myspace?
score: 2
comment on: http://stackoverflow.com/q/22149364
type: QuestionComment

http://stackoverflow.com/comment/33572775
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22127725
type: Comment
has text: You should post logcat so that we can analyze your error

http://stackoverflow.com/q/22066130
type: Question
score: 1
tagged with: java
downvote count: 0
answer count: 1
favorite count: 0
tagged with: android
tagged with: http://stackoverflow.com/tag/html
tagged with: email
has title: href is not working when I try to send email using native email client in android
has body: Well here is a issue I am using href to give a link in my email body which works fine if I use gmail client but if I use native email client then it does not make it a link it shows me as a plain text. following is the code chunk that i am using . String format="Link1 Some Info %s OR dial %s number %s"; String msg = String.format(format, url,info, number, pin); emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(msg)); startActivity(Intent.createChooser(emailIntent, "Send mail...")); Can anyone help in this couldn't find any solution.
type: UnansweredQuestion
upvote count: 1
has answer: http://stackoverflow.com/a/22066433

http://stackoverflow.com/comment/33447688
type: AnswerComment
has text: I was writing an answer but I don't really think anything else needs to be said. Just call sort.
type: Comment
comment on: http://stackoverflow.com/a/22058353
score: 0

http://stackoverflow.com/a/35376504
answers question: http://stackoverflow.com/q/22075224
downvote count: 0
score: 1
has body: public class Palindrome { static int count=0; public static void main(String args[]) { Scanner sc=new Scanner(System.in); String s1=sc.next(); String array[]=s1.split(""); System.out.println("Palindromes are :"); for(int i=0;i&lt;=array.length;i++) { for(int j=0;j&lt;i;j++) { String B=s1.substring(j,i); verify(B); } } System.out.println("\n"+count); sc.close(); } public static void verify(String s1) { StringBuilder sb=new StringBuilder(s1); String s2=sb.reverse().toString(); if(s1.equals(s2)) { System.out.print(s1+" "); count++; } } }
upvote count: 1
type: Answer

bufferedreader
tags question: http://stackoverflow.com/q/22110409
tags question: http://stackoverflow.com/q/22116236
tags question: http://stackoverflow.com/q/22021291
tags question: http://stackoverflow.com/q/22144643
tags question: http://stackoverflow.com/q/22071020
tags question: http://stackoverflow.com/q/22156066
tags question: http://stackoverflow.com/q/22136137
tags question: http://stackoverflow.com/q/22132135
tags question: http://stackoverflow.com/q/22129573
tags question: http://stackoverflow.com/q/22135261
tags question: http://stackoverflow.com/q/22162871
tags question: http://stackoverflow.com/q/22123612
tags question: http://stackoverflow.com/q/22052185
tags question: http://stackoverflow.com/q/22080326
tag name: bufferedreader
tags question: http://stackoverflow.com/q/22153647
tags question: http://stackoverflow.com/q/22136120
tags question: http://stackoverflow.com/q/22019296
tags question: http://stackoverflow.com/q/22042243
type: Tag
tags question: http://stackoverflow.com/q/22116201

http://stackoverflow.com/q/22016026
tagged with: graph-algorithm
favorite count: 0
has body: I need to process a very large road network graph containing say more than 10,000 nodes. Suppose I have a source node 'S' in the graph which represents a place or a particular location having a specific longitude and latitude. Now my application requires to find out all the places which are existing within 5 km region in the real world around the location represented by 'S' in the graph. Suppose my graph is very dense and hundreds of nodes representing various places/locations may be there in the graph within this 5 km region as mentioned. The nodes represent locations and the edge weights represent distance between two neighbor nodes whose range is from 100 meters to 100 kilometers. So my questions are - 1) How to find out all the nodes efficiently so that less memory and runtime is used? Any special data structure or algorithm to use? 2) If I use neo4j graph database in Java application then how to solve the problem? code segment, cypher query for neo4j + proper theory would be appreciated. *Please provide a solution considering a large scale network. Edit: In my application it is quite possible that a node is processed again and again i.e; suppose in an instance desired nodes for the source node 'S' are found and later in another instance the same process is to be performed for another node 'S1' which is adjacent to 'S'. So it may happen that the nodes which were processed for the case of 'S', most of them are again processed/traversed for 'S1' as 'S' and 'S1' are adjacent. So is there any way of caching the results so that nodes are not processed again and again? Any efficient algorithm rather that Dijkastra or BFS? In BFS even any caching possible?
type: UnansweredQuestion
downvote count: 2
has answer: http://stackoverflow.com/a/22016321
has comment: http://stackoverflow.com/comment/33373438
tagged with: performance
has comment: http://stackoverflow.com/comment/33371677
has title: algorithm to find out all the locations within a range
tagged with: java
tagged with: graph-databases
type: Question
tagged with: graph
answer count: 2
upvote count: 0
score: -2
has comment: http://stackoverflow.com/comment/33373183
has answer: http://stackoverflow.com/a/22016225

http://stackoverflow.com/a/22038927
answers question: http://stackoverflow.com/q/22019651
upvote count: 2
has body: This is not possible using cglib out of the box. Since the XmlRootElement is not inherited, the subclass that is created by cglib will not longer carry this annotation. Cglib itself was written before annotations were introduced to Java and no recent update added this functionality. You can instead register an ASM visitor with the cglib enhancer which should be responsible for adding the annotation to the cglib generated class. However, you might want to consider creating your classes using javassist which has a more modern API and supports the writing of annotations.
type: AcceptedAnswer
type: Answer
has comment: http://stackoverflow.com/comment/33413643
score: 2
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22019651

http://stackoverflow.com/comment/33372153
type: Comment
has text: Do you need exactly a Map? I guess JSONObject can do some recursive transformation into a json format, then you can access it more or less like a Map of Maps
type: AnswerComment
comment on: http://stackoverflow.com/a/22016219
score: 0

http://stackoverflow.com/a/22166218
has body: Try this solution: 1) Click Run Command from start button 2) Enter Services.msc then click OK,you will get all the services in your computer. 3) Select your service and right click on the service and select Properties 4) Goto Logon Properties and select Local System Account then click OK
upvote count: 1
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/22147578

http://stackoverflow.com/comment/33628375
comment on: http://stackoverflow.com/a/22158910
has text: If you get a font not found issue after that, on AWS Ubuntu, sudo apt-get install dejavu*
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33445779
comment on: http://stackoverflow.com/a/22057188
type: AnswerComment
has text: You're correct - for some reason I thought it resulted in a value when the argument supplied was null. (And the darn javadoc is clearly missing a documentable exception :-/)
score: 0
type: Comment

http://stackoverflow.com/comment/33728307
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/22075683
has text: So then why are you passing `text` when the String variable is `Stext`. This is very basic Java

http://stackoverflow.com/a/22070068
type: Answer
has comment: http://stackoverflow.com/comment/33468014
has comment: http://stackoverflow.com/comment/33468186
has comment: http://stackoverflow.com/comment/33467798
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/22069908
has body: If you want to change status of an already created Button then while creating them at run time assign them unique Id's using setID(int) method from the View class. So for your button1 you can, button1.setId(100); and when you want to change thngs you can fetch the ID for the button and change it appropriately. if(toChangeButton.getID() == 100){ //Change button1 } Hope this helps.
downvote count: 0
has comment: http://stackoverflow.com/comment/33468351
has comment: http://stackoverflow.com/comment/33468722
has comment: http://stackoverflow.com/comment/33467696

http://stackoverflow.com/comment/33451807
comment on: http://stackoverflow.com/a/22044251
has text: I ended up disabling findbugs from sonar plugins, but that's just a interim workaround to see the actual percentage of CC. I still have to get to the root of the evil cause..
type: Comment
score: 1
type: AnswerComment

http://stackoverflow.com/comment/33641470
has text: @TruePS - Because the `main` **method** is called by the main **thread**. The `main` **method** completes but the `main` **thread** will wait until all other non-daemon threads it has created are dead before exiting the VM.
score: 1
comment on: http://stackoverflow.com/a/22147045
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33639451
has text: Where is the error log?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22165489
score: 0

http://stackoverflow.com/q/22117899
has comment: http://stackoverflow.com/comment/33554397
has comment: http://stackoverflow.com/comment/33554876
has body: I'm writing a program, that must find all combination: String[] combination = new String[]{"123,"12","34"}; application must return: 113 114 123 124 213 214 223 224 313 314 323 324 There will be 81 elementnts at max in array per most of 9 character to make combination with they. So first digit must be from com[0], second from com[1] and so on. Thx for help!
has comment: http://stackoverflow.com/comment/33554676
has comment: http://stackoverflow.com/comment/33554451
tagged with: combinations
tagged with: digits
type: AnsweredQuestion
tagged with: numbers
has comment: http://stackoverflow.com/comment/33554456
tagged with: java
has comment: http://stackoverflow.com/comment/33554419
has comment: http://stackoverflow.com/comment/33556258
type: Question
has comment: http://stackoverflow.com/comment/33554776
tagged with: arrays
answer count: 1
has answer: http://stackoverflow.com/a/22119748
has comment: http://stackoverflow.com/comment/33554431
accepted answer: http://stackoverflow.com/a/22119748
has title: java combination of char per array
score: 0
has comment: http://stackoverflow.com/comment/33554631
has comment: http://stackoverflow.com/comment/33554417
has comment: http://stackoverflow.com/comment/33554549
has comment: http://stackoverflow.com/comment/33554498
has comment: http://stackoverflow.com/comment/33554395
has comment: http://stackoverflow.com/comment/33554743
has comment: http://stackoverflow.com/comment/33554616

http://stackoverflow.com/comment/33553894
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22117169
has text: I am not supposed to change the existing initial authentication process. I should only use the authenticated user info and use the spring security further to reauthenticate the user. I had a quick look on the link posted by you.In your example, The total authentication is carried out by spring security. In my case it is not. For the first time it is done by 3rd party, from there, spring security should take care using the user info provided by 3rd party.

http://stackoverflow.com/q/22042750
linked to: http://stackoverflow.com/q/510632
tagged with: dictionary
tagged with: collections
linked to: http://stackoverflow.com/q/14947723
tagged with: java
tagged with: concurrency
has answer: http://stackoverflow.com/a/22042867
type: Question
has comment: http://stackoverflow.com/comment/33421493
has comment: http://stackoverflow.com/comment/33419378
has answer: http://stackoverflow.com/a/22042831
has answer: http://stackoverflow.com/a/22042797
score: 0
has answer: http://stackoverflow.com/a/22043717
has title: One concurrent collection inside another: is it thread safe
has body: [Question]: Is it thread safe to use ConcurrentHashMap&lt;Object, ConcurrentHashMap&lt;Object, Object&gt;&gt; or not. [Optional to answer]: Also what about another concurrent maps types? And what about concurrent collections? P.S. I'm asking only about java.util.concurrent package. Specific Usage Context: //we have ConcurrentHashMap&lt;Object, ConcurrentHashMap&lt;Object, Object&gt;&gt; map = new ConcurrentHashMap&lt;Object, ConcurrentHashMap&lt;Object, Object&gt;&gt;(); //each string can be executed separately and concurently ConcurrentHashMap&lt;Object, Object&gt; subMap = new ConcurrentHashMap&lt;Object, Object&gt;() map.put(key, subMap); map.remove(key); map.get(key); map.get(key).put(key, ref); map.get(key).remove(key); Maybe my solution lays around Guava HashBasedTable?
has answer: http://stackoverflow.com/a/22042859
has comment: http://stackoverflow.com/comment/33419374
answer count: 5
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33420827

http://stackoverflow.com/comment/33502149
has text: May be some cache problems, try to close Session after committing transaction.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22088821
type: Comment

http://stackoverflow.com/comment/33625397
comment on: http://stackoverflow.com/a/22157021
has text: Yes but palindromes are generally considered to be case independent (e.g. A man a plan a canal Panama) which also brings to issue the fact that this test does not strip white space which is essential to most palindromes.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33649511
type: Comment
comment on: http://stackoverflow.com/a/22168776
type: AnswerComment
has text: I downloaded it and put it in the directory. It works now. Thanx. Another question: I don't want to make these operationsevery time. Where can I put the mysql jdbc jar to access it automatically ?
score: 0

http://stackoverflow.com/comment/33463601
has text: @UdiOshi its impossible to run it it underlined onActivityResult and write: void is an invalid type for the variable onActivityResult
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22067696
type: QuestionComment

http://stackoverflow.com/comment/33522158
type: Comment
comment on: http://stackoverflow.com/a/22099821
has text: I have actually found what was causing the 413 and corrected it. But it still doesn't login. Help, please?
score: 0
type: AnswerComment

http://stackoverflow.com/q/22153288
type: Question
has comment: http://stackoverflow.com/comment/33618289
linked to: http://stackoverflow.com/q/18483470
has answer: http://stackoverflow.com/a/22153342
answer count: 3
upvote count: 1
downvote count: 0
tagged with: coercion
has comment: http://stackoverflow.com/comment/33618009
possible better answer: http://stackoverflow.com/a/22153342
favorite count: 0
has comment: http://stackoverflow.com/comment/33617737
has comment: http://stackoverflow.com/comment/33617998
has title: Java byte to int Coercion
duplicate of: http://stackoverflow.com/q/18483470
type: AnsweredQuestion
has body: I have a question about the code below. The code is taken from my Programming Languages book. byte x, y, z; ... /* The values of y and z are coerced into int and int addition is performed */ /* The sum is converted into byte */ x = y + z; My question is why Java does a coercion like that. Do you have any ideas? Thanks in advance.
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22153486
accepted answer: http://stackoverflow.com/a/22153486
has comment: http://stackoverflow.com/comment/33617708
has answer: http://stackoverflow.com/a/22153403

http://stackoverflow.com/a/22130073
accepted answer of: http://stackoverflow.com/q/22092180
answers question: http://stackoverflow.com/q/22092180
has body: With the default ListSelect there is probably no other way. If you're willing to use other components however, there is. The FilterTable add-on has the unselect behavior built-in. It can be styled to look just like a ListSelect (or prettier, for that matter).
type: Answer
upvote count: 1
score: 1
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/22168348
has title: Memory leak in web-app, tomcat+hibernate+Guice
type: Question
tagged with: jakarta-ee
type: AnsweredQuestion
tagged with: java
tagged with: hibernate
has answer: http://stackoverflow.com/a/22168637
answer count: 2
has comment: http://stackoverflow.com/comment/33657105
possible better answer: http://stackoverflow.com/a/22168637
tagged with: tomcat
score: 0
has answer: http://stackoverflow.com/a/22187867
accepted answer: http://stackoverflow.com/a/22187867
has body: After several redeploys app crashes with PermGen error. I know abou workarounds with increasing permgen size. But I try to reveal cause of leak. After redeploy I'v made heap dump with jvisualvm and searching for instances of WebAppClassLoader. As expected there was one not GC-ed. Show nearest GC root points to platformMBeanServer (MangementFactory type). So the question is what can i do with it? And some additional info. My jdbc driver jar locates in lib directory of tomcat and .dll file in bin directory. When I comment hibernate sessionFactory creation - problem disappear. Session factory created in init method of servlet filter, and closed in destroy method. Hibernate uses c3p0 connection pool.
tagged with: jvisualvm

http://stackoverflow.com/a/22012115
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/33364636
answers question: http://stackoverflow.com/q/22012067
downvote count: 1
has comment: http://stackoverflow.com/comment/33364657
has body: It is not supposed to call the run method. If it does, it will do it in the same running thread. Just like a program starts in the main method of a class, a new thread starts in the run method of the class. You have to look into native code to find it.
upvote count: 1

http://stackoverflow.com/comment/33552728
score: 0
type: AnswerComment
has text: you can directly save byte array into image
type: Comment
comment on: http://stackoverflow.com/a/22116684

awt
tags question: http://stackoverflow.com/q/22030424
tag name: awt
tags question: http://stackoverflow.com/q/22030127
tags question: http://stackoverflow.com/q/22155234
tags question: http://stackoverflow.com/q/22057332
tags question: http://stackoverflow.com/q/22167743
tags question: http://stackoverflow.com/q/22106171
tags question: http://stackoverflow.com/q/22153871
tags question: http://stackoverflow.com/q/22091974
tags question: http://stackoverflow.com/q/22060601
type: Tag
tags question: http://stackoverflow.com/q/22158244
tags question: http://stackoverflow.com/q/22020385

http://stackoverflow.com/comment/33452871
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22061628
has text: Put your `hardtask()` code into `AsyncTask InBackground(....)`

http://stackoverflow.com/comment/33402965
comment on: http://stackoverflow.com/q/22033213
score: 0
type: Comment
type: QuestionComment
has text: Yes I was hoping Amigo will realize that and next logical thing - file a bug with the Rhino team.

http://stackoverflow.com/comment/33628521
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22158295
score: 0
has text: @SotiriosDelimanolis - But what about the numeric types you write? I guess they could all implement some interface. As the number of types grow, either approach creates a huge burden to handle all the different types.

http://stackoverflow.com/q/22161758
tagged with: arrays
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/22161781
has answer: http://stackoverflow.com/a/22161851
has title: toString method and searching a list for string equality
tagged with: tostring
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22161781
accepted answer: http://stackoverflow.com/a/22161851
has body: This is an Object Oriented program with two classes Catalog and Products that reads a file that contains the product name, quantity, and price, adds them to a list array, and calculate the total Price of the items. Everything works with my program except that it has a toString method that when I ran the program it prints something like this @445ea7e I think this happens because the addProducts() and getProducts(String name) on the Catalog class has to do something with the toString() and I don't know how to connect them to work. import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Catalog{ private static int MAX_ITEMS = 10; /** * List of Products objects. */ private Products[] list; private int nextItem; /** * Default constructor */ public Catalog(){ list = new Products[MAX_ITEMS]; nextItem = 0; } /** * Adds an item to the list */ public void addProducts (String name, int quantity, double price){ **//I tried this: list[nextItem] = new Products(name, quantity, price); //but I'm not sure if that's ok.** } /** * Reads items from an input file. */ public void loadList(String fileName) throws FileNotFoundException { if ( (fileName != null) &amp;&amp; (!fileName.equals("")) ) { Scanner input = new Scanner(new File(fileName)); String newLine = null; String name = null; int quantity = 0; double price = 0.0; while (input.hasNextLine() &amp;&amp; nextItem &lt; MAX_ITEMS) { if (input.hasNext()) { name = input.next(); } else { System.err.println("ERROR Not a String"); System.exit(2); } if (input.hasNextInt()) { quantity = input.nextInt(); } else { System.err.println("ERROR Not an integer"); System.exit(2); } if (input.hasNextDouble()) { price = input.nextDouble(); } else { System.err.println("ERROR Not a double"); System.exit(2); } list[nextItem] = new Products(name, quantity, price); newLine = input.nextLine(); nextItem += 1; } } return; } /** * Calculate the total cost of products. */ public double getTotalPrice(){ double total = 0…
tagged with: oop
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22161956

http://stackoverflow.com/comment/33656776
type: Comment
comment on: http://stackoverflow.com/a/22124655
has text: i have another question in the below link... can you suggest an answer as well either in java or xslt?http://stackoverflow.com/questions/22149000/splitting-an-xml-based-on-the-contents-of-xml-either-using-java-or-xslt
score: 0
type: AnswerComment

http://stackoverflow.com/q/22013336
has comment: http://stackoverflow.com/comment/33368492
upvote count: 3
has comment: http://stackoverflow.com/comment/33366611
has comment: http://stackoverflow.com/comment/33368048
tagged with: java
has title: Java BlockingQueue produces/consumes not properly
has comment: http://stackoverflow.com/comment/33366653
has answer: http://stackoverflow.com/a/22015637
has comment: http://stackoverflow.com/comment/33366755
has comment: http://stackoverflow.com/comment/33369406
has comment: http://stackoverflow.com/comment/33366982
has comment: http://stackoverflow.com/comment/33367071
type: Question
has comment: http://stackoverflow.com/comment/33366904
has comment: http://stackoverflow.com/comment/33367354
has comment: http://stackoverflow.com/comment/33367060
has body: I'm working on a project where I need to retrieve Twitter messages using the TwitterAPI, process them and store them in a database. I am using Producer/Consumer BlockingQueue where the elements act as follows: Producer : retrieves the Twitter messages using the TwitterAPI and stores it in a BlockingQueue. Consumer : takes an element from the queue, processes it and stores it in a database. Here is the Main class: // Creating shared object BlockingQueue&lt;TwitterMessage&gt; sharedQueue = new ArrayBlockingQueue&lt;TwitterMessage&gt;(1); // Creating Producer and Consumer Thread Thread prodThread = new Thread(new TwitterStreamProducer(sharedQueue)); Thread consThread = new Thread(new TwitterStreamConsumer(sharedQueue)); // Starting producer and Consumer thread prodThread.start(); consThread.start(); The producer processes the TwitterAPI response and adds the object to the queue. @Override public void run() { while (true) { try { message = extractData(); // extract data from TwitterAPI response and return TwitterMessage object sharedQueue.put(message); System.out.println("Produced: " + message.getTwitterMessage()); } catch (Exception ex) { Logger.getLogger(TwitterStreamProducer.class.getName()).log(Level.SEVERE, null, ex); } } } The consumer does as follows: private final BlockingQueue&lt;TwitterMessage&gt; sharedQueue; private TwitterProcessor twitterProcessor; private TwitterMessage twitterMessage; public TwitterStreamConsumer(BlockingQueue&lt;TwitterMessage&gt; sharedQueue) { this.sharedQueue = sharedQueue; twitterProcessor = new TwitterProcessor(); } @Override public void run() { while (true) { try { twitterMessage = this.twitterProcessor.process(sharedQueue.take()); if (twitterMessage.getTwitterMessage().length() &gt; 1) { System.out.printf("Consumed: %s\n", twitterMessage.getTwitterMessage()); } } catch (InterruptedException ex) { Logger.getLogger(TwitterStreamConsumer.class.getName()).log(Level.SEVERE, null, ex); } } } As I would expect to see is the following: P…
has comment: http://stackoverflow.com/comment/33367837
tagged with: blockingqueue
has comment: http://stackoverflow.com/comment/33366812
has comment: http://stackoverflow.com/comment/33367058
has comment: http://stackoverflow.com/comment/33366647
has comment: http://stackoverflow.com/comment/33368407
has answer: http://stackoverflow.com/a/22014725
has comment: http://stackoverflow.com/comment/33367015
has comment: http://stackoverflow.com/comment/33367216
answer count: 2
has comment: http://stackoverflow.com/comment/33367743
has comment: http://stackoverflow.com/comment/33366451
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/33367659
has comment: http://stackoverflow.com/comment/33366684
type: UnansweredQuestion
tagged with: multithreading
has comment: http://stackoverflow.com/comment/33368149
has comment: http://stackoverflow.com/comment/33366930
has comment: http://stackoverflow.com/comment/33366557
has comment: http://stackoverflow.com/comment/33368618
score: 3
has comment: http://stackoverflow.com/comment/33368562

android-gridview
type: Tag
tag name: android-gridview
tags question: http://stackoverflow.com/q/22102643

http://stackoverflow.com/comment/33606697
has text: See [hear](https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:8812348049)
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22146150

http://stackoverflow.com/comment/33426698
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22046638
score: 0
has text: Then it may be implementation specific. Why don't you write a test exposing the behavior?

http://stackoverflow.com/q/22157734
tagged with: http://stackoverflow.com/tag/xml
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33626293
tagged with: java
has comment: http://stackoverflow.com/comment/33627485
has answer: http://stackoverflow.com/a/22161336
type: Question
has title: Dynamically reposition view in RelativeLayout
has body: I'm trying to reposition a view (which contains a canvas element) dynamically. The idea is to have the user touch the box and be able to drag it around the screen. I intend to grab the touch motion_events in order to reposition the block where the user is dragging. This is the code I currently have which I thought would work but hasn't produced any success so far. int[] coords = getLastLocations(); setContentView(R.layout.activity_main); View mainv = findViewById(R.id.mainRelativeLayout); BoxView bvr = (BoxView) findViewById(R.id.BoxViewRed); BoxView bvb = (BoxView) findViewById(R.id.BoxViewBlue); bvr.setColor(255, 0, 0); bvr.layout(coords[0], coords[1], 60, 60); bvb.setColor(0, 0, 255); bvb.layout(coords[2], coords[3], 60, 60); mainv.invalidate(); Any tips on how to get this code to work or another method would be perfect. P.S. Targeting ICS+ (API 14-19)
has comment: http://stackoverflow.com/comment/33626259
upvote count: 2
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33628527
linked to: http://stackoverflow.com/q/5037799
type: UnansweredQuestion
tagged with: android

http://stackoverflow.com/comment/33521471
type: QuestionComment
comment on: http://stackoverflow.com/q/22099608
has text: What's wrong with using the same `${TEXT_AREA_LENGTH-fn:length(status.value)}` in the 2nd JSP too?
score: 0
type: Comment

http://stackoverflow.com/a/22036150
has comment: http://stackoverflow.com/comment/87664259
score: 0
has comment: http://stackoverflow.com/comment/33407644
upvote count: 1
type: AcceptedAnswer
type: Answer
has body: for(int i = 0; i &lt; 100; i++){ for (int j = 10; j &lt; 100; j++) { //code; if(code == true){ j = 100; //will cancel the inner for loop. } } }
has comment: http://stackoverflow.com/comment/33407675
downvote count: 1
has comment: http://stackoverflow.com/comment/33407905
answers question: http://stackoverflow.com/q/22036043
accepted answer of: http://stackoverflow.com/q/22036043

waveform
tag name: waveform
tags question: http://stackoverflow.com/q/22127992
type: Tag

http://stackoverflow.com/comment/33453353
comment on: http://stackoverflow.com/a/22059527
type: Comment
has text: It uses Apache POI in back end that I'm using already.It won't make any difference using POI again with Tika.
score: 0
type: AnswerComment

http://stackoverflow.com/a/22137277
answers question: http://stackoverflow.com/q/22136224
type: Answer
has comment: http://stackoverflow.com/comment/33589905
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/33590086
downvote count: 0
has body: You could use a lookahead assertion String[] array = str.split(",(?=R)");

http://stackoverflow.com/q/22113385
has answer: http://stackoverflow.com/a/56406597
has answer: http://stackoverflow.com/a/22113561
has title: Url encoding issue with url connection
tagged with: encoding
type: AnsweredQuestion
tagged with: url
accepted answer: http://stackoverflow.com/a/56406597
has answer: http://stackoverflow.com/a/22113695
type: Question
tagged with: android
tagged with: utf-8
score: 0
has body: Please help me to encode the url: http://dsxsd.com/def/fss/default/files/10 رسم الصباح - 1.mp3 I need to download this file in android app. when i am trying to make url connection it gives me 404. but on browser the url is working. when i pasted browser encoded url its working fine. But i can't hardcore the things as i have my urls like this coming from server. I tried to encode using Urlencoder.encode(url,"UTF-8"); but server call gives me wrong url I am getting "java.net.MalformedURLException: Protocol not found: http%3A%2F%........ have this url not separate path params and query params to encode separately. please help me in it.
tagged with: java
answer count: 3
possible better answer: http://stackoverflow.com/a/22113561

http://stackoverflow.com/a/22096460
has comment: http://stackoverflow.com/comment/33543929
type: AcceptedAnswer
score: 4
accepted answer of: http://stackoverflow.com/q/22096221
answers question: http://stackoverflow.com/q/22096221
type: Answer
upvote count: 4
has body: I checked the documentation and, unfortunately GraphUser is not serializable. What you can do is to convert from List to List before calling setResult: List&lt;String&gt; tmpList = new ArrayList&lt;String&gt;(); for (GraphUser tmp : friendList) { tmpList.add(tmp.getInnnerJSONObject().toString()); } Intent intent = new Intent(); intent.putExtra("list", tmpList); setResult(RESULT_OK, intent); finish(); On onActivityResult, you can read the data back: else if (resultCode == Activity.RESULT_OK) { List&lt;String&gt; tmpList = intent.getExtra("list"); List&lt;GraphUser&gt; list = new ArrayList&lt;GraphUser&gt;(); for (String tmpString : tmpList) { GraphUser user = (GraphUser) GraphObject.Factory.create(new JSONObject(tmpString), ,GraphUser.class); list.add(user); } } Check for typo/null values/correct cast
downvote count: 0

http://stackoverflow.com/a/22132166
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22131962
answers question: http://stackoverflow.com/q/22131962
type: Answer
has body: Just to answer your question: So, my question is whether it's worth the duplicate code and virtually identical data in order to use MVC It's all up to you, Google's Documentation recommends avoid object creation exactly like this kind if possible, so If you consider the benefits of having the MVC implementation worth you should go for it, but take on count that programming for mobile devices involve constraints in memory and performance, if the design starts impacting the performance of your application even when the code is "scalable, extendible, etc..." it might not be the way to go, in case of mobile designs I always go for a good programming advice I took from a Book "Make code usable before making it reusable" but always avoid to do a disaster, there's no hard rules in software, you could implement a light version of MVC that meets the balance between having readable code and good throughput code. Hope it Helps! Regards!
score: 0

http://stackoverflow.com/comment/33585548
comment on: http://stackoverflow.com/a/22134669
type: AnswerComment
score: 0
type: Comment
has text: If I understand the question correctly, using a `Comparator` is a requirement. (This sounds like a school assignment.)

http://stackoverflow.com/comment/33578633
type: QuestionComment
has text: Any exception? What's returned from the database?
comment on: http://stackoverflow.com/q/22130934
score: 0
type: Comment

http://stackoverflow.com/comment/33418846
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22042427
has text: @NPE It could be a "practical, answerable problem that is unique to software development" if it was more specific.

http://stackoverflow.com/comment/33462481
type: QuestionComment
has text: small advice - you should never use Double or Float for money calculations. Use BigDecimal instead.
score: 3
comment on: http://stackoverflow.com/q/22067214
type: Comment

http://stackoverflow.com/q/22108084
downvote count: 0
has title: A Beginner’s Confusion about Screen Dimensions and Screen Density
tagged with: android
favorite count: 0
answer count: 0
upvote count: 2
tagged with: resolution
type: UnansweredQuestion
tagged with: screen
has comment: http://stackoverflow.com/comment/33537484
score: 2
tagged with: java
has body: I’m very new to Android programming and the one thing that really has me confused relates to screen density and screen dimensions. I’ve read plenty of replies to other questions on here and I’ve read the Google docs on how to program for multiple screen sizes. None have really helped address either the problem or my own general ignorance. I hope it is okay to ask this here so somebody might finally explain it simply enough so that I’ll be able to wrap my brain around this problem. First of all, I’ve been working with SurfaceViews onto which I’m throwing bitmaps. I’ve been primarily programming for the Samsung Note 10.1 (2014) edition. The screen is 2048x1536 and returns a screen density of 2.0 when I query the display. My approach has been to make graphics that work at those dimensions but within the code, I’ve used the oft-quoted formula to convert floating point dp coordinates into pixels, ready for the moment I move to other devices. px = (dp * density) + 0.5f I’ve now been trying to get the app working on a Samsung S2. The screen is 480 by 800.On the phone, the app is (I assume correctly) loading graphics from the HDPI folder because the pixel density is 1.5. My first problem was that the graphics in the HDPI were originally far too big. I’d used the Resize program to quickly resize my original XHDPI folder. Perhaps I simply didn’t select the correct source setting but the resulting graphics where far bigger than the actual 480x800 graphic I finally found filled the screen. However, that was only a symptom of my larger confusion. When developing an app using bitmaps, is there some magic formula I’ve missed which allows dp values to be translated to pixels or should I be doing calculations based on the actual screen dimensions? By the formular, 100dp is approximately 150px on the (1.5 density) 800px wide screen but 200px on the bigger (2.0 density) 2560 display. That’s 18% horizontally across the S2’s screen but only 8% across the wider screen on the Note 10.1. I…
type: Question
has comment: http://stackoverflow.com/comment/33537532

http://stackoverflow.com/comment/33511416
type: Comment
has text: Let me know if u are not completely cleared your doubt.
comment on: http://stackoverflow.com/a/22094038
score: 0
type: AnswerComment

http://stackoverflow.com/a/22130791
score: 0
has comment: http://stackoverflow.com/comment/33579852
has body: You probably want something like: myComponent.setBorder(BorderFactory.createMatteBorder(0, 5, 0, 5, Color.Black)); You can checkout the Java Tutorial "How to Use Borders" - http://docs.oracle.com/javase/tutorial/uiswing/components/border.html for more examples, or just read the API for Borders and BorderFactory.
has comment: http://stackoverflow.com/comment/33580552
has comment: http://stackoverflow.com/comment/33581157
answers question: http://stackoverflow.com/q/22130295
type: Answer
has comment: http://stackoverflow.com/comment/33579392
has comment: http://stackoverflow.com/comment/33585022

http://stackoverflow.com/a/22009796
score: 4
type: Answer
has comment: http://stackoverflow.com/comment/33360941
answers question: http://stackoverflow.com/q/22009630
has body: Two possible solutions either use Map&lt;String, Object&gt;or create a class like public class DualValue { private final String stringValue; private final Long longValue; public DualValue(final String stringValue) { this.stringValue = stringValue; this.longValue = null; } public DualValue(final Long longValue) { this.stringValue = null; this.longValue = longValue; } public String getStringValue() { return stringValue; } public Long getLongValue() { return longValue; } public boolean isString() { return stringValue != null; } public boolean isLong() { return longValue != null; } // next two are optional but should be implemented, // if you ever want to use this class as key of a Map @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DualValue dualValue = (DualValue) o; if (longValue != null ? !longValue.equals(dualValue.longValue) : dualValue.longValue != null) { return false; } if (stringValue != null ? !stringValue.equals(dualValue.stringValue) : dualValue.stringValue != null) { return false; } return true; } @Override public int hashCode() { int result = stringValue != null ? stringValue.hashCode() : 0; result = 31 * result + (longValue != null ? longValue.hashCode() : 0); return result; } } and use Map&lt;String, DualValue&gt;. You are right that the compiler is not able to merge two destinct class-hirachies with a pure genric approach in another way than using Object which is common parent to every Java class. Even if it could you would probably have to check by using value instanceof String or value instanceof Long and cast to one of those if you would want to call any functions on the value not present in Object.
upvote count: 4
has comment: http://stackoverflow.com/comment/33361132
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22009630

http://stackoverflow.com/a/22069554
has comment: http://stackoverflow.com/comment/33469236
has comment: http://stackoverflow.com/comment/33474679
has body: You could start with a Cache&lt;SomeKey, Collection&lt;SomeValue&gt;&gt; (so you still get the expiration) and use synchronized collections (Collections.synchronized*()) as the values. But what's really the question here is the type of concurrent access you need on the collections: Is it enough that the operations are synchronized so the collections don't get corrupted, or do you need higher-level semantics like what ConcurrentMap.putIfAbsent() offers? Do you need to do multiple operations on the collections of values in an atomic way? Like if you need to do if (c.contains(v)) { c.remove(v); } else { c.add(v); } you usually want to put that into a synchronized(c) { } block. If so, you'll probably want to wrap the collection inside a class exposing those higher-level semantics and managing the lock around multiple operations to get the atomicity you need, and use that class as the value: Cache&lt;SomeKey, SomeValuesContainer&gt;. As mentioned in the comments, Striped&lt;Lock&gt; can be used to synchronize the access to multiple Caches/ConcurrentHashMaps without imposing a single lock and its performance impact in case of even moderate contention. If you need multiple Caches/ConcurrentHashMaps, that is: why don't the Peers (or a wrapper around it) actually contain that information? 1. Deadlocks, performance Guava's Cache is similar to ConcurrentHashMap, but it doesn't use it. However, both work in the same way by having segments which can be locked independently, thus reducing contention when accessing the map concurrently (especially when updating). Using a Striped&lt;Lock&gt; around the access to either one cannot cause a deadlock, which only happens if you're not locking multiple locks in a consistent order: that can't happen here, as you'll always lock your Lock obtained from Striped&lt;Lock&gt; before calling the Cache or ConcurrentHashMap, which then locks its segment (invisible to you). As to performance, yes, locking has a cost but it really depends on the lev…
has comment: http://stackoverflow.com/comment/33475101
upvote count: 2
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33474592
has comment: http://stackoverflow.com/comment/33602861
type: Answer
has comment: http://stackoverflow.com/comment/33474328
answers question: http://stackoverflow.com/q/22068772
score: 2
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22068772

http://stackoverflow.com/comment/33539286
comment on: http://stackoverflow.com/q/22109227
score: 0
has text: Please show some examples of how `insertInOrder(i[],i,i)` is being called.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33711900
comment on: http://stackoverflow.com/a/22175080
type: Comment
score: 0
type: AnswerComment
has text: What went wrong? You broke it ;-) Please download the original sample I posted in itextpdf.com; adapt it and post the complete sample (e.g. in your question) so that we can reproduce the problem. Just telling us what you changed doesn't help much (it's also not clear why you'd change it that way). Also: which version of iText are you using?

http://stackoverflow.com/comment/33361973
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22010430
has text: Tomcat - so its NOT an actual proper JEE application. In any case load testing is more difficult than you might think; you can't apply one machine to do a proper load test since that one machine can't do a great number of things exactly at the same time; that will be limited to the number of cores the machine has. What is it exactly that you want to prove with this load test?
type: Comment

http://stackoverflow.com/q/22123810
downvote count: 0
has title: Why JVM taking three times more memory in production than localhost?
score: 1
tagged with: java
has body: My webApp in prod (linus, tomcat 7.0.22) takes 390 MB memory where as same takes about 106 MB in local environment. I am continue to investigate heap issues using eclipse MAT but don't understand why same App would consume so drastically different memory in prod ? Any clues will be helpful.
type: Question
tagged with: jvm-crash
tagged with: performance
has comment: http://stackoverflow.com/comment/33579827
answer count: 2
has answer: http://stackoverflow.com/a/22125568
has comment: http://stackoverflow.com/comment/33565615
upvote count: 1
has comment: http://stackoverflow.com/comment/33583410
tagged with: jvm
favorite count: 0
has comment: http://stackoverflow.com/comment/33565559
has answer: http://stackoverflow.com/a/22123844
type: UnansweredQuestion

http://stackoverflow.com/a/22080222
upvote count: 4
has body: You're in an infinite loop. You aren't incrementing i. Add i++; to the bottom of your loop and the loop should at least terminate.
downvote count: 0
score: 4
has comment: http://stackoverflow.com/comment/33487000
answers question: http://stackoverflow.com/q/22080190
has comment: http://stackoverflow.com/comment/33487147
type: Answer

http://stackoverflow.com/q/22067124
has comment: http://stackoverflow.com/comment/33462465
answer count: 1
tagged with: arrays
has answer: http://stackoverflow.com/a/22090086
has comment: http://stackoverflow.com/comment/33462180
has comment: http://stackoverflow.com/comment/33462682
has title: StringBuffer char[] appears to be out of bounds in heapdump
tagged with: memory-leaks
accepted answer: http://stackoverflow.com/a/22090086
has comment: http://stackoverflow.com/comment/33462346
has comment: http://stackoverflow.com/comment/33462453
score: 0
has comment: http://stackoverflow.com/comment/33463326
has comment: http://stackoverflow.com/comment/33462784
type: Question
type: AnsweredQuestion
tagged with: ibm-jvm
has body: Following an OutOfMemoryError I processed the resultant heapdumps through IBM Support Assistant's 64bit memory analyzer ( J9 VM running on Websphere 7.0.23) Several leak candidates were listed ( all system classloader related ) however one of these appears to indicate that a char[] initialised with a value of 256 in StringBuffer actually contains 77 million null characters. The resultant heapdump analysis from the Support Assistant shows a char[77418987] @ 0xc32*** \u0000\u0000\u0000....... this is referenced by StringBuffer -> PatternLayout -> TimeAndSizeRollingAppender The retained heap checks out, 2 bytes for each char and 18 for the array itself for a total of 150+ Mbs. Log4j version is 1.2.16 and we use the simonsite TimeAndSizeRollingAppender ( though I would like to remove this dependency ). Could this be a false positive from Support Assistant or is there some way in which a char[256] can become a char[77000000+] on the heap?
tagged with: java
tagged with: stringbuffer

http://stackoverflow.com/comment/33422413
comment on: http://stackoverflow.com/q/22044413
has text: {1,2,4,5}, key is 3, which one is closest?
type: Comment
type: QuestionComment
score: 1

http://stackoverflow.com/a/22077643
has body: You can do Pattern p = Pattern.compile("[" + Pattern.quote(letters) + "]*"); and then later: if (word.length() &lt;= letters.length() &amp;&amp; p.matcher(word).matches());
type: AcceptedAnswer
downvote count: 0
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/22077569
score: 1
has comment: http://stackoverflow.com/comment/33482249
accepted answer of: http://stackoverflow.com/q/22077569

http://stackoverflow.com/comment/33626488
type: Comment
comment on: http://stackoverflow.com/a/22157102
type: AnswerComment
has text: You'll probably have to dig in to the Windows API then assuming this will be running on Windows. I did it once before with a Bejeweled bot but I don't have the source anymore. It's pretty straightforward, but ugly. This question seems to have some helpful stuff: http://stackoverflow.com/questions/606820/is-there-a-java-library-to-access-the-native-windows-api
score: 0

http://stackoverflow.com/q/22144913
has answer: http://stackoverflow.com/a/22145061
tagged with: java
possible better answer: http://stackoverflow.com/a/22145038
type: Question
has answer: http://stackoverflow.com/a/22145038
score: 0
tagged with: random
has comment: http://stackoverflow.com/comment/33602224
answer count: 3
accepted answer: http://stackoverflow.com/a/22145001
tagged with: arrays
tagged with: string
has body: I have a set of code that, currently, uses a pre-set list of 30 manually inputed strings made up of numbers, which can be seen below: String[] elementsToAdd2 = { "100", "510", "170", "214", "268", "398", "235", "802", "900", "723", "699", "1", "16", "999", "890", "725", "998", "978", "988", "990", "989", "984", "320", "321", "400", "415", "450", "50", "660", "624" }; I want to replace this with something else that can produce any amount of random string numbers that I want, between a certain pre-set size. What I had in mind was to use the following code in its place: public class HashFunction { . . . private Random r = new Random(); public String randomString(int limit) { int n = r.nextInt(limit); return n+""; } . . . public static void main(String[] args) { HashFunction theFunc = new HashFunction(30); // this is where you can control the number of spaces in the hash table!!! String[] elementsToAdd2 = new String[30]; for (int i = 0; i &lt;= elementsToAdd2.length; i++) { String[i] elementsToAdd2 = randomString(1000); } When I read this, I take it to mean that the array string value at "i" will be assigned to the random value that will be between 0 and 1000. However, I instead get an error message. It says that a ";" was expected, and that I have incompatible types. I think that Java is reading this as saying that I am trying to set an array of strings equal to single string, even though I included the "i" within "String[i]" to specify where in the array to place the value. If anyone can help me understand my problem, please let me know. Thank you! p.s. This code creates hash tables, in case that is relevant to the problem I am encountering. I can provide the code if you'd like, but I wanted to isolate the problem and only show what is relevant to it.
has answer: http://stackoverflow.com/a/22145001
has title: Java: Creating an array of random string numbers
type: AnsweredQuestion

http://stackoverflow.com/comment/33500295
score: 1
type: AnswerComment
type: Comment
has text: Can you tell me how you initialise the transFile object ??
comment on: http://stackoverflow.com/a/22087669

http://stackoverflow.com/q/22077801
tagged with: jframe
tagged with: android
upvote count: 1
tagged with: swing
type: AnsweredQuestion
has body: Hey i am really new to this so sorry if this is a stupid question. I created an android application and my goal is to make it into a PC application and i believe this to be possible without to much trouble since they can both be written in java. So my main question is in android application we used the XML files for the user interface. While in the pc application we would need to use jframes. I have been looking around im not sure if its parsing or i need something else i am very confused. i was hoping i can use the XML as a file which will create my user interface and my program would just be in the java files like a android application or is that not possible? confused by what people have been saying about parsing, i checked out some examples and it just seems they just get some information from xml but dont use it for the actual layout. any help will be great.
score: 1
tagged with: java
has title: Jframe vs xml GUI
type: Question
has answer: http://stackoverflow.com/a/22077835
accepted answer: http://stackoverflow.com/a/22077835
downvote count: 0
answer count: 1
tagged with: http://stackoverflow.com/tag/xml
favorite count: 0

http://stackoverflow.com/q/22092404
type: Question
has body: I want to save some file content to database with hibernate, my model for hibernate is: import javax.persistence.*; import java.io.Serializable; import static javax.persistence.AccessType.FIELD; @Entity @Access(FIELD) @Table(name = "MYFILE") public class MyFile implements Serializable { @Id @SequenceGenerator(name = "MYSEQ", sequenceName = "MYSEQ", allocationSize = 1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "MYSEQ") @Column(name = "ID") private Long id; @Column(name = "FILE_CONTENT") @Lob private byte[] fileContent; // getters and setters } You can see the type of the fileContent field is byte[], and there is a @Lob on it. It's working well, but the problem is if the files are huge, e.g. 10M, or 20M, it will use a lot of memory, which is an issue in production. I wonder if there is any way to make it using low memory, say, use a stream instead of byte[]? But I'm not sure what is the correct solution.
tagged with: java
tagged with: hibernate
has comment: http://stackoverflow.com/comment/33508976
has comment: http://stackoverflow.com/comment/33513816
linked to: http://stackoverflow.com/q/9607307
score: 0
tagged with: lob
has comment: http://stackoverflow.com/comment/33515232
has comment: http://stackoverflow.com/comment/33508308
has comment: http://stackoverflow.com/comment/33523840
linked to: http://stackoverflow.com/q/9253323
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33508210
tagged with: bigdata
has title: How to save a big file to and read it from database with hibernate with low-memory usage?

http://stackoverflow.com/a/22165721
upvote count: 2
has body: Here you can see how it can be done with OpenCV in C++. You just need to translate it to Java: // C++: Mat outImg(inputImg.size(),inputImg.type()); inputImg(Rect(0, 0, shiftX, height)).copyTo(outImg(Rect(width-shiftX, 0, shiftX, height))); Becomes something like: Mat outImg = new Mat(inputImg.size(),inputImg.type()); inputImg.submat(new Rect(0, 0, shiftX, height)).copyTo(outImg.submat(new Rect(width-shiftX, 0, shiftX, height))); Although this one liner is not very readable ;)
score: 2
answers question: http://stackoverflow.com/q/22156887
accepted answer of: http://stackoverflow.com/q/22156887
type: AcceptedAnswer
downvote count: 0
type: Answer

http://stackoverflow.com/tag/xml
tags question: http://stackoverflow.com/q/22077203
tags question: http://stackoverflow.com/q/22062587
tags question: http://stackoverflow.com/q/22018424
tags question: http://stackoverflow.com/q/22092623
tags question: http://stackoverflow.com/q/22087130
tags question: http://stackoverflow.com/q/22141341
tags question: http://stackoverflow.com/q/22052738
tags question: http://stackoverflow.com/q/22131013
tags question: http://stackoverflow.com/q/22163383
tags question: http://stackoverflow.com/q/22060447
tags question: http://stackoverflow.com/q/22072872
tags question: http://stackoverflow.com/q/22157734
tags question: http://stackoverflow.com/q/22152073
type: Tag
tags question: http://stackoverflow.com/q/22028671
tags question: http://stackoverflow.com/q/22121374
tags question: http://stackoverflow.com/q/22086664
tags question: http://stackoverflow.com/q/22063509
tags question: http://stackoverflow.com/q/22144122
tags question: http://stackoverflow.com/q/22043616
tags question: http://stackoverflow.com/q/22091866
tags question: http://stackoverflow.com/q/22032568
tags question: http://stackoverflow.com/q/22028197
tags question: http://stackoverflow.com/q/22149000
tags question: http://stackoverflow.com/q/22040001
tags question: http://stackoverflow.com/q/22032976
tags question: http://stackoverflow.com/q/22021483
tags question: http://stackoverflow.com/q/22070709
tags question: http://stackoverflow.com/q/22158288
tags question: http://stackoverflow.com/q/22013287
tags question: http://stackoverflow.com/q/22073870
tags question: http://stackoverflow.com/q/22146703
tags question: http://stackoverflow.com/q/22071463
tags question: http://stackoverflow.com/q/22059343
tags question: http://stackoverflow.com/q/22084212
tags question: http://stackoverflow.com/q/22106700
tags question: http://stackoverflow.com/q/22081292
tags question: http://stackoverflow.com/q/22142102
tags question: http://stackoverflow.com/q/22009229
tags question: http://stackoverflow.com/q/22154510
tags question: http://stackoverflow.com/q/22075832
tags question: http://stackoverflow.com/q/22045664
tags question: http://stackoverflow.com/q/22093617
tags question: http://stackoverflow.com/q/22035229
tags question: http://stackoverflow.com/q/22067643
tags question: http://stackoverflow.com/q/22156768
tags question: http://stackoverflow.com/q/22019651
tags question: http://stackoverflow.com/q/22117919
tags question: http://stackoverflow.com/q/22134885
tags question: http://stackoverflow.com/q/22009203
tags question: http://stackoverflow.com/q/22088021
tags question: http://stackoverflow.com/q/22011875
tags question: http://stackoverflow.com/q/22009861
tags question: http://stackoverflow.com/q/22076943
tags question: http://stackoverflow.com/q/22133940
tags question: http://stackoverflow.com/q/22029359
tags question: http://stackoverflow.com/q/22155837
tags question: http://stackoverflow.com/q/22053616
tags question: http://stackoverflow.com/q/22158811
tags question: http://stackoverflow.com/q/22023460
tag name: xml
tags question: http://stackoverflow.com/q/22051816
tags question: http://stackoverflow.com/q/22077801
tags question: http://stackoverflow.com/q/22146742
tags question: http://stackoverflow.com/q/22151653
tags question: http://stackoverflow.com/q/22051344
tags question: http://stackoverflow.com/q/22164642
tags question: http://stackoverflow.com/q/22072714
tags question: http://stackoverflow.com/q/22048433
tags question: http://stackoverflow.com/q/22037077
tags question: http://stackoverflow.com/q/22057305
tags question: http://stackoverflow.com/q/22041082
tags question: http://stackoverflow.com/q/22027865
tags question: http://stackoverflow.com/q/22042197
tags question: http://stackoverflow.com/q/22139494
tags question: http://stackoverflow.com/q/22017149
tags question: http://stackoverflow.com/q/22036622
tags question: http://stackoverflow.com/q/22142830
tags question: http://stackoverflow.com/q/22109124
tags question: http://stackoverflow.com/q/22076142

http://stackoverflow.com/comment/33405793
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22034262
has text: try with CascadeType.ALL

http://stackoverflow.com/q/22043564
has title: Is it possible to create key of map of type map?
score: 1
has comment: http://stackoverflow.com/comment/33420922
has answer: http://stackoverflow.com/a/22043772
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22043636
has comment: http://stackoverflow.com/comment/33420910
upvote count: 1
has answer: http://stackoverflow.com/a/22044563
has comment: http://stackoverflow.com/comment/33420976
has comment: http://stackoverflow.com/comment/33420908
has body: I would like to create a LinkedMap which the key is of type Map too, like this: LinkedHashMap&lt;LinkedHashMap&lt;String, Float&gt;, String&gt; map = new LinkedHashMap &lt;LinkedHashMap&lt;String, Float&gt;, String&gt; Is it possible or not? If yes: how can I call for Keys and Values of Map Key?
tagged with: java
has comment: http://stackoverflow.com/comment/33421588
has comment: http://stackoverflow.com/comment/33420879
type: Question
has comment: http://stackoverflow.com/comment/33421045
has comment: http://stackoverflow.com/comment/33421781
downvote count: 0
has comment: http://stackoverflow.com/comment/33420943
favorite count: 0
has comment: http://stackoverflow.com/comment/33420993
answer count: 3

http://stackoverflow.com/comment/33467266
type: Comment
comment on: http://stackoverflow.com/q/22069908
score: 0
type: QuestionComment
has text: what do you mean by OFF??

http://stackoverflow.com/comment/33609749
score: 0
comment on: http://stackoverflow.com/q/22149006
type: Comment
type: QuestionComment
has text: what is line number 231?

http://stackoverflow.com/comment/33355765
has text: Another good question on the subject: http://stackoverflow.com/questions/15629398/c4-5-algorithm-continuous-data
comment on: http://stackoverflow.com/q/22006363
type: Comment
type: QuestionComment
score: 1

http://stackoverflow.com/a/22098068
answers question: http://stackoverflow.com/q/22097774
downvote count: 0
score: 1
type: Answer
upvote count: 1
has body: Try creating a resultDocument and use adoptNode(). This will move the nodes from the old documents to the new resultDocument. From the javadoc: Attempts to adopt a node from another document to this document. If supported, it changes the ownerDocument of the source node, its children, as well as the attached attribute nodes if there are any. If the source node has a parent it is first removed from the child list of its parent. This effectively allows moving a subtree from one document to another (unlike importNode() which create a copy of the source node instead of moving it). When it fails, applications should use Document.importNode() instead.

http://stackoverflow.com/q/22146343
accepted answer: http://stackoverflow.com/a/22146412
score: 2
upvote count: 2
has answer: http://stackoverflow.com/a/22146378
tagged with: java
type: Question
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22146378
tagged with: lucene
has title: how to check that what lucene folder data contain?
has body: hello i am working on java and i am using lucene for the indexing purpose. i am storing data there but how to check that what lucene data contain? i am tried with this to check data on lucene. public static void main(String[] args) throws Exception { File indexDir = new File("/path/to/solr/data/index/"); int hits = 100; SimpleSearcher searcher = new SimpleSearcher(); searcher.searchIndex(indexDir, args[0], hits); } private void searchIndex(File indexDir, String queryStr, int maxHits) throws Exception { Directory directory = FSDirectory.open(indexDir); IndexSearcher searcher = new IndexSearcher(directory); QueryParser parser = new QueryParser(Version.LUCENE_35, "title", new SimpleAnalyzer()); Query query = parser.parse(queryStr); TopDocs topDocs = searcher.search(query, maxHits); ScoreDoc[] hits = topDocs.scoreDocs; for (int i = 0; i &lt; hits.length; i++) { int docId = hits[i].doc; Document d = searcher.doc(docId); List&lt;Fieldable&gt; fields = d.getFields(); System.out.println( (i+1) + ". =========================================================="); for ( Fieldable field : fields ) { if (field.isStored()) { System.out.println(" &gt;&gt; " + field.name() + " - " + d.get(field.name())); } } } System.out.println("Found " + hits.length); } is there any tool available to download it??
answer count: 2
has answer: http://stackoverflow.com/a/22146412
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/22105070
type: Answer
answers question: http://stackoverflow.com/q/22005548
has body: Check out this section of the docs: http://docs.spring.io/spring-data/data-mongo/docs/1.4.0.RELEASE/reference/html/mongo.repositories.html#mongodb.repositories.queries.json-based In particular, this example: public interface PersonRepository extends MongoRepository&lt;Person, String&gt; @Query(value="{ 'firstname' : ?0 }", fields="{ 'firstname' : 1, 'lastname' : 1}") List&lt;Person&gt; findByThePersonsFirstname(String firstname); } It's quite likely that you simply need to change field="{'id', 'address'}" to fields="{'address': 1}", I've left out id since it is always included unless explicitly repressed (i.e. {_id: 0}).
score: 0

http://stackoverflow.com/comment/109750860
type: Comment
comment on: http://stackoverflow.com/a/51462308
has text: Great anticipation.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33516515
has text: Although this answer is perfectly sufficient for this case, I would also try with actions. Here you've got a nice intro: http://docs.oracle.com/javase/tutorial/uiswing/misc/action.html It will make your solution more flexible - you can use one action for many UI components and controll its "enabled" state in one place ;)
comment on: http://stackoverflow.com/a/22094339
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/comment/33608497
score: 0
comment on: http://stackoverflow.com/q/22148257
has text: I guess you OP want to execute the method and get the returned value
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22042646
has comment: http://stackoverflow.com/comment/33419785
answers question: http://stackoverflow.com/q/22042570
upvote count: 1
has body: Yo can do this if it must use array: int j = 0; for (int i = 0; i &lt; frame.length; i++) { if (frame[i]!=0) { j++ } } final int[] sorted = new int[j]; j = 0; for (int i = 0; i &lt; frame.length; i++) { if (frame[i]!=0) { sorted[j] = frame[i]; j++; } }
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33419645

http://stackoverflow.com/q/22085215
answer count: 1
accepted answer: http://stackoverflow.com/a/22085455
favorite count: 0
tagged with: static
linked to: http://stackoverflow.com/q/413898
score: -3
has title: Use of Static in the example
has comment: http://stackoverflow.com/comment/33496002
has comment: http://stackoverflow.com/comment/33495892
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33496371
has comment: http://stackoverflow.com/comment/33496585
tagged with: java
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/22085455
duplicate of: http://stackoverflow.com/q/413898
tagged with: static-members
has body: I want to know the meaning of static in my file. Everytime, I come across an error and then find out that the word static is missed. Can you please explain when and where should the word static be used. Here, for example in the code, even if I remove static from the variable, it shows error. Is, it static class, so it has to be static variable ?? public class TestJavaServer { static String xCordinate; public static void main(String[] args) { readFromFile(); } public static void readFromFile() throws IOException { xCordinate ="something"; }
downvote count: 4
has comment: http://stackoverflow.com/comment/33496336

http://stackoverflow.com/comment/33633809
type: QuestionComment
has text: Well... If they are to be made `public` then I would venture a guess that they will be used **outside** of the class that defines them.
type: Comment
comment on: http://stackoverflow.com/q/22162052
score: 0

http://stackoverflow.com/a/27873675
upvote count: 1
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/22022001
type: Answer
has body: This is a BluetoothSocket.close() bug in Android 4.2 - 4.4.4 (and 4.4w &amp; L Preview)... Internally, it's calling mPfd.detachFd() and then not actually releasing the underlying file descriptor. The fix is to instead call mPfd.close() and set mPfd=null, which is exactly how Android 5.0 now does it. You can mostly fix this with the other solutions posted here that call mPfd.close() and then calling your platform's BluetoothSocket.close(), but I found that wasn't quite enough for me and some weird things could happen. I went a bit further and also clean up mSocket first and set that null, then call mPfd.close() and set that null, and finally call BluetoothSocket.close() which is needed to set mSocketState. public static void cleanClose(BluetoothSocket btSocket) { if(btSocket == null) return; if(Build.VERSION.SDK_INT &gt;= 17 &amp;&amp; Build.VERSION.SDK_INT &lt;= 20) { try { cleanCloseFix(btSocket); } catch (Exception e) { Log.d(sLogName, "Exception during BluetoothSocket close bug fix: " + e.toString()); } //Go on to call BluetoothSocket.close() too, because our code didn't do quite everything } //Call BluetoothSocket.close() try { btSocket.close(); } catch (Exception e) { Log.d(sLogName, "Exception during BluetoothSocket close: " + e.toString()); } } private static void cleanCloseFix(BluetoothSocket btSocket) throws IOException { synchronized(btSocket) { Field socketField = null; LocalSocket mSocket = null; try { socketField = btSocket.getClass().getDeclaredField("mSocket"); socketField.setAccessible(true); mSocket = (LocalSocket)socketField.get(btSocket); } catch(Exception e) { Log.d(sLogName, "Exception getting mSocket in cleanCloseFix(): " + e.toString()); } if(mSocket != null) { mSocket.shutdownInput(); mSocket.shutdownOutput(); mSocket.close(); mSocket = null; try { socketField.set(btSocket, mSocket); } catch(Exception e) { Log.d(sLogName, "Exception setting mSocket = null in cleanCloseFix(): " + e.toString()); } } Field pfdField = null; ParcelFileDescriptor m…

http://stackoverflow.com/comment/33483021
type: AnswerComment
score: 0
type: Comment
has text: If its your code that you're talking about, then yes. When you do `add(a);`, the frame adds the component `a` in `center`, then when you do `add(b);`, the frame adds the component in center again, effectively covering the previously added components. Use Layout hints as I showed above in my code, and you can then easily resolve the issue.
comment on: http://stackoverflow.com/a/22076834

http://stackoverflow.com/comment/33427687
comment on: http://stackoverflow.com/a/22046028
score: 0
type: Comment
has text: you can use this line, say inside the constructor, to verify the root path: `System.out.println(this.getClass().getClassLoader().getResource(""));` from that root path you can follow to find your image, and it should be Pictures/mario.png
type: AnswerComment

http://stackoverflow.com/comment/33516757
comment on: http://stackoverflow.com/a/22097022
has text: But the jar file commons-cli-1.3-SNAPSHOT.jar (in which the missing class is inside) still remains in ./dependency-jars folder
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33648949
comment on: http://stackoverflow.com/q/22167743
score: 0
type: Comment
type: QuestionComment
has text: Because SWT has no support for Popups on TreeItems. And I mean to extend the Popup with buttons, I see no better way to do it than this. Why should it "blow up"? It works..

http://stackoverflow.com/a/22189080
answers question: http://stackoverflow.com/q/22167592
downvote count: 0
has body: You may use the same approach we did for our EJB application. You may call some of the tests 'unit tests' but they are really integration tests. Running these tests includes starting the application server first, then running the JUnit test cases and finally stopping the server. These test cases act as the client, loading the ejb remote interface, make the appropriate calls, validate the return values, etc just like your client would. One of the problems with this is that these tests can take a while to run, depending on how many you have. It also requires the server be up and running. I know there must be better ways, but this has worked for our project for about 10 years.
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/comment/42216028
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/26771479
has text: The problem is the one described in the OP's question. This is what the question is about. You don't seem to have read that either.

http://stackoverflow.com/q/22089078
answer count: 5
has answer: http://stackoverflow.com/a/22089291
has answer: http://stackoverflow.com/a/22089187
has answer: http://stackoverflow.com/a/22089144
score: 0
tagged with: java
has body: public static boolean isValidNumber(String a1) { String x = ("0123456789"); boolean valid = false; for (int i = 0; i &lt; 4; i++) { char c = a1.charAt(i); for (int j = 0; j &lt; 10; j++) { if ( c == x.charAt(j)) { valid = true; } else { valid = false; } } } return valid; } The above method checks to see whether an input of a four character string is composed of the characters 0123456789. However, regardless of what the input is, the method always returns as false. If I were to change the valid value in the else statement to true, the method would always return as true. What is the error that I have made in this method?
has title: Java - Boolean method always returning as false
has answer: http://stackoverflow.com/a/22089203
type: UnansweredQuestion
tagged with: boolean
has answer: http://stackoverflow.com/a/22089874
has comment: http://stackoverflow.com/comment/33502482
type: Question

http://stackoverflow.com/a/22069350
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/22069051
score: 1
answers question: http://stackoverflow.com/q/22069051
upvote count: 1
has body: Unfortunately, you will have to loop through each pixel (until you find a transparent pixel) to be sure. If you don't need to be 100% sure, you could of course test only some pixels, where you think transparency is most likely to occur. By looking at various images, I think you'll find that most images that has transparent parts contains transparency along the edges. This optimization will help in many common cases. Unfortunately, I don't think that there's an optimization that can be done in one of the most common cases, the one where the color model allows transparency, but there really are no transparent pixels... You really need to test every pixel in this case, to know for sure. Accessing the alpha values in its "native representation" (through the Raster/DataBuffer/SampleModel classes) is going to be faster than using BufferedImage.getRGB(x, y) and mask out the alpha values.
type: AcceptedAnswer

http://stackoverflow.com/comment/124695059
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/52619873
score: 0
has text: It's really easy to use

http://stackoverflow.com/comment/33459964
comment on: http://stackoverflow.com/a/22065273
type: Comment
has text: Ok I got your actual problem. I think you are using package for your code at the first line. eg. package com.example; If you use package you need to compile using javac -d . cancelladir.java and execute using javac com.example.cancelladir. Try like this your actual code should work now.
score: 0
type: AnswerComment

jsp
tags question: http://stackoverflow.com/q/22126807
tags question: http://stackoverflow.com/q/22063552
tags question: http://stackoverflow.com/q/22010038
tags question: http://stackoverflow.com/q/22099648
tags question: http://stackoverflow.com/q/22040812
tags question: http://stackoverflow.com/q/22146598
tags question: http://stackoverflow.com/q/22090291
tags question: http://stackoverflow.com/q/22031119
tags question: http://stackoverflow.com/q/22015446
tags question: http://stackoverflow.com/q/22009341
tags question: http://stackoverflow.com/q/22096068
tags question: http://stackoverflow.com/q/22028290
tags question: http://stackoverflow.com/q/22142731
tags question: http://stackoverflow.com/q/22151344
tags question: http://stackoverflow.com/q/22096266
tags question: http://stackoverflow.com/q/22128143
tags question: http://stackoverflow.com/q/22012591
tags question: http://stackoverflow.com/q/22027000
tags question: http://stackoverflow.com/q/22128864
tags question: http://stackoverflow.com/q/22064355
tags question: http://stackoverflow.com/q/22124498
tags question: http://stackoverflow.com/q/22109509
tags question: http://stackoverflow.com/q/22110348
tags question: http://stackoverflow.com/q/22101237
tags question: http://stackoverflow.com/q/22039458
tags question: http://stackoverflow.com/q/22097251
tags question: http://stackoverflow.com/q/22019803
tags question: http://stackoverflow.com/q/22126864
tags question: http://stackoverflow.com/q/22117250
tags question: http://stackoverflow.com/q/22050255
tags question: http://stackoverflow.com/q/22038378
tags question: http://stackoverflow.com/q/22124300
tags question: http://stackoverflow.com/q/22070125
tags question: http://stackoverflow.com/q/22055191
tags question: http://stackoverflow.com/q/22110856
tags question: http://stackoverflow.com/q/22094071
tags question: http://stackoverflow.com/q/22016978
tags question: http://stackoverflow.com/q/22112688
type: Tag
tags question: http://stackoverflow.com/q/22033076
tags question: http://stackoverflow.com/q/22061168
tags question: http://stackoverflow.com/q/22061414
tags question: http://stackoverflow.com/q/22134763
tags question: http://stackoverflow.com/q/22153869
tags question: http://stackoverflow.com/q/22139572
tags question: http://stackoverflow.com/q/22087394
tags question: http://stackoverflow.com/q/22157505
tags question: http://stackoverflow.com/q/22140017
tags question: http://stackoverflow.com/q/22020601
tags question: http://stackoverflow.com/q/22162886
tags question: http://stackoverflow.com/q/22086093
tags question: http://stackoverflow.com/q/22130564
tags question: http://stackoverflow.com/q/22117863
tags question: http://stackoverflow.com/q/22127102
tags question: http://stackoverflow.com/q/22067567
tag name: jsp
tags question: http://stackoverflow.com/q/22026512
tags question: http://stackoverflow.com/q/22164837
tags question: http://stackoverflow.com/q/22156112
tags question: http://stackoverflow.com/q/22107384
tags question: http://stackoverflow.com/q/22005681
tags question: http://stackoverflow.com/q/22055097
tags question: http://stackoverflow.com/q/22099608
tags question: http://stackoverflow.com/q/22167708
tags question: http://stackoverflow.com/q/22130432
tags question: http://stackoverflow.com/q/22086406
tags question: http://stackoverflow.com/q/22164575
tags question: http://stackoverflow.com/q/22098642
tags question: http://stackoverflow.com/q/22110759
tags question: http://stackoverflow.com/q/22108865
tags question: http://stackoverflow.com/q/22050787
tags question: http://stackoverflow.com/q/22128150
tags question: http://stackoverflow.com/q/22041707
tags question: http://stackoverflow.com/q/22166415
tags question: http://stackoverflow.com/q/22017463
tags question: http://stackoverflow.com/q/22108774
tags question: http://stackoverflow.com/q/22139964
tags question: http://stackoverflow.com/q/22025285
tags question: http://stackoverflow.com/q/22030630
tags question: http://stackoverflow.com/q/22005734

http://stackoverflow.com/a/22124922
score: 1
has comment: http://stackoverflow.com/comment/33568696
has comment: http://stackoverflow.com/comment/33569220
type: Answer
upvote count: 1
has body: I'd like to add my two cents here. Just to start with logging without any configuration hassle, here is what I usually do. import java.util.logging.Logger; public class LoggingDemo { //First, you instantiate a logger object as a member private static final Logger logger = Logger.getLogger( LoggingDemo.class.getName() ); public Object someMethod( Object someParameter ) { // Then, use the logger wherever you want logger.info("some message"); ... } }
answers question: http://stackoverflow.com/q/22124601
has comment: http://stackoverflow.com/comment/33567631
downvote count: 0

http://stackoverflow.com/q/22075035
has body: I need a way to read the stored emails in Thunderbird with Java and retrieve attached files. The problem is that I have an old FoxPro app that reads Zip files from a folder. The FoxPro used to retrieve those files from attachments into the emails in Outlook Express, when we installed Outlook 2007 this function of retrieve the files from Outlook didn't work anymore so it was replaced with a simple Java app (reading directly from the PST file). So now FoxPro app executes the Java app to retrieve those files. Now I want to replace Outlook 2003 with Thunderbird and I want to read the emails from there. IMPORTANT: The accounts are POP3 so I can't use IMAP to extract files directly from the email server. There is a lib or something?
tagged with: java
type: Question
answer count: 2
tagged with: email-attachments
has title: Read emails stored in Thunderbird with Java
has answer: http://stackoverflow.com/a/22075387
score: 0
tagged with: thunderbird
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/32890963

http://stackoverflow.com/q/22044439
has title: NullPointerException in fragment's onCreateView only on emulator
answer count: 1
has comment: http://stackoverflow.com/comment/33422677
accepted answer: http://stackoverflow.com/a/22044629
tagged with: nullpointerexception
tagged with: android
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/14536595
type: Question
has answer: http://stackoverflow.com/a/22044629
tagged with: android-fragments
tagged with: java
has body: I'm getting a NullPointerException in the onCreateView method of my fragment but what is strange is that this only occurrs on the emulator. On the device the app runs fine. If I set a breakpoint for NullPointerException and debug in eclipse it stops at this line: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_map, container, false); mapTrackButton = (Button) rootView.findViewById(R.id.track_user_button); map = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); map.setMyLocationEnabled(true); // This line // More code }
tagged with: android-emulator
score: 0
has comment: http://stackoverflow.com/comment/33422504

http://stackoverflow.com/comment/33616628
type: QuestionComment
has text: It solved by using InputStream modelInput = this.getClass.getResourceAsStream("en-token.bin"); And add the en-token.bin to the same package of the java class.
comment on: http://stackoverflow.com/q/22099648
score: 0
type: Comment

http://stackoverflow.com/q/22152219
tagged with: java
type: Question
tagged with: variables
tagged with: scope
has answer: http://stackoverflow.com/a/22152666
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/22152247
has title: Accessing variables declared within onCreateView() from class methods
possible better answer: http://stackoverflow.com/a/22152480
has answer: http://stackoverflow.com/a/22152480
has body: If I have variables that are declared within the onCreateView of a fragment; is there a way I can access those variables from outside the onCreateView? public View onCreateView(LayoutInflater viewInflation, ViewGroup container, Bundle SavedInstantState) { superContext = getActivity().getApplicationContext(); digitalfragmentview = viewInflation.inflate( R.layout.digitalfragment_page, container, false); digitalIO0Mode = (Switch) digitalfragmentview .findViewById(R.id.digitalio0mode); digitalIO1Mode = (Switch) digitalfragmentview .findViewById(R.id.digitalio1mode); digitalIO2Mode = (Switch) digitalfragmentview .findViewById(R.id.digitalio2mode); digitalIO3Mode = (Switch) digitalfragmentview .findViewById(R.id.digitalio3mode); digitalIO4Mode = (Switch) digitalfragmentview .findViewById(R.id.digitalio4mode); digitalIO5Mode = (Switch) digitalfragmentview .findViewById(R.id.digitalio5mode); digitalIO6Mode = (Switch) digitalfragmentview .findViewById(R.id.digitalio6mode); digitalIO7Mode = (Switch) digitalfragmentview .findViewById(R.id.digitalio7mode); digitalIO8Mode = (Switch) digitalfragmentview .findViewById(R.id.digitalio8mode); digitalIO9Mode = (Switch) digitalfragmentview .findViewById(R.id.digitalio9mode); centralDigitalTable = (TableLayout) digitalfragmentview .findViewById(R.id.digitalTable); Switch[] digitalIOModeSwitchArray = {digitalIO0Mode, digitalIO1Mode, digitalIO2Mode, digitalIO3Mode, digitalIO4Mode, digitalIO5Mode, digitalIO6Mode, digitalIO7Mode, digitalIO8Mode, digitalIO9Mode}; return digitalfragmentview; } Now I have these methods within the class: public Switch getIOModeSwitch(int index) { return digitalIOModeSwitchArray[index]; } public void getIOModeSwitch(int index, boolean status) { digitalIOModeSwitchArray[index].setActivated(status); } However; they obviously cannot access digitalIOModeSwitchArray as it is out of their scope and localized to the onCreateView method. I tried to put all of the initiation of the variables after the class's header howe…
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22152247

http://stackoverflow.com/comment/33622326
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22155679
has text: There is no reason to unbox, as none of the arguments calls for a primitive comparison
score: 2

http://stackoverflow.com/a/22155299
answers question: http://stackoverflow.com/q/22146208
upvote count: 2
has body: Consider the API you're creating here, especially regarding future extensions or implementations. You evidently have a number of stateful FirstDep instances around, because the SecondDep depends on the particular FirstDep, but a future SecondDep may not depend on that same FirstDep (or any FirstDep at all). The fact that createMyObject(first) can be a shorthand to createMyObject(first, factory.createSecond(first)) is specific to your business case, and I don't think there's a shorthand in Guice to make that assumption. That said, you have two options. One, you can create a very small helper: // Encapsulate the createMyObject(first) shorthand. class MyObjectHelper { @Inject MyObjectFactory rawFactory; MyObject createMyObject(FirstDep first) { return rawFactory.createMyObject(first, rawFactory.createSecond(first)); } } Or, two, you can use @AssistedInject to have Guice effectively overload the constructor: class MyObject { // Multiple @AssistedInject constructors, selected based on which parameters // are marked with @Assisted. @AssistedInject public MyObject(@Assisted FirstDep first, SecondFactory secondFactory, ThirdDep third) { this(first, secondFactory.createSecond(first), third); } @AssistedInject public MyObject(@Assisted FirstDep first, @Assisted SecondDep second, ThirdDep third) { /**/ } } interface SecondFactory { // Note that @Assisted annotations are not needed here. Every parameter in // these interfaces is for assisted injection, by definition. SecondDep createSecond(FirstDep first); } interface MyObjectFactory { MyObject createMyObject(FirstDep first); MyObject createMyObject(FirstDep first, SecondDep second); } Though it's slightly more verbose to create a separate factory per class, I think you'll find it to be helpful in keeping your classes/factories separate and easy-to-follow, and it neatly avoids a potential circular-reference that I can't remember offhand if Guice supports. I tend to expose my factories as nested interfaces: class SecondDep { int…
type: Answer
accepted answer of: http://stackoverflow.com/q/22146208
score: 2
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/33410771
has text: Using Iterator over Enumeration is preferable, there is no need to use Enumeration anymore.
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22037855
type: QuestionComment

http://stackoverflow.com/comment/33476341
has text: You can replace `.toString()` with `.name()` in this example since by default, this is what an `Enum` does
type: AnswerComment
type: Comment
score: 1
comment on: http://stackoverflow.com/a/22074582

http://stackoverflow.com/comment/33642449
type: Comment
has text: Ok, so `String.toCharArray()` is also a standard function. How do you do it without that huh? ;)
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22167153

http://stackoverflow.com/comment/33461272
type: Comment
has text: Hi paulkayuk, deviceloc d=new deviceloc(); d.id=mqttClientId; d.add=strAddress; d.lat=loc.getLatitude(); d.lon=loc.getLongitude(); ByteArrayOutputStream b = new ByteArrayOutputStream(); ObjectOutputStream o=new ObjectOutputStream(b); o.writeObject(d); byte bytes[]=b.toByteArray(); mqttClient.publish("admin/location",bytes,MQTT_QUALITY_OF_SERVICE,MQTT_RETAINED_PUBLISH); this is how i send the message. i am deserializing on server side, but i am getting error as clientsidepackagename.deviceloc class not found error. how to rectify that
comment on: http://stackoverflow.com/a/22063705
type: AnswerComment
score: 0

http://stackoverflow.com/comment/42121461
has text: Hi, I have this added. Can it be a concern with the underlining android implementation...I was trying to run it on ics on my HTC one x...
comment on: http://stackoverflow.com/a/26761223
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33626285
type: Comment
type: QuestionComment
has text: possible duplicate of [How to deal with "java.lang.OutOfMemoryError: Java heap space" error (64MB heap size)](http://stackoverflow.com/questions/37335/how-to-deal-with-java-lang-outofmemoryerror-java-heap-space-error-64mb-heap)
comment on: http://stackoverflow.com/q/22157849
score: 0

http://stackoverflow.com/q/22063215
answer count: 2
has body: I have a textbox to input a mathematical formular inlcude +,-,*,/,(,),TRUNC,ROUND,POWER,MOD,SQRT,FLOOR,DECODE. After user input a formula string, i want to validate this string but i don't know how ??? Please help me out.
has comment: http://stackoverflow.com/comment/33455583
favorite count: 0
has answer: http://stackoverflow.com/a/22065000
accepted answer: http://stackoverflow.com/a/22065026
has comment: http://stackoverflow.com/comment/33455578
tagged with: regex
has title: How to validate math formular string using regex?
possible better answer: http://stackoverflow.com/a/22065000
type: AnsweredQuestion
tagged with: java
upvote count: 1
downvote count: 1
type: Question
tagged with: math
has answer: http://stackoverflow.com/a/22065026
score: 0

http://stackoverflow.com/comment/33557517
has text: You've got the Item what is needed on button press. That is implemented properly. You need to pass Item to proper method which would show the data. The line ViewData view = new ViewData(Item) is confusing to me.. is ViewData a class in you code, otherwise that line wouldn't even compile. You've used ViewData as the name of a Button also which is why it is confusing.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22119441

http://stackoverflow.com/q/22160778
has comment: http://stackoverflow.com/comment/33632206
has answer: http://stackoverflow.com/a/22166330
type: Question
answer count: 1
downvote count: 0
favorite count: 0
has body: I'm developing an app that uses an internal sqlite database. The MainActivity contains a Fragment.This fragment has a ViewPager which contains other 3 fragments, each of these 3 fragments has a ListView in it. when you click an item of the list, a second Activity is opened containing another ViewPager that has fragments showing the complete details(a bitmap and Strings) of each list item. My question is, what would be better for performance ? To make constant calls to the database each time the user scrolls through the detail fragments(ViewPager). Make only three calls to the database (one for each listview in the mainActivity), to create 3 ArrayList of objects and keep them in memory. The list could have lots of items. Is there something else I'm not considering ?
has comment: http://stackoverflow.com/comment/33631593
accepted answer: http://stackoverflow.com/a/22166330
tagged with: android
tagged with: sqlite
has comment: http://stackoverflow.com/comment/33673606
upvote count: 1
has title: Better Performance, SQLite queries vs ArrayList<Object> in memory
type: AnsweredQuestion
tagged with: performance
score: 1
tagged with: java

http://stackoverflow.com/comment/33551708
type: Comment
score: 1
comment on: http://stackoverflow.com/a/22116375
type: AnswerComment
has text: 1+ for not giving just a solution but also a decent explanation to someone who has shown no effort.

http://stackoverflow.com/q/22141880
has comment: http://stackoverflow.com/comment/33600283
has comment: http://stackoverflow.com/comment/33598145
favorite count: 0
type: Question
has comment: http://stackoverflow.com/comment/33598324
has comment: http://stackoverflow.com/comment/33599230
has comment: http://stackoverflow.com/comment/33598296
has comment: http://stackoverflow.com/comment/33598391
has title: WebCrawler with recursion
has comment: http://stackoverflow.com/comment/33597829
tagged with: recursion
has comment: http://stackoverflow.com/comment/33597229
has comment: http://stackoverflow.com/comment/33598106
has comment: http://stackoverflow.com/comment/33598593
score: 0
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/22143205
answer count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/33598058
has comment: http://stackoverflow.com/comment/33597377
has comment: http://stackoverflow.com/comment/33597316
has body: So I am working on a webcrawler that is supposed to download all images, files, and webpages, and then recursively do the same for all webpages found. However, I seem to have a logic error. public class WebCrawler { private static String url; private static int maxCrawlDepth; private static String filePath; /* Recursive function that crawls all web pages found on a given web page. * This function also saves elements from the DownloadRepository to disk. */ public static void crawling(WebPage webpage, int currentCrawlDepth, int maxCrawlDepth) { webpage.crawl(currentCrawlDepth); HashMap&lt;String, WebPage&gt; pages = webpage.getCrawledWebPages(); if(currentCrawlDepth &lt; maxCrawlDepth) { for(WebPage wp : pages.values()) { crawling(wp, currentCrawlDepth+1, maxCrawlDepth); } } } public static void main(String[] args) { if(args.length != 3) { System.out.println("Must pass three parameters"); System.exit(0); } url = ""; maxCrawlDepth = 0; filePath = ""; url = args[0]; try { URL testUrl = new URL(url); URLConnection urlConnection = testUrl.openConnection(); urlConnection.connect(); } catch (MalformedURLException e) { System.out.println("Not a valid URL"); System.exit(0); } catch (IOException e) { System.out.println("Could not open URL"); System.exit(0); } try { maxCrawlDepth = Integer.parseInt(args[1]); } catch (NumberFormatException e) { System.out.println("Argument is not an int"); System.exit(0); } filePath = args[2]; File path = new File(filePath); if(!path.exists()) { System.out.println("File Path is invalid"); System.exit(0); } WebPage webpage = new WebPage(url); crawling(webpage, 0, maxCrawlDepth); System.out.println("Web crawl is complete"); } } the function crawl will parse the contents of a website storing any found images, files, or links into a hashmap, for example: public class WebPage implements WebElement { private static Elements images; private static Elements links; private HashMap&lt;String, WebImage&gt; webImages = new HashMap&lt;String, WebImage&gt;();…
has comment: http://stackoverflow.com/comment/33598468
type: UnansweredQuestion
tagged with: web-crawler
has comment: http://stackoverflow.com/comment/33598140
has comment: http://stackoverflow.com/comment/33598365
has comment: http://stackoverflow.com/comment/33599031

http://stackoverflow.com/comment/33565818
comment on: http://stackoverflow.com/q/22123972
score: 0
type: Comment
type: QuestionComment
has text: Read [this tutorial](http://docs.oracle.com/javase/tutorial/java/javaOO/).

http://stackoverflow.com/q/22038782
type: Question
tagged with: oop
has answer: http://stackoverflow.com/a/22039241
tagged with: java
tagged with: class
has answer: http://stackoverflow.com/a/22039226
upvote count: 1
has answer: http://stackoverflow.com/a/22039071
favorite count: 0
has body: I am a college student currently learning OOP in Java. I have been given a fairly difficult assignment and as I am very new to OOP it's proving quite tough. I'll firstly give an overview of what I've been asked to do &amp; then the details of where I'm currently at with it. The program we have been asked to implement is an application of a doctors surgery to manage the relationship between Doctors &amp; Patients. A fully operational GUI is required but I will avoid starting that for now as it will only complicate matters. The following is the assignment spec: "Develop an application to manage a doctor’s surgery. The doctor will have to be authenticated to gain access to the system. The doctor will be presented with a list of their patients when they login. The doctor will need to review a patient’s details, update patients details, add new patients. a. Patient details include, name, address, number, patient history (details of each visit/procedure/serious illness + dates) b. up to week 8 we will use an arraylist to store the data. This will be persisted to a file at shutdown, and loaded in at start up. c. After week 8 a database should be used to replace the arraylist and any files used previously for persistance. The doctor should be able to search for a patient under patient name or patient id Backup and Restore : In the event of a disaster where the database is corrupted or destroyed the system will need to be restored from a backup. The doctor will need to be able to backup all system information to a file and restore from this file if necessary. The file should be labelled with the date of backup, the backup should be done weekly. Two reports should be generated one is just a list of all patients in the system followed by their history(ordered alphabetically on patient name), and secondly a report on all patients who visited between certain dates ordered on date. " So far I have managed to create the classes and my code is as follows (we have been given class-d…
answer count: 4
has comment: http://stackoverflow.com/comment/33412646
has answer: http://stackoverflow.com/a/22038873
downvote count: 0
type: UnansweredQuestion
score: 1
has title: How to approach Java OOP program

http://stackoverflow.com/comment/33602831
type: Comment
type: QuestionComment
has text: This might be helpful to you: [link](http://stackoverflow.com/questions/14275315/how-to-call-previous-activity-in-android)
score: 0
comment on: http://stackoverflow.com/q/22145206

http://stackoverflow.com/comment/33542176
has text: @SotiriosDelimanolis what do you mean? there is nothing as "overflow" for XOR
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22111005

http://stackoverflow.com/comment/33396824
type: AnswerComment
type: Comment
has text: That's the weard thing! I initialize M in the constructor - i.e. public Algorithm(int M) { this.M = M; } and I set in main() M = 4. Therefore, the value 4 passes, M is 4. And I get java.lang.ArrayIndexOutOfBoundsException: 4. But I try to assign a value to the index M-1 = 3!
comment on: http://stackoverflow.com/a/22029624
score: 0

http://stackoverflow.com/comment/33355929
comment on: http://stackoverflow.com/q/22006814
score: 0
type: Comment
type: QuestionComment
has text: @MD This is not available "Build Path -> Remove from Build Path"

http://stackoverflow.com/q/22057121
score: 1
has comment: http://stackoverflow.com/comment/33445917
has answer: http://stackoverflow.com/a/22057390
favorite count: 0
type: Question
has comment: http://stackoverflow.com/comment/33445911
has comment: http://stackoverflow.com/comment/33445742
tagged with: user-input
has comment: http://stackoverflow.com/comment/33445900
has comment: http://stackoverflow.com/comment/33445735
tagged with: breadth-first-search
has comment: http://stackoverflow.com/comment/33446181
accepted answer: http://stackoverflow.com/a/22057390
upvote count: 1
has comment: http://stackoverflow.com/comment/33445927
answer count: 1
has comment: http://stackoverflow.com/comment/33446036
has title: User input to display shortest path
has comment: http://stackoverflow.com/comment/33445618
tagged with: java
tagged with: indexoutofboundsexception
type: AnsweredQuestion
has body: I am having an ArrayOutOfBounds exception and I do not know why. I am trying to get the user to input which city they want the program to start at, then have my program perform the breadth first search from that point. My program is due in an hour so any quick help would be great! Really quick, my program performs a breadth first search on an adjacency matrix! Thanks guys, here is my main: import java.util.*; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.Collection; import java.io.File; import java.io.FileNotFoundException; public class Main { public static void main(String[] args) { //Lets create nodes Node Seattle = new Node("Seattle"); Node Vancouver=new Node("Vancouver"); Node Portland = new Node("Portland"); Node Houston = new Node("Houston"); Node New_Orleans = new Node("New_Orleans"); Node Miami = new Node("Miami"); Node Omaha = new Node("Omaha"); Node Louisville=new Node("Louisville"); Node Boston = new Node("Boston"); Node Boise = new Node("Boise "); Node Chicago = new Node("Chicago"); Node Jacksonville = new Node("Jacksonville"); Node Baltimore = new Node("Baltimore"); Node Detroit = new Node("Detroit"); Node Nashville =new Node("Nashville "); Node Oakland = new Node("Oakland "); Node Denver= new Node("Denver "); Node Olympia = new Node("Olympia"); Node Memphis = new Node("Memphis"); // //Create the graph, add nodes, create edges between nodes g.addNode(Seattle); g.addNode(Vancouver); g.addNode(Portland); g.addNode(Houston); g.addNode(New_Orleans); g.addNode(Miami); g.addNode(Omaha); g.addNode(Louisville); g.addNode(Boston); g.addNode(Boise); g.addNode(Chicago); g.addNode(Jacksonville); g.addNode(Baltimore); g.addNode(Detroit); g.addNode(Nashville); g.addNode(Oakland); g.addNode(Denver); g.addNode(Olympia); g.addNode(Memphis); // Scanner sc = new Scanner(System.in); // String shortPath = sc.next(); // Node spath = new Node(shortPath); g.connectNode(Louisville,Memphis); g.connectNode(Houston,Seattle);…
downvote count: 0

http://stackoverflow.com/q/22073268
tagged with: eclipse-rcp
score: 0
has comment: http://stackoverflow.com/comment/33474115
tagged with: classnotfoundexception
answer count: 1
has title: ClassNotFoundException in handlers and Viewparts eclipse rcp e4
tagged with: e4
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33473786
has answer: http://stackoverflow.com/a/22076489
has body: I am using eclipse e4 application. I have created the project and it was running succesfully. I made some changes like adding the JFreechart library and made use of it in the Part in eclipse e4. After that when i try to run the application it shows ClassNotFoundException for all the Handlers and the parts that I have created. The excetion that I have got is as follows !ENTRY org.eclipse.e4.ui.workbench 4 0 2014-02-27 16:30:34.023 !MESSAGE Unable to load class 'com.xyz.project.parts.LisOfProtocolPart' from bundle '35' !STACK 0 java.lang.ClassNotFoundException: com.xyz.project.parts.LisOfProtocolPart cannot be found by com.xyz.project_1.0.0.qualifier at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) at java.lang.ClassLoader.loadClass(Unknown Source) at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:340) at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:229) at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1212) at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:100) at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:71) at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:53) at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:129) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:949) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingE…
tagged with: java
has comment: http://stackoverflow.com/comment/33474062
tagged with: eclipse
type: Question

http://stackoverflow.com/comment/39710628
comment on: http://stackoverflow.com/q/22027216
type: QuestionComment
type: Comment
has text: I switched jobs and no longer have access to HP Fortify, so I won't be able to verify an answer.
score: 0

http://stackoverflow.com/q/22155673
tagged with: jbutton
has title: How effects are added to the icon of JButton?
type: AnsweredQuestion
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/22156529
tagged with: effects
answer count: 1
has body: I'm trying to make a game like bejeweled or candycrush for homework. It's almost over. but I have a little problem. Now, when I clicked, buttons that have the same icon are popping up and the above pictures are coming instead of exploding. but it's going too fast. How can I slow this event? Or can I add effects? public class ButtonActionListener implements ActionListener { public JButton previousButton = null; public int numP, numC; public JButton[] buttons=butondeneme.getButton(); @Override public void actionPerformed(ActionEvent e){ // TODO Auto-generated method stub JButton currentButton = (JButton)e.getSource(); if (previousButton == null) { previousButton = currentButton; return; } int numP=Integer.parseInt(((JButton)previousButton).getActionCommand()); int numC=Integer.parseInt(((JButton)currentButton).getActionCommand()); //change picture of icons that clicked if (numP==(numC+1) || numP==(numC-1) || numP==(numC+8) || numP==(numC-8) ){ Icon previousIcon = previousButton.getIcon(); Icon currentIcon = currentButton.getIcon(); currentButton.setIcon(previousIcon); previousButton.setIcon(currentIcon); previousButton = null; } else previousButton=null; Random r = new Random(); int a = r.nextInt(64); int b = r.nextInt(64); int c = r.nextInt(64); //buttons that have same picture are explode. for(int i=0; i&lt;63; i++){ if(buttons[i].getIcon().toString()==buttons[i+1].getIcon().toString() &amp;&amp; buttons[i+1].getIcon().toString()== buttons[i+2].getIcon().toString() ){ //System.out.println("slm"); if(i &gt; 7){ buttons[i].setIcon(buttons[i-8].getIcon()); buttons[i+1].setIcon(buttons[i-7].getIcon()); buttons[i+2].setIcon(buttons[i-6].getIcon()); for(int j = i; j &gt; 0; j=j-8){ if(j &gt; 7){ buttons[j].setIcon(buttons[j-8].getIcon()); buttons[j+1].setIcon(buttons[j-7].getIcon()); buttons[j+2].setIcon(buttons[j-6].getIcon()); } else{ buttons[j].setIcon(buttons[a].getIcon()); buttons[j+1].setIcon(buttons[b].getIcon()); buttons[j+2].setIcon(buttons[c].getIcon()); } } } e…
has comment: http://stackoverflow.com/comment/33622325
has answer: http://stackoverflow.com/a/22156529
score: 0
tagged with: swing

http://stackoverflow.com/a/22110897
has body: At the bottom of the page, there is a link as follows, See all versions available on the Maven Central Repository. I have went through that page and found a previous version of Directory API Client Library for Java. By looking at it's pom i have tried following dependency and it worked. com.google.apis google-api-services-admin directory_v1-rev22-1.16.0-rc Then I tried to update the version to latest as follows and also worked. com.google.apis google-api-services-admin directory_v1-rev28-1.17.0-rc
upvote count: 2
accepted answer of: http://stackoverflow.com/q/22110847
answers question: http://stackoverflow.com/q/22110847
score: 2
type: AcceptedAnswer
downvote count: 0
type: Answer

http://stackoverflow.com/q/22045617
type: Question
tagged with: filenotfoundexception
linked to: http://stackoverflow.com/q/19219351
has title: Mallet SimpleTagger FileNotFoundException: c:\mallet-2.0.7 (Access is denied)
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/22063233
tagged with: mallet
type: AnsweredQuestion
tagged with: java
has body: I tried running Mallet from windows cmd following exactly the examples in the documentation and also from the solution in this post I keep getting this error, what could be the problem? c:\&gt;java -cp "C:\mallet-2.0.7\class;C:\mallet-2.0.7\lib\mallet-deps.jar" cc.mallet.fst.SimpleTagger --model-file c:\mallet-2.0.7 c:\mallet-2.0.7\sample.txt Exception in thread "main" java.io.FileNotFoundException: c:\mallet-2.0.7 (Access is denied) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.&lt;init&gt;(Unknown Source) at cc.mallet.fst.SimpleTagger.main(SimpleTagger.java:519)
tagged with: classpath
accepted answer: http://stackoverflow.com/a/22063233

http://stackoverflow.com/a/22013409
answers question: http://stackoverflow.com/q/22013361
type: Answer
downvote count: 0
score: 44
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22013361
upvote count: 44
has body: if the break statements are not used, Then we know that the following cases will be executed. So if you are permitted to declare in both cases that will cause a conflict. For example switch(x) { case 1: int a = 1; // i have removed the break; case 2: int a = 2; // now what will happen here :) break; }

http://stackoverflow.com/comment/33542820
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22111177
has text: @Transactional should be at repository or service level class

http://stackoverflow.com/comment/33432552
type: AnswerComment
has text: It compiles and runs, which is different from what the OP has. However, you still can't store it in a variable or field without at least first declaring an interface that includes the speak method.
comment on: http://stackoverflow.com/a/22049767
type: Comment
score: 1

http://stackoverflow.com/comment/33570495
type: QuestionComment
comment on: http://stackoverflow.com/q/22126570
type: Comment
score: 1
has text: post the mapping here

http://stackoverflow.com/q/22060193
tagged with: ibm-midrange
type: Question
downvote count: 0
answer count: 1
favorite count: 0
accepted answer: http://stackoverflow.com/a/22060324
tagged with: exception
tagged with: constructor
has body: Error NoClassDefFound for Exception Handling in Constructor this is Constructor in Java Code public Class MyBook{ String name; public MyBook(){ try{ name = "BookName"; } catch(javax.xml.rpc.ServiceException se){} } } this is how i call MyBook in RPG DBookObj S O Class(*java:'com.abc.MyBook') DMyBook PR O ExtProc(*Java:'com.abc.MyBook':*Constructor) C EVAL BookObj = MyBook() . EVAL BookObj = MyBook() give me error NoClassDefFound: javax.xml.rpc.ServiceException any solution ? should i create a procedure specifically for this Exception Handler ?
upvote count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22060324
has title: Rpg call Java Constructor, error ClassDefNotFound on Exception handler
score: 1
tagged with: rpgle
tagged with: java

http://stackoverflow.com/comment/33542479
type: AnswerComment
comment on: http://stackoverflow.com/a/22068879
score: 0
type: Comment
has text: hey when i am DOING echo$PATH changes are not present

http://stackoverflow.com/q/22118551
has title: Null Pointer exception when trying to call getLayoutInflater
accepted answer: http://stackoverflow.com/a/22118916
favorite count: 0
has comment: http://stackoverflow.com/comment/33555681
tagged with: android
has answer: http://stackoverflow.com/a/22118916
possible better answer: http://stackoverflow.com/a/22119052
has comment: http://stackoverflow.com/comment/33556583
downvote count: 0
has body: In class socialNetworksActivity i have a method: public void getResultFromFBPost(String result) { if (result.equals("SUC")) ShowToast("Your message have been posted successfully", Toast.LENGTH_LONG); else ShowToast("There was an error posting," + " please check your Internt connection", Toast.LENGTH_LONG); } Which calls this method (also in class socialNetworksActivity): public void ShowToast(String message, int duration) { LayoutInflater inflater = getLayoutInflater(); .... } When I call this method from inside the class it works fine. But when I call this method from class B like this: @Override protected void onPostExecute(String result) { socialNetworksActivity.getResultFromFBPost(result); pd.dismiss(); } I get a NullPointerException when code get to: LayoutInflater inflater = getLayoutInflater(); Any idea why?
has comment: http://stackoverflow.com/comment/33557018
score: 2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33555703
has comment: http://stackoverflow.com/comment/33556197
tagged with: java
has comment: http://stackoverflow.com/comment/33555620
type: Question
upvote count: 2
has answer: http://stackoverflow.com/a/22119052
linked to: http://stackoverflow.com/q/7803771
answer count: 2

http://stackoverflow.com/comment/33353922
type: Comment
type: QuestionComment
has text: post stacktrace which line you are getting NullPointerException...
comment on: http://stackoverflow.com/q/22005516
score: 0

http://stackoverflow.com/comment/33508418
comment on: http://stackoverflow.com/a/22078341
type: Comment
has text: putting groovy in your XML puts logic in there - is this logic used only to deal with the process itself? a service is usually a clear logical barrier (e.g. tested with your app). groovy (without @CompileStatic) adds a slight performance hit (you will never notice it most likely). groovy is much more expressive than java - but if no one understands it in your team, why bother, when each line looks like java in the end anyway?
score: 0
type: AnswerComment

http://stackoverflow.com/q/22051695
upvote count: 1
has comment: http://stackoverflow.com/comment/33465502
answer count: 1
tagged with: java
has answer: http://stackoverflow.com/a/30576118
has comment: http://stackoverflow.com/comment/33436323
has body: I want to try to open my (old) car (who have an IR receptor) with a simple app. On the electronic board in the key I have a paper with a code (Exemple : 06495 167.5 ) I think that the code in this exemple is only 06495, based on this source : http://farancullas.blogspot.fr/2012/10/recodificacion-receptor-infrarojo.html On android you have to send a HEX code converted to dec ? This is a part of my code (working because no exeption, and blue led on my note 3). I Just need some help to proper format the IR_CODE variable. I can send any string it seems to work because the led is flashing. Have you and idea to format this code ? I think It's something like hex2dec("195F") ? 195F is 6495 in hex It can be : IR_CODE=hex2dec(Integer.toHexString(Integer.decode(IR_CODE))); Based on this source : https://github.com/rngtng/IrDude/blob/master/src/com/rngtng/irdude/MainActivity.java , but I'm not sure, and I can't test the app too much. String IR_CODE="06495"; Class irClass = irService.getClass(); Class params[] = new Class[1]; params[0] = String.class; try { Method sendIR = irClass.getMethod("write_irsend", params); for(int i=0;i&lt;2;i++) sendIR.invoke(irService, IR_CODE); } Can you help me to format IR_CODE ? Thank you !
downvote count: 0
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/28794899
type: Question
tagged with: android
has comment: http://stackoverflow.com/comment/33464893
score: 1
has title: How to send an IR code, convert a String to "IR string"
favorite count: 0
has comment: http://stackoverflow.com/comment/48898120
tagged with: infrared

http://stackoverflow.com/comment/33479042
comment on: http://stackoverflow.com/a/22076103
type: AnswerComment
score: 0
type: Comment
has text: can you define "best"?

http://stackoverflow.com/q/22161718
has answer: http://stackoverflow.com/a/22162399
type: AnsweredQuestion
tagged with: java
type: Question
linked to: http://stackoverflow.com/q/13762248
score: 0
answer count: 2
possible better answer: http://stackoverflow.com/a/22161753
has answer: http://stackoverflow.com/a/22161753
tagged with: android
has comment: http://stackoverflow.com/comment/33635521
has comment: http://stackoverflow.com/comment/33633015
accepted answer: http://stackoverflow.com/a/22162399
has title: How to not save to SharedPreferences if cancel was clicked on a ListPreference
has body: I need to make it so that if cancel or back was pushed when a ListPreference was open that, the value is not saved in SharedPreferences and takes no effect on the app. I have everything in my application working and have been searching for some type of solution but could not find it. Thanks! Edit: Is there a way to start the list preference with none of the values selected?

http://stackoverflow.com/a/22111532
accepted answer of: http://stackoverflow.com/q/22111512
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/22111512
type: Answer
upvote count: 6
score: 6
has body: When you write int i = 0 it creates no garbage. The variable i has type int which is a primitive type, not an object (or reference) type. The state of i is held entirely within the stack frame of the enclosing method; i.e. not on the heap. Does that create a lot of garbage? No. And would there be an alternative? No alternative is necessary ...

http://stackoverflow.com/q/22131013
type: Question
tagged with: android-layout
tagged with: java
has comment: http://stackoverflow.com/comment/33578861
tagged with: eclipse
has answer: http://stackoverflow.com/a/22131101
answer count: 2
score: 2
downvote count: 0
favorite count: 0
has body: I'm having problems with my xml layout. I want to make my layout using xml that "simplemessage" would stick to the top, and "textchange" would be filled and centered in the middle of the screen while "hiraganaconfbutton" would stick at the bottom, i tried gravity and centering but for some reason it's not working Thank you in advance for your help This is my xml layout <?xml version="1.0" encoding="utf-8"?> <TextView android:id="@+id/simplemessage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/guess" android:textSize="19sp" /> <TextView android:id="@+id/textchange" android:layout_width="wrap_content" android:layout_height="392dp" android:text="@string/a" android:textSize="60sp" />
tagged with: android
accepted answer: http://stackoverflow.com/a/22131101
tagged with: http://stackoverflow.com/tag/xml
type: AnsweredQuestion
upvote count: 2
possible better answer: http://stackoverflow.com/a/22343527
has title: LinearLayout gravity
has answer: http://stackoverflow.com/a/22343527

executorservice
tags question: http://stackoverflow.com/q/22069026
type: Tag
tags question: http://stackoverflow.com/q/22098884
tags question: http://stackoverflow.com/q/22069325
tag name: executorservice
tags question: http://stackoverflow.com/q/22077258
tags question: http://stackoverflow.com/q/22042120
tags question: http://stackoverflow.com/q/22039990
tags question: http://stackoverflow.com/q/22072774
tags question: http://stackoverflow.com/q/22167776

http://stackoverflow.com/a/22021193
answers question: http://stackoverflow.com/q/22020511
has body: Can get a scaled bitmap or try other options like inSampleSize, do check how your solution affects the quality of your image too. Esp for "..loading ALL the images at once, even the ones that aren't seen on the first tab.."(i have done the following for a similar implementation): you can use inSampleSize to load all images and replace the visible tab images by the original ones- meaning for the selected tab, dynamically load images without the inSampleSize for the BitmapFactory and its Options. You could scale them down depending on different devices to load the images without facing a memory problem. In your case, some phones may not exhibit the same behavior on the first run, but eventually, without handling an optimized image loading solution, app will crash. Check more on this: Topic under Load a Scaled Down Version into Memory. http://developer.android.com/training/displaying-bitmaps/load-bitmap.html Out of memory error on Android On how to avoid them: How to avoid an out of memory error while using bitmaps in Android For an overview: http://blogs.innovationm.com/android-out-of-memory-error-causes-solution-and-best-practices/ http://android-developers.blogspot.de/2009/01/avoiding-memory-leaks.html Also, android:largeHeap android:largeHeap="true" convention?
score: 0
type: Answer

amazon-web-services
tags question: http://stackoverflow.com/q/22125823
tags question: http://stackoverflow.com/q/22043166
tags question: http://stackoverflow.com/q/22103099
tags question: http://stackoverflow.com/q/22055845
tags question: http://stackoverflow.com/q/22023312
type: Tag
tags question: http://stackoverflow.com/q/22064297
tag name: amazon-web-services
tags question: http://stackoverflow.com/q/22021466
tags question: http://stackoverflow.com/q/22078516
tags question: http://stackoverflow.com/q/22131718
tags question: http://stackoverflow.com/q/22134483
tags question: http://stackoverflow.com/q/22048081

http://stackoverflow.com/q/22089481
has comment: http://stackoverflow.com/comment/33503146
score: 1
tagged with: java
type: Question
tagged with: sqlite
downvote count: 0
favorite count: 0
has title: Where/When should I create a table that is the basis of my program?
answer count: 3
tagged with: deployment
has answer: http://stackoverflow.com/a/22089579
has body: I'm developing a desktop java program that takes advantage of an SQLite database to restore some data. I now how to create the database and create my table : Class.forName("org.sqlite.JDBC"); c = DriverManager.getConnection("jdbc:sqlite:mokvoc.db"); stmt = c.createStatement(); String sql = "CREATE TABLE COMPANY " + ... problem The problem is that I want to execute this statement just once through the whole life time of the program and specially at the first time that the program runs or during the installation step. Please tell me how can I perform this and is it required to add a new JFrame or I don't now sth like that?
has answer: http://stackoverflow.com/a/22090661
has answer: http://stackoverflow.com/a/22089540
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33503256
has comment: http://stackoverflow.com/comment/33503307
upvote count: 1
tagged with: swing

http://stackoverflow.com/q/22029064
has comment: http://stackoverflow.com/comment/33395967
has answer: http://stackoverflow.com/a/22029188
tagged with: java
has answer: http://stackoverflow.com/a/22029122
type: Question
possible better answer: http://stackoverflow.com/a/22029188
answer count: 2
downvote count: 0
tagged with: inheritance
favorite count: 0
has comment: http://stackoverflow.com/comment/33395945
tagged with: static
linked to: http://stackoverflow.com/q/3911278
accepted answer: http://stackoverflow.com/a/22029122
score: 2
has body: So I am making a ticket booth that sales three tickets using inheritance and polymorphism. the output needs to look like this. Regular Season: Ticket type: Walkup, Number: 123, Price: 10.00 Ticket type: Advance, Number: 234, Price: 7.50 Ticket type: Student Advance, Number: 345, Price: 3.75 (ID Required) Finals: Ticket type: Walkup, Number: 321, Price: 12.00 Ticket type: Advance, Number: 432, Price: 9.00 Ticket type: Student Advance, Number: 543, Price: 4.50 (ID Required) My output is this. Regular Season: Ticket type: Walkup, Number: 123, Price: 10.00 Ticket type: Advance, Number: 234, Price: 10.00 Ticket type: Student Advance, Number: 345, Price: 10.00 Finals: Ticket type: Walkup, Number: 321, Price: 12.00 Ticket type: Advance, Number: 432, Price: 12.00 Ticket type: Student Advance, Number: 543, Price: 12.00 So my question is how do i change a static double, price, in my code to make it those prices without changing the whole price to what i set it to. heres my code: public abstract class Ticket { protected String ticketNumber; protected static double price = 10.00; protected String ticketName; // constructor so i can change my ticket number in the main as a parameter public Ticket(String string) { this.ticketNumber = string; } // get name in other classes public String getName() { return ticketName; } // get price public double getPrice() { return price; } // so i can chang the price in the main public static void setPrice(double price) { Ticket.price = price; } // toString method so i can print my descriptive information. public String toString() { String result = String.format("\tTicket type: %s, Number: %s, Price: %.2f", getName(), ticketNumber, getPrice()); return result; } } public class WalkUpTicket extends Ticket { public WalkUpTicket(String string) { super(string); } public String getName() { return this.ticketName = "Walkup"; } } public class AdvanceTicket extends Ticket { public AdvanceTicket(String string) { super(string); } public String getName() { r…
upvote count: 2
has title: Changing static double in other classes
type: AnsweredQuestion

http://stackoverflow.com/comment/33559500
has text: When I do that I get 2 error messages: FinalExam.java:19: error: cannot find symbol penny.deposit(amount); ^ symbol: variable penny location: class FinalExam FinalExam.java:30: error: cannot find symbol penny.withdraw(amount); ^ symbol: variable penny location: class FinalExam 2 errors
type: Comment
comment on: http://stackoverflow.com/a/22120609
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33546720
type: QuestionComment
has text: Could you please post the exception message and the full stacktrace? Virtually any exception thrown by Oracle JDBC will include the three lines of stacktrace you have shown.
comment on: http://stackoverflow.com/q/22085970
score: 0
type: Comment

http://stackoverflow.com/comment/33458357
type: Comment
comment on: http://stackoverflow.com/a/22017685
type: AnswerComment
has text: I have edited my code according to your procedure. But i can't set the location and size of the button. I want it exactly on the middle of the image.
score: 0

http://stackoverflow.com/q/22012522
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/33366580
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22012582
has comment: http://stackoverflow.com/comment/33365263
tagged with: spring
has comment: http://stackoverflow.com/comment/33365255
tagged with: java
has body: ResultSet A ResultSet object maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set. RowMapper Like ResultSetExtractor, we can use RowMapper interface to fetch the records from the database using query() method of JdbcTemplate class. In the execute of we need to pass the instance of RowMapper now.
has comment: http://stackoverflow.com/comment/33366506
type: Question
has title: Resultset or RowMapper? which one best in Spring MVC?

http://stackoverflow.com/comment/33428651
comment on: http://stackoverflow.com/q/22047432
has text: user3291997: But you're also missing ```}``` at the end of the method! The one you have on the last line pairs with the anonymous class of ```DBUrowToObject```
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/33517010
comment on: http://stackoverflow.com/q/22097171
score: 0
has text: Eh, OK, but that was pure chance; I don't see why your original attempt failed, but ohwell... Anyway, drop `File`. Starting with Java 7, it makes no sense at all to use it anymore.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33533572
type: Comment
has text: I figured out the problem. It was a dumb mistake on my part
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22105203

http://stackoverflow.com/q/22111141
answer count: 2
has comment: http://stackoverflow.com/comment/33542775
has comment: http://stackoverflow.com/comment/33542753
upvote count: 1
has answer: http://stackoverflow.com/a/22113108
has comment: http://stackoverflow.com/comment/33542886
has comment: http://stackoverflow.com/comment/33542715
favorite count: 0
has comment: http://stackoverflow.com/comment/33542564
downvote count: 2
tagged with: android
tagged with: textview
has comment: http://stackoverflow.com/comment/33543002
has title: Android Textview is not showing full typeface of hindi text
has body: xml file <?xml version="1.0" encoding="utf-8"?> <TextView android:id="@+id/tv_question" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="none" android:text="………यांच्या मते १८५७ चा उठाव म्हणजे “भारतीयाचे पहिले स्वातंत्रयुद्ध ” होय ." android:textColor="@android:color/black" android:textStyle="bold" /> भारतीयाचे - this word is not full.
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22113332
tagged with: android-typeface
tagged with: typeface
tagged with: java
score: -1
has comment: http://stackoverflow.com/comment/33543047
has comment: http://stackoverflow.com/comment/33542677
has comment: http://stackoverflow.com/comment/33542651
type: Question
has comment: http://stackoverflow.com/comment/33542727

http://stackoverflow.com/comment/97281478
type: AnswerComment
comment on: http://stackoverflow.com/a/22148805
score: 0
type: Comment
has text: Just small additional - unselect abstract methods before call context menu. For me menu was unavailable when abstract methods selected

e4
tags question: http://stackoverflow.com/q/22035861
type: Tag
tags question: http://stackoverflow.com/q/22073268
tags question: http://stackoverflow.com/q/22156920
tag name: e4

http://stackoverflow.com/a/22063989
answers question: http://stackoverflow.com/q/22063630
has body: Here is a possible prototype public static void main(String[] args) { char input[] = getUserInput(); Map&lt;Character, Double&gt; items = processUserInput(input); BigDecimal result = getResult(items); } /** * Get user input from keyboard. */ private static char[] getUserInput() { // do something return null; } /** * Associate each item with its price. */ private static Map&lt;Character, Double&gt; processUserInput(char[] input) { // do something return null; } /** * Count summ of each item. */ private static BigDecimal getResult(Map&lt;Character, Double&gt; items) { // do something; return null; }
score: 0
has comment: http://stackoverflow.com/comment/33457076
type: Answer

http://stackoverflow.com/q/22007078
score: 0
tagged with: java
possible better answer: http://stackoverflow.com/a/22007415
has body: Okay, so I have a clarification, since the question is a little misleading!--I know how to create a menu, list choices and prompt for input, read the user's input, etc. The issue that I've run into is purely logical. I need to create a main menu with 3 choices: -Create an array of student "objects" with associated attributes -Search the list -Exit . At this point, I have boolean-operated while loops that activate the "sub-menus". The booleans become true or false based on whether or not they want to create the list, search, etc. (Important to know, I have a class above (Student) that contains all of the attribute for the array, such as name, grade average, etc.) The general layout of my main program is as follows: while(bMainMenu) { boolean bList = false; boolean bSearch = false; [all the code prompting choices] -if input is "create" then bList = true; -if input is "search" then bSearch = true; -if input is "exit" then bMainMenu = false; while(bList) { [all the code that creates the array and prompts for student info where the array is as long as the user chooses] bList = false; } while (bSearch) { [all the code for searching the array] bSearch = false; } } After creating the list, everything else is false, and it re-loops the main menu. This time, the user says, "Search", and it makes the boolean for the search menu true. The issue I'm having: referencing the array that was just created. I'm trying to figure out WHERE I need to call it. As far as I can tell, the way that I've just done everything makes the array contained only within the "bList loop". Where would I call the array to make it "visible" to the "bSearch" loop? Or do I need to restructure everything differently? Thanks in advance!
has answer: http://stackoverflow.com/a/22007415
type: Question
type: AnsweredQuestion
tagged with: submenu
has title: How to create a main menu in Java?
answer count: 2
tagged with: arrays
tagged with: scope
has answer: http://stackoverflow.com/a/22014425
has comment: http://stackoverflow.com/comment/33355919
accepted answer: http://stackoverflow.com/a/22014425

http://stackoverflow.com/q/22060032
favorite count: 0
has answer: http://stackoverflow.com/a/22060160
has answer: http://stackoverflow.com/a/40066409
answer count: 9
has title: Print loop output horizontally?
has answer: http://stackoverflow.com/a/22060065
type: AnsweredQuestion
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22060055
type: Question
possible better answer: http://stackoverflow.com/a/40066409
tagged with: for-loop
has answer: http://stackoverflow.com/a/22060216
has comment: http://stackoverflow.com/comment/33450486
has body: Hey guys I have to write a program for class that asks me to produce a bar graph based on how many cars a salesperson sold for the month. An example is this: Pam XXXX Leo XXXXXX I'm almost there but not quite. As of right now I can get one X next to the salespersons name but any others are printed underneath on separate lines. Pam X X X If you can help me get those other X's on the same line I would really appreciate it. Thank you for your input! import java.util.Scanner; public class BarGraph { public static int Pam = 0; public static int Leo = 0; public static int Kim = 0; public static int Bob = 0; public static Scanner kb = new Scanner(System.in); public static void main(String args[]) { System.out.println("Enter number of cars sold by Pam "); Pam = kb.nextInt(); kb.nextLine(); System.out.println("Enter number of cars sold by Leo "); Leo = kb.nextInt(); kb.nextLine(); System.out.println("Enter number of cars sold by Kim "); Kim = kb.nextInt(); kb.nextLine(); System.out.println("Enter number of cars sold by Bob "); Bob = kb.nextInt(); kb.nextLine(); System.out.print("Pam "); pamsCars(); System.out.print("Leo "); leosCars(); System.out.print("Kim "); kimsCars(); System.out.print("Bob "); bobsCars(); } public static void leosCars() { for(int i=0; i &lt; Leo; i++) { printX(); } } public static void kimsCars() { for(int i=0; i &lt; Kim; i++) { printX(); } } public static void pamsCars() { for(int i=0; i &lt; Pam; i++) { printX(); } } public static void bobsCars() { for(int i=0; i &lt; Bob; i++) { printX(); } } public static void printX() { System.out.println("X"); } }
has answer: http://stackoverflow.com/a/40646777
upvote count: 2
has answer: http://stackoverflow.com/a/22060105
accepted answer: http://stackoverflow.com/a/22060105
downvote count: 1
has answer: http://stackoverflow.com/a/71905804
has answer: http://stackoverflow.com/a/40066722

http://stackoverflow.com/q/22032811
has answer: http://stackoverflow.com/a/22032904
has comment: http://stackoverflow.com/comment/33402019
has comment: http://stackoverflow.com/comment/33402053
has answer: http://stackoverflow.com/a/22033181
answer count: 4
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33402040
tagged with: java
has answer: http://stackoverflow.com/a/22032921
has title: Basic Java method calling
type: Question
accepted answer: http://stackoverflow.com/a/22032906
has comment: http://stackoverflow.com/comment/33402046
score: 0
possible better answer: http://stackoverflow.com/a/22033181
has body: I was browsing some classes that others had made and ran upon some code that looked like this: public RationalNumber add(RationalNumber op2){ I'm familiar with calling methods such as public int methodName(); with something like object.methodName(); in the main code, but I'm not sure how to properly call a method like the one above. The full code for the program I was looking at can be referenced here: Rational Number Class I'm fairly new to Java so any insight would be appreciated.
has answer: http://stackoverflow.com/a/22032906

http://stackoverflow.com/q/22078129
has body: I have a problem with the method "update()" in the following code. I tried to to use arrays as elements of the array "hyp", since the individual arrays do not all have the same size. Now in the update function I want to compare the elements that are stored in position 0 of the individual arrays, e.g. sky[0], in the j-th position of hyp with the corresponding elements in the trainingexample array. The problem I have is that I can only access the address for each array in the j-th position of the hyp array. I tried to assign the array in the j-th position, i.e. hyp[j], to a variable of type Object[], but this did not work. Should I just use multidimensional arrays, even though there would be empty elements in it or is there a better solution than what I'm trying to do here? public class FindS { static Object[] sky = {"Sunny", "Cloudy", "?", "0", 0}; static Object[] airtemp = {"Warm", "Cold", "?", "0", 0}; static Object[] humidity = {"normal", "high", "?", "0", 0}; static Object[] wind = {"strong", "weak","?", "0",0}; static Object[] water = {"warm", "cold","?", "0", 0}; static Object[] forecast = {"same", "change","?", "0", 0}; static Object[] hyp = {sky,airtemp,humidity,wind, water, forecast}; public static String[] trainingexample = new String[7]; public static int findindex(Object[] a, String s){ int index = 0; while (index != a.length - 1){ if (a[index] == s) return index; index++; } return -1; } public static void exchange(Object[] a, String s){ int exchindex = findindex(a, s); try{ Object temp = a[exchindex]; a[exchindex] = a[0]; a[0] = temp; } catch (ArrayIndexOutOfBoundsException e) { System.out.println(s + "not found"); } } public void update(){ if (trainingexample[6] == "0"); else{ int j = 0; while ( j != hyp.length){ Object[] temp = hyp[j]; if (temp[0] == trainingexample[j]); } } }
has answer: http://stackoverflow.com/a/22078188
upvote count: 1
favorite count: 0
possible better answer: http://stackoverflow.com/a/22078188
accepted answer: http://stackoverflow.com/a/22078217
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22078217
type: Question
answer count: 2
has title: Using arrays as elements of arrays
has comment: http://stackoverflow.com/comment/33482891
tagged with: arrays

http://stackoverflow.com/comment/33542501
type: AnswerComment
type: Comment
score: 0
has text: in this case it does not replace but returns contents of group 1 - expression in round brackets, try it
comment on: http://stackoverflow.com/a/22111097

http://stackoverflow.com/q/22049667
has answer: http://stackoverflow.com/a/22049795
has title: Storing things for use later?
type: UnansweredQuestion
tagged with: java
score: -4
has comment: http://stackoverflow.com/comment/33432176
upvote count: 1
tagged with: methods
has comment: http://stackoverflow.com/comment/33432149
type: Question
has answer: http://stackoverflow.com/a/22049898
downvote count: 5
tagged with: class
tagged with: interaction
answer count: 2
favorite count: 0
has body: Is there any way that I could create a class in which something entered would be stored and be able to used later? For example Coins class will construct a coin that has a name and a value. It will also have necessary accessor methods. Your Purse class (Driver class) will have some coins in it and you will print out how much money you have in the purse in a well formatted output. if not, how would I go about doing this?
has comment: http://stackoverflow.com/comment/33432143
tagged with: construct

http://stackoverflow.com/comment/33574401
comment on: http://stackoverflow.com/q/22128565
score: 0
type: Comment
type: QuestionComment
has text: Agreed with @delnan. The LSP wikipedia page may be a bit obtuse, though. *Basically*, it states subclasses should not *remove* features from superclasses, which is what your proposed design does. I suggest you consider JB Nizet's solution below.

http://stackoverflow.com/a/22021749
has body: Did you tried like this in replaceAll to remove the non-numeric and non-alphabetic characters yourString= yourString.replaceAll("[^0-9A-Za-z]","");
answers question: http://stackoverflow.com/q/22021703
score: 0
type: Answer

http://stackoverflow.com/comment/33534097
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22105795
has text: Sure, it was not supposed to fix the problem. It is a good practice to make constants `final` in java. It is because `PREF_NAME` is just the _key_ for your preference and it is not supposed to change its value. What you are looking for is the preference value for the key `PREF_NAME`

http://stackoverflow.com/a/22067171
answers question: http://stackoverflow.com/q/22066620
has comment: http://stackoverflow.com/comment/33463596
has comment: http://stackoverflow.com/comment/33465015
has comment: http://stackoverflow.com/comment/33464144
score: 18
upvote count: 18
has body: First of all take a look to this topic: The Use of Multiple JFrames, Good/Bad Practice? Note: I am not trying to theme Netbeans itself, I just want the Jframe that I create to have the windows look and feel by default so I don't have to go through the source tab and change Nimbus to Windows for every Jframe I create. What you want to change is called template: every file you can create through the New File wizard has an associated template. Having said this NetBeans gives the developers the ability to update/create default templates. Go to Tools -> Templates and look for Swing GUI Forms -> JFrame You have two options here: Open the template in the editor and modify it there. Create a duplicate template and modify this last one. I'd go with Option 2 just to keep the original template unmodified.. When you edit the template just modify this line (or watherever you want actually): Finally to create a new "custom" JFrame just find your template in Swing GUI Forms -> MyJFrameTemplate as shown below: In addition Reading @Misgevolution's comment below I think there's something to be clarified. This auto-generated main method is there just for test purposes making developers be able to "run" top-level containers. A Java application only needs one main class so this test-only main methods should be deleted when you will deploy your application. As suggested in other answers the L&amp;F should be established only once at the start-up, not in every top-level container.
has comment: http://stackoverflow.com/comment/33466965
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22066620
has comment: http://stackoverflow.com/comment/33466633
type: Answer

http://stackoverflow.com/a/22006697
type: Answer
has comment: http://stackoverflow.com/comment/33355219
upvote count: 2
score: 2
has comment: http://stackoverflow.com/comment/33355392
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22005972
has body: Here String str is static, then where this object will be stored in memory? String str is not an object, it's a reference to an object. "ABC", "XYZ" &amp; "ABCXYZ" are three distinct String objects. Thus, str points to a string. You can change what it points to, but not that which it points at. Since String is immutable, where the object for "XYZ" will be stored? As explained in above &amp; also by Mik378, "XYZ" is just a String object which gets saved in the String pool memory and the reference to this memory is returned when "XYZ" is declared or assigned to any other object. Where will be final object will be Stored? The final object, "ABCXYZ" will also get saved to the pool memory and the reference will be returned to the object when the operation is assigned to any variable. And how will garbage collection will be done? String literals are interned. As of Java 7, the HotSpot JVM puts interned Strings in the heap, not permgen. In earlier versions of Java, JVM placed interned Strings in permgen. However, Strings in permgen were garbage collected. Apparently, Class objects in permgen are also collectable, so everything in permgen is collectable, though permgen collection might not be enabled by default in some old JVMs. String literals, being interned, would be a reference held by the declaring Class object to the String object in the intern pool. So the interned literal String would only be collected if the Class object that referred to it were also collected. Shishir
answers question: http://stackoverflow.com/q/22005972

http://stackoverflow.com/comment/33363593
type: Comment
score: 0
comment on: http://stackoverflow.com/q/22010430
type: QuestionComment
has text: You'll have to define 'small'. for me 200 parallel requests is still peanuts. In any case I'd start by setting up 5-10 computers, each with a simple test application that will fire some SOAP requests at your system which you can run at exactly the same time. For the web application part you'll have to get users which will start clicking around.

http://stackoverflow.com/comment/33552679
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22116913
has text: And also refresh/clean your project, maybe Eclipse does not know your image is there.
score: 0

http://stackoverflow.com/q/22031789
answer count: 4
type: AnsweredQuestion
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33400976
has answer: http://stackoverflow.com/a/22032545
has comment: http://stackoverflow.com/comment/33400477
has comment: http://stackoverflow.com/comment/33400439
upvote count: 1
has comment: http://stackoverflow.com/comment/33417073
has body: The operation I'm hoping to perform is to go from: String "32.63578..." to: float 32.63 long 578... //where '...' is rest of string Something like the following in Python: split = str.find('.')+2 float = str[:split] long = str[split:] I'm new to Java, so I began by trying to look up equivalents, however it seems like a more convoluted solution than perhaps a regex would be? Unless there's more similar functions to python than splitting into a char array, and repeatedly iterating over?
type: Question
has comment: http://stackoverflow.com/comment/33417076
has comment: http://stackoverflow.com/comment/33401458
has answer: http://stackoverflow.com/a/22032211
has comment: http://stackoverflow.com/comment/33401261
has comment: http://stackoverflow.com/comment/33417075
has title: Java string -> two numbers
has comment: http://stackoverflow.com/comment/33400540
has comment: http://stackoverflow.com/comment/33417071
has comment: http://stackoverflow.com/comment/33400547
has comment: http://stackoverflow.com/comment/33400486
has answer: http://stackoverflow.com/a/22031900
accepted answer: http://stackoverflow.com/a/22031900
downvote count: 0
has comment: http://stackoverflow.com/comment/33401451
has comment: http://stackoverflow.com/comment/33401520
favorite count: 0
has comment: http://stackoverflow.com/comment/33417074
linked to: http://stackoverflow.com/q/14833008
has answer: http://stackoverflow.com/a/22031887
has comment: http://stackoverflow.com/comment/33417077
possible better answer: http://stackoverflow.com/a/22032211
tagged with: regex
has comment: http://stackoverflow.com/comment/33417072

http://stackoverflow.com/a/22021128
has comment: http://stackoverflow.com/comment/33407651
upvote count: 2
has comment: http://stackoverflow.com/comment/33381113
has comment: http://stackoverflow.com/comment/33381283
type: Answer
score: 2
downvote count: 0
has body: In 2013, we have enough frameworks that make database access simpler than plain JDBC. Please have a look at jOOQ for a bare-bones Active Record-like API or at Hibernate for something more complex. And if you want a taste of the future, have a look at Spring Data.
answers question: http://stackoverflow.com/q/22021069

http://stackoverflow.com/comment/33449063
type: AnswerComment
has text: did you try using the updated BufferedReader i added in the answer?
type: Comment
score: 0
comment on: http://stackoverflow.com/a/22058871

http://stackoverflow.com/q/22167082
tagged with: java
type: Question
has title: Linux Server RMI with Windows Client Connection refused
has comment: http://stackoverflow.com/comment/33647036
score: 0
tagged with: linux
has comment: http://stackoverflow.com/comment/33643100
has body: I've tried all I've read about this problem and I don't get it fixed. Because of that i will give it a chance that anyone else got the same error and nothing could fix it. A friend of me have a root Server where other Java Application over Network runs. I've opened the Port in the IPTables (1099 Registry). I start the Registry in the Server Code. I setup the System.property hostname Address of the Server to an address like 91.54.2.10 and in the other ipaddress fields. On localhost everything is fine, but not in the linux world. I've pinged the Server : OK, I've netstatted with netstat -napt | grep 1099 and the Port ist Listening my Server comes up with [Server] Listening on Port 1099 and the Client tries to connect. After a few seconds the Server pushes an Exception with Connection time out. Ive set up the /etc/hosts 127.0.1.1 localhost 127.0.0.1 localhost PublicADRESS localhost I dont know whats the matter?! Ive tryed everything could anyone understand why this wont work? http://www.fotos-hochladen.net/view/runningserveriqa4wy61x0.png Client public void generateConnection() { System.setProperty("java.security.policy", "client.java.policy"); if (System.getSecurityManager()==null) { System.setSecurityManager( new RMISecurityManager() ); } else { } try { Registry registry = LocateRegistry.getRegistry(xx.xx.xx.xx, Registry.REGISTRY_PORT); chatserver = (CServer) Naming.lookup("rmi://"+xx.xx.xx.xx+"/server"); CClientImpl client = new CClientImpl(); client.setUsername(username); chatserver.login(client); } catch (RemoteException | NotBoundException e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, "Server is not online!"); connectbutton.setEnabled(true); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public class ChatServer { public static ChatServer instance; public static ChatServer getInstance() { if(instance==null) { instance = new ChatServer(); } return instance; } public void generateNetwork() { System.set…
answer count: 0
type: UnansweredQuestion
tagged with: rmi

google-oauth
type: Tag
tags question: http://stackoverflow.com/q/22057552
tag name: google-oauth
tags question: http://stackoverflow.com/q/22048357

http://stackoverflow.com/q/22038801
score: 1
tagged with: dex2jar
favorite count: 0
upvote count: 1
type: AnsweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22038940
tagged with: dex
downvote count: 0
tagged with: jar
has body: I have made an application that converts .dex file to .jar file using the library dex2jar. the code is given as follows: import com.googlecode.dex2jar.v3.Main; { String apkPath = "D://myapk.apk" ; Main.main(apkPath); } this code block works properly and I am getting asd_dex2jar.jar file, but the problem is after executing calling the main(), the program closes automatically, so is there any way to do this any another way ??
accepted answer: http://stackoverflow.com/a/22038940
has title: Convert .dex file to .jar file using dex2jar
tagged with: android
answer count: 1

http://stackoverflow.com/q/22061725
favorite count: 0
has title: How can we invoke a Java UDF in XText Grammar?
tagged with: xtext
has answer: http://stackoverflow.com/a/22062465
accepted answer: http://stackoverflow.com/a/22062465
score: 2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33453689
type: Question
tagged with: java
has body: I am working on a DSL wherein I am supposed to call Java Functions I have written. How can they be called in XText Grammar definition rules ? Example Sample.xtext Data: 'Data'':' (objectRules += ObjectRule)+ //Call to Java Function here ; I am writng the grammar and I want to invoke Java Function to perform further processing like pasting a block of code when the Rule is encountered.
upvote count: 2
has comment: http://stackoverflow.com/comment/33456213
answer count: 1
downvote count: 0

http://stackoverflow.com/a/22158914
type: Answer
has comment: http://stackoverflow.com/comment/33647054
score: 0
has body: Scanner s = new Scanner(System.in); System.out.println("please Enter an Idintifire: " +s); You are printing the value of the scanner object you have created in the line above. try removing the s in the print statement. System.out.println("please Enter an Idintifire: "); EDIT: Scanner s = new Scanner(System.in); System.out.println("please Enter an Idintifire: "); String input = s.next(); for(int i=0;i&lt; s.length();i++){ char c = input.charAt(i); if (Character.isDigit(c)) { numeric = true; } else if (Character.isLetter(c)) { alpha = true; } else if (Character.isUnicodeIdentifierPart(c)) { underscore = true; } else { accepted = false; } } if (accepted &amp;&amp; alpha &amp;&amp; numeric &amp;&amp; underscore) { System.out.println("this is an idintifire " +input); } else { System.out.println(input+ " this not an idintifire "); }
has comment: http://stackoverflow.com/comment/33650900
answers question: http://stackoverflow.com/q/22158658

http://stackoverflow.com/q/22064094
score: 0
accepted answer: http://stackoverflow.com/a/22081758
answer count: 1
has answer: http://stackoverflow.com/a/22081758
tagged with: spring
tagged with: classloader
has title: what do I get when I call pathMatchingResourcePatternResolver.getResourceLoader().getClassloader().getResourece("")
has body: when I call pathMatchingResourcePatternResolver.getResourceLoader().getClassloader().getResourece("") I get this: Enumeration&lt;URL&gt; founds then call founds.nextElement(); , and get this /path/build/resources/main/ /path/build/classes/main/ why?
type: AnsweredQuestion
tagged with: java
type: Question

codeigniter
tags question: http://stackoverflow.com/q/22012916
type: Tag
tag name: codeigniter

http://stackoverflow.com/comment/33503658
type: Comment
comment on: http://stackoverflow.com/a/22089610
score: 1
type: AnswerComment
has text: Yes I do @Liondancer. That's what I get for staying up late and answering stackoverflow questions ;-)

http://stackoverflow.com/q/22058272
tagged with: java
has answer: http://stackoverflow.com/a/22058377
has comment: http://stackoverflow.com/comment/33447927
type: Question
upvote count: 4
answer count: 2
possible better answer: http://stackoverflow.com/a/22058377
downvote count: 0
tagged with: sorting
score: 4
has comment: http://stackoverflow.com/comment/33447827
favorite count: 0
has comment: http://stackoverflow.com/comment/33447628
has answer: http://stackoverflow.com/a/22058353
has title: Sorting arrays of objects using compareTo()
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22058353
has body: I may be making this a lot harder than it is...but my assignment was to create a showtimes class that implements Comparable. With this it constructs sort of a list of several different theatres w/ what movies are showing, with the times etc. Then I have to use the compareTo() method to sort it by first the cinema that it's showing in, and by the movie title. I have the following code...the confusion comes when I'm trying to output the sorted results. I have it to where it will output the - or + number from comparing the strings. public class ShowTimeTest { public static void main(String[] args) { ShowTime[] movieTimes= new ShowTime[20]; // TODO Auto-generated method stub //****************************************************** //Instantiates 20 showtime objects //****************************************************** ShowTime cinemark1 = new ShowTime("Cinemark", "Lorde", "Friday @ 3:30", "Saturday @ 7:00", "Sunday @ 6:00","R", 1, 2); ShowTime cinemark2 = new ShowTime("Amstar Cinemas", "Star Wars", "Thursday @ 12:00AM", "Monday @ 4:00PM", "Sunday @ 3:45PM","R", 1, 2); ShowTime cinemark3 = new ShowTime("Fayette Movies", "Pokemon", "Friday @ 3:30", "Saturday @ 7:00", "Sunday @ 6:00","R", 1, 2); ShowTime cinemark4 = new ShowTime("Dollar Theatre", "Reincarnated", "Friday @ 3:30", "Saturday @ 7:00", "Sunday @ 6:00","R", 1, 2); ShowTime cinemark5 = new ShowTime("Rad Chads Cinemas", "Lorde", "Friday @ 3:30", "Saturday @ 7:00", "Sunday @ 6:00","R", 1, 2); movieTimes[0] = cinemark1; movieTimes[1] = cinemark2; movieTimes[2] = cinemark3; movieTimes[3] = cinemark4; movieTimes[4] = cinemark5; for(int i = 1; i &lt; 5; i ++){ System.out.println(movieTimes[i].compareTo(movieTimes[i-1])); } } } contd... public class ShowTime implements Comparable&lt;ShowTime&gt;{ public String name, title, rating, showTime1, showTime2, showTime3; public double ticket, adultTicket; public String[] times = new String[3]; public ShowTime(String theatreName, String movieTitle, String showTime1, String sh…
has comment: http://stackoverflow.com/comment/33447555

http://stackoverflow.com/q/22132044
tagged with: md5
accepted answer: http://stackoverflow.com/a/22132127
type: AnsweredQuestion
tagged with: java
tagged with: file
has title: Java checksum md5 on a file situated on a FTP server
has answer: http://stackoverflow.com/a/22132127
type: Question
has comment: http://stackoverflow.com/comment/33582290
has comment: http://stackoverflow.com/comment/33580685
score: 0
has body: I got a program which needs to compare a file that situated on the Local disk and one on a FTP server. I've decided to go with md5 checksum. I am able to do it with the local file, but I am having problems with the ftp one. Also, I am using Apache FTPClient common. MessageDigest digest = MessageDigest.getInstance("MD5"); FileInputStream is = new FileInputStream(FTP_listFiles[i]); //ERROR HERE //FTP_files is a FTPFile from FTPClient apache commons. byte[] buffer = new byte[8192]; int read = 0; try { while( (read = is.read(buffer)) &gt; 0) { digest.update(buffer, 0, read); } byte[] md5sum = digest.digest(); BigInteger bigInt = new BigInteger(1, md5sum); String output = bigInt.toString(16); System.out.println("MD5: \n" + output); } catch(IOException e) { throw new RuntimeException("Unable to process file for MD5", e); } finally { try { is.close(); } catch(IOException e) { throw new RuntimeException("Unable to close input stream for MD5 calculation", e); } } NB: If impossible, do you know any equivilant to md5 but can do the same?
answer count: 1
tagged with: ftp

http://stackoverflow.com/comment/110404524
type: Comment
type: QuestionComment
has text: Refer to : https://community.jboss.org/wiki/HttpSessionTimeout The HttpSession timeout in JBoss can be set at three different levels: web.xml 30 Your message doesn't really give much more information :\
comment on: http://stackoverflow.com/q/22116128
score: 0

http://stackoverflow.com/comment/33635683
comment on: http://stackoverflow.com/q/22163326
has text: You can't do this the way you are now, the font is applied to the entire text
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33497069
type: Comment
has text: What do you mean by "it does not work. It does compile and runs without a problem". What is it doing wrong?
comment on: http://stackoverflow.com/q/22085935
score: 0
type: QuestionComment

http://stackoverflow.com/comment/33600162
score: 0
type: Comment
has text: The answer that you have accepted in your question works fine, just i guess the use of libraries is improper, include [org-json jar](https://code.google.com/p/org-json-java/downloads/detail?name=org.json-20120521.jar&can=2&q=) and then try.
type: QuestionComment
comment on: http://stackoverflow.com/q/22143093

http://stackoverflow.com/a/22138367
has body: You need to pass something jersey-related into ServletHandler, usually org.glassfish.jersey.servlet.ServletContainer: org.glassfish.jersey.server.ResourceConfig resourceConfig = ... org.glassfish.jersey.servlet.ServletContainer servletContainer = new ServletContainer( resourceConfig ); org.eclipse.jetty.servlet.ServletHolder servletHolder = new ServletHolder( servletContainer ); org.eclipse.jetty.servlet.ServletHandler handler = new ServletHandler(); handler.addServlet( servletHolder ); org.eclipse.jetty.server.Server server = new Server( 8080 ); server.setHandler( handler ); ResourceConfig provides a number of constructors and static factories that will allow you to create a ResourceConfig instance eother from an JAX-RS Application or by symply specifying a set of packages to scan for JAX-RS components.
has comment: http://stackoverflow.com/comment/33595307
score: 0
answers question: http://stackoverflow.com/q/22137920
type: Answer
has comment: http://stackoverflow.com/comment/33599700

http://stackoverflow.com/q/22120814
tagged with: android
score: -1
answer count: 1
downvote count: 1
tagged with: gwt
tagged with: java
type: UnansweredQuestion
has title: GWT compilation failed - Error - Java ADT
has answer: http://stackoverflow.com/a/22121979
upvote count: 0
has body: When ever I try to Compile The code to HTML I get the error: GWT compilatiopn failed! here ist the what ever it is.. http://hastebin.com/latexumowi.rb
favorite count: 0
type: Question

http://stackoverflow.com/comment/33382994
type: AnswerComment
has text: Yes, My TabSongsActivity is calling NowPlayingActivity. TabSongsActivity is the list of songs, NowPlayingActivity is the player that receives the OnItemClick from TabSongs.
score: 0
comment on: http://stackoverflow.com/a/22021743
type: Comment

http://stackoverflow.com/q/22100991
tagged with: maven
has body: I'm adding on a executable jar test to my maven project. I've edited my pom file to use a main class in src/main/resources. However when I try to run the jar it cannot find my main class. Any thoughts?
has comment: http://stackoverflow.com/comment/33523793
has answer: http://stackoverflow.com/a/42013319
score: 2
has comment: http://stackoverflow.com/comment/33532546
upvote count: 2
tagged with: java
type: Question
tagged with: testing
has comment: http://stackoverflow.com/comment/33523809
tagged with: jar
has comment: http://stackoverflow.com/comment/71201808
answer count: 2
downvote count: 0
has title: Maven Jar main class in src/main/resources
favorite count: 0
has answer: http://stackoverflow.com/a/22103882
type: UnansweredQuestion

http://stackoverflow.com/a/22120726
has comment: http://stackoverflow.com/comment/33559839
has comment: http://stackoverflow.com/comment/33559923
type: Answer
score: 4
answers question: http://stackoverflow.com/q/22120698
has body: You should almost never use a KeyListener on a JTextArea or other JTextComponent. For this, I'd use a DocumentFilter which allows you to update the Document before the user's input has been sent to it. e.g., import javax.swing.*; import javax.swing.text.*; public class DocFilterEg { public static void main(String[] args) { JTextArea textArea = new JTextArea(10, 20); PlainDocument doc = (PlainDocument) textArea.getDocument(); doc.setDocumentFilter(new DocumentFilter() { @Override public void insertString(FilterBypass fb, int offset, String text, AttributeSet attr) throws BadLocationException { text = checkTextForParenthesis(text); super.insertString(fb, offset, text, attr); } @Override public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException { text = checkTextForParenthesis(text); super.replace(fb, offset, length, text, attrs); } private String checkTextForParenthesis(String text) { if (text.contains("{") &amp;&amp; !text.contains("}")) { int index = text.indexOf("{") + 1; text = text.substring(0, index) + "}" + text.substring(index); } return text; } }); JOptionPane.showMessageDialog(null, new JScrollPane(textArea)); } }
has comment: http://stackoverflow.com/comment/33559862
has comment: http://stackoverflow.com/comment/33559925
upvote count: 4
downvote count: 0

http://stackoverflow.com/comment/33571280
type: Comment
has text: Thanks, this looks like something that I can use
comment on: http://stackoverflow.com/a/22114976
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33590990
has text: @tonga: The question is about passing or assigning Java's references vs. C++'s pointers to objects. They are the same. What part of this do you disagree with? Pointers to pointers in C++ is irrelevant. Just because C++ has additional unrelated stuff (taking address of something) Java doesn't have doesn't mean the equivalence between something in Java and something in C++ doesn't hold.
type: Comment
comment on: http://stackoverflow.com/q/22109223
type: QuestionComment
score: 0

http://stackoverflow.com/comment/33607927
type: Comment
has text: jackyesind, you can't update using sql loader, did you read my reply?
comment on: http://stackoverflow.com/a/22146150
type: AnswerComment
score: 0

http://stackoverflow.com/q/22069423
has answer: http://stackoverflow.com/a/22094522
has title: Why this extra padding of the value field in class jsr166e.Striped64.Cell?
downvote count: 0
has body: In a class introduced as part of the JSR166, the author uses so called padding to pad the single value field of the Striped64.Cell class. Here is an excerpt of that class: /** * Padded variant of AtomicLong supporting only raw accesses plus CAS. The value field is placed * between pads, hoping that the JVM doesn't reorder them. * &lt;p/&gt; * JVM intrinsics note: It would be possible to use a release-only form of CAS here, if it were * provided. */ static final class Cell { volatile long p0, p1, p2, p3, p4, p5, p6; volatile long value; volatile long q0, q1, q2, q3, q4, q5, q6; ... The author then uses CAS to modify the value atomically. In the Striped64 class, the author also uses Unsafe to access two other fields but does not apply any of such padding. My question is: Why would one need to do such a thing, introduce 14 redundant fields for padding off a single value field?
tagged with: jvm
favorite count: 0
possible better answer: http://stackoverflow.com/a/22094522
has answer: http://stackoverflow.com/a/22069678
upvote count: 6
type: AnsweredQuestion
score: 6
type: Question
accepted answer: http://stackoverflow.com/a/22069678
tagged with: java
tagged with: concurrency
answer count: 2

http://stackoverflow.com/q/22083104
answer count: 2
upvote count: 0
has comment: http://stackoverflow.com/comment/33492199
favorite count: 0
has comment: http://stackoverflow.com/comment/33492120
has comment: http://stackoverflow.com/comment/33492208
accepted answer: http://stackoverflow.com/a/22083179
tagged with: dictionary
has body: I want to convert a HashMap&lt;Character, Integer&gt; into a TreeMap&lt;Integer, ArrayList&lt;Character&gt;&gt; in an efficient manner, but I'm having trouble conceptualizing it. Anything I might try?
type: AnsweredQuestion
tagged with: list
tagged with: java
downvote count: 1
type: Question
tagged with: algorithm
has title: Efficiently converting maps?
score: -1
possible better answer: http://stackoverflow.com/a/22084077
has answer: http://stackoverflow.com/a/22083179
has answer: http://stackoverflow.com/a/22084077
has comment: http://stackoverflow.com/comment/33492129

http://stackoverflow.com/a/22117791
score: 1
has comment: http://stackoverflow.com/comment/33576326
downvote count: 0
has body: void SomeRandomCall&lt;T extends SomeClass&gt;( T t ) is compiled as if it was void SomeRandomCall( Someclass t ) And that's why EnclosingClass.&lt;ClassB&gt;SomeRandomCall( new ClassB() ); will result in A because ClassB as compile time type is no longer visible inside the method. This is also visible if you look at the class (Main in below example) via javap -c -s (i.e. decompiled) static &lt;T extends Main$A&gt; void SomeRandomCall(T); Signature: (LMain$A;)V Code: 0: aload_0 1: invokestatic #18 // Method Main$Runner.Run:(LMain$A;)V 4: return It's signature is void SomeRandomCall( A ) and it will always call Run( A ). See also Overloading in Java and multiple dispatch why the compile time type matters with overloaded methods. public static class Runner{ public static void Run( A a ){System.out.println("A");}; public static void Run( B b ){System.out.println("B");}; public static void Run( C c ){System.out.println("C");}; } public static void main(String[] args) { B b = new B(); Runner.Run(b); A a = b; Runner.Run(a); } The compiler will only choose the correct overloaded method if it can. E.g. above will decompile to public static void main(java.lang.String[]); Signature: ([Ljava/lang/String;)V Code: 0: new #29 // class Main$B 3: dup 4: invokespecial #31 // Method Main$B."&lt;init&gt;":()V 7: astore_1 8: aload_1 9: invokestatic #32 // Method Main$Runner.Run:(LMain$B;)V 12: aload_1 13: astore_2 14: aload_2 15: invokestatic #18 // Method Main$Runner.Run:(LMain$A;)V 18: return Every call to Run will use a different overloaded version (identified by the number after invokestatic)
has comment: http://stackoverflow.com/comment/33615454
answers question: http://stackoverflow.com/q/22116010
has comment: http://stackoverflow.com/comment/33585874
type: Answer
upvote count: 1

http://stackoverflow.com/comment/33692114
score: 2
has text: Additionally can say that the second method is just not a "way of instantiating new object". It is specific to Java, i.e. you can't do this in `C#`.
comment on: http://stackoverflow.com/q/22164036
type: QuestionComment
type: Comment

http://stackoverflow.com/q/22167776
has comment: http://stackoverflow.com/comment/33643689
has comment: http://stackoverflow.com/comment/33644372
has comment: http://stackoverflow.com/comment/33643613
tagged with: java
type: Question
has title: Execute task on shutdown executor service - no exception?
has body: any ideas why default java.util.concurrent.ThreadPoolExecutor doesnt throw any exception if I try to execute task on executor service which is shutdown? ( executorService.shutdown() was called before ) Yes, my rejection handler is invoked but still task is not run because: if (!e.isShutdown()) { r.run(); } I wonder if not throwing any exception is behaviour by design or a glitch... Its just misleading when it silently fails. //forgot to mention - its java 6 in this case
score: 0
tagged with: executorservice
answer count: 0
type: UnansweredQuestion

http://stackoverflow.com/comment/33479048
score: 1
type: AnswerComment
has text: @solvator that's false and I don't know where you get that idea.
type: Comment
comment on: http://stackoverflow.com/a/22076135

http://stackoverflow.com/comment/59979845
score: 0
type: Comment
has text: Thanks for the Shade suggestion, this worked for me in create a executable .jar with Spring dependencies.
comment on: http://stackoverflow.com/a/22097164
type: AnswerComment

http://stackoverflow.com/q/22134881
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22134904
tagged with: java
has comment: http://stackoverflow.com/comment/33585932
has body: So I tracked down the bugger, but I am no closer to understanding what is wrong. Here is what the compiler says: Exception in thread "main" java.lang.NullPointerException at BasicFile.Search(BasicFile.java:215) at TestFile.main(TestFile.java:42) Line 215 is the one that starts with while, first one. String Search(String key) throws IOException { int lines = 0; String line = ""; String foundAt = ""; BufferedReader BF = new BufferedReader(new FileReader(f)); try { while ((line = BF.readLine().toLowerCase()) != null) { lines++; //create tokenizer words with what is in line StringTokenizer words = new StringTokenizer(line); while(words.hasMoreTokens()) { //while words has tokens left //go to next token and compare to key if (words.nextToken().equals(key.toLowerCase())) foundAt = foundAt + "\n" + lines + ":" + line; //do nothing continue loop } } BF.close(); } catch(FileNotFoundException e) { } return foundAt; }
type: Question
has title: nullpointer exception at a search method in Java
has answer: http://stackoverflow.com/a/22135079
possible better answer: http://stackoverflow.com/a/22134902
has comment: http://stackoverflow.com/comment/33585753
score: 0
has comment: http://stackoverflow.com/comment/33585736
tagged with: nullpointerexception
accepted answer: http://stackoverflow.com/a/22134904
has answer: http://stackoverflow.com/a/22134921
has comment: http://stackoverflow.com/comment/33585922
has answer: http://stackoverflow.com/a/22134902

http://stackoverflow.com/comment/33367453
type: QuestionComment
comment on: http://stackoverflow.com/q/22011757
has text: @JBNizet I have noticed that adding sessionFactory.getCurrentSession().flush(); sessionFactory.getCurrentSession().clear(); before productService.getProduct(product1.getProductId()); in the unit test helped me a lot, but now I am wondering why hibernate has this strange behaviour with junit?
score: 0
type: Comment

http://stackoverflow.com/q/22129439
tagged with: java
has body: When I run this code, it prints out only the groups found in the first pattern it matched per line. However, there are multiple strings I want to replace in each line and I want it to print out the specific groups for each string in the pattern it matched. How can I change it so that it prints out the groups specific to the patterns/strings it found in each line instead of printing only the groups in the first pattern match it found? import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.io.FileNotFoundException; import java.io.File; public class RealReadFile { private static final String fileName = "KLSadd.tex"; private Scanner myFile = null; // No-args constructor, create a new scanner for the specific file defined // above public RealReadFile() throws FileNotFoundException { if (myFile == null) myFile = new Scanner(new File(fileName)); } // One-arg constructor - the name of the file to open public RealReadFile(String name) throws FileNotFoundException { if (myFile != null) myFile.close(); myFile = new Scanner(new File(name)); } public boolean endOfFile() { // Return true is there is no more input return !myFile.hasNext(); // hasNext() returns true if there is more input, so I negate it } public String nextLine() { return myFile.nextLine().trim(); } public static void main(String[] args) throws FileNotFoundException { RealReadFile file = new RealReadFile(); while(!file.endOfFile()) { String line = file.nextLine(); Pattern cpochhammer = Pattern.compile("(\\(([^\\)]+)\\)_\\{?([^\\}]+)\\}?)"); Matcher pochhammer = cpochhammer.matcher(line); while (pochhammer.find()){ System.out.println(line); String line2=pochhammer.replaceAll("\\\\pochhammer{" + pochhammer.group(2) + "}{" + pochhammer.group(3) + "}"); System.out.println(line2); } } } }
type: Question
linked to: http://stackoverflow.com/q/5319840
has answer: http://stackoverflow.com/a/22129594
accepted answer: http://stackoverflow.com/a/22129594
score: 0
answer count: 1
has title: Java Pattern Matching with Groups
tagged with: pattern-matching
tagged with: regex-group
tagged with: regex
type: AnsweredQuestion

http://stackoverflow.com/comment/33611205
comment on: http://stackoverflow.com/q/22145590
has text: Class or packages naming, and I don't mean conventions, sometimes is really cumbersome. On one hand names should be short, on the other hand they should be descriptive. It's not easy task to accomplish both. However maybe you should consider, if you really need to have this long `search_result_list` instead of just `result`. Try to pick just most important noun. You actually know, what are these classes for.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33410386
type: QuestionComment
comment on: http://stackoverflow.com/q/22037736
score: 7
has text: how can int be null
type: Comment

http://stackoverflow.com/comment/33527555
type: QuestionComment
has text: You should include any and all errors to help us help you debug this.
comment on: http://stackoverflow.com/q/22102881
score: 0
type: Comment

http://stackoverflow.com/q/22162967
tagged with: swing
tagged with: java
tagged with: nattable
upvote count: 1
tagged with: eclipse
answer count: 1
has title: How to install and use NatTable?
has answer: http://stackoverflow.com/a/24882244
accepted answer: http://stackoverflow.com/a/24882244
type: AnsweredQuestion
has body: I have developed some web applications before and everything is well documented and there is a framework for anything. I am new to Swing and desktop application development and I found that documentation is sparse and you have to figure out a lot of things by experimenting. I've been googling for a few hours on how to setup NatTable and I couldn't find anything. I was surprised no one asked the question before. I just want some instructions on how to get the basics working on Eclipse and NetBeans. I was using Eclipse in the past but I think I will use NetBeans for this project as the Swing GUI editor is better. Is NatTable exclusive to Eclipse or will it also work with NetBeans? If someone can post screenshots of the setup procedure, that would be awesome. Any help is appreciated. Thanks in advance.
downvote count: 0
score: 1
favorite count: 0
tagged with: netbeans
type: Question
has comment: http://stackoverflow.com/comment/33635061

http://stackoverflow.com/q/22039621
has title: Java wait for all threads before terminating
favorite count: 0
has body: I am trying to test an application with Jmeter. The application uses a proprietary library that creates multiple threads. In JMeter I have created a AbstractJavaSamplerClient, which does not seem to wait for all the other threads that might be generated in the application. Instead it just runs its own default method and closes leaving the other threads running in the background - since I am connecting to a server in the application, I can see through the server logs that it is still connected. Since I don't have the references to the other threads as they are instantiated through the proprietary library, I can't use the common solutions of wait() or join().How can I get the main thread to wait for all the threads (none of which I have references too)?
tagged with: jmeter
tagged with: multithreading
upvote count: 1
type: AnsweredQuestion
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22039886
type: Question
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/22040243
accepted answer: http://stackoverflow.com/a/22040243
tagged with: load-testing
possible better answer: http://stackoverflow.com/a/22039886

http://stackoverflow.com/q/22007696
has body: I've the below code. import java.io.File; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Scanner; public class Scalar { public static void main(String args[]) throws Exception { Scanner sc=new Scanner(new File("D:/GC/Scalar/A-small.in")); int testcases=Integer.parseInt(sc.next()); System.out.println(testcases); ArrayList&lt;BigInteger&gt; a=new ArrayList&lt;BigInteger&gt;(); ArrayList&lt;BigInteger&gt; b=new ArrayList&lt;BigInteger&gt;(); for(int j=0;j&lt;2;j++){ int size=Integer.parseInt(sc.next()); System.out.println(size); for(int i=0;i&lt;size;i++) { a.add(sc.nextBigInteger()); } for(int i=0;i&lt;size;i++) { b.add(sc.nextBigInteger()); } Collections.sort(a); System.out.println(a.size()); System.out.println(a); Collections.sort(b,Collections.reverseOrder()); System.out.println(b); BigInteger sum; for(int i=0;i&lt;a.size();i++){ sum=a.get(i).multiply(b.get(i)); sum=sum.add(sum); } } } } and the below content in a text file. 1000 3 1 -5 3 -2 1 4 5 5 4 3 1 2 1 1 0 1 0 7 677 463 -569 516 401 -998 882 890 588 959 909 948 -617 -655 8 -912 937 167 366 -222 -397 190 -216 354 Here i'm trying to sort the first array and the second in reverse order and then do sum and product, here i took only 2 cases and the 1000 in above input is total number of test cases, and the single number lines denote the array size, and in my program to be sure that the size of the array matches the size given, i'm printing the size, here in the first case, the input is of size 3 and i get it correct but in the second case the input is of size 5 but i'm getting it 8 as size of array, and below is the output that i get. 1000 3 3 [-5, 1, 3] [4, 1, -2] 5 8 [-5, 1, 1, 2, 3, 3, 4, 5] [4, 1, 1, 1, 1, 0, 0, -2] please let me know where am i going wrong. Thanks
has title: size is not compared when input taken from a text file
type: Question
accepted answer: http://stackoverflow.com/a/22007847
tagged with: arraylist
score: 0
has answer: http://stackoverflow.com/a/22007847
answer count: 1
tagged with: arrays
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/comment/33608300
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22148089
has text: Hope it is work: http://stackoverflow.com/questions/9222495/i-need-to-fill-text-field-programatically-in-a-web-page-opened-inside-a-webview
score: 0

http://stackoverflow.com/q/22030630
has body: I am getting this error " Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: null Stroke" while executing the code in jsp. The jsp is working fine in another project but when I use it in my project , it is receiving this error. the jsp code is: &lt;%@ page language="java" import="java.util.*,java.sql.*,com.ibm.database.*,org.jfree.*" pageEncoding="ISO-8859-1"%&gt; &lt;%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %&gt; &lt;%@ page import="java.awt.*"%&gt; &lt;%@ page import="java.sql.Connection"%&gt; &lt;%@ page import="java.sql.PreparedStatement"%&gt; &lt;%@ page import="java.sql.ResultSet"%&gt; &lt;%@ page import="org.jfree.chart.ChartFactory"%&gt; &lt;%@ page import="org.jfree.chart.ChartFrame"%&gt; &lt;%@ page import="org.jfree.chart.JFreeChart"%&gt; &lt;%@ page import="org.jfree.chart.plot.PlotOrientation"%&gt; &lt;%@ page import="org.jfree.data.category.DefaultCategoryDataset"%&gt; &lt;%@ page import="org.jfree.chart.plot.CategoryPlot"%&gt; &lt;% String pc="SP120";//request.getParameter("pc"); String sc="SC14";//request.getParameter("sc"); BarChart lc= new BarChart(pc,sc); response.sendRedirect("ViewMIS.jsp"); %&gt; &lt;%! public class BarChart { public BarChart(String pc,String sc) { String title; title="Deviation between Forecasted and Actual Demand for Part "+pc+" of Service Centre "+sc; final DefaultCategoryDataset dataset = createDataset(pc,sc); final JFreeChart chart1 = createChart(dataset,title); ChartFrame frame = new ChartFrame("BarChart", chart1); frame.setSize(500,500); frame.setVisible(true); } private DefaultCategoryDataset createDataset(String pc,String sc) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); int i,j,k; try { Connection con=DbConnection.getMyConnection(); PreparedStatement st=con.prepareStatement("select * from FDATA WHERE PARTCODE=? AND SERVICECENTREID=?"); st.setString(1,pc); st.setString(2,sc)…
has comment: http://stackoverflow.com/comment/33401401
type: UnansweredQuestion
answer count: 0
has title: Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: null Stroke in my Project
tagged with: java
tagged with: multithreading
has comment: http://stackoverflow.com/comment/33398453
tagged with: swing
tagged with: jfreechart
type: Question
has comment: http://stackoverflow.com/comment/33402571
score: 0
has comment: http://stackoverflow.com/comment/33401447
has comment: http://stackoverflow.com/comment/33401472
tagged with: jsp

http://stackoverflow.com/comment/33366594
has text: It's useless : a isnt' available after the switch.
type: Comment
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/22013408

http://stackoverflow.com/q/22162797
tagged with: java
has body: I am very new to programming and I have to write a method and program for the following; public static String repeat(String str, int n) that returns the string repeated n times. Example ("ho", 3) returns "hohoho" Here is my program so far: public static void main(String[] args) { // **METHOD** // Scanner in = new Scanner(System.in); System.out.println("Enter a string"); String str = in.nextLine(); System.out.println(repeat (str));//Having trouble with this line } // **TEST PROGRAM**// public static String repeat(String str, int n) { if (n &lt;= 0) { return ""//Having trouble with this line } else if (n % 2 == 0) { return repeat(str+str, n/2); } else { return str + repeat(str+str, n/2); } } } I made some changes to my code, but it still is not working public static void main(String[] args) { // **METHOD** // Scanner in = new Scanner(System.in); System.out.println("Enter a string"); String str = in.nextLine(); int n = in.nextInt(); System.out.println(repeat(str,n)); } // **TEST PROGRAM**// public static String repeat(String str, int n) { if (n &lt;= 0) { return ""; } else if (n % 2 == 0) { return repeat(str+str, n/2); } else { return str + repeat(str+str, n/2); } } }
type: Question
has comment: http://stackoverflow.com/comment/33634817
has comment: http://stackoverflow.com/comment/33634842
score: -1
has title: Repeating a string
has comment: http://stackoverflow.com/comment/33634812
has comment: http://stackoverflow.com/comment/33634829
downvote count: 1
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/22162822
has answer: http://stackoverflow.com/a/22162865
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22162827
has answer: http://stackoverflow.com/a/22162847
upvote count: 0
has comment: http://stackoverflow.com/comment/33634857

http://stackoverflow.com/comment/33910131
has text: That's great. So with me it generated a build directory and the jar was put in the build/libs directory.
comment on: http://stackoverflow.com/a/22289632
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/22157227
possible better answer: http://stackoverflow.com/a/22183125
has comment: http://stackoverflow.com/comment/33625271
has answer: http://stackoverflow.com/a/22183125
has comment: http://stackoverflow.com/comment/33625137
type: AnsweredQuestion
downvote count: 0
has title: HQL and checking if object is null or object field have specific value
has body: I have problem with executing following query: from Customer c where c.connectedUserID = 1 and (c.connectedFinancialAnalyst is null or c.connectedFinancialAnalyst.completed = false) object c.connectedFinancialAnalyst can be null. What I need is to find Customers that dont have financial analyst or property in financial analyst has specific value. Edit: completed property is boolean in postgres and in java Output generated by Hibernate select customer0_.id as id1_0_, customer0_.birthDate as birthDat2_0_, customer0_.birthPlace as birthPla3_0_, customer0_.city as city4_0_, customer0_.email as email5_0_, customer0_.fatherName as fatherNa6_0_, customer0_.motherName as motherNa7_0_, customer0_.name as name8_0_, customer0_.pesel as pesel9_0_, customer0_.phoneNumber as phoneNu10_0_, customer0_.postalCode as postalC11_0_, customer0_.secondName as secondN12_0_, customer0_.sex as sex13_0_, customer0_.street as street14_0_, customer0_.surname as surname15_0_, customer0_.connectedFinancialAnalyst_id as connect17_0_, customer0_.connectedUserID as connect16_0_ from Customer customer0_ cross join FinancialAnalyst financiala1_ where customer0_.connectedFinancialAnalyst_id=financiala1_.id and customer0_.connectedUserID=1 and ( customer0_.connectedFinancialAnalyst_id is null or financiala1_.completed='false' )
type: Question
score: 1
tagged with: java
tagged with: hibernate
has comment: http://stackoverflow.com/comment/33625184
tagged with: hql
has comment: http://stackoverflow.com/comment/33625367
answer count: 2
has answer: http://stackoverflow.com/a/22157739
tagged with: sql
upvote count: 1
accepted answer: http://stackoverflow.com/a/22157739
favorite count: 0

glyph
type: Tag
tag name: glyph
tags question: http://stackoverflow.com/q/22075924

http://stackoverflow.com/comment/33519756
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22079024
has text: The data queue objects in IBM i have been around since 1982, with the introduction of the System/38, a system way ahead of it's time.

http://stackoverflow.com/a/22102084
downvote count: 0
has comment: http://stackoverflow.com/comment/33526078
type: Answer
answers question: http://stackoverflow.com/q/22101923
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/33526259
has comment: http://stackoverflow.com/comment/33526424
has body: Put them all into HashSet instead of list and check the return value of add() method. HashSet&lt;Word&gt; wordSet = new HashSet&lt;&gt;(); for(int i = 0; i &lt; word.size(); i++) { if(!wordSet.add(word.get(i)){ //Found duplicate } } Note that you can also do it during/instead of creation of the list of the words.

http://stackoverflow.com/comment/33506697
has text: you will get force close as you are not findViewById by your dialog's view. You Just have to set inflater.inflate(R.layout.addalbumsdialog, null) before findViewById of button b1.
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/22091326

http://stackoverflow.com/q/22154613
tagged with: java
accepted answer: http://stackoverflow.com/a/22154712
type: Question
answer count: 2
tagged with: arrays
possible better answer: http://stackoverflow.com/a/22154738
has answer: http://stackoverflow.com/a/22154738
has comment: http://stackoverflow.com/comment/33620169
has comment: http://stackoverflow.com/comment/33622227
downvote count: 0
tagged with: string
has title: String manupilation
favorite count: 0
has answer: http://stackoverflow.com/a/22154712
tagged with: android
upvote count: 1
has body: Here I am reading a string by opening my database and then trying to plot a graph based on that.I will really appreciate if anyone could help me solve this.Thanks Method from MyDatabase which I am reading; public String getData() { // TODO Auto-generated method stub String[] columns = new String[]{KEY_SYSTOLIC,KEY_DIASTOLIC,KEY_PULSE}; Cursor c = ourDatabase.query(DATABASE_TABLE, columns, null, null, null, null, null); String result =" "; int iSys = c.getColumnIndex(KEY_SYSTOLIC); for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){ result = result + c.getString(iSys) + ","; } return result; // The string from the database looks like "1,2,3,4,5"; MyDatabase myDb = new MyDatabase(this); myDb.open(); String pull = myDb.getData(); pull = pull.substring(0, pull.length() - 1); myDb.close(); String test = '"' + pull + '"'; String[] items = test.split(","); int[] results = new int[items.length]; for (int i = 0; i &lt; items.length; i++) { try { results[i] = Integer.parseInt(items[i]); } catch (NumberFormatException nfe) {}; } // doesn't plots a graph on int[] results. int[] yAxis = new int[]{11,12,13}; TimeSeries series = new TimeSeries("X-Axis"); for(int s=0; s&lt; results.length; s++){ series.add(results[s], yAxis[s]); } XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); dataset.addSeries(series); XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer(); XYSeriesRenderer renderer = new XYSeriesRenderer(); mRenderer.addSeriesRenderer(renderer); LinearLayout chart_container=(LinearLayout)findViewById(R.id.Chart_layout); mChart=(GraphicalView)ChartFactory.getLineChartView(getBaseContext(), dataset, mRenderer); chart_container.addView(mChart); }
type: AnsweredQuestion
score: 1

http://stackoverflow.com/a/22035534
has comment: http://stackoverflow.com/comment/33407838
answers question: http://stackoverflow.com/q/22035337
has comment: http://stackoverflow.com/comment/33406715
has comment: http://stackoverflow.com/comment/33407615
accepted answer of: http://stackoverflow.com/q/22035337
has comment: http://stackoverflow.com/comment/33407717
has comment: http://stackoverflow.com/comment/33407746
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33407639
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33407829
has comment: http://stackoverflow.com/comment/33407516
has comment: http://stackoverflow.com/comment/33406910
upvote count: 1
has body: as this code en.getValue().compareTo(max2.getValue()) &lt;= max1.getValue()) will always be true when max2 is less than max1's value I think what you want is if (max2 == null || en.getValue().compareTo(max2.getValue()) &gt; 0 &amp;&amp; en.getValue().compareTo(max1.getValue() &lt; 0)) { max2 = en; } The above will return the second highest values.
has comment: http://stackoverflow.com/comment/33407248
type: Answer
has comment: http://stackoverflow.com/comment/33407089

http://stackoverflow.com/a/22195932
upvote count: 9
has body: the problem is the fieldname count; it is a reserved word and should be quoted. Expected OPEN means HQL parser is expecting count(&lt;expression&gt;) SQL expression and not count = .... The only solution is to alias User and force dotted fieldname as: update User u set u.count = (u.count + ?) where id = ?
answers question: http://stackoverflow.com/q/22142224
downvote count: 0
score: 9
type: Answer

http://stackoverflow.com/comment/33583570
type: QuestionComment
has text: @blgt: Then it won't be a valid `main()` method: http://stackoverflow.com/a/13603500/367273
score: 3
comment on: http://stackoverflow.com/q/22133590
type: Comment

http://stackoverflow.com/q/22048511
has comment: http://stackoverflow.com/comment/33434523
answer count: 1
downvote count: 0
tagged with: spring-security
favorite count: 0
has comment: http://stackoverflow.com/comment/33453617
tagged with: rest
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33505241
tagged with: spring
has body: I have Spring application with REST API using Spring-Security. The issue is that some POST functions sometimes work fine by returning 200 OK and then start giving me "405 Method Not Allowed" responses. This is very weird since after I do the Digest authentication the first couple of calls go fine (200 OK) and then the rest return 405. Here is my configuration: The controller @Controller @RequestMapping("/restapi") public class RestApiController { private final static Logger logger = LoggerFactory.getLogger(ProviderApiController.class); private Settings settings; @RequestMapping(value = "/postmethod", method = RequestMethod.POST, consumes = MediaType.ALL_VALUE) @ResponseBody public String postmethod() { return "OK"; } } web.xml <?xml version="1.0" encoding="UTF-8"?> contextConfigLocation /WEB-INF/application-context.xml org.springframework.web.context.ContextLoaderListener dispatcherServlet org.springframework.web.servlet.DispatcherServlet contextConfigLocation /WEB-INF/web-context.xml 1 dispatcherServlet / springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy springSecurityFilterChain /* 10 true true 401 /error/401 404 /error/404 500 /error/500 web-context.xml <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:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:security="http://www.springframework.org/schema/security" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd …
has comment: http://stackoverflow.com/comment/33468952
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/33471769
type: Question
has title: 405 Method Not Allowed for HTTP POST in Spring 3.1
tagged with: java
has comment: http://stackoverflow.com/comment/33505301
has comment: http://stackoverflow.com/comment/33489230
has comment: http://stackoverflow.com/comment/33433131
has answer: http://stackoverflow.com/a/25230315
has comment: http://stackoverflow.com/comment/34012406

http://stackoverflow.com/comment/33509404
type: Comment
has text: why not, change "Empty" to "Button" + index
comment on: http://stackoverflow.com/a/22093193
score: 0
type: AnswerComment

http://stackoverflow.com/a/22092126
accepted answer of: http://stackoverflow.com/q/22091083
has comment: http://stackoverflow.com/comment/33507691
has body: To create a tree with multiple levels you need to add new children to the children of other nodes. You are trying to do that using the toReadList. However, when adding nodes to that list you are not actually taking the node you added to the tree, but a newly created node. You are creating new trees (which you later just discard) to which you are adding all the new nodes. They thus never end up in the tree with top as root. Replacing toReadList.add(new DefaultMutableTreeNode(toWrite)); by toReadList.add(toTree); fixes that.
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/22091083
score: 2
upvote count: 2

getter-setter
tags question: http://stackoverflow.com/q/22008180
tag name: getter-setter
type: Tag
tags question: http://stackoverflow.com/q/22134219
tags question: http://stackoverflow.com/q/22094196

http://stackoverflow.com/comment/33443624
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22055962
has text: Your code works perfectly . guess[] values was initialized by default to '0' automatically. what's you problem ?

http://stackoverflow.com/comment/33510050
type: AnswerComment
has text: There is no while now. I made reqursive call to the same method look deeper. :)
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22093532

http://stackoverflow.com/comment/33391846
score: 1
type: QuestionComment
has text: @fge Well it will run once, perhaps he was just testing with a single iteration :) Please post the line of the error, that will make it much easier to pinpoint the mistake. This cannot be too hard to debug..
type: Comment
comment on: http://stackoverflow.com/q/22026683

http://stackoverflow.com/comment/33564731
type: Comment
comment on: http://stackoverflow.com/q/22123233
score: 0
has text: External links go stale, and few people will follow them. For better help sooner, post a [MCTaRE](http://stackoverflow.com/help/mcve) (Minimal Complete Tested and Readable Example) (as an edit to the question).
type: QuestionComment

http://stackoverflow.com/comment/105513327
comment on: http://stackoverflow.com/a/22061879
type: Comment
score: 1
has text: With this regex you accept also `0000-01-01`, I used this one instead: `^([1-9][0-9]{3})\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])$`
type: AnswerComment

http://stackoverflow.com/comment/33562537
has text: What is it you are trying to test? Don't use junit as a verb.
type: Comment
score: 4
type: QuestionComment
comment on: http://stackoverflow.com/q/22122269

http://stackoverflow.com/q/22090316
has title: Alertdialog with checkbox ( Don't show again )
has comment: http://stackoverflow.com/comment/33504717
score: 0
has body: I need to show an AlertDialog with "Don't Show Again" checkbox. I searched, but I couldn't find a working solution :/ final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); PackageManager pk = getPackageManager(); Drawable icon; alertDialogBuilder .setTitle(R.string.confirm) .setPositiveButton(R.string.close, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,int id) { //Do something } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show();
upvote count: 1
has comment: http://stackoverflow.com/comment/33504591
downvote count: 1
possible better answer: http://stackoverflow.com/a/22090480
favorite count: 0
has answer: http://stackoverflow.com/a/75280038
has answer: http://stackoverflow.com/a/22090480
has comment: http://stackoverflow.com/comment/33504715
has answer: http://stackoverflow.com/a/22090388
accepted answer: http://stackoverflow.com/a/22090388
tagged with: android
tagged with: checkbox
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22090437
tagged with: java
has comment: http://stackoverflow.com/comment/33504627
type: Question
tagged with: dialog
linked to: http://stackoverflow.com/q/9550039

http://stackoverflow.com/q/22135261
answer count: 2
downvote count: 0
tagged with: bufferedreader
accepted answer: http://stackoverflow.com/a/22135382
favorite count: 0
has comment: http://stackoverflow.com/comment/33586491
has comment: http://stackoverflow.com/comment/33586612
tagged with: offset
has body: I have a text file like one two three four five I need to get the offset of each line in the file. How do I do this in Java? I have searched through some of the I/O libraries(like BufferedReader and RandomAccessFile) but I'm unable to find a satisfactory answer to this. Can anyone suggest how to deal with this?
type: AnsweredQuestion
upvote count: 3
tagged with: java
has title: Getting byte offset of line in a text file?
type: Question
possible better answer: http://stackoverflow.com/a/22135316
has answer: http://stackoverflow.com/a/22135382
score: 3
has answer: http://stackoverflow.com/a/22135316
tagged with: randomaccessfile

http://stackoverflow.com/a/22204689
downvote count: 0
score: 4
has body: Marshalling - No Problems To marshal (output) a colon (:) in an element name you simply need to specify it in the name parameter on the corresponding JAXB annotation. @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Foo { @XmlElement(name="notANamespacePrefix:bar") String bar; } Output &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;foo&gt; &lt;notANamespacePrefix:bar&gt;Hello World&lt;/notANamespacePrefix:bar&gt; &lt;/foo&gt; Unmarshalling - Special Handling Required What Won't Work If you try to unmarshal XML that contains a colon in the element name where the portion before the colon does not correspond to a namespace prefix as follows: Unmarshaller unmarshaller = jc.createUnmarshaller(); File xml = new File("src/forum22088353/input.xml"); Foo uFoo = (Foo) unmarshaller.unmarshal(xml); Then you are going to get an exception like the following: Exception in thread "main" javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax.SAXParseException; systemId: file:/Users/bdoughan/GIT/EclipseLink-Trunk3/Scratch/src/forum22088353/input.xml; lineNumber: 3; columnNumber: 30; The prefix "notANamespacePrefix" for element "notANamespacePrefix:bar" is not bound.] at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:335) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:514) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:215) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:184) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:157) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:162) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:171) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.…
type: Answer
upvote count: 4
has comment: http://stackoverflow.com/comment/136768152
answers question: http://stackoverflow.com/q/22088353

http://stackoverflow.com/q/22038455
tagged with: clojure
score: 8
type: AnsweredQuestion
has body: I have a Clojure program that is consuming a large amount of heap while running (I once measured it at somewhere around 2.8GiB), and I'm trying to find a way to reduce its memory footprint. My current plan is to force garbage collection every so often, but I'm wondering if this is a good idea. I've read How to force garbage collection in Java? and Can I Force Garbage Collection in Java? and understand how to do it — just call (System/gc) — but I don't know if it's a good idea, or even if it's needed. Here's how the program works. I have a large number of documents in a legacy format that I'm trying to convert to HTML. The legacy format consists of several XML files: a metadata file that describes the document, and contains links to any number of content files (usually one, but it can be several — for example, some documents have "main" content and footnotes in separate files). The conversion takes anywhere from a few milliseconds for the smallest documents, to about 58 seconds for the largest document. Basically, I'm writing a glorified XSLT processor, though in a much nicer language than XSLT. My current (rather naïve) approach, written when I was just starting out in Clojure, builds a list of all the metadata files, then does the following: (let [parsed-trees (map parse metadata-files)] (dorun (map work-func parsed-trees))) work-func converts the files to HTML and writes the result to disk, returning nil. (I was trying to throw away the parsed-XML trees for each document, which is quite large, after each pass through a single document). I now realize that although map is lazy and dorun throws away the head of the sequence it's iterating over, the fact that I was holding onto the head of the seq in parsed-trees is why I was failing. My new plan is to move the parsing into work-func, so that it will look like: (defn work-func [metadata-filename] (-&gt; metadata-filename e/parse xml-to-html write-html-file) (System/gc)) Then I can call work-func with map, or possibly…
linked to: http://stackoverflow.com/q/9527491
linked to: http://stackoverflow.com/q/1481178
tagged with: java
has comment: http://stackoverflow.com/comment/33425038
tagged with: garbage-collection
accepted answer: http://stackoverflow.com/a/22038944
type: Question
has comment: http://stackoverflow.com/comment/33423211
has title: Is it a good idea to force garbage collection in Clojure?
has comment: http://stackoverflow.com/comment/33411979
has comment: http://stackoverflow.com/comment/33422660
has comment: http://stackoverflow.com/comment/33411729
has comment: http://stackoverflow.com/comment/33424785
has comment: http://stackoverflow.com/comment/33449231
linked to: http://stackoverflow.com/q/21332187
downvote count: 0
answer count: 1
has comment: http://stackoverflow.com/comment/33420640
favorite count: 0
has answer: http://stackoverflow.com/a/22038944
has comment: http://stackoverflow.com/comment/33447405
has comment: http://stackoverflow.com/comment/33446468
upvote count: 8
has comment: http://stackoverflow.com/comment/33414110
has comment: http://stackoverflow.com/comment/33412016
has comment: http://stackoverflow.com/comment/33456306
has comment: http://stackoverflow.com/comment/33426343
has comment: http://stackoverflow.com/comment/33411921
has comment: http://stackoverflow.com/comment/33456128

http://stackoverflow.com/comment/33580552
score: 0
comment on: http://stackoverflow.com/a/22130791
type: Comment
type: AnswerComment
has text: i want that the part of jsplitpane will be clearly separated by these border , so i have two part the left and right side and i want to set the border to them , the problem when i get the left component and can't set the border because there is no method to do this

http://stackoverflow.com/comment/33461318
comment on: http://stackoverflow.com/a/22066609
has text: i agree @nithin nambiar, the server on the other end is like a provisioning system, which provisions one record at once ..unfortunately, if i could control that yeah you are right that would have saved a lot of network latency issues. Thanks so much for the input :)
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/22079792
has answer: http://stackoverflow.com/a/22081003
answer count: 1
has body: I'm reading in a text file of unsorted numbers static void insertInOrder( int[] arr, int cnt, int newVal ) { int belongs = -( bSearch( arr, 0, arr.length-1, newVal)) - 1; { for ( int i = cnt; i &gt;= belongs+1 ; --i) { arr[i] = arr[i-1]; } arr[belongs] = newVal; } } // We do not need to pass in count. The incoming lo and hi define the range public static int bSearch(int[] a, int lo, int hi, int key) { int mid = (lo+hi)/2; if(lo&gt;hi) return -1; else if (a[mid]==key) return mid; else if (a[mid]&lt;key) return bSearch(a, mid+1, hi, key); else return bSearch(a, lo, mid-1, key); } The binary search is working, but my insertinorder isn't putting the numbers in ascending order and I can't figure out why. It's just printing the list out backwards. And this has to be done using a recursive binary search in an insertinorder.
type: UnansweredQuestion
tagged with: insertion-sort
tagged with: recursion
tagged with: java
type: Question
has title: Using a recursive binary search in an InsertInOrder
tagged with: binary-search
has comment: http://stackoverflow.com/comment/33486950
has comment: http://stackoverflow.com/comment/33486670
score: 0

http://stackoverflow.com/comment/59009920
score: 0
type: Comment
has text: Could have been very nice. Too bad about the horrible code.
comment on: http://stackoverflow.com/a/22438509
type: AnswerComment

http://stackoverflow.com/a/22140057
has body: You can easily use a Java Swing theme like Nimbus. Or check out Stack Overflow question Make a button round.
downvote count: 0
has comment: http://stackoverflow.com/comment/51338486
has comment: http://stackoverflow.com/comment/33685126
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/33685098
upvote count: 2
answers question: http://stackoverflow.com/q/22140006

http://stackoverflow.com/q/22016572
has body: I've got the following problem (one important restriction - cannot use external jar/libraries, only java primitives that come with regular install): Objects of class X are stored long term in sql DB. Objects are cached for performance sake (needs to be written. Intend to base it on LinkedHashMap). get(key): check if object is in cache and not in use - return it. if object is in use - sleep till it's available. if object is not in cache - read it from DB. putInCache(object): update object in cache (if it's not there, add it). if the cache is exhausted it will trigger a saveToDB operation by the cache and remove from cache the least recent used item. saveToDB(object): write object to DB (not removed from cache) and mark object and "not changed". There are multiple threads calling get. A thread can change the object it received from get (and the object will be marked as "changed") - when it's finished it will call putInCache. There is one dedicated thread that goes over the cache objects and when it encounters a "changed" object it will trigger saveToDB (object will be marked as used while DB access is going on). How would you recommend to ensure thread safety ? Basically I'm looking for the right Java classes that will enable: 1. get to synchronize it's access to each object in the cache. So that it can check if it's there and if so - if it's used or free for grabbing. If it's used - it should sleep until it's available. 2. the dedicated thread should not lock the cache while calling saveToDB but still making sure all the cache is examined and no starvation is caused (the cache might change while saveToDB is running) just to clarify I'm only interested in the locking/synchronization solutions - things like the cache triggering and DB access can be assumed as given.
has comment: http://stackoverflow.com/comment/33373779
tagged with: multithreading
has answer: http://stackoverflow.com/a/22017420
has title: How do I synchronize cache list access
upvote count: 1
answer count: 1
has comment: http://stackoverflow.com/comment/33372801
has comment: http://stackoverflow.com/comment/33372934
tagged with: java
has comment: http://stackoverflow.com/comment/33373449
type: UnansweredQuestion
tagged with: caching
has comment: http://stackoverflow.com/comment/33372536
tagged with: locking
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33373947
tagged with: synchronization
favorite count: 0
type: Question
has comment: http://stackoverflow.com/comment/33376560
has comment: http://stackoverflow.com/comment/33373595

http://stackoverflow.com/comment/42209152
has text: @EJP *"There's no mapping from that via Channels"* - what about `RandomAccessFile.getChannel()`?
type: Comment
comment on: http://stackoverflow.com/a/26771479
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33490332
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22081094
type: AnswerComment
has text: Ultimately the function `return new HashMap<Integer, String>();`, populated using `map.put(jobId,"APPLIED")` where jobId is of type Integer

http://stackoverflow.com/q/22076208
type: UnansweredQuestion
has body: I'm following through a book called "The JFC Swing Tutorial (Second Edition)" and I'm pretty much at the start I have followed this code and it should be displaying the button and the label in the content pane, but All im getting is a blank screen. any ideas? Thanks. import java.awt.GridLayout; import javax.swing.*; public class m extends JFrame { void UserFrame() { //JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("Hellow You"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel jp = new JPanel(new GridLayout(0,1)); //makes label JLabel label = new JLabel("Sup "); //adds to the frames content pane a label frame.getContentPane().add(label); JButton button = new JButton("Hai"); frame.getContentPane().add(button); jp.add(button); jp.add(label); jp.setBorder(BorderFactory.createEmptyBorder(30,30,10,30)); //pack set the window to what it needs AKA to display all components frame.pack(); //frame.setSize(250, 250); //shows window frame.setVisible(true); } public static void main(String[] args) { final m window = new m(); SwingUtilities.invokeLater(new Runnable() { public void run() { window.UserFrame(); } }); } }
has title: Java Swing blank screen instead of window displayed
downvote count: 0
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33479496
tagged with: swing
has comment: http://stackoverflow.com/comment/33479572
has comment: http://stackoverflow.com/comment/33479528
type: Question
has comment: http://stackoverflow.com/comment/33479270
has comment: http://stackoverflow.com/comment/33480598
has comment: http://stackoverflow.com/comment/33479290
has comment: http://stackoverflow.com/comment/33479297
has comment: http://stackoverflow.com/comment/33479336
linked to: http://stackoverflow.com/q/7229226
upvote count: 1
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/22076334

http://stackoverflow.com/comment/53860618
type: AnswerComment
has text: In my opinion this is difficult to maintain. Workflow engines should be declarative in style rather than imperative.
comment on: http://stackoverflow.com/a/22061636
type: Comment
score: 0

http://stackoverflow.com/comment/33532221
type: QuestionComment
comment on: http://stackoverflow.com/q/22105296
score: 1
has text: As a first step to debugging any program that uses random numbers, use java.util.Random with a way to force the seed, so that you can do multiple runs with the same sequence of random numbers.
type: Comment

http://stackoverflow.com/comment/33496650
type: AnswerComment
comment on: http://stackoverflow.com/a/22085439
type: Comment
has text: @SSH: You basically need the concept (class?) of a "colored" sorted array with 6 pointers per element. It has two types of elements, red and blue ones (let's say blue are the elements embedded from earlier lists). Every element has pointers to its blue/red predecessors/successors and every blue element has a pointer to its index in the embedded list. You embed an array into another by a merge-like procedure (`O(n)`) and then you preprocess your lists by embedding the lists into each other. The query procedure itself is then reasonably easy to implement
score: 0

http://stackoverflow.com/comment/33638423
type: Comment
type: QuestionComment
score: 0
has text: I'll just try it out will let you know
comment on: http://stackoverflow.com/q/22164575

http://stackoverflow.com/q/22120782
tagged with: sql
tagged with: jpa
answer count: 1
score: 1
has title: Best practices for OneToMany with Java
favorite count: 0
has answer: http://stackoverflow.com/a/22120876
type: AnsweredQuestion
upvote count: 2
tagged with: design-patterns
downvote count: 1
type: Question
tagged with: java
tagged with: hibernate
accepted answer: http://stackoverflow.com/a/22120876
has body: Short version: Lets say I have a One to many relation ship, between Parent and Child. Now in the Java code, is the best practice to read the parent object (get it from the database), and apply some method called addChild in it, or I directly create a child and persist it without reading the Parent ? Long version Lets say we have this Parent and Child (from http://en.wikibooks.org/wiki/Java_Persistence/OneToMany) @Entity public class Employee { @Id @Column(name="EMP_ID") private long id; ... @OneToMany(mappedBy="owner") private List&lt;Phone&gt; phones; ... } @Entity public class Phone { @Id private long id; ... @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="OWNER_ID") private Employee owner; ... } And now consider I have a web page where employee can add a phone number. So I already have the id of the parent Employee but I don't have the complete Employee object. 1- I get the whole Employee object from the database (by JPA mapping of course). Then I apply the method employee.addPhone(Phone phone) or something like that. This leads to two queries. 2- I create the phone object, and a wrong employee object that contains only the id of the employee and I persist ? What are the best practices for this ?

http://stackoverflow.com/comment/33696156
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22196592
has text: Look inside the default Nexus plugins some of them contains Guice modules. So, you can find out how works Guice for plugins.
score: 0

http://stackoverflow.com/q/22006081
downvote count: 0
score: 1
has answer: http://stackoverflow.com/a/22008781
favorite count: 0
tagged with: android
has answer: http://stackoverflow.com/a/22006930
has answer: http://stackoverflow.com/a/22006180
has body: Files ==> ==> As I'm showing in this picture flow, my image(960-Minimalism.jpg) is inside internal phone storage and I'm trying to get it's path for further use through File class. What I have tried yet 1st: String filePath = MainActivity.this.getFilesDir().getAbsolutePath(); File file = new File(filePath, "960-Minimalism.jpg"); 2nd: File file = new File(Environment.getExternalStorageDirectory()+ "/Android/data/"+ getApplicationContext().getPackageName() + "/Files/"+"960-Minimalism.jpg"); The extreme hard code way: File file = new File("/data/data/com.example.net/files/","960-Minimalism.jpg") Exception here same as 1st.. I know I'm missing something or doing something wrong here but unable to find out till now. Any Idea.. EDIT Please don't think I have three problems . The above are my tried solutions which not worked. But problem is one that I want to fetch the image path which is in my internal storage memory. That's why I deleted my exceptions here.
answer count: 4
type: AnsweredQuestion
tagged with: java
tagged with: file
has comment: http://stackoverflow.com/comment/33354435
has comment: http://stackoverflow.com/comment/33354303
has comment: http://stackoverflow.com/comment/33354246
has comment: http://stackoverflow.com/comment/33354601
upvote count: 1
has title: FileNotFoundException when fetch image from Internal Storage
has answer: http://stackoverflow.com/a/22006119
type: Question
tagged with: filenotfoundexception
accepted answer: http://stackoverflow.com/a/22006930
has comment: http://stackoverflow.com/comment/33354543
has comment: http://stackoverflow.com/comment/33354626
possible better answer: http://stackoverflow.com/a/22006119
has comment: http://stackoverflow.com/comment/33354370
linked to: http://stackoverflow.com/q/2789276

http://stackoverflow.com/q/22021793
has answer: http://stackoverflow.com/a/28638371
has comment: http://stackoverflow.com/comment/33398031
has answer: http://stackoverflow.com/a/28637667
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33427953
upvote count: 1
has comment: http://stackoverflow.com/comment/33421991
tagged with: selenium-webdriver
has comment: http://stackoverflow.com/comment/33383974
score: 1
tagged with: java
has body: I'm conducting Automation testing using Selenium Webdriver, this code is for TestNg dataprovider, Summary: I am taking data from Excel sheet to data, it's working fine. When I'm debugging the code, I'm getting TestData as testGoogle1(String search1, String Search2) for 1st Iteration it Search1 = Webdriver, Search2 = Qtp, so on,,,, What I want is that it should directly return the array of values something like testGoogle1(String search[]) so that in the @Test itself I can add my function iterate all the rows and columns and test them. Can anyone please give me the idea how to write it. Test Data sheet here is my code package ExcelTest; import com.thoughtworks.selenium.*; import static org.testng.AssertJUnit.*; import java.io.IOException; import jxl.Cell; import jxl.CellType; import jxl.Sheet; import jxl.Workbook; import jxl.read.biff.BiffException; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import org.testng.annotations.AfterTest; import java.io.File; import java.io.FileInputStream; import java.util.Iterator; import jxl.*; public class Sample{ WebDriver driver; @BeforeTest public void startTest(){ driver = Startup.basic(); } @DataProvider(name = "DP1") public Object[][] createData1() throws Exception{ Object[][] retObjArr=getTableArray("G:\\Selenium Jar Files\\TestData\\Data.xls","DataPool"); return(retObjArr); } @Test (dataProvider = "DP1") public void testGoogle1(String search1, String Search2) throws Exception{ //selenium.open("http://www.google.co.in/"); // driver.get("http://www.google.co.in/"); //String hello = search.length; //for(int i=0; i&lt; search.length ;i++) //{ System.out.println("param " +search); Thread.sleep(3000); System.out.println("Opened"); WebElement element = driver.findElement(By.name("q")); element.sendKeys(search);…
type: Question
has comment: http://stackoverflow.com/comment/33416310
has title: TestNG: Iterate through array using the Dataprovider
downvote count: 0
tagged with: jxl
has comment: http://stackoverflow.com/comment/33428168
favorite count: 0
has answer: http://stackoverflow.com/a/59948803
answer count: 4
has answer: http://stackoverflow.com/a/22048051
tagged with: testng

http://stackoverflow.com/a/22010010
answers question: http://stackoverflow.com/q/22009861
type: AcceptedAnswer
downvote count: 0
has body: Try something like this: NodeList list = yourNodeList.getChildNodes(); for (int i = 0; i &lt; list.getLength(); i++) { Node node = list.item(i); if ("result".equals(node.getNodeName())) { node.setTextContent("your_value"); } } Also, take a look here. Google is full of examples ; )
type: Answer
score: 1
upvote count: 1
accepted answer of: http://stackoverflow.com/q/22009861

http://stackoverflow.com/comment/33404247
type: QuestionComment
has text: @UliKöhler - My interpretation is that this is an "idle curiosity" question. It starts *"I'm wondering how Java implements ..."*.
comment on: http://stackoverflow.com/q/22030798
score: 0
type: Comment

http://stackoverflow.com/q/22032568
tagged with: internationalization
tagged with: http://stackoverflow.com/tag/xml
has body: I'm doing i18n for my web app and I have a list of error messages in an xml file, like this: We are unable to find your booking. Please try again. OR Seek assistance at the Check-In counter. 我们无法找到您的预订。 请再试一次。. 或 请联系登机柜台寻求帮助。 I use the DOM xml parser to load the error messages. Then I get the specific error by matching Error id: DocumentBuilder builder = DocumentBuilderFactory.newInstance(). newDocumentBuilder(); Document doc = builder.parse(xml); doc.getDocumentElement().normalize(); NodeList nList = doc.getElementsByTagName("Error"); for (int temp = 0; temp < nList.getLength(); temp++) { Node nNode = nList.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) nNode; Error _error = new Error(); _error.setKey(eElement.getAttribute("id")); _error.setHeading1(eElement.getElementsByTagName("Heading1").item(0).getTextContent()); _error.setHeading2(eElement.getElementsByTagName("Heading2").item(0).getTextContent()); _error.setDescription1(eElement.getElementsByTagName("Description1").item(0).getTextContent()); _error.setDescription2(eElement.getElementsByTagName("Description2").item(0).getTextContent()); _error.setDescription3(eElement.getElementsByTagName("Description3").item(0).getTextContent()); _error.setDescription5(eElement.getElementsByTagName("Description4").item(0).getTextContent()); getErrors().add(_error); How do I go about specifying the culture id to only load the error messages in that section? For example, when I switch to chinese, it looks up the Errors culture="zh" and only parses in that section? Thanks.
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33414111
type: Question
has title: Java parse xml i18n
has answer: http://stackoverflow.com/a/22033217
answer count: 1
accepted answer: http://stackoverflow.com/a/22033217
score: 0

http://stackoverflow.com/comment/33475101
type: Comment
has text: `MyObj` (or `Peer`) associates with user's session or to be more precise with user's tab. User can work with my application from multiple tabs, and each tab is proceeded in separate thread. BUT all those tabs have the same `sessionId`. So actually my map looks like `ConcurrentHashMap<Long, Peer>`. It can contains multiple `Peer` objects for the same `sessionId`.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22069554

http://stackoverflow.com/q/22144463
has title: java NIO - multithreaded access to channels
has body: Based on the documentation of java.NIO, buffers are thread-unsafe, while channels in most of the cases (FileChannel, SocketChannel etc.) are safe to be used by multiple threads. What I cannot find in the documentation is a clear description of what happens when e.g. two threads start to read from a FileChannel concurrently. Does the first operation read first N bytes, or is it possible to get first M bytes to the first channel's buffer, and then the next couple would go to the second buffer, before we context switch would read some more into the first etc. Does anyone know what the guarantees are for multithreaded access to channels?
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/22144731
type: Question
answer count: 1
tagged with: nio
score: 0
tagged with: channel
has answer: http://stackoverflow.com/a/22144731
tagged with: buffer

http://stackoverflow.com/q/22005458
answer count: 1
accepted answer: http://stackoverflow.com/a/22005642
has comment: http://stackoverflow.com/comment/33353871
has title: Tabe field status auto update checking system date using query in mysql & java
has comment: http://stackoverflow.com/comment/33353415
type: AnsweredQuestion
has body: table field status auto update when checking with system date and expirydate using query in mysql &amp; java In my table, tbl-member: id, name, expirydate,status are fields. How to use this with TRIGGER (expirydate,systemdate) CREATE TRIGGER autoupdation trigger_time UPDATE ON tbl-member FOR EACH ROW trigger_body how to create trigger_body for this function... field expirydate check with system date and auto update the status field. here is the code use function for check-updation @Override public List&lt;Member&gt; FindExpiredMembers() throws ParseException { List&lt;Member&gt; memberlistforreturn=new ArrayList&lt;&gt;(); List&lt;Member&gt; memberlist=getAllMember(); java.util.Date utilDate=new java.util.Date(); java.sql.Date sqldate=new java.sql.Date(utilDate.getTime()); for(Member i : memberlist){ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); java.util.Date exp_Date=sdf.parse(sqldate.toString()); java.util.Date renew_Date=sdf.parse(i.getRenewDate().toString()); if(renew_Date.compareTo(exp_Date)&lt;0){ memberlistforreturn.add(i); i.setStatus(true); update(i); } } System.out.println(memberlistforreturn.size()); System.out.println("working...!!!!!!"); return memberlistforreturn; } using this function the program run on slow
tagged with: java
tagged with: mysql
has answer: http://stackoverflow.com/a/22005642
type: Question
has comment: http://stackoverflow.com/comment/33353372
has comment: http://stackoverflow.com/comment/33353393
has comment: http://stackoverflow.com/comment/33353812
has comment: http://stackoverflow.com/comment/33353695
score: 0
tagged with: sql

http://stackoverflow.com/comment/33563120
type: QuestionComment
has text: I don't know what any of that means. I haven't expressed any confusion, and I have no idea what you mean by 'persistent favour'.
comment on: http://stackoverflow.com/q/22084982
score: 0
type: Comment

http://stackoverflow.com/a/22113370
answers question: http://stackoverflow.com/q/22113348
has body: put the rest of your code into an else statement like this: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { if (txt_pangkat.getText().trim().equals("")||icon_image1 == null) { JOptionPane.showMessageDialog(null,"Please Insert a value"); dispose(); } else { try { String sql="insert into KKKB1 (Pangkat,Sains)values (?,?)"; pst=conn.prepareStatement(sql); pst.setString(1, txt_pangkat.getText()); pst.setBytes(2, icon_image1); pst.execute(); JOptionPane.showMessageDialog(null, "Data Saved"); txt_pangkat.setText(""); back(); } catch(Exception e) { JOptionPane.showMessageDialog(null, e); } finally { try { pst.close(); } catch(Exception e){} } } }
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33546399
upvote count: 1

http://stackoverflow.com/comment/33553831
type: Comment
has text: as I wrote, with a `long` data type, you won't get overflow (until `N * K > 63`. But then we're talking about `10^19` nodes. It'll be hard to store them. Even if a node would occupy only 1 bit, you'd need 10^18 bytes, that's one billion gigabytes or a million terabytes. I have found a speed optimization that is easy to implement. The binomial coefficients can be calculated and stored. That substantially reduces the number of calls to fac().
type: AnswerComment
comment on: http://stackoverflow.com/a/22073691
score: 0

http://stackoverflow.com/q/22164954
tagged with: eclipse
tagged with: prepared-statement
has comment: http://stackoverflow.com/comment/33642987
type: Question
has comment: http://stackoverflow.com/comment/33641406
has comment: http://stackoverflow.com/comment/33642867
answer count: 1
has comment: http://stackoverflow.com/comment/33643185
upvote count: 1
has answer: http://stackoverflow.com/a/27108570
has title: Generate preparedstatement with bean properties
favorite count: 0
tagged with: netbeans
type: UnansweredQuestion
downvote count: 0
score: 1
tagged with: java
has body: I have a bean named Customer, has 40 properties.I am using java prepare statement to insert bean data into database so every time i have to write setString() or setInt() can anyone suggest me how can i minimize this? means is there any shortcuts in Netbeans or Eclipse IDE to generate prepared statement with bean getter properties int x = 0; Connection con = null; String query = "INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) VALUES (?,?,?,?,?,?); PreparedStatement ps = con.prepareStatement(query); ps.setString(++x, person.custName()); . . . . . 40 times

http://stackoverflow.com/comment/76017883
score: 0
type: Comment
has text: While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
comment on: http://stackoverflow.com/a/44512417
type: AnswerComment

http://stackoverflow.com/a/22150794
answers question: http://stackoverflow.com/q/22150644
score: 2
has comment: http://stackoverflow.com/comment/33623893
type: Answer
has comment: http://stackoverflow.com/comment/33625598
has comment: http://stackoverflow.com/comment/33623697
upvote count: 2
has comment: http://stackoverflow.com/comment/33624095
has comment: http://stackoverflow.com/comment/33666450
accepted answer of: http://stackoverflow.com/q/22150644
type: AcceptedAnswer
downvote count: 0
has body: Can't you check twice for user action inside the actionPerformer? No, Swing is event-based so only one component can trigger the ActionEvent. This means that you will need to place if (e.getSource() == gtf) { at an outer level of the if statement to check the source component (which will be triggered by pressing ENTER)

http://stackoverflow.com/comment/33558328
type: Comment
has text: it isn´t, because that would still be a privacy issue.
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/22112385

http://stackoverflow.com/comment/33481060
has text: What a terrible idea. The compiler would never be able to alert you that you had forgotten to implement one. Nothing would prevent you from instantiating a class with methods that would blow up if you ever called them.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22077172
score: 1

http://stackoverflow.com/q/22053616
accepted answer: http://stackoverflow.com/a/22054010
possible better answer: http://stackoverflow.com/a/22053756
linked to: http://stackoverflow.com/q/11970024
type: AnsweredQuestion
tagged with: java
has title: First app (developer.android.com) errors, what is wrong?
tagged with: eclipse
has answer: http://stackoverflow.com/a/22053738
type: Question
has answer: http://stackoverflow.com/a/22053784
has answer: http://stackoverflow.com/a/22053715
score: 2
downvote count: 0
has answer: http://stackoverflow.com/a/22054010
tagged with: http://stackoverflow.com/tag/xml
favorite count: 0
has answer: http://stackoverflow.com/a/22053756
has body: So I have followed the tutorial on https://developer.android.com/training/basics/firstapp/index.html trying to build an app, and I've written all the code now but have got a few errors. I am using Eclipse if that matters. activity_main.xml : I get errors on @string/edit_message - "error: Error: No resource found that matches the given name (at 'hint' with value '@string/edit_message')." and @string/button_send - "error: Error: No resource found that matches the given name (at 'text' with value '@string/button_send')." <EditText android:layout_weight="1" android:layout_width="0dp" android:layout_height="wrap_content" android:hint="@string/edit_message" /> And then there's MainActivity.java - Here I get an error on EditText editText = (EditText) findViewById | this part (R.id.edit_message); | saying "edit_message cannot be resolved or is not a field" package com.example.myfirstapp; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.EditText; public class MainActivity extends Activity { public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @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; } /** Called when the user clicks the Send button */ public void sendMessage(View view) { Intent intent = new Intent(this, DisplayMessageActivity.class); EditText editText = (EditText) findViewById(R.id.edit_message); String message = editText.getText().toString(); intent.putExtra(EXTRA_MESSAGE, message); startActivity(intent); // Do something in response to button } } Next, on strings.xml, I get this: "Multiple annotations found at this line: - error: Error parsing XML: not well…
upvote count: 2
answer count: 5
tagged with: android

http://stackoverflow.com/comment/33554451
has text: @JonSkeet haha :) Yeah that is a bit confusing sentence, but one can make a wild guess what OP is talking about :)
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22117899

http://stackoverflow.com/comment/33443980
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22055295
has text: This may sound silly, but try shutting Eclipse down, maybe even rebooting the system. It's possible that a sequence of these try-and-fails has left a number of event listeners (INotifier's) still running and active. That would explain why a simple invocation works while an invocation nested inside an event handler might not. I saw a similar symptom with windows and window handles a long time ago and this could be the same sort of problem. Even if this isn't the solution, you should look at having too many INotifiers from inside a event listener

http://stackoverflow.com/a/22195468
score: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22145517
type: Answer
has body: Change the content-type on the REST client to be application/x-www-form-urlencoded
answers question: http://stackoverflow.com/q/22145517

http://stackoverflow.com/q/22010326
has title: Add condition to search box in Google maps?
tagged with: android
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/22010484
type: Question
tagged with: google-maps
tagged with: search
has comment: http://stackoverflow.com/comment/33364971
score: 0
has body: I am new in android and working for developing an app with Google maps V2. I designed map and every thing is OK. I put a textbox and button at the top that help user to search for any location he want and used this bottom method to the search operation. The problem when the user enter invalid place the app crashed. I want to add condition with toast in this method that when the user enter invalid location, the toast appear( please enter a valid location ) please help me public void search(View v) throws IOException{ EditText textbox = (EditText) findViewById(R.id.editText1); String location = textboxt.getText().toString(); if (location.length() == 0) { Toast.makeText(this, "Please Enter a location", Toast.LENGTH_SHORT).show(); return; } Geocoder gc = new Geocoder(this); List&lt;Address&gt; list = gc.getFromLocationName(location, 1); Address add = list.get(0); String locality = add.getLocality(); double lat = add.getLatitude(); double lng = add.getLongitude(); LatLng ll = new LatLng(lat, lng); Gmap.moveCamera(CameraUpdateFactory.newLatLng(ll)); // zoom in Google map Gmap.animateCamera(CameraUpdateFactory.zoomTo(20));
answer count: 1
has answer: http://stackoverflow.com/a/22010484

http://stackoverflow.com/comment/33491293
comment on: http://stackoverflow.com/a/22082512
score: 1
has text: @user1988876: your statement is equivalent to `Object[] o = new Object[] {"a", "b"}`, not to `Object[] o = new String[] {"a", "b"}`
type: AnswerComment
type: Comment

http://stackoverflow.com/q/22119280
answer count: 1
has comment: http://stackoverflow.com/comment/33557036
favorite count: 0
tagged with: interceptor
has title: Is it possible and how to pass some additional arguments to interceptor in Java?
has comment: http://stackoverflow.com/comment/33556996
upvote count: 4
downvote count: 0
type: UnansweredQuestion
tagged with: java
type: Question
tagged with: jakarta-ee
has answer: http://stackoverflow.com/a/68979640
tagged with: ejb
has comment: http://stackoverflow.com/comment/33557015
has comment: http://stackoverflow.com/comment/33556932
has body: For example I have some methods for whom I need some common logic: @MyIntercept(value="Some value") public void doSomething(int param1, String param2) { //.................... } @MyIntercept(value="Some other value") public void doSomethingElse(String param1) { //.................... } And inside MyInterceptor: public class MyInterceptor { @AroundInvoke public void aroundInvoke (InvocationContext ic) throws Exception { //common logic, but considering the value } } How can I achieve the goal?
score: 4

http://stackoverflow.com/comment/33651248
comment on: http://stackoverflow.com/a/22139802
type: Comment
has text: when i click enter button in activity_main.xml then it has to display main.xml file@rajshree
type: AnswerComment
score: 0

http://stackoverflow.com/q/22107602
tagged with: java
upvote count: 1
possible better answer: http://stackoverflow.com/a/22107685
accepted answer: http://stackoverflow.com/a/22107741
type: Question
has answer: http://stackoverflow.com/a/22107685
has title: Double Printing of Data
answer count: 3
has answer: http://stackoverflow.com/a/22107757
downvote count: 0
score: 1
favorite count: 0
has answer: http://stackoverflow.com/a/22107741
has body: I am writing a program to print the area and perimeter of a rectangle when a user provides the length and width. The user is asked to input how many rectangles he/she wants and then I use a for loop to ask for the length and width, which loops based on the number of rectangles the user inputed. It prints and works like I want it to ... however, when the user chooses to continue and create more rectangles, the program will print the results of the old data plus the new data instead of just printing the new data. I am very new to programming in Java and am stuck on how to fix this. It would be great if someone could help me out. Thanks! This is my code: import javax.swing.*; public class RectangleProgram { public static void main(String[] args) { String defaultRectangleOutput = ""; String newRectangleOutput = ""; String finalOutput = ""; int option = JOptionPane.YES_OPTION; while (option == JOptionPane.YES_OPTION) { String rectangleNumberString = JOptionPane.showInputDialog(null, "How many rectangles would you like to create? ", "Number of Rectangles", JOptionPane.QUESTION_MESSAGE); if (rectangleNumberString == null) return; while (rectangleNumberString.equals("")) { rectangleNumberString = JOptionPane.showInputDialog( "You have entered nothing.\n" + "Please try again: "); } int rectangleNumber = Integer.parseInt(rectangleNumberString); while (rectangleNumber &lt;= 0) { rectangleNumberString = JOptionPane.showInputDialog( "Entry cannot be 0 or negative.\n" + "Please try again: "); if (rectangleNumberString == null) return; rectangleNumber = Integer.parseInt(rectangleNumberString); } for (int i = 0; i &lt; rectangleNumber; i++) { String lengthString = JOptionPane.showInputDialog(null, "Enter Length for rectangle: ", "Getting Length", JOptionPane.QUESTION_MESSAGE); if (lengthString == null) return; while (lengthString.equals("")) { lengthString = JOptionPane.showInputDialog( "You have entered nothing.\n" + "Please try again: "); } double length = Double.parseDouble(leng…
type: AnsweredQuestion

embeddable
type: Tag
tags question: http://stackoverflow.com/q/22126397
tag name: embeddable

http://stackoverflow.com/q/22013786
type: Question
downvote count: 8
has comment: http://stackoverflow.com/comment/33367668
has answer: http://stackoverflow.com/a/22013903
accepted answer: http://stackoverflow.com/a/22013903
has title: Number of column in a two dimensional ArrayList
upvote count: 2
tagged with: arraylist
answer count: 3
has body: How do I determine which column in a double ArrayList has the same value in all rows? My ArrayList looks like the image below. Update: Seems like there are many where were confused by the question. I should have asked in a more eloquent way. I have a two dimensional ArrayList which consists of ArrayLists. I have a certain number of rows and columns in this two dimensional ArrayList. I would like to create a method that would return how many numbers of columns are in that ArrayList. That was what I meant in my original question. Now I know how to create this method as I got help from some of the answers below.
score: -6
favorite count: 0
has comment: http://stackoverflow.com/comment/33367399
has comment: http://stackoverflow.com/comment/33367172
has answer: http://stackoverflow.com/a/22013868
has answer: http://stackoverflow.com/a/22013848
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/22013848

http://stackoverflow.com/a/22059079
answers question: http://stackoverflow.com/q/22058738
has body: Basically, the answer will depend on whether the label is displayed on the screen or not. To ensure that the label (or in fact, any component) can be printed, it must first be sized properly... This can be done using setSize and feeding it getPreferredSize at the very basic level. The next step is passing using the components printAll method (or print method depending on your needs) which is better suited for...printing...as it disables double buffering and won't produce nasty exceptions when it's not attached to a native peer... Example printed as preferred size... Example printed to fill available area... Now the example uses the printComponentToFile method, but you'll want to use the printComponent method for actually printing it a printer, the first is useful for doing things like page previews and screen dumps... import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.awt.print.PageFormat; import java.awt.print.Paper; import java.awt.print.Printable; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JOptionPane; public class PrintALabel { public static void main(String[] args) { try { JLabel label = new JLabel( "This is a test", new ImageIcon("path/to/image"), JLabel.CENTER); printComponentToFile(label, true); printComponentToFile(label, false); } catch (PrinterException exp) { exp.printStackTrace(); } } public static void printComponent(JComponent comp, boolean fill) throws PrinterException { PrinterJob pjob = PrinterJob.getPrinterJob(); PageFormat pf = pjob.defaultPage(); pf.setOrientation(PageFormat.LANDSCAPE); PageFormat postformat = pjob.pageDialog(pf); if (pf != postformat) { //Set print component pjob.setPrintable(new Componen…
has comment: http://stackoverflow.com/comment/33510937
has comment: http://stackoverflow.com/comment/33452750
has comment: http://stackoverflow.com/comment/33452933
has comment: http://stackoverflow.com/comment/33452916
has comment: http://stackoverflow.com/comment/33452722
downvote count: 0
has comment: http://stackoverflow.com/comment/33458580
has comment: http://stackoverflow.com/comment/33467666
has comment: http://stackoverflow.com/comment/33452960
type: Answer
has comment: http://stackoverflow.com/comment/33453153
score: 1
has comment: http://stackoverflow.com/comment/33487055
upvote count: 1
has comment: http://stackoverflow.com/comment/33467929
has comment: http://stackoverflow.com/comment/33514416

http://stackoverflow.com/comment/33586669
comment on: http://stackoverflow.com/a/22135012
type: Comment
score: 0
type: AnswerComment
has text: sorry wrongly copied code http://developer.android.com/reference/android/app/DialogFragment.html#onAttach(android.app.Activity) this is the link to function u need to override

http://stackoverflow.com/q/22118184
tagged with: ioexception
possible better answer: http://stackoverflow.com/a/22118469
tagged with: java
has answer: http://stackoverflow.com/a/22118469
tagged with: methods
has comment: http://stackoverflow.com/comment/33555265
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/22118360
has body: I had this program with which i have to check if the value the user entered is present in the text file i created in the source file. However it throws me an error everytime i try to call the method with IOException. Please help me out thanks. import java.util.*; import java.io.*; public class chargeAccountModi { public boolean sequentialSearch ( double chargeNumber ) throws IOException { Scanner keyboard= new Scanner(System.in); int index = 0; int element = -1; boolean found = false; System.out.println(" Enter the Charge Account Number : " ); chargeNumber = keyboard.nextInt(); int[] tests = new int[18]; int i = 0; File file = new File ("Names.txt"); Scanner inputFile = new Scanner(file); while(inputFile.hasNext() &amp;&amp; i &lt; tests.length ) { tests [i] = inputFile.nextInt(); i++; } inputFile.close(); for ( index = 0 ; index &lt; tests.length ; index ++ ) { if ( tests[index] == chargeNumber ) { found = true; element = index; } } return found; } public static void main(String[]Args) { double chargeNumber = 0; chargeAccountModi object1 = new chargeAccountModi(); try { object1.sequentialSearch(chargeNumber); } catch (IOException ioe) { } System.out.println(" The search result is : " + object1.sequentialSearch (chargeNumber)); } }
has title: calling method with IOException
has comment: http://stackoverflow.com/comment/33555119
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33554941
favorite count: 0
accepted answer: http://stackoverflow.com/a/22118360
has comment: http://stackoverflow.com/comment/33555274
upvote count: 1
type: AnsweredQuestion

http://stackoverflow.com/a/22106457
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 2
upvote count: 2
has body: I need some kind of a queue that will be synchronized for adding new elements and removing new elements: You should use a BlockingQueue (for example ArrayBlockingQueue) which takes care of all of the synchronization for you. You call queue.add(...) to add to the queue and another thread would call take() to remove items from the queue.
accepted answer of: http://stackoverflow.com/q/22106428
answers question: http://stackoverflow.com/q/22106428

http://stackoverflow.com/q/22157849
has answer: http://stackoverflow.com/a/22158042
score: -1
answer count: 1
favorite count: 0
linked to: http://stackoverflow.com/q/37335
tagged with: heap-memory
tagged with: out-of-memory
type: UnansweredQuestion
has body: I am writing a crawler of Google Play Store. My method visit(link) takes the html code in a string Page and visit all the other applications that link to the page is through the method searchApp(page) that re-calls visit(link). But I get OutOfMemoyError and I could not find a solution. I would not increase the JVM heap size. How can I fix it? Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOfRange(Arrays.java:2694) at java.lang.String.&lt;init&gt;(String.java:203) at java.lang.StringBuffer.toString(StringBuffer.java:561) at java.io.BufferedReader.readLine(BufferedReader.java:352) at java.io.BufferedReader.readLine(BufferedReader.java:382) at Main.visita(Main.java:34) at Main.cercaApp(Main.java:83) public static void visit(String link) { try { URL my_url = new URL(link); BufferedReader br = new BufferedReader(new InputStreamReader(my_url.openStream())); String strTemp; StringBuilder builder= new StringBuilder(); while(null != (strTemp =br.readLine())){ builder.append(new String(strTemp.trim())); } br.close(); String page = new String(builder.toString()); builder=null; strTemp=null; System.gc(); page =page.toLowerCase(); searchApp(page); page=null; System.gc(); } catch (Exception ex) { return; } } public static void searchApp(String page){ int i=0, j=0, k=0; String link=new String (""); while(true){ i=page.indexOf("/store/apps/details?",i); if(i==-1) break; j=page.indexOf("\"",i); k=page.indexOf("&amp;",i); if(k&lt;j) j=k; k=page.indexOf("&lt;",i); if(k != -1 &amp;&amp; k&lt;j) j=k; k=page.indexOf(")",i); if(k != -1 &amp;&amp; k&lt;j) j=k; try{ link=new String("https://play.google.com"+page.substring(i,j)); if(!(link.contains("%") || link.contains("\\"))){ if (!linkVisited.contains(link)) { linkVisited.add(new String(link)); System.out.println("ADDED : "); System.out.println(link); visita(link); } } i=j; } catch(StringIndexOutOfBoundsException e){ break; } } page=null; System.gc(); }
has title: java.lang.OutOfMemoryError: Java heap space (StringBuffer)
upvote count: 0
has comment: http://stackoverflow.com/comment/33626285
tagged with: java
downvote count: 1
type: Question

http://stackoverflow.com/a/22155809
answers question: http://stackoverflow.com/q/22155234
score: 0
type: AcceptedAnswer
has body: Start drawPoint as false. And the change the names of your variables to save points. Then you'll want something like this in your click: public void mouseClicked(MouseEvent mouse){ if(!drawPoint) { pointX = mouse.getX(); pointY = mouse.getY(); drawPoint = true; } else if(!drawLine) { lineX = mouse.getX(); lineY = mouse.getY(); drawLine = true; } repaint(); } And then your paint is simple: public void paintComponent(Graphics g){ super.paintComponent(g); if(drawLine){ g.drawLine(pointX, pointY, lineX, lineY); } else if(drawPoint){ g.drawOval(pointX-5,pointY-5,10,10); } } It's actually important that in your paint loop, you check drawLine first, and in your mouseClicked you check drawPoint first. Once you've grasped what's happening here, you can attempt the drawTriangle yourself!
type: Answer
accepted answer of: http://stackoverflow.com/q/22155234

http://stackoverflow.com/q/22055766
has title: How can I change cardLayout card within child card?
score: 1
tagged with: java
upvote count: 1
tagged with: swing
type: Question
tagged with: cardlayout
has body: I have a parent class which is CardLayout. I also have two child classes(JPanel) that has textfields and buttons. What I want is when the user click a button on the first card the screen will change to the second screen. Here is the code public class GUI extends JFrame { /** * */ private static final long serialVersionUID = 1L; private JPanel contentPane; private static LoginScreen login; private static DatabaseSelection selector; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { GUI frame = new GUI(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public GUI() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 300); setLocationRelativeTo(null); contentPane = new JPanel(); CardLayout card = new CardLayout(); contentPane.setLayout(card); login = new LoginScreen(); selector = new DatabaseSelection(); contentPane.add(login, "1"); contentPane.add(selector, "2"); setContentPane(contentPane); card.show(contentPane, "1"); } } public class LoginScreen extends JPanel implements ActionListener { /** * */ private static final long serialVersionUID = 1L; private JTextField userName; private JPasswordField passWord; private JTextField port; private JTextField host; private JLabel hostLabel; private JLabel portLabel; private Connection con; /** * Create the panel. */ public LoginScreen() { GridBagLayout gridBagLayout = new GridBagLayout(); setLayout(gridBagLayout); JLabel userNameLabel = new JLabel("Username: "); GridBagConstraints gbc_userNameLabel = new GridBagConstraints(); gbc_userNameLabel.anchor = GridBagConstraints.EAST; gbc_userNameLabel.insets = new Insets(0, 0, 5, 5); gbc_userNameLabel.gridx = 1; gbc_userNameLabel.gridy = 1; add(userNameLabel, gbc_userNameLabel); userName = new JTextField(); GridBagConstraints gbc_userName = new GridBagConstraints(); gbc_userName.anchor = GridBagConstraints.EAST; gbc…
answer count: 1
has comment: http://stackoverflow.com/comment/33443243
downvote count: 0
has comment: http://stackoverflow.com/comment/33443198
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22055847

http://stackoverflow.com/comment/33729462
type: Comment
has text: no if i change the other way round also only one condition is working the problem in the code is uname=request.getParameter (txtUsername); is getting a null value dono y
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/22202945

http://stackoverflow.com/a/42599407
has comment: http://stackoverflow.com/comment/101865344
type: Answer
downvote count: 0
has body: I had a similar issue and solved it by simply adding 'SetSkipJ2SDKCheck true' to one of the below files. /home/abc/.sqldeveloper/4.1.5/product.conf /opt/sqldeveloper/sqldeveloper/bin/sqldeveloper.conf
score: 1
answers question: http://stackoverflow.com/q/22158923
upvote count: 1

http://stackoverflow.com/comment/33558672
score: 0
has text: Wow, these URLEncoders really aren't helping are they? I've updated my answer again!
comment on: http://stackoverflow.com/q/22119045
type: Comment
type: QuestionComment

heap-memory
tag name: heap-memory
tags question: http://stackoverflow.com/q/22015365
tags question: http://stackoverflow.com/q/22150454
tags question: http://stackoverflow.com/q/22165264
type: Tag
tags question: http://stackoverflow.com/q/22157849

osx-mavericks
type: Tag
tags question: http://stackoverflow.com/q/22028066
tag name: osx-mavericks
tags question: http://stackoverflow.com/q/22057805

http://stackoverflow.com/comment/33447265
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22058103
type: AnswerComment
has text: Think of f(x) = sin(x). Here x is not defined, but this is the whole idea, now you can call it as f(0.2) and get a value from it or whatever other parameter.

http://stackoverflow.com/a/22148976
answers question: http://stackoverflow.com/q/22148860
downvote count: 0
score: 1
has body: you could do it with out using recursive, just like this: String s = "value"; StringBuilder sb = new StringBuilder(); for (int i = (s.length() - 1); i &gt;= 0; i--) { sb.append(s.charAt(i)); sb.append("-"); } System.out.println(sb.toString()); }
type: Answer
upvote count: 1

http://stackoverflow.com/comment/85736471
type: AnswerComment
comment on: http://stackoverflow.com/a/27406400
type: Comment
has text: So instead of writing `@With(Secure.class)`, OP now has to write `@Secure(superAnnotation = @With(Secure.class))`? How does that help?
score: 59

http://stackoverflow.com/a/22083370
type: Answer
score: 0
has body: First you should have a look at the File class. It provides you methods to create, open, modify and save files. To read files you also might want to give BufferedReader or any other Reader a shot. Creating a file: File has the method createNewFile(), use it in combination with exists(). To open and read a file use a try-with-resource (There's actually a nice tutorial about it in the Java Manuals). To save a file you should check out the FileWriter, it can write strings or append them to files. For your editor you might want to replace the before mentioned BufferedReader with a LineReader, which also provides methods to get the line number. Other than that you have to figure out yourself how to number the lines. (Actually it's just googling around a lot, there will be some ideas like this one - which I didn't check in detail but it might help). Of course for the editor you should first read the file into a string, use a formatter for it and then you can present it and reformat it when needed. Apart from these hints I can not provide you with more detailed answers, as you can also read in the comments it would be easier if you would provide more detailed questions. You now just gave us a GUI which has almost nothing to do with your actual problems. Show us some of your (problematic) work and we can help you, but otherwise we can not do much more than giving you some hints as I just did. So try to think about your problems, try how to ask for more precise answers and open some new questions if you want. But don't forget to check out the site for answers, for me almost all of my questions I'd like to ask are already asked somewhere in a similar manner.
answers question: http://stackoverflow.com/q/22082752

http://stackoverflow.com/comment/33518501
type: Comment
comment on: http://stackoverflow.com/q/22098121
score: 0
type: QuestionComment
has text: logcat trace added to original question.

http://stackoverflow.com/comment/33592346
type: QuestionComment
comment on: http://stackoverflow.com/q/22138250
has text: yes I mean it literally it doesn't print out anything. For some reason it doesn't read from the file.
score: 0
type: Comment

http://stackoverflow.com/a/23221803
has body: This is bug of the broker, the workround is to use sync_publish='all', for details see ServiceBus over AMQP/QPID client closes consumer
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/22046467
type: Answer
accepted answer of: http://stackoverflow.com/q/22046467
upvote count: 1
score: 1

http://stackoverflow.com/comment/33444789
type: QuestionComment
comment on: http://stackoverflow.com/q/22055236
has text: You are making the namespace explicit. You could remove the "/" but you would need to add the namespace="/" attribute/value to the tag. "Login" alone could work but the action would need to be in the default package (namespace is "" generally this is best avoided, people start complaining that they end up with weird URLS when too many actions are done that way)
score: 2
type: Comment

http://stackoverflow.com/comment/33465708
type: AnswerComment
comment on: http://stackoverflow.com/a/22069012
score: 0
type: Comment
has text: That is exactly what I meant, but as the previous comment mentioned, the count should be initialized with 0 to give the wanted result.

http://stackoverflow.com/a/22016385
score: 0
answers question: http://stackoverflow.com/q/22016253
type: Answer
has body: Use java.util.Arrays.toString(price) to get a readable result. What you are getting now is the default toString method of the Object object: public String toString() { return getClass().getName() + "@" + Integer.toHexString(hashCode()); }

http://stackoverflow.com/a/22124927
answers question: http://stackoverflow.com/q/22124885
score: 0
type: Answer
has body: Your condition for the "for" loop is wrong. It should be i &lt; length or i &lt; length - 1

http://stackoverflow.com/q/22167737
has answer: http://stackoverflow.com/a/22176330
has comment: http://stackoverflow.com/comment/33643309
has body: In my 2D physics simulation (Java) I calculate the center of a convex polygon as follows, where the parameter area is the enclosed area of the polygon calculated before. private Vector2d calculateCenterOfMass(double area) { Vector2d center = new Vector2d(0, 0); for (int i = 0; i &lt; vertices.length; i++) { int j = (i + 1) % vertices.length; double factor = (vertices[i].x * vertices[j].y - vertices[j].x * vertices[i].y); center.x += (vertices[i].x + vertices[j].x) * factor; center.y += (vertices[i].y + vertices[j].y) * factor; } center.scale(1 / (area * 6)); return center; } I further have a polygon with the following points I use the function to calculate the center of mass of: Vector2d [x=325.20399446366355, y=400.0, length=515.5168649182318] Vector2d [x=375.20399446366355, y=400.0, length=548.4323453822622] Vector2d [x=375.20399446366355, y=450.0, length=585.8993407245727] Vector2d [x=325.20399446366355, y=450.0, length=555.2095442399406] As you can see just by looking at the y values the center must be at y=425.0. Due to floating point magic the y value becomes 425.00000000000017 instead. The area given as parameter has the exact value 2500.0. How can I avoid this and get my expected 425.0?
possible better answer: http://stackoverflow.com/a/22176330
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33643871
tagged with: java
tagged with: floating-point
type: Question
has answer: http://stackoverflow.com/a/22167885
has title: Avoid floating-point precision error in algorithm
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/33643408
accepted answer: http://stackoverflow.com/a/22167885
tagged with: floating-point-precision

http://stackoverflow.com/q/22159699
answer count: 1
favorite count: 0
has body: My project has both Java (N files) and Groovy code (1 file only). Java compile depends upon this single Groovy file's class file for Java compilation (compileJava task to succeed). When I don't use src/java as one of the srcDir within main>groovy> sourceSet section, then I get an error saying class/symbol not found which is in the groovy file/class. In ANT, it's easy that we are calling compile-groovy target first, before calling compile-java target but the same in Gradle is what I'm trying to find. I read some posts and found that if I make main>java section NULL and specify srcDir for main>java which is src/java inside main>groovy sourceSet section, then it compiles fine. My ?s: 1. Is there any other way to do? for ex, the following should work: compileJava { dependsOn compileGroovy } though, this goes to an infinte loop. OR what about using doFirst for compileJava task: compileJava { doFirst { compileGroovy } } this doesn't work either. build.gradle This works, but compileJava in one sense becomes useless here even though the source code has N no. of java files in the src/java or src/java-test etc tree. I know this build script is working but logically it might bring some confusion to the developer if s/he is not familiar why sourceSet for Groovy MUST have "src/java" as its srcDir value. apply plugin: 'java' apply plugin: 'groovy' sourceSets { main { groovy { srcDir 'src/groovy' srcDir 'src/java' } java { //The following needs to be commented out OR Gradle will always pick compileJava before compileGroovy //srcDir 'src/java' //srcDir 'src/java-test' } } test { groovy { srcDir 'test/groovy' } java { srcDir 'test/java' } resources { srcDir 'test/resources' srcDir 'conf' } } integrationTest { groovy { srcDir 'src/groovy-test' } java { srcDir 'src/java-test' } resources { srcDir 'test/resources' srcDir 'conf' } } } Other links: How to make Gradle compile Groovy tests before Java tests
linked to: http://stackoverflow.com/q/19574078
type: UnansweredQuestion
score: 13
has answer: http://stackoverflow.com/a/22164339
has title: Gradle - Groovy and Java class dependency - Compile
has comment: http://stackoverflow.com/comment/33631509
has comment: http://stackoverflow.com/comment/33630276
downvote count: 0
tagged with: java
tagged with: gradle
type: Question
tagged with: compilation
upvote count: 13
tagged with: class
tagged with: groovy

http://stackoverflow.com/q/22057839
tagged with: themes
linked to: http://stackoverflow.com/q/19409398
score: 0
tagged with: android
has comment: http://stackoverflow.com/comment/33446782
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22057934
has comment: http://stackoverflow.com/comment/33447817
has comment: http://stackoverflow.com/comment/33446949
tagged with: java
type: Question
tagged with: android-layout
answer count: 2
has answer: http://stackoverflow.com/a/22059205
has title: Change theme on runtime in Android App
has comment: http://stackoverflow.com/comment/33446937
has comment: http://stackoverflow.com/comment/33446838
has body: Im new to android programming and Im trying to apply a theme on my flashlight app. The error seems to be when I click on "OK" button when trying to apply one of the two themes. Here's my code on SimpleNotificationAppActivity.java public class SimpleNotificationAppActivity extends Activity implements android.content.DialogInterface.OnClickListener{ private boolean isFlashOn = false; private Camera camera; //private ImageButton button; private Button button; private MediaPlayer button2; //////////// public final static int CREATE_DIALOG = -1; public final static int THEME_HOLO_LIGHT = 0; public final static int THEME_HOLO = 1; int position; /////////////// @Override protected void onStop() { super.onStop(); if (camera != null) { camera.release(); } } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setTheme(android.R.style.Theme_Holo_Light); setContentView(R.layout.main); button = (Button) findViewById(R.id.buttonFlashlight); button2 = MediaPlayer.create(SimpleNotificationAppActivity.this,R.raw.two_tone_nav); //SOM DO CLIQUE //button = (ImageButton) findViewById(R.drawable.image_on); //button.setBackgroundResource(R.drawable.switch_on); Context context = this; PackageManager pm = context.getPackageManager(); if (!pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) { Log.e("err", "Device has no camera."); Toast.makeText(getApplicationContext(), "Sorry, your device doesn't have camera :(", Toast.LENGTH_SHORT).show(); return; } camera = Camera.open(); final Parameters p = camera.getParameters(); button.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { if (isFlashOn) { Log.i("info", "torch is turned off!"); button2.start(); p.setFlashMode(Parameters.FLASH_MODE_OFF); camera.setParameters(p); isFlashOn = false; //button.setText("Torch-ON"); button.setBackgroundResource(R.drawable.button_on); } else { Log.i("info", "torch is turned on!"); button2.start(); p.setFlashMode(Parameters.FLASH_MODE_TORCH); c…

http://stackoverflow.com/a/22111878
has body: Ex - String dob = "05/02/1989"; //its in MM/dd/yyyy String newDate = null; Date dtDob = new Date(dob); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { newDate = sdf.format(dtDob); } catch (ParseException e) {} System.out.println(newDate); //Output is 1989-05-02
type: Answer
score: 2
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/22111209

http://stackoverflow.com/a/22060257
has body: From the docs If a constructor does not explicitly invoke a superclass constructor, the Java compiler automatically inserts a call to the no-argument constructor of the superclass. If the super class does not have a no-argument constructor, you will get a compile-time error. Object does have such a constructor, so if Object is the only superclass, there is no problem. So even though you've not explicitly called the super class constructor, the compiler inserts a statement called super() in the constructor of class B. This is how the class B constructor would look post compilation. public B(String s){ super(); // this is inserted by the compiler, if you hadn't done it yourself. System.out.println(s); }
accepted answer of: http://stackoverflow.com/q/22060217
downvote count: 0
score: 7
answers question: http://stackoverflow.com/q/22060217
type: AcceptedAnswer
upvote count: 7
type: Answer

http://stackoverflow.com/comment/33514529
has text: This won't work for files with spaces... Again, URLEncoder.encode() does NOT work for URIs!
comment on: http://stackoverflow.com/a/22094845
type: AnswerComment
score: 4
type: Comment

http://stackoverflow.com/q/22058151
has body: I have this sittuation: 3 public methods, 2 are commands and 1 check inputs and will start command1 or command2 in thread. My question is how i can do that? public void blablabla() { input = get_user_input; if(input == 1) { start thread with command1 } else { start thread with command2 } } public void command1() { // do action } public void command2() { // do action2 } I think its impossible start a thread with method directly but using Runnable i can do that. I was thinking if its good choice and great idea for performance declare command1 and command2 are static runnable on class and use this runnables to start thread. Doing this as static runnable it will spend more memory than a method ? Thanks!
tagged with: android
has title: Android Thread with Methods
accepted answer: http://stackoverflow.com/a/22059241
type: AnsweredQuestion
tagged with: multithreading
type: Question
tagged with: java
score: 0
has answer: http://stackoverflow.com/a/22059241
answer count: 1

http://stackoverflow.com/a/22097279
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/22064173
accepted answer of: http://stackoverflow.com/q/22064173
has body: After going through tons of documentations and forum posts again, I think that I've found a working solution in logback. Instead of using the (nonexistent) LogManager class I am now using the logback LoggerContext: LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); And instead of using getLoggerRepository().getCurrentLoggers() I switched to using lc.getLoggerList();
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33518716
type: Answer

http://stackoverflow.com/q/22157348
upvote count: 2
tagged with: java
type: Question
tagged with: android-layout
has answer: http://stackoverflow.com/a/22198086
has answer: http://stackoverflow.com/a/25274646
downvote count: 0
has answer: http://stackoverflow.com/a/22157507
has answer: http://stackoverflow.com/a/22157452
favorite count: 0
has comment: http://stackoverflow.com/comment/33661903
has comment: http://stackoverflow.com/comment/33639352
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33626776
tagged with: android
has title: R.java file is not updated in Android Studio
answer count: 4
tagged with: android-studio
score: 2
has body: I have a problem with Android Studio 0.4.2. The R.java is not updated when I create or update layout resources files. I have seen there was an issue on earlier versions of Android Studio that deals with that problem but it doesn't to work anymore for Android Studio 0.4.2. Android Studio doesn't seems to log any error message when I build the module. I have also seen similar questions but mainly for Eclipse and I didn't find answers for Android Studio 0.4.2. Furthermore, I imported this module into Android Studio From an ADT Eclipse project.
has comment: http://stackoverflow.com/comment/33627374

http://stackoverflow.com/comment/33530423
score: 1
has text: @MarioStoilov "[implementing] only part of an interface" is the whole point. It's no different from someone implementing an abstract class where only some of the methods in the class are abstract (aside from the potential multiple inheritance issues default implementations in interfaces could cause, but I don't know if Java 8 will allow that).
comment on: http://stackoverflow.com/q/22096052
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22034146
has comment: http://stackoverflow.com/comment/33404604
has comment: http://stackoverflow.com/comment/33404177
has comment: http://stackoverflow.com/comment/33404838
has comment: http://stackoverflow.com/comment/33405145
type: Answer
has comment: http://stackoverflow.com/comment/33404883
score: 0
has comment: http://stackoverflow.com/comment/33404655
has body: Best way to check this is checking if you can rename the file String fileName = "C:\\Text.xlsx"; File file = new File(fileName); // try to rename the file with the same name File sameFileName = new File(fileName); if(file.renameTo(sameFileName)){ // if the file is renamed System.out.println("file is closed"); }else{ // if the file didnt accept the renaming operation System.out.println("file is opened"); } or use Apache Common IO library
answers question: http://stackoverflow.com/q/22034056

http://stackoverflow.com/q/22071675
has title: Maven run from bash script ignoring profile?
type: UnansweredQuestion
tagged with: maven
has answer: http://stackoverflow.com/a/22071899
has body: I wrote a little script to compile the test version of a .jar and put it out on my test server. cd /home/myusername/workspace/td-daily-budget mvn -P test clean compile package scp /home/myusername/workspace/td-daily-budget/target/td-daily-budget-1.0.jar myusername@666.666.666.666:/home/myusername/bin/td-daily-budget.jar When I run it I get a jar file whose config.properties contains things like db.connect.string=${db.connect.string} but when I run mvn -P test clean compile package all by itself in the terminal window I get a jar file put together with the test profile, e.g. config.properties contains db.connect.string=[what I expect it to be for the dev profile]. Why does the same command ignore the profile when run inside a script? Thanks in advance! [edit/addendum] Tried changing the script line to /bin/bash mvn -P env-test clean package (it's bash, not Windows, so there's no call command, but using bash to call another script seems to make sense to me) but just got *Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher * I think calling it as an external process mucks up Maven's understanding of where it's supposed to be executing. [2nd edit/addendum] Removed the redundant compile from the command. It now appears that this is actually an intermittent problem. The filtering almost always fails when mvn -P [pretty much ANY profile] clean package runs from inside the bash script, but if I run it standalone from the command line repeatedly it will work eight or nine times and then fail several times in a row. I cannot find any pattern to this at all. As soon as I discovered this I thought I knew the culprit: The m2e plugin for Eclipse was "helping" me in the background every time it saw files changing. So I excitedly shutdown Eclipse thinking the problem would vanish instantly, ran mvn -P env-test clean compile package several times in a row--it worked the first few times and then failed. /headdesk [edit/addendum] Removed the spac…
has answer: http://stackoverflow.com/a/22071957
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33472608
score: 0
tagged with: bash
answer count: 2

http://stackoverflow.com/q/22166610
has answer: http://stackoverflow.com/a/22181597
has body: I want to create a popup window in a JavaFX application. Give me some ideas. When I click on Check button it opens the popup window. How to do it?
has answer: http://stackoverflow.com/a/22167142
score: 22
tagged with: javafx-8
has answer: http://stackoverflow.com/a/22175915
has comment: http://stackoverflow.com/comment/92968046
duplicate of: http://stackoverflow.com/q/12717969
answer count: 4
tagged with: javafx-2
favorite count: 0
upvote count: 25
has title: How to create a popup window in javafx
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/12717969
has answer: http://stackoverflow.com/a/26716623
tagged with: java
tagged with: scenebuilder
tagged with: javafx
downvote count: 3
type: Question
linked to: http://stackoverflow.com/q/10527895

http://stackoverflow.com/comment/33386767
has text: @Leo I'm using jre7, Standard VM @@Dave Newton Nothing shows up in task manager or task switcher.
type: QuestionComment
comment on: http://stackoverflow.com/q/22024030
score: 0
type: Comment

http://stackoverflow.com/a/22149993
downvote count: 0
has body: To print the first, middle, and last, you could do something like this: if(numbers != null &amp;&amp; numbers.length &gt; 0) { System.out.println(numbers[0]); System.out.println(numbers[numbers.length / 2]); System.out.println(numbers[numbers.length - 1]); } Another suggestion is not to use Bubble Sort :)
score: 1
answers question: http://stackoverflow.com/q/22149615
upvote count: 1
type: Answer

http://stackoverflow.com/q/22107417
type: AnsweredQuestion
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/22107495
type: Question
answer count: 2
downvote count: 0
has body: I have read several posts on both Stack Exchange and other sites, but am still a bit stuck on how I can go about printing the Astrological Signs in Java. public static void main(String[] args) { char aa = \u2648; char ab = \u2649; char ac = \u264A; char ad = \u264B; char ae = \u264C; char af = \u264D; char ag = \u264E; char ah = \u264F; char ai = \u2650; char aj = \u2651; char ak = \u2652; char al = \u2653; while(true) { System.out.println(aa + ab + ac + ad + ae + af + ag + ah + ai + aj + ak + al); } } From what I understand, one can only use \u when the hex value value of the unicode is inside of the range U+0000 to U+FFFF, which this is. I tried compiling this and it gives me 12 illegal character syntax errors. Any help would be greatly appreciated. ^_^ Additional Info: I am printing this to the console and I am using TextPad to compile.
has comment: http://stackoverflow.com/comment/33536216
tagged with: printing
has comment: http://stackoverflow.com/comment/33536154
upvote count: 1
has title: Print Unicode Astrological Signs in Java
has answer: http://stackoverflow.com/a/22107495
has comment: http://stackoverflow.com/comment/33536098
tagged with: unicode
favorite count: 0
has comment: http://stackoverflow.com/comment/33536318
has comment: http://stackoverflow.com/comment/33536583
has answer: http://stackoverflow.com/a/22107467
accepted answer: http://stackoverflow.com/a/22107467
tagged with: escaping

http://stackoverflow.com/a/22019691
score: 3
has body: No ArrayDequeue is a Dequeue implementation, which means it is meant to be used to insert and remove elements only at start and end of the collection. It does not provide indexed access to elements (unlike List). If you need indexed access to elements, and swap operation, you should reconsider your design and use another Collection type.
accepted answer of: http://stackoverflow.com/q/22019555
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/22019555
type: Answer
upvote count: 3

http://stackoverflow.com/q/22048805
tagged with: ruby
tagged with: stdin
answer count: 0
upvote count: 2
type: UnansweredQuestion
score: 2
tagged with: java
tagged with: stdout
has title: ruby—call Java prgramm that reads from Stdin
type: Question
tagged with: rjb
downvote count: 0
has body: I would like to run a java program from within a ruby script, using rjb. All in all, I would like to write a String to the Stdin as input for the program and read its output from stdout. I have tried something like that, but the script just hangs: Open3.popen3(Java.com.package.name.anothername.Classname.main([--arg1, …])) do |i, o, e, t| i.write "Hello World!" i.close puts o.read end What could I do to fix that?
favorite count: 0

http://stackoverflow.com/q/22072100
accepted answer: http://stackoverflow.com/a/22073211
tagged with: xa
has comment: http://stackoverflow.com/comment/33472192
score: 0
has comment: http://stackoverflow.com/comment/33472099
answer count: 1
has comment: http://stackoverflow.com/comment/33472639
tagged with: distributed-transactions
has body: I am trying to move jms messages between 2 different, remote, activeMQ brokers and after a lot of reading I am using Atomikos, as I am writing a standalone application, and I am also using spring to get the whole thing working. I have the following bean javaconfig setup @Bean(name="atomikosSrcConnectionFactory") public AtomikosConnectionFactoryBean consumerXAConnectionFactory() { AtomikosConnectionFactoryBean consumerBean = new AtomikosConnectionFactoryBean(); consumerBean.setUniqueResourceName("atomikosSrcConnectionFactory"); consumerBean.setLocalTransactionMode(false); return consumerBean; } @Bean(name="atomikosDstConnectionFactory") public AtomikosConnectionFactoryBean producerXAConnectionFactory() { AtomikosConnectionFactoryBean producerBean = new AtomikosConnectionFactoryBean(); producerBean.setUniqueResourceName("atomikosDstConnectionFactory"); producerBean.setLocalTransactionMode(false); return producerBean; } @Bean(name="jtaTransactionManager") public JtaTransactionManager jtaTransactionManager() throws SystemException { JtaTransactionManager jtaTM = new JtaTransactionManager(); jtaTM.setTransactionManager(userTransactionManager()); jtaTM.setUserTransaction(userTransactionImp()); return jtaTM; } @Bean(initMethod="init", destroyMethod="close", name="userTransactionManager") public UserTransactionManager userTransactionManager() { UserTransactionManager utm = new UserTransactionManager(); utm.setForceShutdown(false); return utm; } @Bean(name="userTransactionImp") public UserTransactionImp userTransactionImp() throws SystemException { UserTransactionImp uti = new UserTransactionImp(); uti.setTransactionTimeout(300); return uti; } @Bean(name="jmsContainer") @Lazy(value=true) public DefaultMessageListenerContainer jmsContainer() throws SystemException { DefaultMessageListenerContainer dmlc = new DefaultMessageListenerContainer(); dmlc.setAutoStartup(false); dmlc.setTransactionManager(jtaTransactionManager()); dmlc.setSessionTransacted(true); dmlc.setSessionAcknow…
has title: XA Transactions between 2 JMS Brokers (ActiveMQ)
has answer: http://stackoverflow.com/a/22073211
tagged with: spring
tagged with: atomikos
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33472004
has comment: http://stackoverflow.com/comment/33473604
type: Question
has comment: http://stackoverflow.com/comment/33472741

http://stackoverflow.com/q/22107771
has answer: http://stackoverflow.com/a/22107787
score: 6
has answer: http://stackoverflow.com/a/22107798
type: AnsweredQuestion
tagged with: java
has body: I have to add User identified by his id into set and in runtime all users form that set have to be sorted by this id. I've created TreeSet added some User objects and tried to iterate through it. Here is my attempt: //irrelevant code removed TreeSet&lt;User&gt; userSet = new TreeSet&lt;User&gt;(); userSet.add(new User(2)); userSet.add(new User(1)); userSet.add(new User(3)); Iterator&lt;User&gt; iterator = userSet.iterator(); while (iterator.hasNext()) { System.out.print(iterator.next() + " "); } I wrote class User where is one of the fields id and constructor have id as parameter. public class User { private int id; // irrelevant code removed public User(int id) { this.id = id; } // irrelevant code removed public String toString() { return id + ""; } } When i run this code I get ClassCastException. Here is the stacktrace: Exception in thread "main" java.lang.ClassCastException: OrderedUsers$User cannot be cast to java.lang.Comparable at java.util.TreeMap.compare(TreeMap.java:1188) at java.util.TreeMap.put(TreeMap.java:531) at java.util.TreeSet.add(TreeSet.java:255) at OrderedUsers.&lt;init&gt;(OrderedUsers.java:9) at Main.main(Main.java:6) What I am doing wrong?
type: Question
has answer: http://stackoverflow.com/a/22107857
has title: I can't iterate through TreeSet
has answer: http://stackoverflow.com/a/22107796
downvote count: 0
upvote count: 6
answer count: 4
favorite count: 0
accepted answer: http://stackoverflow.com/a/22107796
possible better answer: http://stackoverflow.com/a/22107787

http://stackoverflow.com/comment/33436982
type: QuestionComment
comment on: http://stackoverflow.com/q/22052320
type: Comment
has text: getOdataValue = /Date(1393358368000)/` but getFormatedValue will be Tue, 25 Feb 2014 21:59:28
score: 0

http://stackoverflow.com/a/22055021
has body: Your logic is incorrect. Let's say you have 26 letters, and want 3 fragments. That makes a first fragment of 9 elements, a second of 9 elements, and a last one of 8 elements. Your logic makes each fragments of length 8 (floor(26 / 3)), except the first one, which is of length 9 (ceil(26 / 3)). Not only that, but you add the additional letter of the first fragment to the second one. Side note: the test if(fragment[i] == fragment[0]) should in fact be if (i == 0). And you should make your numbers double to avoid losing the decimal part.
type: Answer
has comment: http://stackoverflow.com/comment/33464113
answers question: http://stackoverflow.com/q/22054820
accepted answer of: http://stackoverflow.com/q/22054820
score: 0
type: AcceptedAnswer

jsr356
tag name: jsr356
type: Tag
tags question: http://stackoverflow.com/q/22074422

http://stackoverflow.com/comment/33558483
type: QuestionComment
comment on: http://stackoverflow.com/q/22120093
score: 0
has text: Why do you install a headless JRE with apt-get when you're being instructed to install a JDK to download from http://www.oracle.com/technetwork/java/javase/downloads? JRE means: runtime environment (i.e. without all the dev tools of the JDK). And headless means: without UI, although you want to run a graphical application. Follow the instructions, and everything will be easier.
type: Comment

http://stackoverflow.com/q/22167290
type: UnansweredQuestion
answer count: 0
tagged with: storage
has body: I'm trying to wirte files to the internal storage actually to an other apps unprotected storage the code I'm using works it just doesn't work when I want to copy to /android/data/com.some.app can this be done or do I have to make the app use root access Thanks public class tools extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tools); } public void installflat(View view) { Toast.makeText(tools.this, "This could take a long time", Toast.LENGTH_LONG).show(); File direct = new File(Environment.getExternalStorageDirectory() + "/android" + "/data" + "/com.some.app" +"/"); if (!direct.exists()) { if (direct.mkdir()) { //directory is created; }} installflat_pt2(); Toast.makeText(tools.this, "try it now", Toast.LENGTH_LONG).show(); } private void installflat_pt2() { AssetManager assetManager = getAssets(); String[] files = null; try { files = assetManager.list("tools"); } catch (IOException e) { Log.e("tag", e.getMessage()); } for (String filename : files) { System.out.println("File name =&gt; " + filename); InputStream in = null; OutputStream out = null; try { in = assetManager.open("tools/" + filename); // if files resides inside the "Files" directory itself out = new FileOutputStream(Environment.getExternalStorageDirectory().toString() + "/android" + "/data" + "/com.some.app" + filename); copyFile(in, out); in.close(); in = null; out.flush(); out.close(); out = null; } catch (Exception e) { Log.e("tag", e.getMessage()); } } } private void copyFile(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[1024]; int read; while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } } }
type: Question
tagged with: android
has comment: http://stackoverflow.com/comment/33643217
has title: copying to another apps unprotected storage Android
has comment: http://stackoverflow.com/comment/33642894
has comment: http://stackoverflow.com/comment/33668907
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/33642723
tagged with: sd-card

http://stackoverflow.com/comment/33383794
has text: @user3267872 As a general rule: If you are trying to compare two things, then they need to be comparable. Translation to Java: If you are trying to compare objects of a class, that class must implement `Comparable`. In your case you need to compare `Automobile`s to sort them, so it follows that `Automobile` must implement `Comparable`.
comment on: http://stackoverflow.com/a/22022522
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/22168066
has comment: http://stackoverflow.com/comment/33643969
has comment: http://stackoverflow.com/comment/33654575
has body: @ManagedBean @SessionScoped public class Login { @EJB LoginManager em; private String username; private String password; private boolean rememberme; private String errorMsg; public Login() { System.out.println(" In Construct " + username); if (username == null || username.equalsIgnoreCase("")) { System.out.println("val = " + username); try { FacesContext.getCurrentInstance().getExternalContext().redirect("index.xhtml"); } catch (IOException ex) { System.out.println("--------I/O exception------"); } } } // Getters &amp; Setters ........ } I want that if the username is null then it will redirect me to the index.xhtml page. It Prints the value null in console but cannot redirect me to the index.xhtml page. Why ???
answer count: 0
has comment: http://stackoverflow.com/comment/33643915
tagged with: java
type: Question
tagged with: http://stackoverflow.com/tag/xhtml
tagged with: jboss6.x
tagged with: jsf-2
score: 0
has comment: http://stackoverflow.com/comment/33643832
has title: Why Not Redirecting in Java Server Faces?
has comment: http://stackoverflow.com/comment/33644228
has comment: http://stackoverflow.com/comment/33644402
has comment: http://stackoverflow.com/comment/33644260
has comment: http://stackoverflow.com/comment/33643793
tagged with: javabeans
has comment: http://stackoverflow.com/comment/33645444
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33732926

http://stackoverflow.com/comment/33542996
has text: I have used the code from [link](http://www.codejava.net/coding/capture-and-record-sound-into-wav-file-with-java-sound-api). I used the code in the above answer to read the AudioInputStream. PS: I moved the declaration of ais (AudioInputStream reference) from start() to make ais a field of class. So it is visible in finish(). Modified sampleRate to 44100.0, sampleSizeInBits to 16 and channels to 1.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22096325
type: Comment

http://stackoverflow.com/a/22050793
has body: The general idea with a library project is you create classes within it. Then you reference them via your main projects manifest. Add the library project in the main project settings and you will have general classes that you can share to any project. I assume this is what you are looking for based on your post. Edit Here is how to do it: 1) Set project to be library (you have said you have done this). 2) Put your classes in your library project. (So you can call them from other projects). 3) Go to the main project and right click on it, select Android from the settings. This is where you turned your library project, into a library project. 4) Anyway, at the bottom click add. 5) In the manifest, create and activity reference to a class in the library project. 6) So if you are trying to get MainActivity you call com.library.project.package.MainActivity Now you will have the MainActivity viewing able if you ran the project.
has comment: http://stackoverflow.com/comment/33434334
has comment: http://stackoverflow.com/comment/33434562
type: Answer
answers question: http://stackoverflow.com/q/22050741
score: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22050741

http://stackoverflow.com/comment/33542808
score: 0
comment on: http://stackoverflow.com/a/22111280
type: Comment
type: AnswerComment
has text: when i run the program, i need to be able to enter the integers separated by spaces, then hit enter and have it run everything… can't hit ctrl-d or anything… hitting enter should resume the program through completion

http://stackoverflow.com/comment/33614135
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22151147
has text: How do you get the complete stacktrace? The code does not reach the catch block.

http://stackoverflow.com/q/22146173
has comment: http://stackoverflow.com/comment/33606738
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33604975
tagged with: java
has body: My regex is (?:--|#|\/\*|{) When i compile this using Pattern.complie() in java, I am getting *Illegal Repetitive Character * I tested this regex (a|\/\*|b) When i compiled this, It shows no error. Why does this occur ?
type: Question
score: 0
tagged with: regex-greedy
answer count: 1
favorite count: 0
accepted answer: http://stackoverflow.com/a/22146473
tagged with: regex
has title: Java Regex - Ilegal Repetition character
has answer: http://stackoverflow.com/a/22146473
has comment: http://stackoverflow.com/comment/33604878
has comment: http://stackoverflow.com/comment/33604381
upvote count: 1
has comment: http://stackoverflow.com/comment/33604550
downvote count: 1

http://stackoverflow.com/q/22151191
has answer: http://stackoverflow.com/a/22151530
has answer: http://stackoverflow.com/a/22151511
tagged with: conditional-operator
has title: Java Multiple Ternary operators
has comment: http://stackoverflow.com/comment/33613916
has answer: http://stackoverflow.com/a/22151309
tagged with: java
has answer: http://stackoverflow.com/a/69992929
has answer: http://stackoverflow.com/a/22151270
type: Question
upvote count: 4
answer count: 8
has comment: http://stackoverflow.com/comment/33613783
has body: I'm studying some Java at the moment at I've come across the following piece of code. I understand how the typical ternary operator (e.g. the line beginning with "boolean a" below), but I can't understand how to read the expression on the line beginning with "boolean b". Any help on how to read this line would be much appreciated! Thanks! public class Ternary{ public static void main (String[] args){ int x = 10; int i = 2; boolean a = x &gt; 10 ? true: false; boolean b = a = true ? ++i &gt; 2 ? true:false:false; System.out.print(b); } }
downvote count: 0
has answer: http://stackoverflow.com/a/22151398
tagged with: assignment-operator
score: 4
has answer: http://stackoverflow.com/a/22151675
has answer: http://stackoverflow.com/a/22151279
favorite count: 0
type: UnansweredQuestion

magic-numbers
tag name: magic-numbers
tags question: http://stackoverflow.com/q/22087568
type: Tag

http://stackoverflow.com/q/22016091
score: 7
tagged with: java
has comment: http://stackoverflow.com/comment/69414848
has comment: http://stackoverflow.com/comment/69497326
upvote count: 7
has comment: http://stackoverflow.com/comment/69414497
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/69542468
has title: How can I save a BufferedImage to be below a particular size
has body: (Using java 8) Given a image user needs to be able to specify min/max image size in pixels and also maximum size of saved image in kbs, image is saved as jpg. So I have the first bit working, by resizing buffered image: public static BufferedImage resizeUsingImageIO(Image srcImage, int size) { int w = srcImage.getWidth(null); int h = srcImage.getHeight(null); // Determine the scaling required to get desired result. float scaleW = (float) size / (float) w; float scaleH = (float) size / (float) h; MainWindow.logger.finest("Image Resizing to size:" + size + " w:" + w + ":h:" + h + ":scaleW:" + scaleW + ":scaleH" + scaleH); //Create an image buffer in which to paint on, create as an opaque Rgb type image, it doesn't matter what type //the original image is we want to convert to the best type for displaying on screen regardless BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB); // Set the scale. AffineTransform tx = new AffineTransform(); tx.scale(scaleW, scaleH); // Paint image. Graphics2D g2d = bi.createGraphics(); g2d.setColor(Color.WHITE); g2d.fillRect(0, 0, size, size); g2d.setComposite(AlphaComposite.SrcOver); g2d.drawImage(srcImage, tx, null); g2d.dispose(); return bi; } The image is eventually output as a jpg as follows public static byte[] convertToByteArray(BufferedImage bi) throws Exception { final ByteArrayOutputStream output = new ByteArrayOutputStream(); //Convert JPEG and then a byte array if (ImageIO.write(bi, FILE_SUFFIX_JPG, new DataOutputStream(output))) { final byte[] imageData = output.toByteArray(); return imageData; } } but is there a way I specify a max image size , and make it perform more compression as required to get underneath that size. And should I set limits to width and height in first stage based on total size required, i.e if the total size is too small it would be impossible to get a good image if compression to a size that is too small
tagged with: java-2d
has comment: http://stackoverflow.com/comment/33371678
downvote count: 0
has answer: http://stackoverflow.com/a/22016608
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/69378202
has comment: http://stackoverflow.com/comment/69415025
tagged with: bufferedimage
tagged with: java-8
type: Question
has comment: http://stackoverflow.com/comment/69458175
has comment: http://stackoverflow.com/comment/69541450

http://stackoverflow.com/comment/33520020
comment on: http://stackoverflow.com/q/22099000
score: 0
type: QuestionComment
has text: It sure is an integer
type: Comment

http://stackoverflow.com/q/22030127
favorite count: 0
upvote count: 0
has comment: http://stackoverflow.com/comment/33397678
has answer: http://stackoverflow.com/a/22030318
tagged with: jframe
has title: Why is nothing showing up in my Java GUI?
tagged with: swing
has body: I am currently working on a calculator. Right now, I am trying to gain experience with coding Java GUI, by making a simple program that makes a window with a text field. The code can compile without errors, but when I execute the program, the window appears, but without the text field. How do I make the text field visible? The code is shown as follows: import javax.swing.*; import java.awt.*; public class Window { public static void main(String[] args) { JFrame Window = new JFrame("Window"); Window.setSize(400,550); Window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel Panel = new JPanel (new FlowLayout()); JTextField TextField = new JTextField("Type something here"); Window.setVisible(true); } }
possible better answer: http://stackoverflow.com/a/22030201
type: AnsweredQuestion
tagged with: java
score: -1
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33397675
tagged with: awt
has answer: http://stackoverflow.com/a/22030201
has answer: http://stackoverflow.com/a/22030149
accepted answer: http://stackoverflow.com/a/22030149
answer count: 3
tagged with: user-interface

http://stackoverflow.com/q/22017994
type: Question
tagged with: libgdx
tagged with: camera
tagged with: java
accepted answer: http://stackoverflow.com/a/22019750
possible better answer: http://stackoverflow.com/a/22018214
answer count: 2
upvote count: 1
tagged with: user-interface
has answer: http://stackoverflow.com/a/22019750
downvote count: 0
favorite count: 0
has body: Im having a box2d screen where you can move the camera around. I want to be able to show a scene2d menu around that screen that moves with the camera. The problem right now is that I have no idea how to do this. The BuildScreen below extends from an AbstractControllerScreen which is a class that implements Screen and uses a ViewScreen and ModelScreen. These matches that of the MVC model. Below is the screen that represents the screen where I want the menu and the box2d area. I apologize in beforehand if there is too much code but this is what I have to work with. public class BuildScreen extends AbstractControllerScreen{ private World world; private List&lt;BuildPart&gt; ships; private float r = 70f*BodyConstants.WORLD_TO_BOX; private Renderable stageRendrable; private final Stage stage; private Entity stageEntity; private InputMultiplexer inputHandler; public BuildScreen (Nimby game) { super(game, new CameraControllerBuild()); ships = new LinkedList&lt;&gt;(); World world = new World(Vector2.Zero, true); this.world = world; inputHandler = new InputMultiplexer(); stageRendrable = new Renderable() { @Override public void render(final SpriteBatch batch) { Table.drawDebug(stage); } @Override public void debug(final ShapeRenderer sr) { } }; stageEntity = new Entity() { public void update(final float delta, final OrthographicCamera cam) { float width = Gdx.graphics.getWidth(); float height = Gdx.graphics.getHeight(); stage.act(delta); } }; stage = new Stage(); stage.setCamera(getViewScreen().getCam()); inputHandler.addProcessor(stage); Bundle stageBundle = new Bundle(stageEntity, stageRendrable); addBundles(stageBundle); //Box2d code omitted// Bundle b = new Bundle(engine, engine); addBundles(b); inputHandler.addProcessor(new BuildScreenInputProcessor(world, getCamera(), stage)); world.setContactListener(new NodeSnapper()); Gdx.input.setInputProcessor(inputHandler); } public void resize(int width, int height) { getViewScreen().getCam().setToOrtho(false, 1, height / width…
has answer: http://stackoverflow.com/a/22018214
type: AnsweredQuestion
has title: Making an UI for Libgdx that moves with the camera
score: 1
tagged with: box2d

http://stackoverflow.com/comment/33551918
has text: For which element are you getting this exception?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22116106

http://stackoverflow.com/a/22099525
answers question: http://stackoverflow.com/q/22099307
has comment: http://stackoverflow.com/comment/33521396
has comment: http://stackoverflow.com/comment/33774377
has comment: http://stackoverflow.com/comment/33705344
has comment: http://stackoverflow.com/comment/33764774
has body: In the OnCreateView method, you need to setup your tabs programatically. Something like this: TabHost host = (TabHost) root.findViewById(R.id.tab_host); host.setup(); TabSpec spec = host.newTabSpec("Tab One"); spec.setContent(R.id.tab_one_container); spec.setIndicator("One"); host.addTab(spec); spec = host.newTabSpec("Tab Two"); spec.setContent(R.id.tab_two_container); spec.setIndicator("Two"); host.addTab(spec); spec = host.newTabSpec("Tab Three"); spec.setContent(R.id.tab_three_container); spec.setIndicator("Three"); host.addTab(spec); host.setCurrentTab(0); And in your xml you need to set the tabs up, too. Like this: <?xml version="1.0" encoding="utf-8"?> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:layout_marginLeft="20dp" android:text="Test1" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:layout_marginLeft="20dp" android:text="Test2" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:layout_marginLeft="20dp" android:text="Test3" /> This should set up your 3 tabs.
has comment: http://stackoverflow.com/comment/33706060
has comment: http://stackoverflow.com/comment/33707231
has comment: http://stackoverflow.com/comment/33794070
has comment: http://stackoverflow.com/comment/33707484
has comment: http://stackoverflow.com/comment/33705883
has comment: http://stackoverflow.com/comment/33706433
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33522450
has comment: http://stackoverflow.com/comment/33772997
accepted answer of: http://stackoverflow.com/q/22099307
type: Answer

http://stackoverflow.com/a/22117036
has comment: http://stackoverflow.com/comment/33552948
has body: there are many possible solutions for this kind of problem, eg: use enums use chain of responsibilty pattern if it is suitable refactor your swithes to private methods for more readable code Martin Fowler - Refactoring can be a good source (chapter 9 - Simplifying conditional expressions)
answers question: http://stackoverflow.com/q/22116884
score: 0
type: Answer

http://stackoverflow.com/a/22018324
downvote count: 0
answers question: http://stackoverflow.com/q/22011757
type: Answer
has comment: http://stackoverflow.com/comment/69952701
has comment: http://stackoverflow.com/comment/33414199
has comment: http://stackoverflow.com/comment/33408374
accepted answer of: http://stackoverflow.com/q/22011757
score: 10
has comment: http://stackoverflow.com/comment/104908564
upvote count: 10
has body: Here's what (most probably) happens. Your whole test method is transactional. The calls of the service thus happen in the same transaction as the code of the test itself. In the test, you're creating and persisting a Product, without any license. This stores a Product instance in the session cache, tied to the transaction. This product has an empty list of licenses. Then you call a service method, still inside the same transaction, that creates a license whose product is the produc you created previously. My guess is that the code of this service looks like the following: Product product = (Product) session.get(Product.class, productId); ProductLicense license = new ProductLicense(); license.setProduct(product); session.persist(license); In the code above, the product is obtained from the session cache, and the license is then persisted with the found product. Note that the code sets the product of the license, but it doesn't add the license to the product, which is the problem. Then you're getting the product by ID, still in the same transaction. Hibernate thus retrieves the product directly from the cache. And in the cache, since you omitted to add the license to the product, the license list is still empty. So, in short, it's your responsibility to maintain both sides of the bidirectional association. If you only initialize the owner side, Hibernate will persist the association, and will initialize the list correctly if it loads the product from the database. But while the product is in the cache, it stays as you stored it in the cache. This is why you see an empty list, unless you explicitely clear the session and thus reload the state from the database.
has comment: http://stackoverflow.com/comment/33382561
has comment: http://stackoverflow.com/comment/33380176
type: AcceptedAnswer

http://stackoverflow.com/a/22180296
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33670445
has comment: http://stackoverflow.com/comment/33671729
has comment: http://stackoverflow.com/comment/33666460
has comment: http://stackoverflow.com/comment/33670541
answers question: http://stackoverflow.com/q/22106436
has comment: http://stackoverflow.com/comment/33671556
has body: This sounds like an Ubuntu permissions error. Your personal Ubuntu user has execute access, but the user / process that is running the java file may not.
upvote count: 1

http://stackoverflow.com/a/22076078
downvote count: 0
has comment: http://stackoverflow.com/comment/33545619
answers question: http://stackoverflow.com/q/22075910
upvote count: 2
has body: The minimum/maximum of array values must come from that array. If the array is empty, there there is no value to take. Returning Integer.MAX_VALUE OR Integer.MIN_VALUE here would be wrong, because those values aren't in the array. Nothing is in the array. Mathematically, the answer is the empty set, but that isn't a valid value among possible int values. There is no possible int correct answer, so the only possible correct course of action is to throw an Exception.
type: Answer
score: 2

shell
tags question: http://stackoverflow.com/q/22032283
tags question: http://stackoverflow.com/q/22128406
tags question: http://stackoverflow.com/q/22167773
tags question: http://stackoverflow.com/q/22168649
tag name: shell
tags question: http://stackoverflow.com/q/22056883
tags question: http://stackoverflow.com/q/22071322
tags question: http://stackoverflow.com/q/22046252
tags question: http://stackoverflow.com/q/22164358
type: Tag
tags question: http://stackoverflow.com/q/22016481
tags question: http://stackoverflow.com/q/22019057

http://stackoverflow.com/a/22128677
score: 1
upvote count: 1
has body: You need a do-while loop, which performs an action and then checks for condition to do it again. This has a difference with regular while loop. do-while loops have to perform that block of code at least once. So change your main method like this: public static void main(String[] args) { JOptionPane.showMessageDialog(null, " Play the Game \"Rock, Paper, Scissors?\""); String computerSide, userSide; do { computerSide = ComputerChoice(); userSide = UserChoice(); if(userSide != null) { JOptionPane.showMessageDialog(null, "The computer's choice is " + computerSide + "."); Winner(computerSide, userSide); } else { JOptionPane.showMessageDialog(null, "Error: Improper UserEntry. Please enter either" + " 'rock', 'paper', or'scissors'."); } } while(JOptionPane.showConfirmDialog(null, "Play Again?", "Rock-Paper-Scissors", JOptionPane.YES_NO_OPTION) == 0); }
downvote count: 0
answers question: http://stackoverflow.com/q/22128437
type: Answer

http://stackoverflow.com/q/22031274
answer count: 1
linked to: http://stackoverflow.com/q/4027289
has body: I have a question about getting a JSlider to point the left instead of right.. BUT, I need it to do so only for one JSlider. This question is very similar but the answer to it only helped if you wanted all JSliders to point the wrong way. Here is a photoshopped image of what i want.
has comment: http://stackoverflow.com/comment/33399757
favorite count: 0
has comment: http://stackoverflow.com/comment/33399743
accepted answer: http://stackoverflow.com/a/22032619
has comment: http://stackoverflow.com/comment/33399658
upvote count: 1
tagged with: swing
type: AnsweredQuestion
tagged with: jslider
has title: JSlider arrow pointing left?
score: 1
tagged with: java
type: Question
tagged with: custom-component
downvote count: 0
has answer: http://stackoverflow.com/a/22032619

http://stackoverflow.com/a/22095384
downvote count: 0
type: Answer
has body: The HttpHandler is executing in an I/O thread. As noted in the documentation: IO threads perform non blocking tasks, and should never perform blocking operations because they are responsible for multiple connections, so while the operation is blocking other connections will essentially hang. One IO thread per CPU core is a reasonable default. The request lifecycle docs discuss how to dispatch a request to a worker thread: import io.undertow.Undertow; import io.undertow.server.*; import io.undertow.util.Headers; public class Under { public static void main(String[] args) { Undertow server = Undertow.builder() .addListener(8080, "localhost") .setHandler(new HttpHandler() { public void handleRequest(HttpServerExchange exchange) throws Exception { if (exchange.isInIoThread()) { exchange.dispatch(this); return; } exchange.getResponseHeaders() .put(Headers.CONTENT_TYPE, "text/plain"); exchange.getResponseSender() .send("Hello World"); } }) .build(); server.start(); } } I noted that you won't necessarily get one worker thread per request - when I set a breakpoint on the header put I got about one thread per client. There are gaps in both the Undertow and the underlying XNIO docs so I'm not sure what the intention is.
score: 15
upvote count: 15
answers question: http://stackoverflow.com/q/22092146
has comment: http://stackoverflow.com/comment/59004679

http://stackoverflow.com/comment/33446977
comment on: http://stackoverflow.com/a/22057739
score: 0
type: AnswerComment
type: Comment
has text: @Cuder_VN I did not realize that you wanted to allow other characters after the beginning of the string. Take a look at the update.

http://stackoverflow.com/q/22155722
favorite count: 0
has body: I have a DAO called Foo. MongoTemplate wants to map this to the database collection named foos. The problems are: In Mongo, the collection is named Foos. The Foo object comes from a third-party library and all its constructors are private. How do I configure my Spring Beans such that MongoTemplate--via a MongoItemReader--knows the collection Foos maps to my Document Foo? If it helps, I'm primarily concerned with reading data from MongoDB.
upvote count: 1
tagged with: spring
has comment: http://stackoverflow.com/comment/33670061
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/22484059
type: Question
tagged with: mongodb
downvote count: 0
tagged with: spring-mongo
tagged with: spring-batch
has title: How to set MongoTemplate Collection Mapping
answer count: 1
accepted answer: http://stackoverflow.com/a/22484059
has comment: http://stackoverflow.com/comment/33669060
score: 1

http://stackoverflow.com/comment/33620942
score: 0
type: AnswerComment
type: Comment
has text: To be able to update the UI, call the no-arg Handler() constructor from the UI thread. You can send it Messages from any thread, if needed. This works, at least until the Activity stops.
comment on: http://stackoverflow.com/a/22121297

http://stackoverflow.com/q/22118487
has comment: http://stackoverflow.com/comment/33556574
answer count: 2
has comment: http://stackoverflow.com/comment/33559513
upvote count: 1
has comment: http://stackoverflow.com/comment/33557354
has body: The last year I have been working on a hobby project. I use Spring MVC (4 at the moment) and I have created a web service trying to adhere to REST principles. I have a resource named Athlete that have relations to other resources such as SportEvent, 'Trainer` and so on. These relations are not embedded in the athlete resource. Instead they are links. This is an example: { "firstName": "James", "lastName":"Smith", "links": [{ "rel": "trainer", "href" : "http://somehost.com/sport/trainers/4" }, { "rel": "sport-events", "href" : "http://somehost.com/sport/athletes/4/sport-events" }] } I am currently writing the client side in AngularJS and I am going to consume this API. It was during this I discovered something that I hadn't thought through. How are the client actually going to consume this? Let say I am building the regular detail page for a athlete. I want to show the athletes trainer as well. I have to somehow have a HTTP client library that is able to resolve the relations I want and attach the response to the "parent" resource (the one that has the relations) in a recursive manner. How is it actually intended to navigate an API like this? You can't follow links without explicitly stating which you want to follow? Because if you don't you will end up creating potentially huge objects. You want some kind of criteriea? I am definitly interested in how to actually consume my API (sounds weird, but I had not thought through the actual process of resolving the links dynamically). And it would be a huge bonus if I could get an explanation on how to do it in JavaScript (using a library is fine). I am using AngularJS so how to apply it there would be even better.
has comment: http://stackoverflow.com/comment/33559741
has comment: http://stackoverflow.com/comment/33583478
has comment: http://stackoverflow.com/comment/33559061
favorite count: 0
tagged with: rest
has comment: http://stackoverflow.com/comment/33555626
tagged with: angularjs
type: UnansweredQuestion
tagged with: spring
has answer: http://stackoverflow.com/a/22121874
has comment: http://stackoverflow.com/comment/33559566
has answer: http://stackoverflow.com/a/22118918
downvote count: 0
has comment: http://stackoverflow.com/comment/33559580
has comment: http://stackoverflow.com/comment/33559683
score: 1
has title: Organizing and consuming an API that apply HATEOAS
tagged with: java
has comment: http://stackoverflow.com/comment/33557587
has comment: http://stackoverflow.com/comment/33559630
has comment: http://stackoverflow.com/comment/33557453
type: Question
linked to: http://stackoverflow.com/q/13542335
has comment: http://stackoverflow.com/comment/33578041
tagged with: javascript

http://stackoverflow.com/q/22035337
accepted answer: http://stackoverflow.com/a/22035534
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33408217
possible better answer: http://stackoverflow.com/a/22035398
has comment: http://stackoverflow.com/comment/33407762
has comment: http://stackoverflow.com/comment/33406380
has answer: http://stackoverflow.com/a/22035398
type: Question
has body: how to get 2 biggest value in hashmap? eg. i have collection{ dare = 10, to =20, be =15, different = 10}, if we count manually the first biggest value is 20 that the key is to, and the second biggest value is 15 the key is be, According to Finding Key associated with max Value in a Java Map i use: Map.Entry&lt;String, Float&gt; max1 = null; Map.Entry&lt;String, Float&gt; max2 = null; //searching the first biggest value for(Map.Entry&lt;String, Float&gt; en : TFIDF.entrySet()){ if (max1 == null || en.getValue().compareTo(max1.getValue()) &gt; 0){ max1 = en; } } //searching the second biggest value for(Map.Entry&lt;String, Float&gt; en : TFIDF.entrySet()){ if (max2 == null || en.getValue().compareTo(max2.getValue()) &lt;= max1.getValue()){ max2 = en; } } but after i compare with the max1 the value return the min value.
has answer: http://stackoverflow.com/a/22035534
score: 0
has title: how to get two max value in hashmap
tagged with: java
answer count: 3
tagged with: collections
tagged with: hashmap
linked to: http://stackoverflow.com/q/5911174
has answer: http://stackoverflow.com/a/22035488

http://stackoverflow.com/comment/33515173
type: Comment
has text: maybe you have to add jackson jars in your classpath
comment on: http://stackoverflow.com/q/22096323
score: 0
type: QuestionComment

http://stackoverflow.com/q/22159599
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/22167278
accepted answer: http://stackoverflow.com/a/22167278
tagged with: datetime
tagged with: swt
has body: I have a DateTime spinner defined like this: //Class Global DateTime dateMin = null; //added to the UI DateTime dateMin = new DateTime(grpPlaybackSearchOptions, SWT.BORDER); dateMin.setBounds(335, 44, 123, 23); later on in my code I'd like the user to be able to load a date that may have been saved off. Digging through the swt DateTime docs I'm not seeing how I can update the date. I've tried this but received an exception error: //running from a method dateMin.setDate(pMinDate[0], pMinDate[1], pMinDate[2]); Can the object be not be updated or am I trying to update the object incorrectly? Thanks!
has title: swt DateTime setDate() error
type: AnsweredQuestion
tagged with: java
type: Question

static
tags question: http://stackoverflow.com/q/22038359
tags question: http://stackoverflow.com/q/22135623
tags question: http://stackoverflow.com/q/22088010
tags question: http://stackoverflow.com/q/22118784
tags question: http://stackoverflow.com/q/22025948
tags question: http://stackoverflow.com/q/22126077
tags question: http://stackoverflow.com/q/22085215
tags question: http://stackoverflow.com/q/22153140
tags question: http://stackoverflow.com/q/22134357
tags question: http://stackoverflow.com/q/22103064
tags question: http://stackoverflow.com/q/22161754
tags question: http://stackoverflow.com/q/22018910
tags question: http://stackoverflow.com/q/22126403
tags question: http://stackoverflow.com/q/22123608
tags question: http://stackoverflow.com/q/22102248
tag name: static
tags question: http://stackoverflow.com/q/22082268
tags question: http://stackoverflow.com/q/22029064
tags question: http://stackoverflow.com/q/22056770
type: Tag

netbeans-7
tags question: http://stackoverflow.com/q/22045016
tags question: http://stackoverflow.com/q/22114201
tags question: http://stackoverflow.com/q/22122626
tags question: http://stackoverflow.com/q/22063675
tag name: netbeans-7
tags question: http://stackoverflow.com/q/22074361
tags question: http://stackoverflow.com/q/22158833
type: Tag
tags question: http://stackoverflow.com/q/22166048
tags question: http://stackoverflow.com/q/22104782
tags question: http://stackoverflow.com/q/22094893
tags question: http://stackoverflow.com/q/22010530

http://stackoverflow.com/q/22156607
answer count: 1
has comment: http://stackoverflow.com/comment/33623925
duplicate of: http://stackoverflow.com/q/1326071
tagged with: jvm
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/95635
has answer: http://stackoverflow.com/a/22156641
has body: I would like to understand if Java programs are Interpreted or compiled, and why? I (think I) know the definitions of compilation and intrepertations: Compilation - Translates the source code to machine code. Then the machine code can be executed. Interpreted - Translates the code and runs it at the same time. Translates one line of source code, runs it, translates the next line, runs it, and so on. Are these definitions correct? If so, are Java programs Interpreted or compiled, and why?
has comment: http://stackoverflow.com/comment/33624152
tagged with: java
tagged with: interpretation
type: Question
tagged with: compilation
has title: Java - Interpreted or compiled?
score: 0
linked to: http://stackoverflow.com/q/1326071

http://stackoverflow.com/comment/33618223
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22153390
has text: Have you tried saving the result in sharedpreferences and check for it inside onreceive before running the thread ? the next time onreceive gets called it should check this value and start the thread only if it is not set.
score: 0

http://stackoverflow.com/a/22159662
has comment: http://stackoverflow.com/comment/36020406
upvote count: 4
type: AcceptedAnswer
downvote count: 0
score: 4
has comment: http://stackoverflow.com/comment/36061241
type: Answer
has comment: http://stackoverflow.com/comment/33813412
accepted answer of: http://stackoverflow.com/q/22158537
has body: Check encoding of messages files, i.e. Idea for some reason creates messages.xy files initially with iso-8859-1 encoding - it is probably because Standard Java API is designed to use ISO 8859-1 encoding for the properties file (IntelliJ docs). To switch to utf-8 in Idea you need first Mark as Plain text, switch the encoding and finally Mark as properties the file again. Of course it's quite possible that you use other IDE/text editor, anyway file's encoding is first thing you need to check,I can ensure you that Play supports perfectly messages files even in Chinese if they are encoded properly.
answers question: http://stackoverflow.com/q/22158537
has comment: http://stackoverflow.com/comment/36059239

http://stackoverflow.com/comment/33539482
has text: @ylun Are you willing to partner? If you're willing to discuss let me know.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22109001

http://stackoverflow.com/q/22039388
tagged with: apache-poi
has body: I need to extract text from large files(max limit 50MB) Files may be doc,ppt,xls,txt or pdf format. So far I've used Apache POI 'http://poi.apache.org/' For Microsoft Office documents and PDFBox to extract text from PDF. However the extraction process gets slow as files get large specially with following files. Results I've achieved so far: 1.PPTX - 45MB - 3 Minutes apx 2.PDF - 62MB - 2 Minutes apx 3.Docx - 32MB - 15 Seconds apx 4.XLS - 17MB - 10 Seconds apx 5.XLSX - 7MB - 20 Seconds apx I need the process to be fast. Which APIs can I use to achieve this, and what best practices can help me enhance my application's performance?
tagged with: java
tagged with: excel
type: Question
has title: Extract text from large files
has comment: http://stackoverflow.com/comment/33418089
tagged with: pdfbox
has answer: http://stackoverflow.com/a/22040341
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/22059527
has comment: http://stackoverflow.com/comment/33415000
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33417420
tagged with: text-extraction

http://stackoverflow.com/comment/33444046
has text: @JohnRasch What else (other than the list) would you then rather return in order to provide the caller with an ordered collection of return values?
comment on: http://stackoverflow.com/q/22055840
type: Comment
type: QuestionComment
score: 0

marker
tag name: marker
tags question: http://stackoverflow.com/q/22012817
type: Tag

http://stackoverflow.com/a/22053596
upvote count: 1
type: Answer
downvote count: 0
score: 1
has body: I would fish for cause at line audioInputStream = AudioSystem.getAudioInputStream(soundFile); and would start with verifying that file is ok (just because you created File object it does not mean that it is associeated with actual file), if it points to REAL file in file system. Morever, do you want to read the file from filesystem every time you hover over the button. Don't you want to store the data into memory?
answers question: http://stackoverflow.com/q/22052499

http://stackoverflow.com/comment/33615749
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/22152204
has text: This is a huge question. Simple answer, always use the most appropriate data structure for the problem you're solving. Start reading :)

http://stackoverflow.com/a/22165030
type: Answer
has body: @user1849139 1) public interface genaricInterface{ public void commonMethod(); } 2)implement above interface to your class and override the method 3)public Class class1 implements genaricInterface{ public void commonMethod(){ //write your logic here for class1 } } 4)Like above class you can implement to n-number of classes in java after that 5)create instance like genaricInterface gi = new class1(); 6)call method gi.commonMethod();
score: 0
answers question: http://stackoverflow.com/q/22163978

servlets
tags question: http://stackoverflow.com/q/22041707
tags question: http://stackoverflow.com/q/22124736
tags question: http://stackoverflow.com/q/22150562
tags question: http://stackoverflow.com/q/22045514
tags question: http://stackoverflow.com/q/22038117
tags question: http://stackoverflow.com/q/22165106
tags question: http://stackoverflow.com/q/22121374
tags question: http://stackoverflow.com/q/22116128
tags question: http://stackoverflow.com/q/22018599
tags question: http://stackoverflow.com/q/22158004
tags question: http://stackoverflow.com/q/22056379
tags question: http://stackoverflow.com/q/22156931
tags question: http://stackoverflow.com/q/22092620
tags question: http://stackoverflow.com/q/22096380
tags question: http://stackoverflow.com/q/22076879
tags question: http://stackoverflow.com/q/22078670
tags question: http://stackoverflow.com/q/22042973
tags question: http://stackoverflow.com/q/22165966
tags question: http://stackoverflow.com/q/22126807
tags question: http://stackoverflow.com/q/22091577
tags question: http://stackoverflow.com/q/22010038
tags question: http://stackoverflow.com/q/22117608
tags question: http://stackoverflow.com/q/22146598
tags question: http://stackoverflow.com/q/22060426
tags question: http://stackoverflow.com/q/22111569
tags question: http://stackoverflow.com/q/22146742
tags question: http://stackoverflow.com/q/22028290
tags question: http://stackoverflow.com/q/22123716
tags question: http://stackoverflow.com/q/22151344
tags question: http://stackoverflow.com/q/22096266
tags question: http://stackoverflow.com/q/22135615
tags question: http://stackoverflow.com/q/22128143
tags question: http://stackoverflow.com/q/22031646
tags question: http://stackoverflow.com/q/22064355
tags question: http://stackoverflow.com/q/22152704
tags question: http://stackoverflow.com/q/22142374
tags question: http://stackoverflow.com/q/22166472
tags question: http://stackoverflow.com/q/22068854
tags question: http://stackoverflow.com/q/22155095
tags question: http://stackoverflow.com/q/22126864
tags question: http://stackoverflow.com/q/22050171
tags question: http://stackoverflow.com/q/22069087
tags question: http://stackoverflow.com/q/22036850
tags question: http://stackoverflow.com/q/22091071
tags question: http://stackoverflow.com/q/22128382
tags question: http://stackoverflow.com/q/22121454
tags question: http://stackoverflow.com/q/22117250
tags question: http://stackoverflow.com/q/22038378
tags question: http://stackoverflow.com/q/22124300
tags question: http://stackoverflow.com/q/22030448
tags question: http://stackoverflow.com/q/22012143
tags question: http://stackoverflow.com/q/22086840
tags question: http://stackoverflow.com/q/22055191
tags question: http://stackoverflow.com/q/22072895
tags question: http://stackoverflow.com/q/22071829
tags question: http://stackoverflow.com/q/22148282
tags question: http://stackoverflow.com/q/22098642
tags question: http://stackoverflow.com/q/22010544
tags question: http://stackoverflow.com/q/22112647
tags question: http://stackoverflow.com/q/22006726
tags question: http://stackoverflow.com/q/22167723
tags question: http://stackoverflow.com/q/22140017
tag name: servlets
tags question: http://stackoverflow.com/q/22138277
tags question: http://stackoverflow.com/q/22060955
tags question: http://stackoverflow.com/q/22061692
tags question: http://stackoverflow.com/q/22044958
tags question: http://stackoverflow.com/q/22031581
type: Tag
tags question: http://stackoverflow.com/q/22088745
tags question: http://stackoverflow.com/q/22019785
tags question: http://stackoverflow.com/q/22164837
tags question: http://stackoverflow.com/q/22167708
tags question: http://stackoverflow.com/q/22150285
tags question: http://stackoverflow.com/q/22127178
tags question: http://stackoverflow.com/q/22062974

http://stackoverflow.com/a/24796155
has body: try edit your WEB.XML file. Check on top of file **http://java.sun.com/xml/ns/j2ee/web-app_3_0.xsd" &gt;**
downvote count: 0
answers question: http://stackoverflow.com/q/22037725
score: 3
type: Answer
upvote count: 3

http://stackoverflow.com/a/22156946
upvote count: 3
downvote count: 0
answers question: http://stackoverflow.com/q/22081505
type: Answer
has body: With a difficult debugging problem, you need to find a way to reproduce it. Only then will you be able to test experimental changes and determine if they make the problem better or worse. In this case, I'd try writing loops that rapidly create &amp; delete server connections, that create a server connection and rapidly send it memory-expensive requests, etc. After you can reproduce it, try reducing the heap size to see if you can reproduce it faster. But do that second since a small heap might not hit the "GC overhead limit" which means the GC is spending excessive time (98% by some measure) trying to recover memory. For a memory leak, you need to figure out where in the code it's accumulating references to objects. E.g. does it build a Map of all incoming network requests? A web search https://www.google.com/search?q=how+to+debug+java+memory+leaks shows many helpful articles on how to debug Java memory leaks, including tips on using tools like the Eclipse Memory Analyzer that you're using. A search for the specific error message https://www.google.com/search?q=GC+overhead+limit+exceeded is also helpful. The no-op finalize() methods shouldn't cause this problem but they may well exacerbate it. The doc on finalize() reveals that having a finalize() method forces the GC to twice determine that the instance is unreferenced (before and after calling finalize()). So once you can reproduce the problem, try deleting those no-op finalize() methods and see if the problem takes longer to reproduce. It's significant that there are many AbstractReferenceMap$WeakRef instances in memory. The point of a weak reference is to refer to an object without forcing it to stay in memory. AbstractReferenceMap is a Map that lets one make the keys and/or values be weak references or soft references. (The point of a soft reference is to try to keep an object in memory but let the GC free it when memory gets low.) Anyway, all those WeakRef instances in memory are probably exacerbating the prob…
has comment: http://stackoverflow.com/comment/33769680
score: 3

http://stackoverflow.com/a/22167568
type: Answer
upvote count: 1
has body: recently implemented in primefaces showcase http://www.primefaces.org/showcase-labs/push/chart.jsf
has comment: http://stackoverflow.com/comment/124250747
answers question: http://stackoverflow.com/q/22151322
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22151322
score: 1

http://stackoverflow.com/a/22051495
answers question: http://stackoverflow.com/q/22050785
upvote count: 1
has body: Now that we know which line it is, the problem lies in this if if (c[npp] != null) { // HERE YOU CHECK IT IS NOT NULL JOptionPane.showMessageDialog(null, "Já possui um cliente neste campo."); } else { // PASS THIS POINT, c[npp] CAN ONLY BE NULL String ccpf = JOptionPane.showInputDialog("Qual o cpf do cliente " + npp + "?"); for (int np2 = 1; np2 &lt; 11; np2++) { if ((c[np2] != null) &amp;&amp; (c[np2].getCpf().equals(ccpf))) { JOptionPane.showMessageDialog(null, "Existe um usuário com este CPF.\n"); flag = 1; break; } else { c[npp].setCpf(ccpf); // NULL POINTER... FOR A GOOD REASON break; } } You either need to change the if for if (c[npp] == null) { or you wanted to write c[np2].setCpf(ccpf); instead. I know Eclipse IDE can find this on the fly if set properly. If you aren't using a IDE, I strongly suggest you start to.
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/33435800
score: 1

http://stackoverflow.com/comment/33458129
type: QuestionComment
has text: @Andreas has your answer !
comment on: http://stackoverflow.com/q/22064613
score: 0
type: Comment

http://stackoverflow.com/q/22119305
has answer: http://stackoverflow.com/a/22119366
has answer: http://stackoverflow.com/a/22119334
tagged with: initialization
favorite count: 0
score: 2
upvote count: 2
answer count: 5
has answer: http://stackoverflow.com/a/22119341
has body: Is it bad practice to set newWeight to 0.0 (before the switch block) before I use it? If i just declare it, I get an error in the complier saying variable newWeight might not have been initialized. import java.util.*; public class SpaceBoxing { public static void main(String[] args){ Scanner s = new Scanner(System.in); System.out.print("Please enter your current weight "); float weight = s.nextFloat(); System.out.println("I have information on the following planets"); System.out.println("1. Venus 2. Mars 3. Jupiter"); System.out.println("4. Saturn 5. Uranus 6. Neptune"); System.out.println(" "); System.out.println("Which planet are you visiting"); int planet = s.nextInt(); double newWeight = 0.0; switch(planet){ case 1: newWeight = weight*0.78; break; case 2: newWeight = weight*0.39; break; case 3: newWeight = weight*2.56; break; case 4: newWeight = weight*1.17; break; case 5: newWeight = weight*1.05; break; case 6: newWeight = weight*1.23; break; } System.out.println("Your weight would be " + newWeight + " pounds on that planet"); } }
has comment: http://stackoverflow.com/comment/33556987
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22119329
tagged with: java
has title: Is this the right way to initialize a variable
type: Question
accepted answer: http://stackoverflow.com/a/22119341
possible better answer: http://stackoverflow.com/a/22119329
downvote count: 0
has answer: http://stackoverflow.com/a/22119376
has comment: http://stackoverflow.com/comment/33556953

http://stackoverflow.com/q/22095583
has title: Redirect from managed bean event JSF
tagged with: jsf-2
score: 0
has body: I have a JSF page containing a Pie Chart. The idea is that when the Sector of Pie Chart is clicked the application redirects to another page. I am facing Challenges Redirecting Because it is Only taking Full url to the page which is not Dynamic as it will change depending on the environment. My ItemSelect Method is : public void itemSelect(ItemSelectEvent event) { try { FacesContext.getCurrentInstance(). getExternalContext().redirect("http://localhost:8084/SIMBANK_BI/faces/OpenedAccountsProductTypeLevel.xhtml"); } catch (IOException asd) { System.err.println(asd.getMessage()); } } My JSF Page: &lt;left&gt; &lt;p:growl id="growl" showDetail="true" /&gt; &lt;p:pieChart id="custom" value="#{OpenedAccountsBranchLevelBean.pieModel}" legendPosition="w" showDataLabels="true" style="width:500px;height:400px" sliceMargin="2"&gt; &lt;p:ajax event="itemSelect" listener="#{OpenedAccountsBranchLevelBean.itemSelect}" update="growl" /&gt; &lt;/p:pieChart&gt; &lt;/left&gt; I have tried; FacesContext.getCurrentInstance(). getExternalContext().redirect("/faces/OpenedAccountsProductTypeLevel.xhtml"); I have also tried: FacesContext.getCurrentInstance(). getExternalContext().redirect("/OpenedAccountsProductTypeLevel.xhtml"); My Question is how Can I redirect without Having to place in the Entire URL??
answer count: 1
tagged with: http-redirect
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22095808
tagged with: java
accepted answer: http://stackoverflow.com/a/22095808
type: Question

http://stackoverflow.com/comment/72712967
comment on: http://stackoverflow.com/a/42794426
score: 0
type: AnswerComment
type: Comment
has text: You may read the JLS I quoted and my answer again. It works because it is a protected field (declared in superclass of another package), and it is accessing thru reference with type same as (or subclass of) itself.

http://stackoverflow.com/comment/60533304
type: Comment
comment on: http://stackoverflow.com/a/24051823
has text: @farmir One can `adb pull` those files, as detailed [here](https://www.reddit.com/r/Android/comments/1r2zha/how_i_managed_to_use_my_android_device_with_a).
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33606886
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22147225
has text: yes that is a better answer but I still need it to display as suggested in the question! I know i have used tab but is there a way of specifying the exact space that the objects are moved so I could set them individually?
score: 0

http://stackoverflow.com/q/22122059
has answer: http://stackoverflow.com/a/51404017
downvote count: 0
has title: Stopping a Job in the beforeStep in Spring Batch
favorite count: 0
answer count: 5
type: UnansweredQuestion
tagged with: spring
has answer: http://stackoverflow.com/a/22142649
has answer: http://stackoverflow.com/a/22147859
tagged with: java
has body: I want to be able to stop a job when a timing threshold is met. There are 2 approaches I was thinking about. First was to stop the job in the afterStep. However, I do not want it to have a Stopped status if it is at the completion of the last step. Therefore, I am going with stopping it in the beforeStep. I tried experimenting with public void beforeStep(StepExecution stepExecution) { stepExecution.setStatus(BatchStatus.STOPPED); return; } and public void beforeStep(StepExecution stepExecution) { stepExecution.setExitStatus(ExitStatus.STOPPED); return; } Neither of these worked. Any suggestions?
has answer: http://stackoverflow.com/a/22129112
type: Question
linked to: http://stackoverflow.com/q/38023018
score: 5
upvote count: 5
tagged with: spring-batch
has answer: http://stackoverflow.com/a/64761283

http://stackoverflow.com/a/22055040
has comment: http://stackoverflow.com/comment/33441964
type: Answer
answers question: http://stackoverflow.com/q/22054966
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/33441931
has body: Just create a method, private void setWidgetColors(Color ... colours){ int i=0; Color btnGrn = i++ &lt;= colours.length?colours[i-1]:new Color(159, 191, 143); //Sets the colour to a class Color txtGrn = i++ &lt;= colours.length?colours[i-1]:new Color(201, 255, 191); //Sets the colour to a class Color txtGry = i++ &lt;= colours.length?colours[i-1]:new Color(89, 89, 89); //Sets the colour to a class this.getContentPane().setBackground(i++ &lt;= colours.length ? colours[3] : new Color(127,191,95)); //Sets background color to green btnConvert.setBackground(btnGrn); //Changes the colors to green btnReset.setBackground(btnGrn); //Changes the colors to green btnClose.setBackground(btnGrn); //Changes the colors to green btnInfo.setBackground(btnGrn); //Changes the colors to green txtIncome.setBackground(txtGrn); //Changes the colors to green txtPayable.setBackground(txtGrn); //Changes the colors to green txtStatus.setBackground(txtGrn); //Changes the colors to green txtIncome.setForeground(txtGry); //Changes the colors to grey txtPayable.setForeground(txtGry); //Changes the colors to grey txtStatus.setForeground(txtGry); //Changes the colors to grey } And then private void btnGreenActionPerformed(ActionEvent evt){ Color btnGrn = new Color(159, 191, 143); //Sets the colour to a class Color txtGrn = new Color(201, 255, 191); //Sets the colour to a class Color txtGry = new Color(89, 89, 89); Color backgroundColor = new Color(127,191,95); setWidgetColors(btnGrn,txtGrn,txtGry,backgroundColor); }
downvote count: 0
has comment: http://stackoverflow.com/comment/33441953

http://stackoverflow.com/comment/33466546
comment on: http://stackoverflow.com/a/22037089
type: Comment
has text: +1 as this is the most correct answer. One nitpick though: you certainly can round doubles, in fact they are implicitly rounded - but to binary, digits, not decimal ones.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33624598
has text: I didn't say no getters/setters. I think you want to annotate the first and last name fields. You won't be saving them the database otherwise.
type: Comment
comment on: http://stackoverflow.com/a/22156609
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33548730
has text: @Andrei Nicusan Now I have provided you the whole funtion code...Please check it out
comment on: http://stackoverflow.com/q/22114201
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33394448
comment on: http://stackoverflow.com/a/22028122
has text: would it help if i posted the info of the variables when i pass in "ppp"?
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/q/22102257
has answer: http://stackoverflow.com/a/22103511
type: Question
tagged with: apache-kafka
has answer: http://stackoverflow.com/a/60038352
has body: I am trying to write Kafka producer and consumer code in Java using Eclipse. I am have downloaded the Kafka jar file and loaded as external Jar file. And it solved the dependency problem. However, there is always a unresolved error and the message looks like below: Multiple markers at this line - The type scala.Product cannot be resolved. It is indirectly referenced from required .class files - The type scala.Serializable cannot be resolved. It is indirectly referenced from required .class files I really don't know what is going on and how to fix that error. Thanks.
has title: Eclipse scala.object cannot be resolved
answer count: 3
downvote count: 0
accepted answer: http://stackoverflow.com/a/22103511
score: 8
favorite count: 0
upvote count: 8
tagged with: scala
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/46666770
tagged with: java
has answer: http://stackoverflow.com/a/46666770

http://stackoverflow.com/comment/33394674
score: 0
comment on: http://stackoverflow.com/a/22028327
type: AnswerComment
type: Comment
has text: @Pointy *"the JavaScript parser will do the work"* - that *is* the "additional parsing"

http://stackoverflow.com/comment/33747086
type: Comment
comment on: http://stackoverflow.com/a/22101754
has text: Sorry for the delay in replying, other things took over. when I try to implement the second example I get an issue at the `getCredentialsProvider` line, Eclipse tells me `The method getCredentialsProvider() is undefined for the type HttpClient` and that I need to Add cast to hc
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33412885
type: QuestionComment
has text: `selectionPanel.add(RCMCombo2);` Try and `revalidate` and `repaint` after this.
score: 0
comment on: http://stackoverflow.com/q/22039109
type: Comment

http://stackoverflow.com/q/22132867
has answer: http://stackoverflow.com/a/22133012
has title: Strange behavior in Java with recursivity
accepted answer: http://stackoverflow.com/a/22133012
has answer: http://stackoverflow.com/a/22132941
type: AnsweredQuestion
tagged with: java
has body: I am learning Java. This is my simple java test. import java.io.Console; import java.util.regex.Pattern; public class Pendu { private static final int MAX_ERRORS_ALLOWED = 10; private static final int MAX_WORDL_LENGHT = 10; public static void main(String[] args) { String motSaisi = Pendu.readMot(); System.out.println("Le mot saisi est "+motSaisi); } public static boolean hasSpecialChar (String s) { Pattern p = Pattern.compile("[^a-zA-Z]"); return (p.matcher(s).find()); } public static String readMot(){ char[] ChaineSaisi = System.console().readPassword("Joueur 1 : Veuillez saisir un mot sans chiffres ni lettres accentuées: "); String text = String.copyValueOf(ChaineSaisi); System.out.println("mot a testé "+text); if(Pendu.hasSpecialChar(text)) { Pendu.readMot(); } System.out.println("mot correct "+text); return text; } } The goal of this is to enter a word witch only characters ( a-Z A-Z) and only this.When i run this with example like this : Joueur 1 : Veuillez saisir un mot sans chiffres ni lettres accentu?es: mot a test? ))) Joueur 1 : Veuillez saisir un mot sans chiffres ni lettres accentu?es: mot a test? """ Joueur 1 : Veuillez saisir un mot sans chiffres ni lettres accentu?es: mot a test? po mot correct po mot correct """ mot correct ))) Le mot saisi est ))) ")))" ( This is not the last word i have tpaed, the last is "po"). Why this happen ?
possible better answer: http://stackoverflow.com/a/22132941
type: Question
score: 0
answer count: 2

http://stackoverflow.com/q/22144254
has comment: http://stackoverflow.com/comment/33602216
tagged with: sql
has body: I am writing a code in Java where user can type a last name in a JTextField named lastname and then search for possible match in MySQL database. Say for example, user begins to type letter "M" (case insensitive and without double quotes), all the last name that starts with letter "M*" will display on JTable. If user types a second letter, say for example "A", the results on JTable will only display last names with "MA", then if user types third letter, say for example "N", JTable will only display all the last names with "MAN***" and so on.. I have read about SELECT * FROM table WHERE lastname LIKE value and tried to use it on my program, however, I am getting an error. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxError.Exception: 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 '%' at line 1 Here's my partial code in event when there's key pressed in JTextField lastname: private void lastNameKeyPressed(java.awt.event.KeyEvent evt) { Connection conn = null; String url = "jdbc:mysql://localhost:3306/"; String dbName = "students_dbs"; Statement stmt = null; ResultSet result = null; String driver = "com.mysql.jdbc.Driver"; String databaseUserName = "user1"; String databasePassword = "test"; PreparedStatement pst = null; try{ conn = DriverManager.getConnection(url + dbName, databaseUserName, databasePassword); stmt = conn.createStatement(); System.out.println("Connected to the database."); }catch(Exception e){ System.out.println("Failed to connect ot the database."); } try{ String sql = "SELECT studentno, lastname, firstname, middlename FROM student WHERE lastname LIKE '%" + lastname.getText() + "'%"; pst = conn.prepareStatement(sql); result = pst.executeQuery(); studentsTable.setModel(DbUtils.resultSetToTableModel(result)); } catch(Exception e){ JOptionPane.showMessageDialog(null, e); } } I googled it for a day or two now, however, I am stuck. I'm kinda new in using LIKE in MySQL. Any ki…
accepted answer: http://stackoverflow.com/a/22144796
has title: Search Filter in Java and MySQL database
favorite count: 0
has answer: http://stackoverflow.com/a/34048380
possible better answer: http://stackoverflow.com/a/49988920
tagged with: swing
has comment: http://stackoverflow.com/comment/33601399
answer count: 4
has answer: http://stackoverflow.com/a/49988920
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/49624451
has comment: http://stackoverflow.com/comment/33601429
score: 3
upvote count: 3
tagged with: java
tagged with: mysql
has answer: http://stackoverflow.com/a/22144796
has comment: http://stackoverflow.com/comment/33602094
type: Question
downvote count: 0
has comment: http://stackoverflow.com/comment/33601167

http://stackoverflow.com/comment/33550552
comment on: http://stackoverflow.com/a/22097157
score: 0
type: AnswerComment
has text: KO. in my activity have registering SmsReceiver IntentFilter filter = new IntentFilter( "android.provider.Telephony.SMS_RECEIVED" ); filter.setPriority( IntentFilter.SYSTEM_HIGH_PRIORITY ); registerReceiver( new SmsReceiver(), filter ); so new error "The constructor SmsReceiver() is undefined"
type: Comment

http://stackoverflow.com/comment/33432065
has text: Yes. It sounds like you got it. You would no longer have 'amt' and would have 'dispAmt', and 'actAmt'. Good luck!
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22047191
type: AnswerComment

http://stackoverflow.com/a/22129696
has comment: http://stackoverflow.com/comment/33581202
downvote count: 0
has body: Few things to notice: in your onCreate(), you're not initializing your AdController you have onCreate11() and onCreate1() on the other hand, which are never called, as these are not Activity lifecycle methods the same goes for onDestroy1(), whatever you're doing there, is never called, because onDestroy1() is NOT Activity lifecycle method unless this is edited for the purpose of this post, MY_LB_AUDIO_ID, MY ID, APPFIREWORKS_API_KEY should be valid strings, which you can get from your LeadBolt dashboard What you have to do: 1.You should initialize your AdController in onCreate(), which gets called when Activity is created, so move the code from onCreate11() or onCreate1() to onCreate() 2. Your cleanup code can be in onDestroy(), so move it from onDestroy1() to onDestroy() 3. Make sure your MY_LB_AUDIO_ID, APPFIREWORKS_API_KEY and MY ID are valid strings. More about activities and lifecycles here, here and here.
has comment: http://stackoverflow.com/comment/33670346
has comment: http://stackoverflow.com/comment/33580674
type: Answer
has comment: http://stackoverflow.com/comment/33580273
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/22129364
has comment: http://stackoverflow.com/comment/33581358

http://stackoverflow.com/q/22148184
tagged with: android
type: AnsweredQuestion
has body: Cursor people = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); while (people.moveToNext()){ int NameIndex = people.getColumnIndex(PhoneLookup.DISPLAY_NAME); int NumIndex = people.getColumnIndex(PhoneLookup.NUMBER); String Name = people.getString(NameIndex); //String Num = people.getString(NumIndex); myArr.add(Name.toString()); myNum.add(Num.toString()); } Hello I am experiencing problems retrieving a contact's phone number where each time i enable this line of code String Num = people.getString(NumIndex); 03-03 15:38:30.436: E/AndroidRuntime(496): FATAL EXCEPTION: main 03-03 15:38:30.436: E/AndroidRuntime(496): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.GhattasAk.RingMe/com.GhattasAk.RingMe.Main}: java.lang.IllegalStateException: get field slot from row 0 col -1 failed 03-03 15:38:30.436: E/AndroidRuntime(496): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647) 03-03 15:38:30.436: E/AndroidRuntime(496): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 03-03 15:38:30.436: E/AndroidRuntime(496): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 03-03 15:38:30.436: E/AndroidRuntime(496): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 03-03 15:38:30.436: E/AndroidRuntime(496): at android.os.Handler.dispatchMessage(Handler.java:99) 03-03 15:38:30.436: E/AndroidRuntime(496): at android.os.Looper.loop(Looper.java:123) 03-03 15:38:30.436: E/AndroidRuntime(496): at android.app.ActivityThread.main(ActivityThread.java:3683) 03-03 15:38:30.436: E/AndroidRuntime(496): at java.lang.reflect.Method.invokeNative(Native Method) 03-03 15:38:30.436: E/AndroidRuntime(496): at java.lang.reflect.Method.invoke(Method.java:507) 03-03 15:38:30.436: E/AndroidRuntime(496): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 03-03 15:38:30.436: E/AndroidRuntime(496): at com.android.internal.os.Zygot…
tagged with: java
has comment: http://stackoverflow.com/comment/33608102
type: Question
answer count: 1
accepted answer: http://stackoverflow.com/a/22148270
tagged with: arraylist
score: 0
tagged with: android-listview
has title: getting contact phone number
has answer: http://stackoverflow.com/a/22148270

http://stackoverflow.com/comment/33365569
type: Comment
type: QuestionComment
score: 1
has text: Composition seems to work nicely for wrappers.
comment on: http://stackoverflow.com/q/22012790

http://stackoverflow.com/q/22065050
has comment: http://stackoverflow.com/comment/33458835
has comment: http://stackoverflow.com/comment/33458915
score: 0
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/33459221
type: Question
has comment: http://stackoverflow.com/comment/33496990
has body: I'm trying to download a file from PC to Android device (emulator or physical) Everything goes fine for small and medium sized files, but when I try to send something larger than say 10Mb, server never reaches this statement out2.println("ready");, hence the client hangs waiting for "ready" from server Seems that server stucks at this: os.write(bytearray, 0, bytearray.length); So far I've tried this on emulator, I'm going to report about results on a real device shortly Here is my client part, in Android app: Android client sends "download" string to server, then receives "ready" reply from it, and starts reading file from InputStream int filesize = 2022386; int bytesRead; int currentTot = 0; Socket socket1 = new Socket("172.16.6.119", 50001); //data line Socket socket2 = new Socket("172.16.6.119", 50001); //control line BufferedReader in2 = new BufferedReader(new InputStreamReader(socket2.getInputStream())); PrintWriter out2 = new PrintWriter(socket2.getOutputStream(), true); out2.println("download:"); //control line String usrtxt = in2.readLine(); if(usrtxt.substring(0,5).equals("ready")) //control line { byte [] bytearray = new byte [filesize]; InputStream is = socket1.getInputStream(); //data line FileOutputStream fos = new FileOutputStream(Environment.getExternalStorageDirectory().toString() + "/sunset.jpg"); BufferedOutputStream bos = new BufferedOutputStream(fos); bytesRead = is.read(bytearray,0,bytearray.length); currentTot = bytesRead; Log.e("DOWNLOAD", "init value: bytesread = " + Integer.toString(bytesRead)); do { bytesRead = is.read(bytearray, currentTot, (bytearray.length-currentTot)); //&lt;--does not pull data (WHY?) Log.e("DOWNLOAD", "bytesread = " + Integer.toString(bytesRead)); if(bytesRead &gt;= 0) currentTot += bytesRead; } while(bytesRead &gt; -1); out1.println("finished:"); bos.write(bytearray, 0 , currentTot); Log.e("DOWNLOAD", Integer.toString(currentTot)); bos.flush(); bos.close(); socket1.close(); socket2.close(); } And this is my server co…
accepted answer: http://stackoverflow.com/a/22084966
tagged with: java
has comment: http://stackoverflow.com/comment/33459026
has comment: http://stackoverflow.com/comment/33460580
tagged with: inputstream
has comment: http://stackoverflow.com/comment/33458708
has comment: http://stackoverflow.com/comment/33458945
answer count: 1
has comment: http://stackoverflow.com/comment/33496446
has comment: http://stackoverflow.com/comment/33459293
favorite count: 0
tagged with: sockets
tagged with: android
has comment: http://stackoverflow.com/comment/33458780
has comment: http://stackoverflow.com/comment/33496484
has title: File download from PC to Android device - OutputStream write( ) stucks for large files
has comment: http://stackoverflow.com/comment/88290923
has answer: http://stackoverflow.com/a/22084966
has comment: http://stackoverflow.com/comment/33459023
has comment: http://stackoverflow.com/comment/33496512
has comment: http://stackoverflow.com/comment/33459246
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33496802
tagged with: download

http://stackoverflow.com/q/22030903
has comment: http://stackoverflow.com/comment/33403901
has title: Converting date to long in Java
has body: I have the following string 02/11/2012 23:11 Is there any way to convert this to the long 021120122311l? I am trying to map objects to a specific position in an array based on their date created.
answer count: 4
possible better answer: http://stackoverflow.com/a/22030942
type: AnsweredQuestion
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22030941
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/22030984
tagged with: date
has answer: http://stackoverflow.com/a/22034076
tagged with: type-conversion
accepted answer: http://stackoverflow.com/a/22030941
tagged with: arrays
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/22030942

http://stackoverflow.com/comment/33628960
score: 1
comment on: http://stackoverflow.com/q/22159233
type: Comment
type: QuestionComment
has text: @Paul And `setBalance`, and `setAnnualInterestRate`... Curiously, it's exactly the same error everywhere.

http://stackoverflow.com/q/22114201
has comment: http://stackoverflow.com/comment/33548239
has comment: http://stackoverflow.com/comment/33548659
tagged with: java
has comment: http://stackoverflow.com/comment/33548606
tagged with: mysql
upvote count: 1
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33547878
has comment: http://stackoverflow.com/comment/33547792
answer count: 2
has comment: http://stackoverflow.com/comment/33548536
has comment: http://stackoverflow.com/comment/33548048
possible better answer: http://stackoverflow.com/a/22114980
has title: Null Pointer Exception While calling MySql Database
has comment: http://stackoverflow.com/comment/33547815
has answer: http://stackoverflow.com/a/22114980
has comment: http://stackoverflow.com/comment/33548730
tagged with: nullreferenceexception
has comment: http://stackoverflow.com/comment/33547912
score: 0
tagged with: nullpointerexception
has answer: http://stackoverflow.com/a/22114967
tagged with: netbeans-7
has body: I'm practicing a Java Netbeans program where I'm calling values from MySql Database but it's giving me this Exception of Null Pointer. I'm new to this so please help me solve this problem. java.lang.NullPointerException at cooling.system.pkg1.pkg0.Calculation1.calculate(Calculation1.java:371) at cooling.system.pkg1.pkg0.Calculation1.btn_setActionPerformed(Calculation1.java:1081) at cooling.system.pkg1.pkg0.Calculation1.access$1000(Calculation1.java:22) at cooling.system.pkg1.pkg0.Calculation1$11.actionPerformed(Calculation1.java:862) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) at java.awt.Component.processMouseEvent(Component.java:6505) at javax.swing.JComponent.processMouseEvent(JComponent.java:3320) at java.awt.Component.processEvent(Component.java:6270) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) at java.awt.Container.dispatchEventImpl(Container.java:2273) 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(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:694) at java.awt.EventQueue$3.run(EventQueue.java:692) at java.security.AccessController…
favorite count: 0
accepted answer: http://stackoverflow.com/a/22114967
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33548657

field
tags question: http://stackoverflow.com/q/22157312
tag name: field
tags question: http://stackoverflow.com/q/22063623
tags question: http://stackoverflow.com/q/22018910
tags question: http://stackoverflow.com/q/22135623
type: Tag

http://stackoverflow.com/a/22049082
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/33431243
score: 2
upvote count: 2
accepted answer of: http://stackoverflow.com/q/22049022
has body: Put code inside case, you also need a variable choice for operation. switch (choice) //choice has to be int, byte, short, or char (String with java 7) { case 1: // Your code goes here System.out.println("Addition selected"); break; case 2: System.out.println("Multiply selected"); break; case 3: System.out.println("Divide selected"); break; case 4: System.out.println("Exit selected"); break; default: System.out.println("Invalid selection"); break; }
answers question: http://stackoverflow.com/q/22049022
type: AcceptedAnswer

http://stackoverflow.com/comment/33615238
score: 0
type: AnswerComment
type: Comment
has text: I give up... I can't be arsed trying to explain myself any more
comment on: http://stackoverflow.com/a/22151899

http://stackoverflow.com/comment/33646236
type: AnswerComment
type: Comment
has text: BTW I've seen now that you are using a checkboxlist, setting the value with `applicazioniSelezionateDefault`. You must ensure that that variable is correctly populated even in case of INPUT result...
comment on: http://stackoverflow.com/a/22069987
score: 0

http://stackoverflow.com/comment/33552625
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22116884
has text: Are the first and the second part of the code related? (They look similar, except for the case `IN_A_WEEK` that is only contained in the second part)
score: 0

http://stackoverflow.com/comment/33416720
type: Comment
comment on: http://stackoverflow.com/a/22040114
type: AnswerComment
has text: Doing a bit search people point that they get errors in the transformer when the source is not valid. I see you initialize the source as new DOMSource(node) instead of new DOMSource(doc)? But it's weird because the Documentation says that "factory.newTransformer()" never returns null.
score: 0

http://stackoverflow.com/comment/33503336
type: Comment
has text: But how to Domain node it because i need two nodes one is :
comment on: http://stackoverflow.com/q/22088353
score: 0
type: QuestionComment

http://stackoverflow.com/q/22160353
answer count: 1
has answer: http://stackoverflow.com/a/22160426
accepted answer: http://stackoverflow.com/a/22160426
favorite count: 0
score: 2
downvote count: 0
tagged with: swing
type: AnsweredQuestion
tagged with: java
has title: java - get content that appears to be layered from another class
type: Question
upvote count: 2
has body: I am trying to make a simple GUI word dragging game and the way I structured the code is that I have a Driver class that sets up the main JFrame and a JPanel where the words are to be contained in and a JButton that prompts a Popup class to ask for a new word to add. and then creates a WordBox. My problem seems to arise from the fact that the Popup class is a sub-class (I think thats the correct term) and so it seems that there seems to be an extra Popup class as a layer between the Driver and the actual Popup with the WordBox. I know its confusing, but here is some of the code: public class Popup extends JFrame implements ActionListener { JLabel lblPrompt; JTextField txtWord; JButton btnOK; BoxWord w; static BoxWord word; public Popup(){ //window formatting was here btnOK.addActionListener(this); } @Override public void actionPerformed(ActionEvent e){ w = new BoxWord(txtWord.getText()); //word = new BoxWord("it works"); } public static void main(String[] args) { Popup p = new Popup(); //System.out.println(word.getWord()); } and public class BoxWord extends JButton { private String s = ""; public BoxWord(String word){ this.s = word; this.setText(word); } public String getWord(){ return s; } } and the Driver: public class Driver extends JFrame implements ActionListener{ JButton addWord; JPanel panel; int x, y; public Driver(){ //Window formatting was here addWord.addActionListener(this); } public static void main(String[] args) { Driver d = new Driver(); } @Override public void actionPerformed(ActionEvent e){//make a new popup to ask for word Popup p = new Popup(); BoxWord w = p.w; System.out.println(w.getWord()); w.setLocation(100,100); } My error is (at least the begining of it. the whole thing is like 20 lines long): Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at worddrag.Driver.actionPerformed(Driver.java:42) The line 42 is the System.out.println(w.getWord()); I feel this is a very trivial and simple problem but I cannot figure out why I…

http://stackoverflow.com/a/22149810
answers question: http://stackoverflow.com/q/22149641
has body: Replace (add action here), with myTestField.setText("0"), or score = 0; myTestField.setText(score). Something along those lines. The official Java tutorials are an excellent place to learn Swing and other related Java techs, it's quite good, so follow that link peeskillet gave you in the comments. There's some good books on Swing too, I would recommend Filthy Rich Clients.
type: AcceptedAnswer
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/33611682
accepted answer of: http://stackoverflow.com/q/22149641

http://stackoverflow.com/a/22071737
answers question: http://stackoverflow.com/q/22071595
score: 1
type: AcceptedAnswer
has body: Endpoint not found. Probably you write wrong methode url for this api
type: Answer
upvote count: 2
downvote count: 1
accepted answer of: http://stackoverflow.com/q/22071595

http://stackoverflow.com/comment/33408217
type: QuestionComment
comment on: http://stackoverflow.com/q/22035337
score: 0
type: Comment
has text: yups, thanks for the help Ted Bigham

http://stackoverflow.com/a/22035830
answers question: http://stackoverflow.com/q/22035667
has body: int smth = (int)(Math.random()-1);
score: -1
upvote count: 0
type: Answer
downvote count: 1

android-lifecycle
tags question: http://stackoverflow.com/q/22160693
type: Tag
tag name: android-lifecycle

http://stackoverflow.com/a/22061636
score: -1
has comment: http://stackoverflow.com/comment/53860618
upvote count: 0
has body: The answer depends on the topology of dependence graph. If it can be split in independent linear sequences, as in your example, then simply represent each sequence as a Runnable and run it each with its own thread or submit them to a thread pool. If a sequence branches like this: A-&gt;B-&gt;C | -&gt;D-&gt;E then run sequence ABC first, and run DE from activity B. Most complex case is when an activity depends on two or more activities: A-&gt;B -&gt; | C -&gt; |-&gt;D // needs both results from B and C You need a node in the graph which collects results and starts new sequence when all results are collected. If you use threads, then you can represent each dependence as a blocking queue, and let dependent activity first read from all input queues, using BlockingQueue.take() method. If you use a thread pool, then you can: use Java8 CompletableFuture class and its methods runAfterBoth (for 2 dependencies) or allOf (for arbitrary number of dependencies). use some dataflow library (being the author, I recommend https://github.com/rfqu/df4j) implement joining node yourself, this is not a big deal
type: Answer
downvote count: 1
answers question: http://stackoverflow.com/q/22060325

http://stackoverflow.com/a/22006358
has comment: http://stackoverflow.com/comment/33355868
has comment: http://stackoverflow.com/comment/33364599
has comment: http://stackoverflow.com/comment/33355661
has comment: http://stackoverflow.com/comment/33358316
score: 4
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33357495
downvote count: 0
has comment: http://stackoverflow.com/comment/33355113
answers question: http://stackoverflow.com/q/22005632
type: Answer
upvote count: 4
accepted answer of: http://stackoverflow.com/q/22005632
has comment: http://stackoverflow.com/comment/33394367
has comment: http://stackoverflow.com/comment/33366786
has comment: http://stackoverflow.com/comment/36432914
has body: The basic concept is simple. A TreeModel is just a bunch of linked nodes, which may or may not contain children Creating the XML is a "little" more complex, but not that difficult, in fact, the most difficult part would be trying to parse each node and saving it... Take a look at Java API for XML Processing (JAXP) for more details import java.io.File; import java.util.Enumeration; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeModel; import javax.swing.tree.TreeNode; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; 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.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; public class ConvertToXML { public static void main(String[] args) { TreeModel model = new DefaultTreeModel(...); try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document doc = factory.newDocumentBuilder().newDocument(); Element rootElement = doc.createElement("treeModel"); doc.appendChild(rootElement); // Get tree root... TreeNode root = (TreeNode) model.getRoot(); parseTreeNode(root, rootElement); // Save the document to disk... Transformer tf = TransformerFactory.newInstance().newTransformer(); tf.setOutputProperty(OutputKeys.INDENT, "yes"); tf.setOutputProperty(OutputKeys.METHOD, "xml"); tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); DOMSource domSource = new DOMSource(doc); StreamResult sr = new StreamResult(new File("TreeModel.xml")); tf.transform(domSource, sr); } catch (ParserConfigurationException | TransformerException ex) { e…
has comment: http://stackoverflow.com/comment/33356225
has comment: http://stackoverflow.com/comment/33355207
has comment: http://stackoverflow.com/comment/33364755
has comment: http://stackoverflow.com/comment/33365002

http://stackoverflow.com/comment/33446329
comment on: http://stackoverflow.com/q/22057553
type: Comment
has text: You're trying to parse it as a JSONArray when it is a JSONObject.
type: QuestionComment
score: 1

http://stackoverflow.com/q/22099901
score: 5
tagged with: jpa
downvote count: 0
answer count: 1
accepted answer: http://stackoverflow.com/a/22225564
favorite count: 0
type: AnsweredQuestion
tagged with: java
linked to: http://stackoverflow.com/q/16939415
has title: Hibernate: Replacement for Ejb3Configuration Class
type: Question
has answer: http://stackoverflow.com/a/22225564
upvote count: 5
tagged with: hibernate
has body: Sorry for the long back story but I wanted to give a good idea of why we're doing what we're doing. Our application currently uses Hibernate 3.6 and we wish to upgrade to Hibernate 4.3. The application was specifically written to avoid using persistence.xml to configure JPA and create the EntityManagerFactory and instead uses Hibernate's Ejb3Configuration class like this (example): Properties properties = new Properties(); properties.put("javax.persistence.provider", "org.hibernate.ejb.HibernatePersistence"); properties.put("javax.persistence.transactionType", "RESOURCE_LOCAL"); properties.put("hibernate.dialect", "org.hibernate.dialect.Oracle10gDialect"); properties.put("hibernate.show_sql", "false"); properties.put("hibernate.format_sql", "true"); Ejb3Configuration cfg = new Ejb3Configuration(); cfg.addProperties(properties); DataSource dataSource = dataSourceProvider.get(); cfg.setDataSource(dataSource); //add the annotated classes cfg.addAnnotatedClass(SomePersistentObject.class); EntityManagerFactory factory = cfg.buildEntityManagerFactory(); The reason we do it this way is because we have a web app (war file) deployed to Tomcat that provides "core" functionality. Then, we install what we call "client bundles" which are jar files in the exploded /WEB-INF/lib directory. The "client bundles" contain overrides to the existing "core" behavior of the web app. This allows us to service multiple clients, each with various customizations from the "core" behavior, in one instance of the web app. We know which client bundle to use based on the domain or subdomain of the incoming HTTP request. Each client bundle always gets its own database instance, and thus each client bundle defines its own EntityManagerFactory. The schemas are almost identical, although client bundles can add new persistent classes if needed. So, the reason we do JPA configuration in Java is so that each client bundle extend the "core" classes and add their own entity classes. Java is great for inheri…

http://stackoverflow.com/q/22014980
tagged with: view
upvote count: 2
type: UnansweredQuestion
has body: I need to extends View class in Android in order to override couple of methods. public class ExtendedView extends View { public ExtendedView(Context context) { super(context); } @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_MOVE &amp;&amp; getParent() != null) getParent().requestDisallowInterceptTouchEvent(true); return super.onTouchEvent(event); } ... } There are couple of view type in android which derive from View such as ImageView and etc. They do not access to overridden methods in ExtendedView class. One solution is creating extended classes for all of them such as : public class ExtendedImageView extends ImageView And override the methods. But is there any better solution to avoid such a code redundancy?
has answer: http://stackoverflow.com/a/22015606
has title: Extend android View class and affect all sub classes
has comment: http://stackoverflow.com/comment/33369738
score: 2
tagged with: oop
has answer: http://stackoverflow.com/a/22015424
tagged with: java
has comment: http://stackoverflow.com/comment/33408315
type: Question
answer count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33369954
has comment: http://stackoverflow.com/comment/33369614
tagged with: android
has comment: http://stackoverflow.com/comment/33369671
favorite count: 0

http://stackoverflow.com/comment/33422064
has text: I am seeing the same behaviour in your code as well. The child JDialog never goes back of parent of Jdialog even after we mention this dialog.getOwner().toFront(); . I can select the windows of parent and child JDialogs but when I select the parent JDialog window, the child JDialog is still in front of parent JDialog. This is the same behavior I observed when I set CustomDialogSearch's parent to be CustomDialog
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22041971

http://stackoverflow.com/comment/56582690
has text: I would assume it is because implementing the Map interface would result in heavy functions (boxing the keys, creating the sets of values and of keys,...) while the functions define in SparseIntArray are designed for efficiency. Having both would be counter-productive.
score: 0
comment on: http://stackoverflow.com/q/22086982
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33605961
type: AnswerComment
comment on: http://stackoverflow.com/a/22104152
type: Comment
has text: Yay, thanks! Hopefully it can help other people with similar problems where it's more applicable than yours. :)
score: 0

http://stackoverflow.com/comment/33601841
score: 0
comment on: http://stackoverflow.com/q/22142374
has text: Hi Jakub Hr, thank you for the reply, yes I get a NPE error which shows that the controller and the bean are not being instantiated, I haven't tried using CDI, I shall give that a try
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33569060
comment on: http://stackoverflow.com/a/22119295
type: AnswerComment
score: 0
type: Comment
has text: Still it doesn't work. I really don't know why. Still 5 are visible and the 6th is visible only partly. I'd like to send you my printscreen that you can see that, but I don't know how.

http://stackoverflow.com/a/22019516
accepted answer of: http://stackoverflow.com/q/22019452
type: Answer
answers question: http://stackoverflow.com/q/22019452
upvote count: 1
score: 1
has body: super() calls the parent constructor of the class and this() calls the constructor defined within the class. //Example of super() class parent { parent() { } } class child() { child() { super(); //Go to parent class constructor } } //Example of this class test { test() { this("a"); //go to test one argument constructor within the test class } test(String a) { } }
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/22110997
has body: Use regular expression for the date format you require and use regex.isMatch method to validate the string. Google it.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/22110949

http://stackoverflow.com/comment/33633010
type: QuestionComment
comment on: http://stackoverflow.com/q/22161555
has text: am clearing list values and then only am adding the list model into jlist
score: 0
type: Comment

http://stackoverflow.com/comment/33375079
has text: Please learn about the postincrement and the preincrement operators. Maybe you then see your mistake.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22017809
score: 1

http://stackoverflow.com/a/22148744
upvote count: 4
has comment: http://stackoverflow.com/comment/33609358
downvote count: 0
answers question: http://stackoverflow.com/q/22148668
type: Answer
has comment: http://stackoverflow.com/comment/33609163
score: 4
has body: {1,2,3} is not an Array initialization. You should add new int[], like: int sum = sumarr(new int[] { 1,2,3 });

http://stackoverflow.com/a/22157035
has body: This SHOULD get what you need. Please bear in mind i have not tested thism but the logic should work: String test = "Corrected Acceleration 20130816_053116_RCS2_21 GNS Science"; int lastUnderScore = test.lastIndexOf("_"); test = test.substring(lastUnderScore + 1); int numLength = test.indexOf(" "); int number = Integer.valueOf(test.substring(0, numLength)); Find the last instance of '_' cut string back to start at the beginning of the number find the position of the first ' ' (This will now be after the number you need) cut string down to before the space and cast to an integer.
downvote count: 0
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/22156876

http://stackoverflow.com/comment/33558100
comment on: http://stackoverflow.com/a/22087638
type: AnswerComment
score: 0
has text: Sorry it has taken me so long to get back to you. Could these if else statements work in a while loop or is the do while loop necessary? I know the do while loop insures at least one iteration of the loop before checking conditions.
type: Comment

http://stackoverflow.com/q/22021758
has comment: http://stackoverflow.com/comment/33382162
has comment: http://stackoverflow.com/comment/33382106
has title: JAVA: Why can't I access a method in the same class?
has comment: http://stackoverflow.com/comment/33382192
has comment: http://stackoverflow.com/comment/33382299
tagged with: find
answer count: 1
has body: I can't seem to find out why my static method is not able to call other methods in the same class. What should I do? import java.util.Scanner; import java.util.*; public class MashupII { public void Append(Sound clip, boolean rev, double scale){ //Void methods... //main method public static void main (String [] args) { Scanner keyboard = new Scanner(System.in); clips = new Sound[100]; System.out.println("Please enter your command (A, I, D, P or Q)"); char command = Character.toUpperCase(keyboard.next().charAt(0)); while (command != 'Q'){ switch (command){ case 'A': //APPENDING //pick the clip System.out.println("Please pick a file."); Sound clip = new Sound(FileChooser.pickAFile()); //reversing System.out.println("Would you like to reverse the clip? (Y|N)"); String reverse = keyboard.nextLine(); boolean rev = reverse.equalsIgnoreCase("Y"); //scaling System.out.println("How much should the clip be scaled? (1 is no scaling)"); double scale = keyboard.nextDouble(); clips.Append(clip,rev,scale); break; case 'I': break; case 'D': System.out.println("Which clip would you like to delete? (1- end)"); int p = keyboard.nextInt(); clips.Delete(p); break; case 'P': break; default: System.out.println("Error! Please enter one of the available commands (A, I, D, P or Q)"); } System.out.println("Please enter another command (A, I, D, P or Q)"); command = Character.toUpperCase(keyboard.next().charAt(0)); } } } I get the error in the switch case. It gives me a symbol not found. Any help would be great!
favorite count: 0
has comment: http://stackoverflow.com/comment/33382309
downvote count: 5
tagged with: symbols
type: AnsweredQuestion
upvote count: 0
score: -5
has answer: http://stackoverflow.com/a/22022097
accepted answer: http://stackoverflow.com/a/22022097
tagged with: methods
type: Question
tagged with: java

http://stackoverflow.com/a/22129734
has body: You can try build in implementation of list in alert dialog. It depends on use case. If you want to use this dialog just for picking value from the list (without custom list item UI) - it is good approach.
answers question: http://stackoverflow.com/q/22128696
score: 0
type: Answer

access-specifier
tags question: http://stackoverflow.com/q/22007143
type: Tag
tag name: access-specifier

http://stackoverflow.com/comment/33532316
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22105318
score: 1
has text: To be clear you want the output to be: "SELECT ele1, ele2, ..., elen FROM" ? where ele1 to elen are selected elements from your list?

http://stackoverflow.com/comment/33573998
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22127891
has text: No, I removed the old .jar. I don't know what the difference is between the .: and :. It states in the documentation that this specifies multiple classpaths, don't know why specifying one before the other would be significant. I'm also baffled as to why the options work when I enter them into a command line prompt but why I save them out to an options file and use javac @options it doesn't work.
score: 0

http://stackoverflow.com/q/22168246
score: 7
tagged with: java
has body: Memory mapped files are (according to the spec) largely dependent on the actual implementation of the OS and a number of these unknown aspects are already explained in the javadoc. However I have some additional questions and not sure where to turn to for answers. Suppose application A maps a file to memory from position=0 to size=10. I would assume the OS needs a continuous piece of memory to map it? Or is this dependent on implementation? Now suppose we have an application B that maps from position=0 to size=11. Are the first 10 bytes shared or is it an entirely different mapping? This relates back to the continuous memory question. If we want to use mapped files for IPC, we need to know how the data is reflected in other applications, so if B writes to memory, does A see this? However as I read the spec, this depends on the OS. This makes it dangerous to use for general purpose IPC as it destroys portability right? Additionally suppose the OS does support it, so B writes to memory, A sees the change, what happens if we do this: B.write("something"); A.write("stuff"); A.read(); What exactly will A read? Or put otherwise: how are the file pointers managed? How does it work with concurrency, is there cross application locking?
upvote count: 7
type: Question
has answer: http://stackoverflow.com/a/25311266
tagged with: memory-mapped-files
answer count: 1
downvote count: 0
favorite count: 0
type: UnansweredQuestion
has title: Memory mapped files in java: too many questions?

http://stackoverflow.com/q/22067525
has answer: http://stackoverflow.com/a/22067684
tagged with: string
accepted answer: http://stackoverflow.com/a/22067684
favorite count: 0
has comment: http://stackoverflow.com/comment/33462944
upvote count: 1
type: AnsweredQuestion
has title: Find substrings of a particular length/ format in Java
tagged with: filenames
score: 1
tagged with: java
tagged with: substring
has body: I have a program in Java that has a string array of filenames and cycles through them performing certain changes. The input filenames all have a similar but not exactly the same format: ABC_0123_08122013_XXX.csv 0123 being an ID number, 08122013 being a date. This file name is stored as a string and I want to be able to pick the ID and date out of it and store them as separate strings. The date and ID number are different for each file so I need to search by substring length I guess. Any help would be much appreciated.
type: Question
downvote count: 0
tagged with: http://stackoverflow.com/tag/csv
answer count: 1

http://stackoverflow.com/comment/33428507
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22047599
type: Comment
has text: Had there been something fishy, the error would have been in 1.6 too. right ?

http://stackoverflow.com/a/22076524
upvote count: 4
has comment: http://stackoverflow.com/comment/33525256
has comment: http://stackoverflow.com/comment/33497889
has comment: http://stackoverflow.com/comment/33497075
downvote count: 0
has body: Use a javax.swing.Timer if you want to animate with swing. See How to use Swing Timers See more examples here and here and here and here. Test this one out. It changes the background of just one panel, instead of trying to use multiple ones like you are trying to do. import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import java.util.Random; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.Timer; public class ColorChange extends JPanel { private static final int D_W = 300; private static final int D_H = 300; private final List&lt;Color&gt; colors; private final Random random; private Color bgColor = Color.BLUE; public ColorChange() { colors = createColorList(); random = new Random(); Timer timer = new Timer(500, new ActionListener(){ public void actionPerformed(ActionEvent e) { int index = random.nextInt(colors.size()); bgColor = colors.get(index); repaint(); } }); timer.start(); } private List&lt;Color&gt; createColorList() { List&lt;Color&gt; list = new ArrayList&lt;&gt;(); list.add(Color.BLUE); list.add(Color.CYAN); list.add(Color.PINK); list.add(Color.ORANGE); list.add(Color.MAGENTA); list.add(Color.GREEN); list.add(Color.YELLOW); list.add(Color.RED); list.add(Color.GRAY); return list; } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(bgColor); g.fillRect(0, 0, getWidth(), getHeight()); } @Override public Dimension getPreferredSize() { return new Dimension(D_W, D_H); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame(); frame.add(new ColorChange()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } }
answers question: http://stackoverflow.com/q/22075483
has comment: http://stackoverflow.com/comment/33524843
type: Answer
has comment: http://stackoverflow.com/comment/33496791
has comment: http://stackoverflow.com/comment/33497800
score: 4
has comment: http://stackoverflow.com/comment/33525412
has comment: http://stackoverflow.com/comment/33524738
has comment: http://stackoverflow.com/comment/33524931
has comment: http://stackoverflow.com/comment/33496753

http://stackoverflow.com/q/22130937
tagged with: jmf
answer count: 0
tagged with: java
score: 0
type: Question
has comment: http://stackoverflow.com/comment/33620141
tagged with: media-player
has title: Java Osgi Eclipse JMF javax.media.MediaLocator
has comment: http://stackoverflow.com/comment/33578686
has comment: http://stackoverflow.com/comment/33605773
tagged with: classnotfoundexception
tagged with: osgi
type: UnansweredQuestion
has body: i have a problem with OSGI JMF. I wrote this media player but not want to work when i run got ERROR. Eclipse not see mediaLocator does anyone have any idea how to solve this problem. I'm a noob in java. I have eclipse kepler and JMF2.1.1e, and JDK try { Player mediaPlayer = Manager.createRealizedPlayer(new MediaLocator(mediauUrl)); Component video = mediaPlayer.getVisualComponent(); Component control = mediaPlayer.getControlPanelComponent();... osgi&gt; !SESSION 2014-03-02 18:13:30.610 ----------------------------------------------- eclipse.buildId=unknown java.version=1.7.0_51 java.vendor=Oracle Corporation BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=pl_PL Command-line arguments: -dev file:C:/OSGI ECLIPSE/ProjektyOSGI/projekt1/.metadata/.plugins/org.eclipse.pde.core/OSGi Framework/dev.properties -os win32 -ws win32 -arch x86 -consoleLog -console !ENTRY videoplayer 4 0 2014-03-02 18:13:35.458 !MESSAGE FrameworkEvent ERROR !STACK 0 org.osgi.framework.BundleException: Exception in videoplayer.Activator.start() of bundle videoplayer. at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381) at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390) at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544) at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457) at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243) at org.eclipse.osgi.framework.internal.core.StartLevelManager.…
has comment: http://stackoverflow.com/comment/33607033

http://stackoverflow.com/comment/33530929
type: AnswerComment
comment on: http://stackoverflow.com/a/22103239
score: 0
type: Comment
has text: @donfuxx I tested your code. But still it is not replacing words. I'll explain my problem again. sentence: I'm going to school. So I need to replace 'school' with 'shop'

http://stackoverflow.com/comment/33585046
score: 0
type: QuestionComment
type: Comment
has text: @arunmoezhi if you don't set the default value to `true`, no number will ever be reported as prime.
comment on: http://stackoverflow.com/q/22134469

http://stackoverflow.com/q/22111603
type: AnsweredQuestion
upvote count: 14
tagged with: java
type: Question
answer count: 2
tagged with: intellij-idea
downvote count: 0
tagged with: tomcat
has answer: http://stackoverflow.com/a/22115281
has title: "Update resources" option missing in IntelliJ IDEA
has body: I am using tomcat 7 for developing a java web application. Running tomcat in the debug mode, I do not have options to "Update resources" and "Update classes and resources" on the "Update" menu. There are only "Hot Swap classes", "Redeploy" and "Restart Server". Please, could you help find them? Thanks a lot in advance! It would save me a lot of time..
possible better answer: http://stackoverflow.com/a/59846741
favorite count: 0
has answer: http://stackoverflow.com/a/59846741
accepted answer: http://stackoverflow.com/a/22115281
score: 14

http://stackoverflow.com/comment/33542864
has text: I'm getting `2` as output.
score: 3
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22111358

http://stackoverflow.com/q/22146784
tagged with: parameters
tagged with: paint
tagged with: java
type: Question
tagged with: graphics
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22147300
score: 0
answer count: 1
accepted answer: http://stackoverflow.com/a/22147300
has title: Java Graphics: Passing Parameters to the paint method
has body: In this example I'm trying to create a dice. To do this I want to pass a random value between 1 and 6 from my updateVal method into my paint method, however I'm not sure how to pass parameters into the paint method. Currently I'm using the repaint method which obviously you can't pass parameters through. public void updateVal(int i){ repaint(); } public void paint(Graphics g, int rollValue){ super.paint(g); int value = rollValue; switch (value) { case 1: g.fillOval(200, 200, 100, 100); break; case 2: g.fillOval(350, 50, 100, 100); g.fillOval(50, 450, 100, 100); break; case 3: g.fillOval(350, 50, 100, 100); g.fillOval(200, 250, 100, 100); g.fillOval(50, 450, 100, 100); break; case 4: g.fillOval(350, 50, 100, 100); g.fillOval(50, 350, 100, 100); g.fillOval(50, 50, 100, 100); g.fillOval(350, 350, 100, 100); break; case 5: g.fillOval(350, 50, 100, 100); g.fillOval(50, 350, 100, 100); g.fillOval(50, 50, 100, 100); g.fillOval(350, 350, 100, 100); g.fillOval(200, 200, 100, 100); break; case 6: g.fillOval(350, 50, 100, 100); g.fillOval(50, 350, 100, 100); g.fillOval(50, 50, 100, 100); g.fillOval(350, 350, 100, 100); g.fillOval(50, 200, 100, 100); g.fillOval(350, 200, 100, 100); break; } }

http://stackoverflow.com/comment/33492214
has text: Show the full exception text, and the exact JDBC driver version.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22075311

http://stackoverflow.com/comment/33475704
has text: Note that you omitted the surrounding `{}` characters, which *are* significant -- they're not just `toString` window-dressing.
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22074192

http://stackoverflow.com/a/22100286
has comment: http://stackoverflow.com/comment/33522649
type: Answer
answers question: http://stackoverflow.com/q/22100189
has comment: http://stackoverflow.com/comment/33611222
has comment: http://stackoverflow.com/comment/33630154
score: 4
accepted answer of: http://stackoverflow.com/q/22100189
upvote count: 4
has comment: http://stackoverflow.com/comment/33522689
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33611926
has body: Well, assuming you only want one instance of this service running at once you could hold a static variable in the service class and access it from anywhere. Example; public class ToonService extends Service{ public static ToonService toonService; public ToonService(){ toonService = this; } ... } The constructor for ToonService now stores the created instance in the static variable toonService. Now you can access that service from anywhere from the class. Example below; ToonService.toonService.stopSelf(); You could also handle multiple instances by having the class store a static List of running instances, rather than just the single instance. It is worth noting, that when you tell a service to stop, you are only requesting that it is stopped. Ultimately the Android OS will determine when it is closed.

http://stackoverflow.com/q/22160617
has title: Bukkit Config - get Subsections and safe casting
type: AnsweredQuestion
tagged with: java
tagged with: bukkit
type: Question
tagged with: configuration
tagged with: minecraft
has body: I have the following config file: arenas arena1 info: infotest info2: info2test arena2 info: infotest info2: info2test So. Now i want to get one arena, and convert it to a arena object, i have a constructor there taking a Map. So i do following: Arena a = new Arena((Map&lt;String, Object&gt;) getConfig().get("arenas.arena1")); That is working. But: im getting the following warning in eclipse: Type safety: Unchecked cast from Object to Map&lt;String,Object&gt; I undestand why this apperas. but how can i change the way getting the informations to avoid this, so to make a "safe" cast? And my second question: Now i want to get all the sub Map 's from arenas."" and initialize them when the plugin loads. How can i get all of them? I cannot find something like arenas.getAll() or i dont know.. something like this.. anyone an idea? Thank you.
score: 0
has answer: http://stackoverflow.com/a/22184196
answer count: 1
accepted answer: http://stackoverflow.com/a/22184196
tagged with: plugins

http://stackoverflow.com/q/22012871
score: 5
tagged with: criteria
upvote count: 5
downvote count: 0
answer count: 3
has answer: http://stackoverflow.com/a/22013739
favorite count: 0
has title: How to prevent duplicate results in Hibernate?
type: UnansweredQuestion
tagged with: hibernate-criteria
has answer: http://stackoverflow.com/a/31998345
has answer: http://stackoverflow.com/a/50511892
tagged with: java
tagged with: hibernate
has body: When trying to search for multiple values of a relation, duplicate results are returned. How can I avoid these duplicates? We have a method on our service that builds the Criteria: @Override protected Criteria createCriteria(Map&lt;String, Object&gt; values) { Criteria criteria = super.createCriteria(values); if (criteria != null &amp;&amp; values != null) { // other criteria restrictions Set&lt;MDTErkenning&gt; erkenningen = (Set&lt;MDTErkenning&gt;) values.get("erkenningen"); if (erkenningen != null &amp;&amp; !erkenningen.isEmpty()) { criteria.createAlias("erkenningen", "erkenningen"); criteria.add(Restrictions.in("erkenningen." + CollectionPropertyNames.COLLECTION_ELEMENTS, erkenningen)); } } return criteria; } which is used to get out paged results and do a count: @Override public List&lt;T&gt; findByCriteria(Map&lt;String, Object&gt; values, int offset, int amount) { Criteria criteria = createCriteria(values) .setFirstResult(offset) .setMaxResults(amount); return criteria.list(); } @Override public Long getCount(Map&lt;String, Object&gt; values) { Criteria criteria = createCriteria(values).setProjection(Projections.rowCount()); return (Long) criteria.uniqueResult(); } Main entity @Entity @Table(name = "mdt") public class MultiDisciplinairTeam { @Id @Column(name = "mdt_uuid") private String id; // other mappings @Column(name = "erkenning") @Cascade(org.hibernate.annotations.CascadeType.ALL) @ElementCollection(fetch = FetchType.EAGER) @Enumerated(EnumType.STRING) @JoinTable(name = "mdt_erkenning", joinColumns = {@JoinColumn(name = PK_NAME)}) @Fetch(FetchMode.SELECT) private Set&lt;MDTErkenning&gt; erkenningen; // getters &amp; setters } Enum instead of entity public enum MDTErkenning { ZORG("Zorg"), IMB("IMB"), PAB("PAB"), ROLSTOELEN("Rolstoelen"); private String beschrijving; private MDTErkenning(String beschrijving) { this.beschrijving = beschrijving; } public String getBeschrijving() { return this.beschrijving; } } The join table mdt_erkenning with some data:…
type: Question

http://stackoverflow.com/comment/33586634
type: QuestionComment
has text: As for why this was put on hold, I guess read [Good Subjective, Bad Subjective](http://blog.stackoverflow.com/2010/09/good-subjective-bad-subjective/). And as some have pointed out some languages do allow multiple return values so this morphs the question in to something more like "why do *some* languages ...?" in which case there is no 1 answer.
comment on: http://stackoverflow.com/q/22135035
score: 0
type: Comment

http://stackoverflow.com/comment/33631482
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22160736
score: 1
has text: A byte is just a shorter version of an int. They both hold a numeric value. You should be able to translate the code very easily to your needs. http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

http://stackoverflow.com/comment/33451155
type: Comment
comment on: http://stackoverflow.com/a/22051506
type: AnswerComment
has text: Look at my answer again; your character class swallowed all the input before being forced to give characters back. This is why you only ever obtained the last match.
score: 0

http://stackoverflow.com/comment/33526656
has text: If you don’t like the reflective code/ temporary array you can replace `Stream.of(getDeclaringClass().getEnumConstants())` with `EnumSet.allOf(getDeclaringClass()).stream()`.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22102121
score: 2

http://stackoverflow.com/q/22067567
linked to: http://stackoverflow.com/q/24823678
has body: I'm using the Struts 2 framework and I want to transfer a list of objects from Java to JSP and back to Java. Transferring to JSP works fine with the <s:iterator> tag. Transferring back to Java does not, my list is never populated. I already checked these questions: Repopulate ArrayList from JSP with Struts 2 a list of list value populated in struts2 iterator Populate Collection from Struts2 Form Submission Populate List<String> in struts2 from form data and followed their suggestions. Here is my Item class (it is has more properties than just name, but I'm only showing relevant ones): Class Item: private String name; public Item(){} public String getName(){ ... }; public void setName(String newName){ ... }; and on my JSP I have: <s:iterator value="items" status="key"> <s:hidden name="items[%{#key.index}].name" value="%{name}" /> </s:iterator> Here's the relevant part of the action class: private List<Item> items = new ArrayList<Item>(); public List<Item> getItems() { System.out.println("now getting Items"); if(Items == null) { System.out.println("Items is null"); } else { System.out.println("Items is not null. size: " + Items.size()); } return Items; } public void setItems(List<Item> Items) { System.out.println("now setting Items"); Items = Items; } I'm 100% sure it has all the necessary getters and setters because the JSP is populated correctly, and when I submit my form I can actually see (with log statements) that my getItems() method is being called once for each item in my list (for each input field in the form). It's just weird that Struts2 is getting the list once for every hidden input field in the form, but then refuses to create an Item object and set it's name to the given value anything in it. The problem cannot be the lack of a no-args constructor. I also added an conversion file named with ActionName-conversion.properties (where ActionName is the name of my action class) and it is in the same folder as my ActionName.java class. Element_items = Item Cre…
has comment: http://stackoverflow.com/comment/33466136
linked to: http://stackoverflow.com/q/23827729
linked to: http://stackoverflow.com/q/19154790
has comment: http://stackoverflow.com/comment/33466219
downvote count: 0
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33465455
has comment: http://stackoverflow.com/comment/33466459
upvote count: 2
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/25228643
linked to: http://stackoverflow.com/q/5834944
linked to: http://stackoverflow.com/q/7897027
score: 2
tagged with: java
linked to: http://stackoverflow.com/q/24186111
type: Question
linked to: http://stackoverflow.com/q/15650800
has comment: http://stackoverflow.com/comment/33465304
linked to: http://stackoverflow.com/q/975883
tagged with: ognl
has title: Repopulating a list from JSP to action in Struts 2
tagged with: jsp
has comment: http://stackoverflow.com/comment/33465821
tagged with: struts2
tagged with: type-conversion

http://stackoverflow.com/comment/33499967
type: QuestionComment
has text: @NickWiggill No problem, updated the question. I'm using Java and Swing.
comment on: http://stackoverflow.com/q/22087609
score: 0
type: Comment

http://stackoverflow.com/a/22048206
upvote count: 2
has body: Use switch/case, and handle the invalid option in the default branch Some additional information: you can switch on Strings from Java SE 7 only. Up till Java SE 6 you can e.g. use Integer.parseInt(truckType) to convert your String values to int and do the switch on that afterwards
type: Answer
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/22048151

http://stackoverflow.com/q/22047432
has comment: http://stackoverflow.com/comment/33428186
has body: My code is perfectly fine in JDK 1.6, but when I complile it in JDK 1.4 i get errrors Code is public void generateSection(long parId, long splId, long ogrId) throws DBUexecuteQueryException, DBUqueryParameterException, DBUcreateQueryInstanceException { DBUquery dbu = new DBUquery(mcl_ts, mainGenerator.con); dbu.createPreparedStatement(stmt); dbu.setPreparedParameter(1, parId); dbu.setPreparedParameter(2, splId); dbu.setPreparedParameter(3, ogrId); dbu.createListFromResultSet(new DBUrowToObject() { //@Override public Object rowToObject(ResultSet rs) throws SQLException { String name = rs.getString("name"); writeLn("&lt;Outlet name=" + q(name) + "/&gt;"); return null; } }); and the error is 'class' or 'interface' expected at }); Any ideas ? :)
has title: JDK 1.4 compilation error
has comment: http://stackoverflow.com/comment/33428283
has comment: http://stackoverflow.com/comment/33428851
type: UnansweredQuestion
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/33428587
has comment: http://stackoverflow.com/comment/33428629
has comment: http://stackoverflow.com/comment/33428107
has comment: http://stackoverflow.com/comment/33428374
tagged with: java
has comment: http://stackoverflow.com/comment/33428651
has comment: http://stackoverflow.com/comment/33428232
type: Question
has comment: http://stackoverflow.com/comment/33428323
has comment: http://stackoverflow.com/comment/33428312
answer count: 1
has comment: http://stackoverflow.com/comment/33428916
favorite count: 0
score: 0
has answer: http://stackoverflow.com/a/22047599
has comment: http://stackoverflow.com/comment/33428524
has comment: http://stackoverflow.com/comment/33428429

http://stackoverflow.com/comment/33467808
type: QuestionComment
type: Comment
has text: @HotLicks. So, I guess that `Vector` is slower because it gobbles up more memory?
comment on: http://stackoverflow.com/q/22069923
score: 0

http://stackoverflow.com/a/25274646
type: Answer
score: 1
answers question: http://stackoverflow.com/q/22157348
upvote count: 1
downvote count: 0
has body: Closing Android studio completely and re-opening it again seems to work for me sometimes. Although this is not specific for 0.4.2, I have been using this technique since 0.6.* up to current version (0.8.* as of today)

http://stackoverflow.com/a/22009568
has comment: http://stackoverflow.com/comment/33361509
type: Answer
accepted answer of: http://stackoverflow.com/q/22008953
has comment: http://stackoverflow.com/comment/33377884
has comment: http://stackoverflow.com/comment/33365906
has comment: http://stackoverflow.com/comment/33366023
answers question: http://stackoverflow.com/q/22008953
has comment: http://stackoverflow.com/comment/33366282
has body: What I have given below is an example for your solution. Here, I have called a method, getElementWithIndex to do so.. This works!! In this example, it captures all the links under specific frame|class|id and Navigate one by one driver.get("www.xyz.com"); WebElement element = driver.findElement(By.id(Value)); List&lt;WebElement&gt; elements = element.findElements(By.tagName("a")); int sizeOfAllLinks = elements.size(); System.out.println(sizeOfAllLinks); for(int i=0; i&lt;sizeOfAllLinks ;i++) { System.out.println(elements.get(i).getAttribute("href")); } for (int index=0; index&lt;sizeOfAllLinks; index++ ) { getElementWithIndex(By.tagName("a"), index).click(); driver.navigate().back(); } public WebElement getElementWithIndex(By by, int index) { WebElement element = driver.findElement(By.id(Value)); List&lt;WebElement&gt; elements = element.findElements(By.tagName("a")); return elements.get(index); }
downvote count: 1
score: 3
has comment: http://stackoverflow.com/comment/33366170
has comment: http://stackoverflow.com/comment/33377967
upvote count: 4
has comment: http://stackoverflow.com/comment/33367394
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33377697
has comment: http://stackoverflow.com/comment/33366215
has comment: http://stackoverflow.com/comment/33365845
has comment: http://stackoverflow.com/comment/33367181
has comment: http://stackoverflow.com/comment/33365783

http://stackoverflow.com/comment/33398766
comment on: http://stackoverflow.com/q/22030766
score: 0
type: Comment
type: QuestionComment
has text: Exactly,instead of eclipse console,the cmd prompt,like the default way we used to do.

http://stackoverflow.com/comment/33538179
comment on: http://stackoverflow.com/a/22108558
type: AnswerComment
score: 0
has text: didn't help. pls see the part below the line comment.
type: Comment

http://stackoverflow.com/q/22104803
has title: java.util.ConcurrentModificationException using an Iterator
has comment: http://stackoverflow.com/comment/33531147
has comment: http://stackoverflow.com/comment/33531117
has answer: http://stackoverflow.com/a/22105439
has comment: http://stackoverflow.com/comment/33531575
score: 2
type: AnsweredQuestion
downvote count: 0
has comment: http://stackoverflow.com/comment/33531687
favorite count: 0
has body: I have looked around and cannot find anything that matches or that fixes my problem. I am trying to make a very basic server system right now that will go onto something more advanced. For some reason if more than one client tries to join it will crash with this error message. Exception in thread "messageRecieveThread" java.util.ConcurrentModificationException at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:819) at java.util.ArrayList$Itr.next(ArrayList.java:791) at zx.server.threads.connections.Message.run(Message.java:23) at java.lang.Thread.run(Thread.java:724) Here is my message class so far: package zx.server.threads.connections; import java.io.IOException; import java.net.Socket; import java.util.Iterator; import zx.server.communication.handle.Processing; import zx.server.storage.severSide.Store; public class Message implements Runnable { private Thread thread; public Message() { thread = new Thread(this); thread.setName("messageRecieveThread"); thread.start(); } @Override public void run() { while (true) { for (Iterator&lt;Socket&gt; it = Store.getAll().iterator(); it.hasNext();) { Socket s = it.next(); try { if (s.getInputStream().available() != 0) { byte[] buffer = new byte[s.getInputStream().available()]; s.getInputStream().read(buffer); new Processing(s, buffer); } } catch (IOException e) { e.printStackTrace(); } } } } } The line that is supposedly causing the error is this one: Socket s = it.next(); Any help would be immensely appreciated. Thanks, ~Ryan
has comment: http://stackoverflow.com/comment/33531504
has comment: http://stackoverflow.com/comment/33531429
has comment: http://stackoverflow.com/comment/33531812
type: Question
tagged with: sockets
tagged with: concurrentmodification
accepted answer: http://stackoverflow.com/a/22105439
has comment: http://stackoverflow.com/comment/33531676
has comment: http://stackoverflow.com/comment/33531474
has comment: http://stackoverflow.com/comment/33531576
upvote count: 2
has comment: http://stackoverflow.com/comment/33531420
tagged with: java
has comment: http://stackoverflow.com/comment/33534110
answer count: 1

http://stackoverflow.com/comment/33506292
score: 0
type: Comment
type: QuestionComment
has text: @fge i'm totally stuck
comment on: http://stackoverflow.com/q/22090850

http://stackoverflow.com/comment/44149216
score: 0
type: Comment
comment on: http://stackoverflow.com/a/27164043
type: AnswerComment
has text: That solves the problem! It should be noted that you need to always do the mPfd stuff (ie clearFileDescriptor() ) before you try socket.close(). The PFD leak will remain if socket.close() is called first. You may also want to do the LocalSocket (mSocket) cleanup before that mPfd stuff. I was seeing some weird things happen until I added that and synchronize()'ed it on the BluetoothSocket obj. Basically replicating the Android 5.0 code: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.0_r1/android/bluetooth/BluetoothSocket.java#BluetoothSocket.close%28%29

http://stackoverflow.com/q/22129515
upvote count: 1
accepted answer: http://stackoverflow.com/a/22129603
type: Question
type: AnsweredQuestion
tagged with: compareto
score: 1
tagged with: java
has body: i have an abstract class that implements comparable and has the following : public abstract class Figure implements Comparable{ protected double height ; public abstract double getArea(); public abstract double calculatevolume();//will be used later to compare the volume public int compareTo(Figure o) { return 0; } } i have circle and square as children of Figure but when i try to compare to volume of two objects it always return 0 ! this is my compareTo method in the circle class: public int compareTo(Object o) { Figure a = (Figure) o; if (this.calculatevolume() &gt; ((Figure) o).calculatevolume()) return (int)this.calculatevolume(); else if (this.calculatevolume() &lt; ((Figure) o).calculatevolume()) return (int) a.calculatevolume(); else return 0; }
answer count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33575832
favorite count: 0
has answer: http://stackoverflow.com/a/22129603
possible better answer: http://stackoverflow.com/a/22129626
has answer: http://stackoverflow.com/a/22129626
has title: comparing two objects with same parent abstract class and the output is zero

http://stackoverflow.com/a/22025816
has comment: http://stackoverflow.com/comment/33390036
has comment: http://stackoverflow.com/comment/33389802
has comment: http://stackoverflow.com/comment/33389942
score: 0
has comment: http://stackoverflow.com/comment/33389702
answers question: http://stackoverflow.com/q/22025590
has body: Use this: public static void printOnLines(int n, int s){ StringBuilder builder = new StringBuilder(); for(int i = 1; i &lt;= n; i++){ builder.append(i); if(i % s == 0)builder.append("\n"); else builder.append(", "); } System.out.println(builder.toString().substring(0,builder.toString().length() - 2)); }
type: Answer

http://stackoverflow.com/comment/33631362
type: AnswerComment
has text: I added that portion before I commented the first time.
type: Comment
comment on: http://stackoverflow.com/a/22160470
score: 0

http://stackoverflow.com/a/22119849
has body: Do not use regex for HTML, use JSoup or a specialized parser instead. I'd use perl for this: $tree-&gt;look_down('_tag', 'td', sub { push @text, $_-&gt;[0]-&gt;as_text; }); ... or something like that.
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 1
answers question: http://stackoverflow.com/q/22119665
upvote count: 1
accepted answer of: http://stackoverflow.com/q/22119665

http://stackoverflow.com/a/22048842
has body: Whenever the super.doLogic() from classB is executed, it will always refer to the doLogic() method of the super class of classB which in this case would be classA. This is the desired behavior so that control does not keep passing between classes within the same method. This is the concept of a class context. Once you are in the context of a class, you will have to follow the rules established by that class and not keep passing control between different contexts.
downvote count: 1
has comment: http://stackoverflow.com/comment/33430798
type: Answer
score: 1
upvote count: 2
answers question: http://stackoverflow.com/q/22048684

http://stackoverflow.com/comment/33725879
type: Comment
comment on: http://stackoverflow.com/a/22140647
type: AnswerComment
has text: @user3373819 The linked documentation and questions have all the information you will need to be able to set up your policy file, and it is a good skill to learn. If you have specific questions about your policy file please open a new question.
score: 0

http://stackoverflow.com/comment/33583606
type: Comment
comment on: http://stackoverflow.com/a/22133362
type: AnswerComment
score: 0
has text: Well, actually i didn't try the byteman method yet, but i had already looked at it and couldn't find the packages / .so required.

http://stackoverflow.com/q/22074570
favorite count: 0
tagged with: jdbc
type: AnsweredQuestion
has title: Can´t delete HSQLDB files
downvote count: 0
score: 1
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22077534
accepted answer: http://stackoverflow.com/a/22077534
has body: I´m developing an application that basically is a installer. At startup creates an HSQL database, a schema and insert some data. After that, if some conditions are met, i want to completely delete the database (files included), for example, if the installation for some reason fails. In my particular case, the error must happen when the user wants to install the application in a folder where there is already the app installed. Because the HSQLDB is already there with the same name and the credentials are changed, the error happens at schema creation time when i try to connect to the db with the default credentials. After i catch this error, the problem i´m having is that when i try to delete the directory where the database is, i get an error because the .log file is locked (and it must be from my running app that is holding that lock, but i can´t figure why). Here is the relevant code that gets executed before the authorization error: private static void createDB(String dbName, String dbPath) { Server server = new Server(); server.setDatabaseName(0, dbName); server.setDatabasePath(0, "file:" + dbPath); server.setSilent(true); server.setRestartOnShutdown(false); server.signalCloseAllServerConnections(); server.setNoSystemExit(true); server.start(); server.stop(); server.shutdown(); } private static void createSchema() throws SQLException, FileNotFoundException, IOException { Connection conn = null; try { conn = DBManager.getConnection(); &lt;---- AUTH ERROR HAPPENS HERE! ScriptRunner runner = new ScriptRunner(conn, true, true); runner.runScript(new BufferedReader(new FileReader("someScript.sql"))); runner.runScript(new BufferedReader(new FileReader("someScript.sql"))); } finally { DBUtils.closeQuietly(conn); } } After i catch the auth exception, i try to delete the hsqldb folder by doing: File directoryFile = new File(dirPathDB); org.apache.commons.io.FileUtils.deleteQuietly(directoryFile); But i get an error saying "unable to delete file somepath/somelogfile.log" I …
upvote count: 1
answer count: 1
tagged with: hsqldb

http://stackoverflow.com/a/22031745
type: Answer
answers question: http://stackoverflow.com/q/22031588
has body: I don't know if there is a built-in facility for that, but you can definitely avoid the chain of ifs by employing an interface and a map that maps types to converters. The following code sets up the map: // This interface defines the conversion method interface Converter { Object fromString(String s); } // This map has one converter per supported class static final Map&lt;Class,Converter&gt; mapper = new HashMap&lt;Class,Converter&gt;(); static { mapper.put(Integer.class, new Converter() { public Object fromString(String s) { return Integer.parseInt(s); } }); mapper.put(Double.class, new Converter() { public Object fromString(String s) { return Double.parseDouble(s); } }); } Once the map is set up, you can do conversions like this: int x = (int)mapper.get(Integer.class).fromString("123"); double y = (double)mapper.get(Double.class).fromString("1.23"); Here is a demo on ideone.
downvote count: 0
score: 1
type: AcceptedAnswer
upvote count: 1
accepted answer of: http://stackoverflow.com/q/22031588

http://stackoverflow.com/comment/33372287
has text: If I correctly understand this: the project with your pom example would be used as a parent project to 'your.project' with my pom above? Wouldn't this be kind of a circular dependency?
type: AnswerComment
comment on: http://stackoverflow.com/a/22016471
score: 0
type: Comment

http://stackoverflow.com/q/22022678
tagged with: java
has comment: http://stackoverflow.com/comment/33383926
has answer: http://stackoverflow.com/a/22022863
score: 0
has comment: http://stackoverflow.com/comment/33383872
answer count: 3
has body: I'm pretty new to java, and I have something to do that is giving me some trouble. I have to read a file line from line and then make two strings from each line and use them for something. Everything is working great except for the thing when I have to read the lines from the file. Right now I have the following code: public static Estructura Read() throws IOException { Estructura list = new Estructura(); Scanner teclat = new Scanner(System.in); System.out.println("Nom del fitxer: "); Scanner file = new Scanner(new File(teclat.nextLine())); teclat.close(); String s = file.toString(); while (file.hasNextLine() || s.charAt(14) != '(') { ... file = new Scanner(new File(teclat.nextLine())); s = file.toString(); } The problem is, when I run it and type 2.txt it brings me this errors: (the file format is correct) Exception in thread "main" java.lang.IllegalStateException: Scanner closed at java.util.Scanner.ensureOpen(Unknown Source) at java.util.Scanner.findWithinHorizon(Unknown Source) at java.util.Scanner.nextLine(Unknown Source) at Llenguatges.Llegir(Llenguatges.java:66) at Llenguatges.main(Llenguatges.java:10) Line 66 is this one: file = new Scanner(new File(teclat.nextLine())); So, how can I read one line, use it and keep reading it until the second condition in the while happens? I hope I explained it well, thanks in advance
has answer: http://stackoverflow.com/a/22023089
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22023038
tagged with: filereader
tagged with: java.util.scanner
type: Question
has title: How to read a file line by line with a scanner and use the info?

http://stackoverflow.com/q/22082575
type: Question
has answer: http://stackoverflow.com/a/22082646
accepted answer: http://stackoverflow.com/a/22082592
has answer: http://stackoverflow.com/a/22082639
downvote count: 0
has title: Unknown error preventing construction of subclasses
possible better answer: http://stackoverflow.com/a/22082588
favorite count: 0
has body: Here is my superclass: public abstract class BankAccount { private String name; private double balance; final int OVERDRAFT_FEE = 35; private static int accountNum=0; public BankAccount(String name) { this.name=name; balance=0; accountNum++; } //various methods omitted public abstract void endOfMonth(); public String toString(BankAccount account) { return "Account Name: "+name+"\nBalance: $"+balance+"\nAccount Number: "+accountNum; } } and here is my subclass: public class CheckingAccount extends BankAccount { final int TRANSACTION_LIMIT = 3; final int MINIMUM_BALANCE = 50; final int FEE = 10; private int transactionCount; // various methods omitted public void endOfMonth() { if(transactionCount&gt;TRANSACTION_LIMIT) { int extra = transactionCount-TRANSACTION_LIMIT; int extra_fee = FEE*extra; super.setBalance((super.getBalance)-extra_fee); } if(super.getBalance()&lt;MINIMUM_BALANCE) { super.setBalance((super.getBalance)-FEE); } } } it gives me an exception when compiling the subclass saying "constructor BankAccount in class BankAccount cannot be applied to given types; required: java.lang.String; found: no arguments; reason: actual and formal argument lists differ in length" i thought it was a problem with the abstract method at first but getting rid of it didn't fix anything. thoughts?
has answer: http://stackoverflow.com/a/22082588
has answer: http://stackoverflow.com/a/22082592
answer count: 4
type: AnsweredQuestion
score: 2
upvote count: 2
tagged with: java

http://stackoverflow.com/comment/33405199
type: Comment
score: 1
has text: I'm guessing this is a school assignment?
comment on: http://stackoverflow.com/q/22034250
type: QuestionComment

http://stackoverflow.com/q/22053413
has comment: http://stackoverflow.com/comment/33438894
has comment: http://stackoverflow.com/comment/33438946
has comment: http://stackoverflow.com/comment/33439047
tagged with: java
has comment: http://stackoverflow.com/comment/33438977
type: Question
has comment: http://stackoverflow.com/comment/33439003
has title: Field shadowing or overriding?
tagged with: overriding
has answer: http://stackoverflow.com/a/22053563
has comment: http://stackoverflow.com/comment/33438937
has comment: http://stackoverflow.com/comment/33438828
score: 0
has body: I have two classes (A and B) and B extends A. public class A { protected int i = 1; } public class B extends A{ protected int i = 2; } In this case the program writes 1. A a = new B(); System.out.println(a.i); //1 But if I assign value i in the constructor it writes 2. public class B extends A{ public B(){ i=2; } } A a = new B(); System.out.println(a.i); //2 Why?
answer count: 1
tagged with: shadowing
has comment: http://stackoverflow.com/comment/33439064
has comment: http://stackoverflow.com/comment/33438887
has comment: http://stackoverflow.com/comment/33439143
has comment: http://stackoverflow.com/comment/33438852
linked to: http://stackoverflow.com/q/12244670
type: UnansweredQuestion

http://stackoverflow.com/a/22064827
has body: After you compile your code, you end up with .class files for each class in your program. These binary files are the bytecode that Java interprets to execute your program. The NoClassDefFoundError indicates that the classloader, which is responsible for dynamically loading classes, cannot find the .class file for the class that you're trying to use. It probably indicates that you haven't set the classpath option when executing your code. This link explains how to set the classpath when you execute
score: 1
upvote count: 1
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/22064705

http://stackoverflow.com/a/22139404
has comment: http://stackoverflow.com/comment/33598218
has body: just try this method to get your arrivaldate + departdate. $("#from_date").datepicker({ minDate : 0, onSelect: function() { var minDate = $(this).datepicker('getDate'); minDate.setDate(minDate.getDate()); $("#to_date").datepicker( "option", "minDate", minDate); } }); $("#to_date").datepicker({ minDate: 0 }); fiddle demo to click here.
answers question: http://stackoverflow.com/q/22134763
score: 0
type: Answer

http://stackoverflow.com/q/22071885
score: 0
answer count: 1
tagged with: jar
has answer: http://stackoverflow.com/a/22074904
has comment: http://stackoverflow.com/comment/33474617
type: AnsweredQuestion
type: Question
has body: i was writing a custom task for ant in java and my idea was that i can give someone the .jar which contains the java files like the classes and the libraries and the build.xml for ant and he can use it. If i export my java project the .jar (antTask.jar) contains : a folder for the compiled classes, one for the libraries, meta-inf folder and .classpath .project files The ant build.xml looks like this: &lt;?xml version="1.0" ?&gt; &lt;project name="repair" basedir="." default="repairTask"&gt; &lt;taskdef name="antTask" classpath="antTask.jar" classname="def.RepairTask"/&gt; &lt;target.... i don't really understand all this classpath stuff, so can someone tell me what i have to add in my build file so it will work only with this .jar file without the java code sources? right now i am getting an error that ant can't find one of the libraries i use in the java code with this error (but the antTask.jar contains this lib as another .jar): taskdef A class needed by class def.RepairTask cannot be found: org/apache/commons/... using the classloader AntClassLoader[C:...\AntTask\antTask.jar] i am trying for hours but i just can't figure out how i have to edit my build.xml so i just have to point to this single .jar file and it works.. Thank you guys
accepted answer: http://stackoverflow.com/a/22074904
has comment: http://stackoverflow.com/comment/33473513
tagged with: ant
tagged with: java
has title: custom ant task with additional libraries

http://stackoverflow.com/q/22007644
answer count: 6
tagged with: http://stackoverflow.com/tag/c
has body: Considering the following code snippets class time implement Runnable{ long t=0L; public void run(){ try{while(true){Thread.sleep(1000);t++;/*show the time*/}}catch(Throwable t){} } } //// long long t=0L; void* time(void* a){//pthread thread start sleep(1);t++;//show the time } I read in some tutorial that in Java Thread.sleep(1000) is not exactly 1 second, and it might be more if the system is busy at the time, then OS switch to the thread late. Questions: Is this case true at all or no? Is this scenario same for native (C/C++) codes? What is the accurate way to count the seconds up in an application?
score: 0
tagged with: pthreads
accepted answer: http://stackoverflow.com/a/22008608
has answer: http://stackoverflow.com/a/22007879
has answer: http://stackoverflow.com/a/22007922
has comment: http://stackoverflow.com/comment/33360090
has answer: http://stackoverflow.com/a/22008608
tagged with: c++
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22007893
has title: Accurate spending time solution
has answer: http://stackoverflow.com/a/22008029
tagged with: java
tagged with: multithreading
has answer: http://stackoverflow.com/a/22007893
has answer: http://stackoverflow.com/a/22008303
type: Question

http://stackoverflow.com/q/22139111
score: 4
has title: Is there a SortedMultimap type implementation in Guava that doesn't care about the order of its values
answer count: 1
favorite count: 0
type: UnansweredQuestion
upvote count: 4
has body: E.g. I want a multimap from Integer to zero or more File objects. I'd like the map to stay sorted as I insert or remove entries. But I don't care about the order of the values (Files), which don't have a natural ordering anyway. There doesn't seem to be an implementation that I can see (which is really unfortunate), so right now I'm stuck using TreeMap&lt;Integer, List&lt;File&gt;&gt;.
has answer: http://stackoverflow.com/a/22139486
tagged with: guava
downvote count: 0
tagged with: java
type: Question

http://stackoverflow.com/comment/33534390
comment on: http://stackoverflow.com/a/22105329
has text: problems, it appears that the twitter.3.0.3 jar I downloaded from http://twitter4j.org/en/versions.html just contains .java files! No class files. Where might I get a the right Jar?
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33479684
has text: There are no pointers in Java. The only way to achieve some form of "out" or "by ref" calling semantics is to *mutate* an object that is supplied as an argument - as is shown in the latter case. I would recommend making `doStuff` simply *return* a useful (compound) value.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22076426
score: 0

http://stackoverflow.com/a/22019448
score: 0
has comment: http://stackoverflow.com/comment/33379267
has comment: http://stackoverflow.com/comment/33379445
type: Answer
has comment: http://stackoverflow.com/comment/33378788
has body: You are never cleaning up the connection to the server. You need to close these output stream once you flush the stream. outToServer.flush(); outToServer.close();
answers question: http://stackoverflow.com/q/22018305

http://stackoverflow.com/a/22165232
downvote count: 0
type: Answer
score: 2
upvote count: 2
has body: I'm sure you you have the following lines inside some method. Instead of hard coding the fq part, have some variable there. SolrQuery solrQuery = new SolrQuery(); solrQuery.set(CommonParams.FQ, “-author:Dickens,Janet”); If you need to use the fq, pass proper parameter (e.g “-author:Dickens,Janet”). Otherwise pass an empty string. So, your query will be like /solr/solrbase/select?q=Dickens&amp;fq=&amp;wt=json&amp;indent=true Then add your faceting part of the query. Though your query having fq=, it won't throw an error. It basically won't work for the fq part. But rest of the query will work fine. Hope this will help.
has comment: http://stackoverflow.com/comment/33839651
answers question: http://stackoverflow.com/q/22041067

http://stackoverflow.com/comment/33408124
comment on: http://stackoverflow.com/q/22035048
score: 0
has text: @MadProgrammer ...or you could use something similar to [this](https://github.com/haraldk/TwelveMonkeys#deploying-the-plugins-in-a-web-app). I wrote it for my own library, but it should work for the JAI imageio plugins as well. Your solution is probably the easiest though. :-)
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33418249
score: 0
has text: In what component are you using it?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22041044

http://stackoverflow.com/a/22150528
has comment: http://stackoverflow.com/comment/33613963
has comment: http://stackoverflow.com/comment/33612635
has body: The simplest way is to write a script that starts the program on 'start', and send a SIGTERM signal to the the Java process on 'stop'. Your code can handle the signal accordingly for clean shutdown. This will be sufficient if it's just a start/stop script scenario. For more advanced behaviour, the other answers mention other alternatives which require networking.
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33613171
upvote count: 1
has comment: http://stackoverflow.com/comment/33612969
has comment: http://stackoverflow.com/comment/33612819
answers question: http://stackoverflow.com/q/22150392
type: Answer

http://stackoverflow.com/q/22014037
accepted answer: http://stackoverflow.com/a/22014067
downvote count: 2
has comment: http://stackoverflow.com/comment/33368049
upvote count: 1
type: Question
tagged with: try-catch
type: AnsweredQuestion
has body: I created a number format try catch: which is something like this try{ int blabla = sc.nextInt(); } catch (numberFormatException E) { doSomething(); } How can I go straight to the catch, if say, blabla &gt; 100? Can I go straight to the catch, without having a number format exception, and using if statements? The try catch is mainly for when a string is entered.
tagged with: java
possible better answer: http://stackoverflow.com/a/22014108
score: -1
has answer: http://stackoverflow.com/a/22014067
has answer: http://stackoverflow.com/a/22014108
has answer: http://stackoverflow.com/a/22014125
answer count: 3
has comment: http://stackoverflow.com/comment/33367596
linked to: http://stackoverflow.com/q/1070590
favorite count: 0
has comment: http://stackoverflow.com/comment/33367629
has title: Can I go straight to exception on a certain condition?

http://stackoverflow.com/comment/33439482
score: 2
comment on: http://stackoverflow.com/q/22053750
has text: You probably want to use Set instead of List.
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22111700
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22111880
tagged with: java
type: Question
score: 0
has title: having error in BlueJ library
answer count: 1
has body: the problem is this (import java.*;). i've been watching some tutorials in youtube about frames and etch. and ive been copying his code. i wonder why this happens only in me. I use BlueJ for my IDE and the error says package javax doesnt exist. please help me. Thank you! well, java.* ; doesnt exist? what's the problem? the guy no youtube has no problem running his code and i copied it carefully without mistake. the only error i get is the line 1 which is: import java.*; same as the guy on youtube.

http://stackoverflow.com/a/22146854
has body: If you're asking for the JPA INsyntax you would do this: SELECT e FROM Employees e where e.employee_no IN :employeelist as well ass query.setParameter( "employeelist" , yourlist ); and of course build yourlist accordingly. If you don't really need to parameterize the inner queries, you can disregard this and just go the straight forward route. Cheers,
answers question: http://stackoverflow.com/q/22146599
type: Answer
score: 0

http://stackoverflow.com/comment/33506848
comment on: http://stackoverflow.com/a/22091531
type: AnswerComment
score: 0
type: Comment
has text: @Sripathi `this` will never be `null` on an invoked method. Do you see any mention of `this == null` here?

http://stackoverflow.com/comment/33592341
type: QuestionComment
has text: I don't think you answered Kakarot question, how do you clear your elements from the list? "after I empty the list and add 1 item to it", how do you empty it? do you call remove first n times? remove last n times? or do you use another method?
score: 1
comment on: http://stackoverflow.com/q/22137316
type: Comment

xslt
tags question: http://stackoverflow.com/q/22148544
tags question: http://stackoverflow.com/q/22094200
tags question: http://stackoverflow.com/q/22052547
tags question: http://stackoverflow.com/q/22066228
tags question: http://stackoverflow.com/q/22149000
tags question: http://stackoverflow.com/q/22076943
tags question: http://stackoverflow.com/q/22029359
tag name: xslt
tags question: http://stackoverflow.com/q/22042197
type: Tag
tags question: http://stackoverflow.com/q/22036622

http://stackoverflow.com/a/22163254
has comment: http://stackoverflow.com/comment/33635857
has comment: http://stackoverflow.com/comment/33635920
type: AcceptedAnswer
downvote count: 0
has body: Since the actual link text is truncated, search using a sub string using atleast the minimum number of characters required to get a unique match. Note that with By.partialLinkText, you have to provide the partial text to search with, like so. //assuming the below string is read from excel String searchTxt = "Front printer (Based on price list) – ADD 1"; //try to search for the link using the first 30 chars driver.findElement(By.partialLinkText(searchTxt.substring(0,30))).click(); The above code will return the first match it finds based on the partial text supplied.
type: Answer
accepted answer of: http://stackoverflow.com/q/22162937
score: 2
answers question: http://stackoverflow.com/q/22162937
upvote count: 2
has comment: http://stackoverflow.com/comment/33636018

http://stackoverflow.com/comment/33399091
type: QuestionComment
has text: more details?.using which platform? or language
comment on: http://stackoverflow.com/q/22030902
score: 0
type: Comment

http://stackoverflow.com/q/22097439
has comment: http://stackoverflow.com/comment/33517416
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33517077
favorite count: 0
has answer: http://stackoverflow.com/a/22097818
type: Question
possible better answer: http://stackoverflow.com/a/22097499
has answer: http://stackoverflow.com/a/22097499
has answer: http://stackoverflow.com/a/22097673
has comment: http://stackoverflow.com/comment/33517101
score: 0
tagged with: java
answer count: 3
upvote count: 1
has comment: http://stackoverflow.com/comment/33517129
downvote count: 1
accepted answer: http://stackoverflow.com/a/22097818
has comment: http://stackoverflow.com/comment/33516995
has body: In my project, I'm working with webservices. To play with them, I use an Hastable in java. I m working with 1.6.x java version. I have an Hashtable declared as Hashtable&lt;String, String&gt; props1 = new Hashtable&lt;String, String&gt;(); I could put data in like this props1.put("@aze", values); The 9 first element: no problem, all work well. At the 10 one, it a crash... and i don't understand. How could I do ? many thx edit: full code source public static void main(String[] args) { Hashtable&lt;String, String&gt; props1 = new Hashtable&lt;String, String&gt;(); props1.put("@matricule", values[0]); props1.put("@nom", values[1]); props1.put("@prenom", values[2]); props1.put("@email", values[3]); props1.put("@estoccasionnel", values[4]); props1.put("@adresse", values[5]); props1.put("@codepostal", values[6]); props1.put("@ville", values[7]); props1.put("@telfixe", values[8]); props1.put("@telmobile", values[9]); } code break at props1.put("@telmobile", values[9]); with error message java.lang.ArrayIndexOutOfBoundsException: 9 at CommandLineCreationWebservice.main(CommandLineCreationWebservice.java:99)
has title: Hashtable length limit java

http://stackoverflow.com/q/22129471
has title: What is the best / most elegant way to limit the number of concurrent evaluation (like with a fixedThreadPool) in parallel streams
has comment: http://stackoverflow.com/comment/33579220
favorite count: 0
has comment: http://stackoverflow.com/comment/33575893
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/21163108
tagged with: java-8
upvote count: 5
has comment: http://stackoverflow.com/comment/33577397
tagged with: java
tagged with: concurrency
has answer: http://stackoverflow.com/a/22130761
linked to: http://stackoverflow.com/q/23442183
type: Question
answer count: 2
score: 5
downvote count: 0
has comment: http://stackoverflow.com/comment/33575787
has answer: http://stackoverflow.com/a/22144111
has body: Assume a lambda expression consume a certain amount of a resource (like memory) which is limited and requires to limit the number of concurrent executions (example: if the lambda temporarily consumes 100 MB (of local memory) and we like to limit it to 1GB, we do not allow for more that 10 concurrent evaluations). What is the best way to limit the number of concurrent execution, say for example in IntStream.range(0, numberOfJobs).parallel().foreach( i -&gt; { /*...*/ }); ? Note: An obvious option is to perform a nesting like double jobsPerThread = (double)numberOfJobs / numberOfThreads; IntStream.range(0, numberOfThreads).parallel().forEach( threadIndex -&gt; IntStream.range((int)(threadIndex * jobsPerThread), (int)((threadIndex+1) * jobsPerThread)).sequential().forEach( i -&gt; { /*...*/ })); Is this the only way? Tt is not that elegant. Actually I would like to have a IntStream.range(0, numberOfJobs).parallel(numberOfThreads).foreach( i -&gt; { /*...*/ });

http://stackoverflow.com/q/22083940
upvote count: 1
type: Question
linked to: http://stackoverflow.com/q/2333285
has comment: http://stackoverflow.com/comment/33493659
has comment: http://stackoverflow.com/comment/33493849
has comment: http://stackoverflow.com/comment/33493713
has comment: http://stackoverflow.com/comment/33493556
has comment: http://stackoverflow.com/comment/33493641
linked to: http://stackoverflow.com/q/513832
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/33493717
favorite count: 0
has comment: http://stackoverflow.com/comment/33493567
has comment: http://stackoverflow.com/comment/33493608
has body: Trying to run the below program but keep getting error. I am not sure where I went wrong. Any assistance would be greatly appreciated. run: Welcome to Mike and Diane's Pizza Enter your first name: Mike Pizza Size (inches ) Cost: 10 $10.99 12 $12.99 14 $14.99 16 $16.99 What size pizza would you like? 10, 12, 14, or 16 (enter the number only): 12 Exception in thread "main" java.lang.RuntimeException: Uncompilable source code Java Result: 1 BUILD SUCCESSFUL (total time: 22 seconds) import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.Scanner; // You have to add an import statement to use the DecimalFormat class import java.text.DecimalFormat; public class Pizza_Order { public static void main(String[] args) { //TASK #5 Create a DecimalFormat object with 2 decimal places // You have to add code!!! DecimalFormat DollarFormat = new DecimalFormat(); //Create a Scanner object to read input Scanner keyboard = new Scanner(System.in); //Create an instance of a Pizza Pizza order = new Pizza(); String firstName; //user's first name boolean discount = false; //flag, //true if user is eligible for discount int inches; //size of the pizza char crustType; //type of crust double cost; //cost of the pizza final double TAX_RATE = .08; //sales tax rate double tax; //amount of tax char choice; //user's choice String input; //user input String toppings = "Cheese "; //list of toppings int numberOfToppings = 0; //number of toppings //prompt user and get first name System.out.println("Welcome to Mike and Diane's Pizza"); System.out.print("Enter your first name: "); firstName = keyboard.nextLine(); //determine if user is eligible for discount by //having the same first name as one of the owners //TASK #1 // You have to add code!!! if(firstName == "Mike" || firstName == "mike") { discount = true; } if(firstName == "Diane" || firstName == "diane…
has comment: http://stackoverflow.com/comment/33493908
has comment: http://stackoverflow.com/comment/33493969
type: AnsweredQuestion
has title: Unexplained Uncompilable Source Code Error
has answer: http://stackoverflow.com/a/22084217
accepted answer: http://stackoverflow.com/a/22084217
score: 1
has comment: http://stackoverflow.com/comment/33493799
tagged with: java

http://stackoverflow.com/comment/33372492
score: 0
type: AnswerComment
type: Comment
has text: The `"` comes from the error message, it is not part of the string value.
comment on: http://stackoverflow.com/a/22016543

http://stackoverflow.com/a/22089121
has comment: http://stackoverflow.com/comment/33563325
type: Answer
answers question: http://stackoverflow.com/q/22089033
upvote count: 1
has comment: http://stackoverflow.com/comment/33566425
has comment: http://stackoverflow.com/comment/33566382
has body: Yes you need to add/replace fragments to the container based on list item click You can use interface as a callback to the activity. Fragment1-->HostingActivity-->Fragment2. Add make sure you add fragments to backstack. http://developer.android.com/training/basics/fragments/communicating.html You can use getActivity().getActionBar().setHomeButtonEnabled(true); getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); More info @ http://developer.android.com/training/implementing-navigation/ancestral.html Example : public interface ListItemCallback { public void callBackList() } Then in fragment ListItemCallback mCallback; @Override public void onAttach(Activity activity) { super.onAttach(activity); // This makes sure that the container activity has implemented // the callback interface. If not, it throws an exception try { mCallback = (ListItemCallback) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement ListItemCallback"); } } Then clientListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { String name = dataList.get(position).clientName; Log.d("message", "the client clicked on is: " + name); mCallback.callBackList(); } }); Then in Activity public class MainActivity extends Activity implements ListItemCallback { ...// rest of the code @Override public void callBackList(String name) { Fragment fragment = new FragmentClientDetail(); FragmentManager manager = getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); transaction.replace(R.id.container, fragment); transaction.addToBackStack("clientdetail"); transaction.commit(); } }
score: 1
downvote count: 0

http://stackoverflow.com/comment/33645188
comment on: http://stackoverflow.com/a/22165728
type: Comment
has text: I suppose my first code don't work because is deprecated and i have make some trobule. I have post new code in Edit1.
score: 0
type: AnswerComment

http://stackoverflow.com/q/22044264
tagged with: java
tagged with: hibernate
linked to: http://stackoverflow.com/q/22042903
tagged with: mysql
upvote count: 1
downvote count: 1
type: Question
has body: Say I have a Role type, which contains a long id, String name, etc. And I have another User class. Each user will have a roleId column which will point to Role.id. In my database I will 2 tables, one for user, the other for role. The roleId in the user table will be a foreign key to role.id table. My question is, how can I map this in Hibernate, so that I'll be able to have a Role role column in my User class, and would be able to do things like user.getRole().getName()?
accepted answer: http://stackoverflow.com/a/22044396
tagged with: foreign-key-relationship
score: 0
answer count: 2
favorite count: 0
has answer: http://stackoverflow.com/a/22044396
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22044433
linked to: http://stackoverflow.com/q/21971272
has title: How to embed another entity in a Hibernate entity using its id?
has answer: http://stackoverflow.com/a/22044433

http://stackoverflow.com/comment/33635944
has text: @sarath, I would recommend using the javax.xml.xpath APIs in the Java SE 5 and above instead of getElementsByTagName to make your code more readable and easier to maintain
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22163383
score: 1

http://stackoverflow.com/a/22093532
score: 0
has comment: http://stackoverflow.com/comment/33513198
has comment: http://stackoverflow.com/comment/33510050
type: Answer
has body: I made little changes in your code. public void searchMethod(List&lt;String&gt; books){ Scanner scanner = new Scanner(System.in); System.out.println("\n\nInput Books you wish for search"); //this code is executed when books is null, so first time you can invoke that method passing as argument simply null. if(books == null){ while(scanner.hasNext()) books.add(scanner.nextLine()); } System.out.println("\n\nBooks by your search"); for(String book : books) { if(book.toLowerCase().contains(search.toLowerCase())) { System.out.println(book); } } System.out.println("\n\nMore Books"); for(String book:books) { if(!(book.toLowerCase().contains(search.toLowerCase()))) { System.out.println(book); } } System.out.println("do you wish to search again from the same records?? (y/n)"); char searchagain=scanner.nextLine(); if(!searchagain.equals("y")) { return; } else if(searchagain.equals("y")) { searchMethod(books); } } }
answers question: http://stackoverflow.com/q/22093349
has comment: http://stackoverflow.com/comment/33510789
has comment: http://stackoverflow.com/comment/33510462
has comment: http://stackoverflow.com/comment/33509943

http://stackoverflow.com/q/22059898
type: AnsweredQuestion
has title: Execution of Quarts scheduler in Spring MVC multiple times
tagged with: java
tagged with: quartz-scheduler
type: Question
answer count: 2
tagged with: scheduling
accepted answer: http://stackoverflow.com/a/22104563
has body: I am using Quarts for task scheduling in Spring MVC, and my problem is that it executes multiple times (twice) every task. Please find the configuration and Java files below. File web.xml contextConfigLocation /WEB-INF/spring-servlet.xml org.springframework.web.context.ContextLoaderListener spring org.springframework.web.servlet.DispatcherServlet contextConfigLocation /WEB-INF/spring-servlet.xml 1 spring *.do File spring-servlet.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd"> <context:component-scan base-package="e24online.corporate.springmvc.controllers" /> <context:component-scan base-package="com.elitecore.dashboard.controller" /> <context:component-scan base-package="e24online.corporate.zeroconfiguration.controllers" /> <import resource="serviceConf.xml" /> <import resource="daoConf.xml" /> <import resource="beanConf.xml" /> <import resource="spring-quartz.xml" /> file:/usr/local/cyberoam/properties/multilingual/menu file:/usr/local/cyberoam/properties/multilingual/label file:/usr/local/cyberoam/properties/multilingual/message file:/usr/local/cyberoam/properties/multilingual/misc file:/usr/local/cyberoam/properties/multilingual/javascript File spring-quartz.xml File FixedDelayWorker.java pac…
score: 0
possible better answer: http://stackoverflow.com/a/25987575
has answer: http://stackoverflow.com/a/25987575
has answer: http://stackoverflow.com/a/22104563
tagged with: spring
tagged with: spring-mvc

http://stackoverflow.com/q/22143148
possible better answer: http://stackoverflow.com/a/22143379
has answer: http://stackoverflow.com/a/22143419
answer count: 4
has body: I want a Generic Method, however I'm not sure if it's ideal for this scenario, nor am I very much familiar with how Generic's work (if someone could link me a good tutorial or article, I'd very much appreciate it.) However, I wanted to create a method that handles initialization of JComponents, and if the array of JComponents was All JRadioButtons, to be sent to a different method. public void initializeComponent(JComponent...components) { if(components[0] instanceof JRadioButton) initializeJRadioButtons(components[]); } However, this will only check whether the first one is a JRadioButton, I feel Generics may handle this better, but is there a way to check if all components are JRadioButtons without looping? Such as if someone does this. JRadioButton[] radioButtons = new JRadioButton[2]; ... initializeComponent(radioButtons);
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22143379
tagged with: java
has comment: http://stackoverflow.com/comment/33599367
has comment: http://stackoverflow.com/comment/33603079
accepted answer: http://stackoverflow.com/a/22143340
type: Question
has comment: http://stackoverflow.com/comment/33599439
has answer: http://stackoverflow.com/a/22143335
has comment: http://stackoverflow.com/comment/33599356
score: 0
has comment: http://stackoverflow.com/comment/33599535
has title: Check if entire array is instanceof
tagged with: generics
has answer: http://stackoverflow.com/a/22143340
has comment: http://stackoverflow.com/comment/33599470
has comment: http://stackoverflow.com/comment/33599442
tagged with: swing

http://stackoverflow.com/q/22066946
tagged with: java
has comment: http://stackoverflow.com/comment/33462230
type: Question
has answer: http://stackoverflow.com/a/22067554
has answer: http://stackoverflow.com/a/22067389
tagged with: hibernate
answer count: 2
has comment: http://stackoverflow.com/comment/33461965
downvote count: 0
has body: This is a general programming practice question and totally open to modifications if its not clear. I have implemented a customDao instead of using hibernate and other orm tools. Take a look at its get method: def list(Map map){ def condition="" int count=0 for (Map.Entry&lt;String, Object&gt; entry : map.entrySet()) { if(count != 0) condition +=" AND " def key=entry.getKey().toLowerCase() def value="'"+entry.getValue()+"'" condition +=key+" = "+value count++ } def SQL="SELECT * FROM "+entityClass.getSimpleName().toLowerCase()+" WHERE "+condition log.debug "........"+SQL return jdbcTemplate.queryForList(SQL) } generally it takes a Map for conditions and returns list we want with the conditions in map. eg. customDao.list([parentid:1,name:"blabla"]) Here I can ask for all database records with parentid=1 and name="blabla" So far so good? What if I need to get a list for parentid!=1, I mean for now ,I take map conditions for equality but what should I do for inequality or greaterThan or lesserThan conditions. Long story short I have to get these conditions in receiving parameters of list method.What are the best practices.
favorite count: 0
type: UnansweredQuestion
score: 2
has title: Structure for genericDAO
upvote count: 2

http://stackoverflow.com/a/22071386
type: Answer
has body: Ordinarily this does work but more than likely you are using this code in a loop. Since nextDouble does not consume newline characters you will need to consume this character explicitly pages = input.nextDouble(); input.readLine() // added - consumes newline
upvote count: 4
answers question: http://stackoverflow.com/q/22071259
downvote count: 0
score: 4

http://stackoverflow.com/comment/33579033
score: 0
has text: i have place the print stack and it give me null pointer exception any idea why..?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22130934

http://stackoverflow.com/comment/33403876
has text: You forgot to ask the question. :D
score: 0
comment on: http://stackoverflow.com/q/22033962
type: Comment
type: QuestionComment

jboss
tags question: http://stackoverflow.com/q/22147287
tags question: http://stackoverflow.com/q/22116128
tags question: http://stackoverflow.com/q/22054047
tags question: http://stackoverflow.com/q/22069052
tag name: jboss
tags question: http://stackoverflow.com/q/22137643
type: Tag
tags question: http://stackoverflow.com/q/22049540
tags question: http://stackoverflow.com/q/22094448
tags question: http://stackoverflow.com/q/22042038
tags question: http://stackoverflow.com/q/22039291
tags question: http://stackoverflow.com/q/22046211
tags question: http://stackoverflow.com/q/22070744
tags question: http://stackoverflow.com/q/22089383
tags question: http://stackoverflow.com/q/22034158
tags question: http://stackoverflow.com/q/22006984
tags question: http://stackoverflow.com/q/22080807
tags question: http://stackoverflow.com/q/22040470

http://stackoverflow.com/comment/33645338
score: 0
comment on: http://stackoverflow.com/q/22168592
type: Comment
type: QuestionComment
has text: @AvinashSahu you want to get an array as result with **8** elements or **4**? you said in your question, your regex gave **almost desired result**, besides the `-` in name case, it will give **8** elements right? but your desired output from you previous edit, has only **4** elements?

http://stackoverflow.com/q/22131076
answer count: 1
favorite count: 0
type: UnansweredQuestion
tagged with: android
linked to: http://stackoverflow.com/q/19275528
has comment: http://stackoverflow.com/comment/33579965
tagged with: java
has answer: http://stackoverflow.com/a/22131482
downvote count: 1
type: Question
linked to: http://stackoverflow.com/q/10501426
has body: I'm parsing this XML Document, but getting the : org.xml.sax.SAXParseException: Unexpected token (position:TEXT Parameter not sp...@1:# in java.io.InputStreamReader@4124af00) I have tried This Link, This Link as well but didn't got any solution This is my code where I convert String Data which got from HttpResponse, to Document and getting Exception: protected Document convertWordDefinationToDocument(Context context, String defSource) { Document destDocument = null; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = null; try { documentBuilder = factory.newDocumentBuilder(); destDocument = documentBuilder.parse(new ByteArrayInputStream(defSource.getBytes("UTF-8")));// This is line where Exception occurs return destDocument; } catch (ParserConfigurationException e) { e.printStackTrace(); return null; } catch (SAXException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; }catch (Exception e) { return null; } } How can I solve that please help me...
has title: SAXParseException when trying to convert String to Document
score: 0
upvote count: 1

http://stackoverflow.com/comment/33643534
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22167779
has text: Thanks but in brief can u tel me how to run it via command line.

ssl
tags question: http://stackoverflow.com/q/22012486
tags question: http://stackoverflow.com/q/22044097
type: Tag
tags question: http://stackoverflow.com/q/22057326
tags question: http://stackoverflow.com/q/22010793
tags question: http://stackoverflow.com/q/22013287
tags question: http://stackoverflow.com/q/22137469
tags question: http://stackoverflow.com/q/22037210
tags question: http://stackoverflow.com/q/22006620
tag name: ssl
tags question: http://stackoverflow.com/q/22029420
tags question: http://stackoverflow.com/q/22149906
tags question: http://stackoverflow.com/q/22046136
tags question: http://stackoverflow.com/q/22132268
tags question: http://stackoverflow.com/q/22083547
tags question: http://stackoverflow.com/q/22044261
tags question: http://stackoverflow.com/q/22128994

http://stackoverflow.com/q/22144624
tagged with: java
type: Question
tagged with: jasper-reports
score: -1
has title: jasper Report - sub report with desire output look like table
has answer: http://stackoverflow.com/a/22151042
downvote count: 1
answer count: 1
has body: I want design as above in detail band.. I tried lot but i could not find any proper way to design. I made 9 sub report's for different content and this design is one of the content's from sub report,in which I tried with table but i dont know how to maintain sub-data-set.
favorite count: 0
type: UnansweredQuestion
upvote count: 0

http://stackoverflow.com/comment/33625810
type: QuestionComment
score: 0
has text: Sorry, if you have not understood me. I wish that when I have a single record also appeared to me the [ ]
comment on: http://stackoverflow.com/q/22157390
type: Comment

http://stackoverflow.com/a/53238217
type: Answer
has body: As of Java 6, the default implementation for PolicySpi is sun.security.provider.PolicySpiFile. You can get inspired from the source code of PolicySpiFile: package sun.security.provider; import java.security.CodeSource; import java.security.Permission; import java.security.PermissionCollection; import java.security.Policy; import java.security.PolicySpi; import java.security.ProtectionDomain; import java.security.URIParameter; import java.net.MalformedURLException; /** * This class wraps the PolicyFile subclass implementation of Policy * inside a PolicySpi implementation that is available from the SUN provider * via the Policy.getInstance calls. * */ public final class PolicySpiFile extends PolicySpi { private PolicyFile pf; public PolicySpiFile(Policy.Parameters params) { if (params == null) { pf = new PolicyFile(); } else { if (!(params instanceof URIParameter)) { throw new IllegalArgumentException ("Unrecognized policy parameter: " + params); } URIParameter uriParam = (URIParameter)params; try { pf = new PolicyFile(uriParam.getURI().toURL()); } catch (MalformedURLException mue) { throw new IllegalArgumentException("Invalid URIParameter", mue); } } } protected PermissionCollection engineGetPermissions(CodeSource codesource) { return pf.getPermissions(codesource); } protected PermissionCollection engineGetPermissions(ProtectionDomain d) { return pf.getPermissions(d); } protected boolean engineImplies(ProtectionDomain d, Permission p) { return pf.implies(d, p); } protected void engineRefresh() { pf.refresh(); } }
answers question: http://stackoverflow.com/q/22016669
score: 0

http://stackoverflow.com/comment/33542364
type: AnswerComment
comment on: http://stackoverflow.com/a/22110927
has text: @ktm5124 the classloader doesn't care which source file your class was in. Classes A, B, C and D are all separate classes loaded at different times. The fact is just that it is legal to refer to an accessible field in another class, no matter where it was declared in source code (before or after the reference) while local variables cannot be referenced before they are declared.
type: Comment
score: 2

http://stackoverflow.com/a/22086152
type: Answer
answers question: http://stackoverflow.com/q/22086128
has body: Well that's because you are starting your count from 0, neglecting the first node. Instead initialize count=1;
score: 0

http://stackoverflow.com/comment/33511364
has text: What do you mean exactly by 'I couldnt get this thing to work' ? Does it compile ? If not did you add the library dependency ? Is it an exception at runtime ? Please give more detail about your issues
comment on: http://stackoverflow.com/q/22091189
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33466795
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22069400
type: QuestionComment
has text: Although it is highly subjective, very few projects in Java adopt the Hungarian notation for classes and interfaces (as opposed to C#).

http://stackoverflow.com/q/22116005
score: 17
has body: How do I create and instantiate a jpa repository inside a class? I'm in a situation where I have to create repositories for different entities inside a generic class. I could do that easily for Neo4j repositories like, GraphRepository&lt;T&gt; graphRepository; this.neo4jTemplate = new Neo4jTemplate(new RestGraphDatabase( "http://localhost:7474/db/data")); this.graphRepository = neo4jTemplate.repositoryFor(domainClass); For JpaRepository, I checked the documentation and found this, RepositoryFactorySupport factory = … // Instantiate factory here UserRepository repository = factory.getRepository(UserRepository.class); I'm not sure how to instantiate factory in the above code. Also Can't I create repository like I did for Neo4j, by specifying the domain class?
type: Question
tagged with: jpa
downvote count: 0
has answer: http://stackoverflow.com/a/66564339
tagged with: spring-data-jpa
answer count: 3
has answer: http://stackoverflow.com/a/22342025
has title: How to create Jpa repository dynamically inside a class?
possible better answer: http://stackoverflow.com/a/66564339
favorite count: 0
accepted answer: http://stackoverflow.com/a/22342025
has answer: http://stackoverflow.com/a/73636195
linked to: http://stackoverflow.com/q/9123964
tagged with: spring-data
tagged with: spring
upvote count: 17
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/comment/33636107
score: 0
type: Comment
has text: camickr: I had tried wrapping up the text string in html but it is not applying the style font-variant:small caps
comment on: http://stackoverflow.com/a/22163359
type: AnswerComment

http://stackoverflow.com/q/22137526
has body: So I'm trying to write a code that searches a txt file for a specific string, then prints all lines on which the string occurs. The most straightforward way to do this seems to be running a Scanner and a LineNumberReader through the document, adding lines that fit the bill to the "found" string. However, whenever it stumbles across a line that doesn't contain the word, it throws a NullPointerException and kills the loop no matter what. Can anyone tell me what I'm doing wrong? FileReader r = new FileReader(f); LineNumberReader l = new LineNumberReader(r); Scanner s = new Scanner(l); int i = 1; String found = "Instances of string found:\n"; { while (s.hasNextLine()) { try { if (s.findInLine(keyword).isEmpty() == false) { found = found + l.readLine() + "\n"; s.nextLine(); } else { s.nextLine(); } } catch (NullPointerException e) { s.nextLine(); } } display(found, "Match found!"); }
upvote count: 1
possible better answer: http://stackoverflow.com/a/22137712
type: Question
tagged with: try-catch
accepted answer: http://stackoverflow.com/a/22137560
has answer: http://stackoverflow.com/a/22137712
has title: Try/Catch interfering with while loop
score: -1
answer count: 2
tagged with: while-loop
favorite count: 0
has comment: http://stackoverflow.com/comment/33589815
has answer: http://stackoverflow.com/a/22137560
downvote count: 2
has comment: http://stackoverflow.com/comment/33589848
linked to: http://stackoverflow.com/q/921471
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/comment/33531355
type: AnswerComment
has text: @assylias One thing to note is that the relationship of the classes and interfaces in my test case seem to be more complicated as in that particular bug, so that may have to do with it.
type: Comment
comment on: http://stackoverflow.com/a/22096371
score: 0

http://stackoverflow.com/q/22045493
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33467044
score: 1
tagged with: java
has title: Struts2 validation, repopulate all the fields when validation fails
tagged with: struts2
type: Question
has comment: http://stackoverflow.com/comment/33461438
linked to: http://stackoverflow.com/q/21291109
has comment: http://stackoverflow.com/comment/33464448
upvote count: 1
has comment: http://stackoverflow.com/comment/33460771
tagged with: validation
answer count: 1
has comment: http://stackoverflow.com/comment/33426866
tagged with: jsp
has comment: http://stackoverflow.com/comment/33427821
linked to: http://stackoverflow.com/q/22019803
favorite count: 0
has comment: http://stackoverflow.com/comment/33436278
has comment: http://stackoverflow.com/comment/33427224
has comment: http://stackoverflow.com/comment/33425492
has comment: http://stackoverflow.com/comment/33467869
has body: I have 2 pages, the first where the user insert the data, and the second where the user confirm the data (or can go back to the edit page). The problem is that when validation fails, all the values in fields are erased. Somebody suggested to use prepare(), but It's a lot of work to copy all the fields, does it exist a faster way to repopulate all the fields? the first page (formDatiUtente.jsp): &lt;%@ page language="java" contentType="text/html;" import="java.util.*,it.alm.bean.*,it.alm.delegate.*;"%&gt; &lt;%@ taglib prefix="s" uri="/struts-tags"%&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;link href="${pageContext.request.contextPath}/css/stile1.css" rel="stylesheet" type="text/css" /&gt; &lt;title&gt;Registrazione account&lt;/title&gt; &lt;script type="text/javascript" src="${pageContext.request.contextPath}/js/scriptFormUtente.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="${pageContext.request.contextPath}/js/scriptDWR.js"&gt;&lt;/script&gt; &lt;script type='text/javascript' src='/gestUtenzeLDAP/dwr/engine.js'&gt;&lt;/script&gt; &lt;script type='text/javascript' src='/gestUtenzeLDAP/dwr/util.js'&gt;&lt;/script&gt; &lt;script type='text/javascript' src='/gestUtenzeLDAP/dwr/interface/DwrAjaxServiceImplEnti.js'&gt;&lt;/script&gt; &lt;script type='text/javascript' src='/gestUtenzeLDAP/dwr/interface/DwrAjaxServiceImplTipoUfficio.js'&gt;&lt;/script&gt; &lt;script type='text/javascript' src='/gestUtenzeLDAP/dwr/interface/DwrAjaxServiceImplUfficio.js'&gt;&lt;/script&gt; &lt;script type='text/javascript' src='/gestUtenzeLDAP/dwr/interface/ComboBean.js'&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;jsp:include page="header.jsp"/&gt; &lt;s:actionerror /&gt; &lt;s:form name="formDatiUtente" action="inviaRichiesta.action" method="post" theme="simple" validate="true"&gt; &lt;% String pathContest=request.getContextPath(); //Collection clRichAna = (ArrayList)re…
accepted answer: http://stackoverflow.com/a/22069987
has comment: http://stackoverflow.com/comment/33428226
has comment: http://stackoverflow.com/comment/33466946
has comment: http://stackoverflow.com/comment/33458342
has comment: http://stackoverflow.com/comment/33467146
downvote count: 0
has comment: http://stackoverflow.com/comment/33425876
has comment: http://stackoverflow.com/comment/33427482
has answer: http://stackoverflow.com/a/22069987

http://stackoverflow.com/q/22076027
has answer: http://stackoverflow.com/a/22076398
score: 3
answer count: 1
downvote count: 0
favorite count: 0
tagged with: maven
tagged with: dependency-management
has body: I'm trying to set up a build for my team on a Jenkins box. They are using a product whose documentation says to drop 2 jar files and a .properties file in the $JAVA_HOME/jre/lib/ext directory. Since this Jenkins build box is managed by another team and houses many builds, I feel that it is a bad idea to tell them to install these files on all the slaves that may build this project. (especially if we were to need to upgrade/change settings/etc.) Is there a best-practice for managing this sort of thing? Things I've tried so far: Installing it in the $JAVA_HOME/jre/lib/ext == works. Installing the jar files in the maven repo and dropping the properties file in src/main/resources == doesn't work (it looks in $M2_REPO/PATH/TO/JAR/jarname.properties)
accepted answer: http://stackoverflow.com/a/22076398
type: AnsweredQuestion
tagged with: jenkins
upvote count: 3
tagged with: java
type: Question
has title: How do I manage jre/lib/ext jars in a Jenkins/Maven build?

http://stackoverflow.com/a/22086583
type: Answer
has body: just add this to controller @PostConstruct public void init(){ //call executor here }
has comment: http://stackoverflow.com/comment/33498327
has comment: http://stackoverflow.com/comment/33498400
score: 0
has comment: http://stackoverflow.com/comment/33498271
answers question: http://stackoverflow.com/q/22086373

http://stackoverflow.com/a/22025274
answers question: http://stackoverflow.com/q/22024770
type: Answer
has body: here we go File: 3,movie title,rating,other,other 4,movie title,rating,other,other 1,movie title,rating,other,other code: public static void main(String[] args) throws IOException { Map&lt;Integer, String&gt; map = new HashMap&lt;Integer, String&gt;(); BufferedReader br = new BufferedReader(new FileReader("movieReviews.txt")); String line=""; int i=0; while (line != null) { line = br.readLine(); map.put(i,line); i++; } String movieNumber=""; String movieTitle=""; String movieRating=""; String movieOther1=""; String movieOther2=""; for(int j=0;j&lt;map.size();j++){ if(!(map.get(j)== null)){ String[] getData=map.get(j).toString().split("\\,"); movieNumber = getData[0]; movieTitle = getData[1]; movieRating = getData[2]; movieOther1 = getData[3]; movieOther2 = getData[4]; System.out.println("|"+movieNumber+"|"+movieTitle+"|"+movieRating+"|"+movieOther1+"|"+movieOther2); } } }
score: 0

http://stackoverflow.com/comment/33590756
type: Comment
has text: I see what you're saying, I'm new to lineNumberReader, so I was using the scanner object because I didn't know how else to get the nextLine of the file.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22138022

http://stackoverflow.com/q/22121061
has answer: http://stackoverflow.com/a/22121136
accepted answer: http://stackoverflow.com/a/22122928
type: AnsweredQuestion
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33560172
favorite count: 0
type: Question
has title: GC overhead limit exceeded, but plenty of memory
has answer: http://stackoverflow.com/a/22122928
has comment: http://stackoverflow.com/comment/33560259
possible better answer: http://stackoverflow.com/a/22123208
has comment: http://stackoverflow.com/comment/33560468
has comment: http://stackoverflow.com/comment/33563601
upvote count: 2
has answer: http://stackoverflow.com/a/22123208
tagged with: java
answer count: 3
tagged with: jakarta-ee
has body: My JBoss server had a weird issue: the exception thrown: java.lang.OutOfMemoryError: GC overhead limit exceeded I looked for low memory conditions, but memory availability looked fine: Heap Configuration: MinHeapFreeRatio = 40 MaxHeapFreeRatio = 70 MaxHeapSize = 2147483648 (2048.0MB) NewSize = 2228224 (2.125MB) MaxNewSize = 4294901760 (4095.9375MB) OldSize = 4194304 (4.0MB) NewRatio = 2 SurvivorRatio = 8 PermSize = 16777216 (16.0MB) MaxPermSize = 805306368 (768.0MB) Heap Usage: PS Young Generation Eden Space: capacity = 176816128 (168.625MB) used = 110937856 (105.798583984375MB) free = 65878272 (62.826416015625MB) 62.741932681616014% used From Space: capacity = 38207488 (36.4375MB) used = 27193584 (25.933822631835938MB) free = 11013904 (10.503677368164062MB) 71.17344118514151% used To Space: capacity = 40960000 (39.0625MB) used = 0 (0.0MB) free = 40960000 (39.0625MB) 0.0% used PS Old Generation capacity = 1434451968 (1368.0MB) used = 818386128 (780.4738311767578MB) free = 616065840 (587.5261688232422MB) 57.052180641575866% used PS Perm Generation capacity = 113246208 (108.0MB) used = 109507808 (104.43478393554688MB) free = 3738400 (3.565216064453125MB) 96.69887401439526% used Has anyone encountered this GC exception before when there was seemingly plenty of memory?

database
tags question: http://stackoverflow.com/q/22015488
tags question: http://stackoverflow.com/q/22079030
tags question: http://stackoverflow.com/q/22138665
tags question: http://stackoverflow.com/q/22038786
tags question: http://stackoverflow.com/q/22096398
tags question: http://stackoverflow.com/q/22046798
tags question: http://stackoverflow.com/q/22094071
tags question: http://stackoverflow.com/q/22127264
type: Tag
tags question: http://stackoverflow.com/q/22106014
tags question: http://stackoverflow.com/q/22162127
tags question: http://stackoverflow.com/q/22121454
tags question: http://stackoverflow.com/q/22035182
tag name: database
tags question: http://stackoverflow.com/q/22054647
tags question: http://stackoverflow.com/q/22027563
tags question: http://stackoverflow.com/q/22125881
tags question: http://stackoverflow.com/q/22150519
tags question: http://stackoverflow.com/q/22020409
tags question: http://stackoverflow.com/q/22097586
tags question: http://stackoverflow.com/q/22016152
tags question: http://stackoverflow.com/q/22048412
tags question: http://stackoverflow.com/q/22145768
tags question: http://stackoverflow.com/q/22164247
tags question: http://stackoverflow.com/q/22055864
tags question: http://stackoverflow.com/q/22099934
tags question: http://stackoverflow.com/q/22075342
tags question: http://stackoverflow.com/q/22008049
tags question: http://stackoverflow.com/q/22049503
tags question: http://stackoverflow.com/q/22009341
tags question: http://stackoverflow.com/q/22023234
tags question: http://stackoverflow.com/q/22027417
tags question: http://stackoverflow.com/q/22066316

http://stackoverflow.com/comment/33422423
type: QuestionComment
comment on: http://stackoverflow.com/q/22044413
has text: If closes means the next element just increment the key by one and check the size of the array so you dont get a NPE, if closes means the one before just decrement the key and check size so you dont get a NPE.
score: 0
type: Comment

http://stackoverflow.com/comment/33602424
has text: @Bohemian Yes there could be. I'm querying MediaWiki pages, and I know that often they do that. Maybe not specifically in wikipedia pages but in wiktionary they do.
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/22144701

http://stackoverflow.com/q/22156945
has answer: http://stackoverflow.com/a/22175479
answer count: 1
has body: Years ago I wrote a Java Web Start application in NetBeans that performs a simple file upload task. For years I had it as a self-signed applet but finally caved and bought a signing certificate. I've got it all signed now, but I'm running into a new problem. One of the main class' public methods gets called by JavaScript. However, it seems to have stopped working. When I try calling this method manually in Firebug, here's the message I get back: Error: Liveconnect call for Applet ID 8 is not allowed in this JVM instance. UPDATE: Here's the version of the error that I get when I try this in Chrome: Error calling method on NPObject. I am already using the most up-to-date version of the Java plugin (7u51), so what gives? This applet used to work, but now apparently it no longer does. Do I need to add something special to the code? Or change a setting in the way it's compiled by NetBeans?
tagged with: liveconnect
type: AnsweredQuestion
score: 3
downvote count: 0
accepted answer: http://stackoverflow.com/a/22175479
tagged with: applet
favorite count: 0
type: Question
has comment: http://stackoverflow.com/comment/33637483
tagged with: netbeans
has title: What do I need to do to get LiveConnect working again?
upvote count: 3
tagged with: java

http://stackoverflow.com/comment/33514622
type: QuestionComment
comment on: http://stackoverflow.com/q/22096076
score: 1
has text: Note that you can also do `static final int i; static { i = 3; }`
type: Comment

http://stackoverflow.com/comment/33633730
type: AnswerComment
type: Comment
score: 0
comment on: http://stackoverflow.com/a/22161270
has text: Would try..jarsigner -verify jar-file

http://stackoverflow.com/q/22031582
answer count: 1
has comment: http://stackoverflow.com/comment/33401390
has answer: http://stackoverflow.com/a/22033136
tagged with: testng
type: AnsweredQuestion
has title: How to execute the Task Scheduler for eclipse?
tagged with: java
tagged with: selenium
type: Question
has comment: http://stackoverflow.com/comment/33401314
has comment: http://stackoverflow.com/comment/33400591
accepted answer: http://stackoverflow.com/a/22033136
tagged with: eclipse
score: 0
tagged with: batch-file
has body: Currently working on Selenium WebDriver and using Java. I have asked a question earlier to create the Task scheduler and i created as mentioned in the How to create scheduler to run my script every night at 12.00- Selenium WebDriver But the Problem it is opening the eclipse at the time i have scheduled but the problem Once it open the eclipse it need to run all test one by one I tried in cmd prompt, and getting error Error: Could not find or load main class org.testng.TestNG Anyone please suggest me to fix the issue. I have a run.bat as follows: set ProjectPath=C:\Documents and Settings\amth\workspace\OneReports\src\ echo %ProjectPath% set classpath=%ProjectPath%bin;%ProjectPath%lib* echo %classpath% java org.testng.TestNG %ProjectPath%Test.xml While checking in the Command Prompt it is appearing as follows: C:\Documents and Settings\amth&gt;cd desktop C:\Documents and Settings\amth\Desktop&gt;run.bat C:\Documents and Settings\amth\workspace\OneReports\src\ C:\Documents and Settings\amth\workspace\OneReports\src\bin;C:\Documents and Settings\amth\workspace\OneReports\src\lib*C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files (x86)\Java\jdk1.7.0_51\bin; Press any key to continue . . . java org.testng.eclipse C:\Documents and Settings\amth\workspace\OneReports\src\Test.xml C:\Documents and Settings\amth\Desktop&gt; Is Jenkins and some other scheduler will work for windowsxp Currently using TestNG framework, Selenium webdriver, Java code
has comment: http://stackoverflow.com/comment/33401620
has comment: http://stackoverflow.com/comment/33401465
linked to: http://stackoverflow.com/q/21744795
has comment: http://stackoverflow.com/comment/33400892

http://stackoverflow.com/comment/33489982
has text: You might want to read this http://stackoverflow.com/questions/15446689/what-is-the-use-of-system-in-read-in-java
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22081817
score: 0

http://stackoverflow.com/comment/33517191
score: 0
comment on: http://stackoverflow.com/q/22097466
has text: Here's another similar SO question with a bunch of explanations: http://stackoverflow.com/questions/65035/does-finally-always-execute-in-java/65949
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33434719
comment on: http://stackoverflow.com/q/22050907
score: 0
type: QuestionComment
has text: Thanks, I'll try to change it. I don't know what is anchored.
type: Comment

http://stackoverflow.com/comment/33443758
comment on: http://stackoverflow.com/a/22056062
type: Comment
has text: This isn't necessary. 600851475143 is far away from a `long`'s max value of 18446744073709551616.
type: AnswerComment
score: 4

http://stackoverflow.com/a/22038400
upvote count: 3
downvote count: 0
has body: Instead of creating a local reference in every place that uses this variable, just use the static method itself. Meaning, if you have a method: public void doSomething() { if(locale.isSomeLocale()) { // Do something } } Just do: public void doSomething() { if(Locale.getDefault().isSomeLocale()) { // Do something } } I think that's the cleanest option you can have. If you try to update 200+ local variables, every time the static variable changes, you'll have a terrible mess. This way, every point in your code is aligned with the locale you use.
type: Answer
answers question: http://stackoverflow.com/q/22038359
score: 3

http://stackoverflow.com/q/22147265
accepted answer: http://stackoverflow.com/a/22147487
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22147843
has answer: http://stackoverflow.com/a/22147843
tagged with: multithreading
upvote count: 1
type: Question
tagged with: java
has title: Does Sychronized block on same object really hold other thread from executing the block?
has answer: http://stackoverflow.com/a/22147487
downvote count: 0
has answer: http://stackoverflow.com/a/22290078
score: 1
tagged with: wait
tagged with: synchronized
favorite count: 0
has body: Hi I was trying to understand wait notify and i see this behaviour in the code that 2 threads are printing statements inside synchronized block on same object. public class WaitNotifyExample { /** * @param args */ public static void main(String[] args) { Message msg = new Message("process it"); Waiter waiter = new Waiter(msg); new Thread(waiter,"waiter").start(); Waiter waiter1 = new Waiter(msg); new Thread(waiter1, "waiter1").start(); Notifier notifier = new Notifier(msg); new Thread(notifier, "notifier").start(); //System.out.println("All the threads are started"); } } class Message { private String msg; public Message(String str){ this.msg=str; } public String getMsg() { return msg; } public void setMsg(String str) { this.msg=str; } } class Waiter implements Runnable{ private Message msg; public Waiter(Message m){ this.msg=m; } @Override public void run() { String name = Thread.currentThread().getName(); synchronized (msg) { try{ System.out.println(name+" waiting to get notified at time:"+System.currentTimeMillis()); msg.wait(); }catch(InterruptedException e){ e.printStackTrace(); } System.out.println(name+" waiter thread got notified at time:"+System.currentTimeMillis()); //process the message now System.out.println(name+" processed: "+msg.getMsg()); } } } class Notifier implements Runnable { private Message msg; public Notifier(Message msg) { this.msg = msg; } @Override public void run() { String name = Thread.currentThread().getName(); System.out.println(name+" started"); try { Thread.sleep(1000); synchronized (msg) { msg.setMsg(name+" Notifier work done"); //msg.notify(); msg.notifyAll(); } } catch (InterruptedException e) { e.printStackTrace(); } } } Here is the output of the program: -waiter waiting to get notified at time:1393849891481 -notifier started -waiter1 waiting to get notified at time:1393849891483 -waiter1 waiter thread got notified at time:1393849892483 -waiter1 processed: notifier Notifier work done -waiter waiter thread got notified at time:13…
answer count: 3

http://stackoverflow.com/a/22152014
has comment: http://stackoverflow.com/comment/33615603
answers question: http://stackoverflow.com/q/22151653
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/34094841
has comment: http://stackoverflow.com/comment/33615929
type: Answer
has comment: http://stackoverflow.com/comment/33615985
has body: you can do like this package com.sof.test; import java.awt.Desktop; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; 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 ticketcount { public static void main(String[] args) throws IOException { List<ticket> ticketList = new ArrayList<ticket>(); String content = ""; String content1 =" "; FileWriter fw =null; BufferedWriter bw=null; String Path = "src"; try { File fXmlFile = new File(Path + "\\ticket.xml"); DocumentBuilderFactory dbFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(fXmlFile); doc.getDocumentElement().normalize(); NodeList ticketNodeList = doc.getElementsByTagName("ticket"); for (int temp = 0; temp < ticketNodeList.getLength(); temp++) { Node varNode = ticketNodeList.item(temp); if (varNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) varNode; NodeList teamList = eElement.getElementsByTagName("team"); NodeList varsionList = eElement.getElementsByTagName("imp"); Node teamNode = teamList.item(0); Node impNode = varsionList.item(0); if (teamNode.getNodeType() == Node.ELEMENT_NODE && impNode.getNodeType() == Node.ELEMENT_NODE) { Element teamElement = (Element) teamNode; Element impElement = (Element) impNode; ticket ticket = new ticket( teamElement.getTextContent(), impElement.getTextContent()); ticketList.add(ticket); } } File file = new File(Path + "\\result1.html"); if (!file.exists()) { file.createNewFile(); } fw = new FileWriter(file.getAbsoluteFile()); bw = new BufferedWriter(fw); } } catch (Exception e) { e.printStackTrace(); } Map<ticket, Integer> co…
has comment: http://stackoverflow.com/comment/33616509
has comment: http://stackoverflow.com/comment/33616023
accepted answer of: http://stackoverflow.com/q/22151653

http://stackoverflow.com/a/22042869
has comment: http://stackoverflow.com/comment/33419813
has comment: http://stackoverflow.com/comment/33419595
type: Answer
upvote count: 1
has body: Take a look here. You will find many projects that will help you. I would try JSONObject.java from Crockford's JSON for Java Github repository. Simple usage : JSONObject obj = new JSONObject() .put("MainData", new JSONObject() .put("columnHeaderKeys", null) .put("rowHeaders", new JSONArray() .put(new JSONObject() .put("id", "001") .put("name", "abc") ) .put(new JSONObject() .put("id", "002") .put("rowId", "R1") // ... ) ); Output string with : String jsonString = obj.toString(); or write directly to file : obj.write(new FileWriter(new File("/path/to/destination/file")));
downvote count: 1
has comment: http://stackoverflow.com/comment/33421246
answers question: http://stackoverflow.com/q/22042794
score: 0

http://stackoverflow.com/a/22049488
score: 1
accepted answer of: http://stackoverflow.com/q/22049256
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22049256
has comment: http://stackoverflow.com/comment/33432984
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/33549015
has comment: http://stackoverflow.com/comment/33433196
has comment: http://stackoverflow.com/comment/33432907
has body: The simplest method would be to simply move all code from your main into a static utility-class function, and then call that function from your other classes mains. For example: public class LoginToWebsiteUtil { public static final void login(String username, String password, ...) { //CODE GOES HERE } } And use it with: public class LoginToMyWebsite { public static final void main(String[] ignored) { LoginToWebsiteUtil.login("myname", "password", ...) } } The only tricky thing will be answering the question: "what variables save state?" Those variables must be declared as static class fields in the utility class. This is because, as soon as the function ends, all state, such as the login-connection, will be terminated. In order to keep it around ("hold its state"), these state variables need to have a larger scope than just the lifetime of the function. For example, instead of public class LoginToWebsiteUtil { public static final void login(String username, String password, ...) { Connection conn = getConnectionFromLogin(username, password); //and so on... It will have to be public class LoginToWebsiteUtil { private static Connection conn = null; public static final void login(String username, String password, ...) { conn = getConnectionFromLogin(username, password); //and so on... Alternatively, you could put all the code from your original main function into the constructor of a new class, such as public class UserLogin { private static Connection conn = null; public UserLog(String username, String password, ...) { conn = getConnectionFromLogin(username, password); //CODE HERE } } But, as you can see, you still have the "what holds state?" issue. (This is a good problem. It sounds like this login code is potentially useful in the future for you.)
downvote count: 0

http://stackoverflow.com/q/22030654
has comment: http://stackoverflow.com/comment/33398613
tagged with: indexoutofboundsexception
tagged with: android-logcat
has comment: http://stackoverflow.com/comment/33398751
has comment: http://stackoverflow.com/comment/33398529
has comment: http://stackoverflow.com/comment/33398681
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/33398739
has comment: http://stackoverflow.com/comment/33398525
answer count: 0
score: 0
has body: I'm developing a music player. I'm getting all the files which are ends with .mp3 extensions. When I run this below code I'm getting StringIndexOutOfBoundException,Even if surround the coding with try,catch I'm getting the same error.Please help me. public ArrayList&lt;HashMap&lt;String, String&gt;&gt; getPlayList() { try{ System.out.println(MEDIA_PATH); if (MEDIA_PATH != null) { File home = new File(MEDIA_PATH); File[] listFiles = home.listFiles(); if (listFiles != null &amp;&amp; listFiles.length &gt; 0) { for (File file : listFiles) { System.out.println(file.getAbsolutePath()); if (file.isDirectory()) { scanDirectory(file); } else { addSongToList(file); } } } } }catch(Exception e){} // return songs list array return songsList; } private void scanDirectory(File directory) { try{ if (directory != null) { File[] listFiles = directory.listFiles(); if (listFiles != null &amp;&amp; listFiles.length &gt; 0) { for (File file : listFiles) { if (file.isDirectory()) { scanDirectory(file); } else { addSongToList(file); } } } } }catch(Exception e){} } private void addSongToList(File song) { try{ if (song.getName().endsWith(mp3Pattern)) { String title = song.getName().substring(0, (song.getName().length() - 4)); String path = song.getPath(); mediaInfo.setDataSource(path); String albumName = "unknown",artist = "unknown",genere = "unknown",duration = "unknown",composer = "unknown"; if(mediaInfo.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM) == null || mediaInfo.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM).equals("") || mediaInfo.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM).startsWith(" ")) albumName = "Unknown Album"; else{ albumName = mediaInfo.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM); } if(mediaInfo.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST) == null || mediaInfo.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST).equals("") || mediaInfo.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST)…
tagged with: java
has comment: http://stackoverflow.com/comment/33398667
has comment: http://stackoverflow.com/comment/33398626
tagged with: android-emulator
has comment: http://stackoverflow.com/comment/33398615
has title: java.lang.stringindexoutofboundsexception in search .mp3 files in emulator android
type: Question
has comment: http://stackoverflow.com/comment/33398659
has comment: http://stackoverflow.com/comment/33398716

http://stackoverflow.com/a/22088995
score: 1
has body: Make sure you have the right permission set in AndroidManifest.xml &lt;uses-feature android:name="android.hardware.camera" /&gt; &lt;uses-feature android:name="android.hardware.camera.autofocus" /&gt; &lt;uses-permission android:name="android.permission.CAMERA" /&gt; &lt;uses-permission android:name="android.permission.RECORD_VIDEO" /&gt; &lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; Check every step's result: surface created; recorder prepare/start ... Try to set video frame rate and size. mRecorder.setVideoFrameRate(10); mRecorder.setVideoSize(320, 240); Gook luck.
downvote count: 0
has comment: http://stackoverflow.com/comment/33503647
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/22087563

http://stackoverflow.com/q/22128766
answer count: 3
tagged with: for-loop
tagged with: junit
downvote count: 0
favorite count: 0
tagged with: exception
has answer: http://stackoverflow.com/a/22133047
has body: I've learnt how to catch an exception in Junit testing. but now I want to loop through arguments which can cause the exception {null, Object.class} currently the test runs for the first loop then exists with a pass and does not check the next loop argument. @Rule public ExpectedException ee; public ClassTest() { this.ee = ExpectedException.none(); } /** * Test of isCompramised method. */ @Test public void testIsCompramised2() { System.out.println("isCompramised Exception"); Class&lt;?&gt;[] c = {null, Object.class}; for (Class&lt;?&gt; class1 : c) { MyClass instance = new MyClass(); ee.expect(IllegalArgumentException.class); boolean result = instance.isCompramised(class1); fail("Exception should have been thrown"); } } So I tried this, it completes the for loop but all the expected exceptions fail as i think Try Catch now steals the exception. /** * Test of isCompramised method, of class MyClass. */ @Test public void testIsCompramised2() { System.out.println("isCompramised Exception"); Class&lt;?&gt;[] c = {null, Object.class}; for (Class&lt;?&gt; class1 : c) { MyClass instance = new MyClass(); try{ ee.expect(IllegalArgumentException.class); boolean result = instance.isCompramised(class1); fail("Exception should have been thrown"); } catch (Exception e){ continue; } } } Suggestions please? Is this correct? try{ boolean result = instance.isCompramised(class1); fail("Exception should have been thrown"); } catch (Exception e){ AssertTrue(e instanceOf IllegalArgumentException); continue; }
has comment: http://stackoverflow.com/comment/33577715
score: 2
has comment: http://stackoverflow.com/comment/33577748
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22131108
upvote count: 2
has answer: http://stackoverflow.com/a/22131108
has title: Junit handling expected exceptions in a loop
has answer: http://stackoverflow.com/a/26325755
type: Question
accepted answer: http://stackoverflow.com/a/22133047
tagged with: java
has comment: http://stackoverflow.com/comment/33575213

http://stackoverflow.com/a/22009084
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33359498
type: Answer
accepted answer of: http://stackoverflow.com/q/22008532
has body: Use colomn instead of i: if ((line % 2) == 0){ System.out.print((((colomn%2) == 0) ? "()" : "&lt;&gt;")); }else{ System.out.print((((colomn%2) == 1) ? "()" : "&lt;&gt;")); }
answers question: http://stackoverflow.com/q/22008532

http://stackoverflow.com/q/22049976
tagged with: selenium-webdriver
answer count: 0
type: UnansweredQuestion
has body: I am running selenium webdriver to insert some records in my website but it got stuck after 3 - 4 records and give error "org.openqa.selenium.NoSuchElementException: Unable to locate element" while those tags are present. I have tried Wait, implicit timeout but again getting same error. Language - Java, OS - Window 7 64 bit, Browser - IE8, IDE - Eclips Most of the time given snippet and locator create problem. I am posting HTML snippet and locator :- 1) HTML:- 0 - Exempt, assumed 1 - Exempt, foreign 2 - Exempt, corporation Fecting value by name 'dd_acct_fed_wthld_ind' Select select = new Select(driver.findElement(By.name(“dd_acct_fed_wthld_ind”))); WebDriverWait wait = new WebDriverWait(driver, 60); wait.until(ExpectedConditions.presenceOfElementLocated(By.name(“dd_acct_fed_wthld_ind”))); WebElement option = select.getFirstSelectedOption(); String str = option.getText(); driver.findElement(By.name("dd_acct_fed_wthld_ind")).sendKeys("1 - Exempt, foreign"); 2.)HTML:- Testing Fecting value by name 'ci_rmrk_lne1_txt' Select select = new Select(driver.findElement(By.Id(“ci_rmrk_lne1_txt”))); WebDriverWait wait = new WebDriverWait(driver, 60); wait.until(ExpectedConditions.presenceOfElementLocated(By.Id(“ci_rmrk_lne1_txt”))); WebElement option = select.getFirstSelectedOption(); String str = option.getText(); driver.findElement(By.id("ci_rmrk_lne1_txt")).sendKeys("Hi");
has comment: http://stackoverflow.com/comment/33467870
has comment: http://stackoverflow.com/comment/33448106
type: Question
tagged with: internet-explorer
tagged with: java
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33602672
has comment: http://stackoverflow.com/comment/33433454
score: 0
has title: Selenium webdriver not running continuously as aspected
has comment: http://stackoverflow.com/comment/33451015

http://stackoverflow.com/comment/33590378
has text: indexOf is linear time complexity
comment on: http://stackoverflow.com/a/22137818
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33406428
has text: No, they are not. Adobe air does it's best to accomodate a lot of widely used features, and since you don't know what really is available it's unlikely you'd miss them. Adobe air is probaly suited enough for your needs.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22035274

http://stackoverflow.com/comment/33597723
comment on: http://stackoverflow.com/a/22142127
has text: mentioned application flow then
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/22064613
has comment: http://stackoverflow.com/comment/33458063
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33458107
tagged with: java
type: Question
has body: I want to insert a record on my database from text fields but it doesn't work.I am using Oracle 10g.I am new to all of this. My whole code is here but the part that doesn't work is private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) button code: package project1; import java.sql.*; 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; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import static project1.InsertFrame.connection; import javax.swing.table.DefaultTableModel; public class CRUD extends javax.swing.JFrame { //static Connection connection = null; //Connection connection = null; public CRUD() { try { initComponents(); String driverName = "oracle.jdbc.driver.OracleDriver"; Class.forName(driverName); String serverName = "192.168.0.2"; String portNumber = "1521"; String sid = "XE"; String url = "jdbc:oracle:thin:@"+serverName+":"+portNumber+":"+sid; String userName = "HR"; String password = "hr"; try { connection = DriverManager.getConnection(url,userName,password); } catch (SQLException ex) { Logger.getLogger(CRUD.class.getName()).log(Level.SEVERE, null, ex); } try { String temp=""; Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT DISTINCT URUN_TIPI FROM KART"); while(rs.next()) // dönebildiği süre boyunca { String s = rs.getString("URUN_TIPI") ; //kolon isimleri oluşturuldu temp+=s+"_"; } Object [] tem_obj; tem_obj=temp.split("_"); listOgrenciler.setListData(tem_obj); } catch (SQLException ex) { Logger.getLogger(edit.class.getName()).log(Level.SEVERE, null, ex); } } catch (ClassNotFoundException ex) { Logger.getLogger(CRUD.class.getName()).log(Level.SEVERE, null, ex); } listOgrenciler.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(L…
accepted answer: http://stackoverflow.com/a/22064737
tagged with: sql-insert
has title: Java-Oracle Inserting a Record
has comment: http://stackoverflow.com/comment/33458129
score: 0
has answer: http://stackoverflow.com/a/22064737
answer count: 1
has comment: http://stackoverflow.com/comment/33458037
has comment: http://stackoverflow.com/comment/33458013
tagged with: oracle-database
tagged with: jdbc
has comment: http://stackoverflow.com/comment/33457990

http://stackoverflow.com/a/22157021
has comment: http://stackoverflow.com/comment/33625092
has comment: http://stackoverflow.com/comment/33625490
score: 1
answers question: http://stackoverflow.com/q/22156928
downvote count: 0
has body: The Palindrome test will only work if your string is all upper case or lower case. The while loop will end when either the left character does not equal the right character, or the right index > the left index (you have passed the "middle" of the string. if (left &lt; right) that is the same as right > left and the string is a palindrome (of one case), otherwise the left character did not equal the right character. I hope that is helpful.
type: Answer
has comment: http://stackoverflow.com/comment/33625397
upvote count: 1

dismiss
tags question: http://stackoverflow.com/q/22143307
type: Tag
tag name: dismiss

http://stackoverflow.com/comment/33409824
score: 0
type: QuestionComment
type: Comment
has text: Can you elaborate on what is wrong with it Smutje? That's the way I've been taught, except for double indenting "losses++:" once..
comment on: http://stackoverflow.com/q/22037198

http://stackoverflow.com/comment/33503149
score: 0
type: AnswerComment
has text: Hard to believe... There was a bug in prev build, try ConEmu 140227. It will show correct "startup directory" in error message. `-new_console:d:` must do the same thing, as you do with "`cd /d`". So, that is very strange that your jar was not found. If 140227 still fails, please show screenshots and run ProcessMonitor to catch "Process create" events.
type: Comment
comment on: http://stackoverflow.com/a/22079547

http://stackoverflow.com/comment/33470422
has text: 404 means page not found.
score: 1
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22071595

http://stackoverflow.com/comment/33387455
has text: what if your subimage is a black square and your whole image has a lot of similar black squares?
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22024539

http://stackoverflow.com/comment/33594851
type: AnswerComment
type: Comment
has text: Ui. Sorry to say, but this is simply not true! A protected member (field or method) can only be accessed via the super mechanism. If you get a reference in another way, you can only access this member when being in the same package (as protected also includes package visibility)!
comment on: http://stackoverflow.com/a/22140088
score: 0

http://stackoverflow.com/q/22167939
tagged with: java
has body: For displaying error message value in JSF page using Java when I read the name lblFathersOrGuardianName from resource mysqlmaven.properties file I got below error. Mar 04, 2014 2:53:21 PM com.sun.faces.application.ActionListenerImpl processAction SEVERE: java.lang.ExceptionInInitializerError javax.faces.el.EvaluationException: java.lang.ExceptionInInitializerError at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:98) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98) at javax.faces.component.UICommand.broadcast(UICommand.java:311) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(Abstract…
type: Question
tagged with: jsf-2
tagged with: resourcebundle
has comment: http://stackoverflow.com/comment/33643963
has answer: http://stackoverflow.com/a/22171282
answer count: 1
has title: How to read properties from resource file using java
score: 0
accepted answer: http://stackoverflow.com/a/22171282
type: AnsweredQuestion
tagged with: jsf
tagged with: primefaces

typeface
tags question: http://stackoverflow.com/q/22111141
tag name: typeface
type: Tag

http://stackoverflow.com/comment/33573726
comment on: http://stackoverflow.com/q/22127829
has text: Like [this](http://stackoverflow.com/a/10862262/230513)?
score: 2
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33638264
comment on: http://stackoverflow.com/q/22160748
type: Comment
type: QuestionComment
has text: @Ziprox09, @yshavit, @rgettman, @leo, thank you all and excuse me. I had a writing error. My issue is that `String result = path + file;` results in `/home/myuser/relativepath/nullfile.txt`. How can I fix it? I'll try to concatenate with File.Separator and checking variable initializations.
score: 0

http://stackoverflow.com/a/22142995
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/22142830
score: 1
answers question: http://stackoverflow.com/q/22142830
upvote count: 1
has body: I suggest that you start using dedicated html parser for such opertations. I personally use Jsoup You can build own HTML structure using it as well.
type: AcceptedAnswer

http://stackoverflow.com/comment/33473907
score: 0
type: Comment
has text: possible duplicate of [Should I avoid the use of set(Preferred|Maximum|Minimum)Size methods in Java Swing?](http://stackoverflow.com/questions/7229226/should-i-avoid-the-use-of-setpreferredmaximumminimumsize-methods-in-java-swi)
type: QuestionComment
comment on: http://stackoverflow.com/q/22072975

http://stackoverflow.com/q/22089659
has answer: http://stackoverflow.com/a/22089869
type: Question
possible better answer: http://stackoverflow.com/a/22089823
has answer: http://stackoverflow.com/a/22089823
answer count: 3
upvote count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/22089836
tagged with: regex
accepted answer: http://stackoverflow.com/a/22089869
type: AnsweredQuestion
downvote count: 0
has title: Regular expression for detecting round brackets
score: 1
tagged with: java
has body: I have a large array with string. Now, I need to use the string in the array to form patterns. However for the string with round brackets, the constructed patterns don't work. Could anyone point out what is wrong? Thank you. Here is my code: String[] phrases = new String[2]; phrases[0] = "student (male)"; phrases[1] = "worker (female)"; Pattern[] ptn = new Pattern[phrases.length]; int i = 0; for (String p : phrases) { p = p.replaceAll("\\(", "\\\\("); p = p.replaceAll("\\)", "\\\\)"); System.out.println(p); ptn[i] = Pattern.compile(p+"\\:\\s\\w+"); i++; } String text = "Student (male): John"; for(Pattern p : ptn) { Matcher m = p.matcher(text); while(m.find()) { System.out.println(m.group()); } } }

http://stackoverflow.com/q/22041082
has comment: http://stackoverflow.com/comment/33418087
has body: I have the following part from xml file: 2000;Generl;All equipment 2001;General;All equipment 2002;General;All equipment 2003;General;All Equipment 001 Don't know smth For now I use the following code: Document doc1 = dBuilder.parse(fXmlFile1); doc1.getDocumentElement().normalize(); NodeList kList1 =doc1.getElementsByTagName("item"); for(int temp=0;temp<kList1.getLength();temp++) { Node kNode1=kList1.item(temp); //System.out.println("\nCurrent Element :" + kNode.getNodeName()); if (kNode1.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) kNode1; //System.out.println("node name"+eElement.getNodeName()); Node in=eElement.getFirstChild(); //System.out.println("__________________"+in.getFirstChild().getTextContent()); //System.out.println("IN text content----:"+in.getTextContent()+":--------"); if(eElement.getAttribute("name").equals("SystemsList")==true) { NodeList kList2=in.getChildNodes(); //if((in.getTextContent()!=null)&&!(in.getTextContent()).isEmpty()&& !(in.getTextContent().length()==0)) //{ for(int k=0;k<kList2.getLength();k++) { Node kNode2 = kList2.item(k); if((kNode2.getTextContent()!=null)&&!(kNode2.getTextContent()).isEmpty()&& !(kNode2.getTextContent().length()==0)) stringBuilder.append(kNode2.getTextContent()+"\n"); } //} } } } String s=new String(stringBuilder); String sa[]=s.split("\n"); System.out.println("size"+sa.length); for(String st:sa) { System.out.println(st); } This code makes the following String="2000;General;All equipment2001;General;All equipment2002;General;All equipment2003;General;All Equipment". The question is how can I get this xml part with break to be ArrayList where each element is 1 line from the xml above or just to make a String array, f/e : SystemsListByYear[0]="2000;Generl;All equipment", SystemsListByYear[1]="2001;Generl;All equipment" and etc. P.S. I use the DOM library. Edited-question-to-correct Edit part: if (kNode1.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) kNode1; //System.out.p…
possible better answer: http://stackoverflow.com/a/22041220
has title: Get element text content from xml with <break> using DOM
accepted answer: http://stackoverflow.com/a/22042264
has answer: http://stackoverflow.com/a/22041220
tagged with: http://stackoverflow.com/tag/xml
score: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33418282
has answer: http://stackoverflow.com/a/22042264
tagged with: java
tagged with: dom
has comment: http://stackoverflow.com/comment/33417904
type: Question
answer count: 2

http://stackoverflow.com/comment/33382543
type: QuestionComment
comment on: http://stackoverflow.com/q/22021149
score: 0
has text: there's a little problem with the code i gave above, the quote should start before the $
type: Comment

http://stackoverflow.com/a/22123909
has comment: http://stackoverflow.com/comment/33565730
has comment: http://stackoverflow.com/comment/33565726
has comment: http://stackoverflow.com/comment/33565799
score: 0
has comment: http://stackoverflow.com/comment/33565708
type: Answer
has comment: http://stackoverflow.com/comment/33565772
answers question: http://stackoverflow.com/q/22123854
has body: You mistake in using power function your power function should be like this Math.pow((rate2/12+1),1)

http://stackoverflow.com/a/22319685
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/22028926
upvote count: 1
has body: try this : int[] imageCordinates = new int[2]; imageView.getLocationOnScreen(imageCordinates); int x = imageCordinates[0]; int y = imageCordinates[1]; // this code will return you coordinates of image on screen whenever you want

http://stackoverflow.com/a/22085519
answers question: http://stackoverflow.com/q/22085365
type: Answer
score: 0
has body: Well . you should read each line in as a String. Then, for each line after the title, you might follow one of several strategies: create an array of date, and an array of float for the stock price for each company Or create a Company Object that itself has an array of for date and stock price) you will need an "addDatePrice(date, price) method in the Company object. You can create the right number of companies from info in the title csv line (and give the Company object a nam)

http://stackoverflow.com/comment/33597318
has text: But this output is different from my expectation.I am trying to get output as 0.62,0.24,0.5,0.5 \n 0.38,0.59,1.0,0.0 \n 0.9,0.1,0.2,0.3 \n
type: AnswerComment
comment on: http://stackoverflow.com/a/22141920
score: 0
type: Comment

http://stackoverflow.com/q/22117826
has comment: http://stackoverflow.com/comment/33554280
tagged with: preferences
has title: Android Save and check, radio button
tagged with: android
has body: Sorry for my bad english. I have 2 classes, 1 MainActivity.java (Standard) 2 settings.java (for settings) I have a RadioGroup with 5 Radiobuttons. I save the state of the radio buttons as follows (in to settings.java class): @Override public void onClick(View v) { // TODO Auto-generated method stub SharedPreferences settings = getSharedPreferences("status", 0); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("blue", blue.isChecked()); editor.putBoolean("orange", orange.isChecked()); editor.putBoolean("purple", purple.isChecked()); editor.putBoolean("grey", grey.isChecked()); editor.putBoolean("green", green.isChecked()); editor.commit(); } public void loadSettings () { SharedPreferences settings = getSharedPreferences("status", 0); royalBlue.setChecked(settings.getBoolean("blue", false)); orange.setChecked(settings.getBoolean("orange", false)); purple.setChecked(settings.getBoolean("purple", false)); titan.setChecked(settings.getBoolean("grey", false)); eighties.setChecked(settings.getBoolean("green", false)); } the status of the radio buttons is saved successfully. Even after a restart of the app the radio button is saved. I would like now when the RadioButton orange (or other) is selected, the ImageButton will change my image. I would like to make in the MainActivity. I have tried it in the Main Activity so but I always get a NullPoinException: Code from the Main ... private settings load = new settings(); ... ... public void change (){ if (load.orange.isChecked()){ imBuOn.setImageResource(R.drawable.orange); } as I said I can so unfortunately unable to access the status of the radio button. Do I need to maybe use PreferenceManager? how shall I put it best?
has answer: http://stackoverflow.com/a/22118809
type: AnsweredQuestion
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33555537
score: 0
answer count: 1
accepted answer: http://stackoverflow.com/a/22118809

http://stackoverflow.com/q/22078472
has answer: http://stackoverflow.com/a/22078776
tagged with: parsing
downvote count: 3
has comment: http://stackoverflow.com/comment/33483514
type: Question
tagged with: actionlistener
has comment: http://stackoverflow.com/comment/33483504
has title: Error when using Double.parseDouble from text field
has comment: http://stackoverflow.com/comment/33483526
tagged with: java
has comment: http://stackoverflow.com/comment/33483928
has comment: http://stackoverflow.com/comment/33483553
has comment: http://stackoverflow.com/comment/33483810
upvote count: 0
answer count: 1
has body: i have been trying to take an input from a text field and put it in a Double variable. but when ever i try to use Double.parseDouble(textTF.getText()) i get errors, i tested using scanner it worked fine private class NumRTFHandler implements ActionListener { public void actionPerformed(ActionEvent e) { String romanN = ""; String dec = numDTF.getText(); Double decimal = Double.parseDouble(dec); } } i guessed it might be the Action listener but im not sure how to deal with it. Double.parseDouble() didn't work neither with a textField nor with a string. please Help. these are the errors. Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: empty String at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source) at java.lang.Double.parseDouble(Unknown Source) at RomanNumeralConvertert$NumRTFHandler.actionPerformed(RomanNumeralConvertert.java:40) at javax.swing.JTextField.fireActionPerformed(Unknown Source) at javax.swing.JTextField.postActionEvent(Unknown Source) at javax.swing.JTextField$NotifyAction.actionPerformed(Unknown Source) at javax.swing.SwingUtilities.notifyAction(Unknown Source) at javax.swing.JComponent.processKeyBinding(Unknown Source) at javax.swing.JComponent.processKeyBindings(Unknown Source) at javax.swing.JComponent.processKeyEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt…
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33483833
score: -3

http://stackoverflow.com/q/22161911
has comment: http://stackoverflow.com/comment/33633458
accepted answer: http://stackoverflow.com/a/32557763
has comment: http://stackoverflow.com/comment/33633608
has title: GridLayout Center Overflow Components
type: AnsweredQuestion
tagged with: components
has body: I have a set of buttons. My JPanel has a layout of GridLayout. I would like any components to go outside the square to get centered. Here is an image: http://screencast.com/t/z86ldR9vh I would like the Options button to be centered under the group. Thanks in advance!
has comment: http://stackoverflow.com/comment/33633538
tagged with: java
tagged with: center
has comment: http://stackoverflow.com/comment/33633509
type: Question
has comment: http://stackoverflow.com/comment/33633293
has comment: http://stackoverflow.com/comment/33633433
has comment: http://stackoverflow.com/comment/33633398
has comment: http://stackoverflow.com/comment/33633311
score: 0
has answer: http://stackoverflow.com/a/32557763
linked to: http://stackoverflow.com/q/22160760
has comment: http://stackoverflow.com/comment/33633343
answer count: 1
has comment: http://stackoverflow.com/comment/33633572
has comment: http://stackoverflow.com/comment/33633368

http://stackoverflow.com/q/22128565
has answer: http://stackoverflow.com/a/22128662
has body: The problem I am having is quite specific, and a bit difficult to explain. Let me know if you need more details about anything. I have an abstract class called System. To hold my System objects, I have a SystemManager which contains an list of Systems, and some functions for manipulating it. Inside it contains: List&lt;System&gt; systems = new ArrayList&lt;System&gt;(); Now, I want to create another abstract class which is a specific type of System called RenderSystem. This will inherit from System but have a few more functions. I also want to create a RenderSystemManager which should do everything SystemManager does, except with a few extra features. Also, instead of having a list of System in the manager, I would like it to have a list of RenderSystem to ensure that the programmers don't put any regular System objects in it. My initial instinct was to inherit SystemManger, and just change the type of the list to RenderSystem: systems = new ArrayList&lt;RenderSystem&gt;(); Java doesn't allow this as systems is type System not RenderSystem. I would have assumed it would be OK considering RenderSystem inherits from System. One way I can think of to resolve this issue is to copy and paste all the code from SystemManager into RenderSystemManager and just change the line of code to be: List&lt;RenderSystem&gt; systems = new ArrayList&lt;RenderSystem&gt;(); My other instinct would be to override the addSystem(System system) function to ensure that it only handles RenderSystem, but the programmers might think they are allowed to do it even if it doesn't work. @Override public void addSystem(System system) { if (system instanceof RenderSystem) { super.addSystem(system); } } These doesn't seem very elegant though. Anybody have any suggestions?
type: AnsweredQuestion
has title: Specific Java inheritance inquiry - Need suggestions
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33576704
has comment: http://stackoverflow.com/comment/33574401
has comment: http://stackoverflow.com/comment/33574341
has answer: http://stackoverflow.com/a/22128688
tagged with: inheritance
score: 0
has comment: http://stackoverflow.com/comment/33574169
answer count: 3
accepted answer: http://stackoverflow.com/a/22128662
possible better answer: http://stackoverflow.com/a/22128656
has answer: http://stackoverflow.com/a/22128656

http://stackoverflow.com/q/22010530
has answer: http://stackoverflow.com/a/22011532
possible better answer: http://stackoverflow.com/a/22010752
tagged with: ejb
downvote count: 0
tagged with: netbeans-7
has comment: http://stackoverflow.com/comment/33363116
favorite count: 0
answer count: 3
has answer: http://stackoverflow.com/a/52978335
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22010752
has comment: http://stackoverflow.com/comment/33362128
upvote count: 1
has body: I have 2 EJB module projects and I want from one of the projects to call a stateless no-interface bean from another project. I want to inject the bean to be called using the EJB annotation. The problem is the injection doesn't work(I use NetBeans 7.4 if that is relevant). The stateless no-interface EJB being called: package standalonepackage; import javax.ejb.Stateless; import javax.ejb.LocalBean; @Stateless @LocalBean public class StandaloneBean { private static final String message="Greetings!"; public String returnMessage(){ return message; } } The interface of the bean that calls the bean above(this ejb resides in another ejb module project) @Local public interface ExampleBeanLocal { public String getMessage(); } The implementation of the interface: @Stateless public class ExampleBean implements ExampleBeanLocal { @EJB private StandaloneBean standaloneBean; @Override public String getMessage() { return String.format("Me - and the second message %s", standaloneBean.returnMessage()); } } I also have a main class that just calls the ExampleBean getMessage method(MainClass is located in the second ejb module project): public class MainClass { private static ExampleBeanLocal instance = new ExampleBean(); public static void main(String[] args) { System.out.println(instance.getMessage()); } } What am I missing?
type: Question
tagged with: jakarta-ee
accepted answer: http://stackoverflow.com/a/22011532
tagged with: dependency-injection
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33362577
has comment: http://stackoverflow.com/comment/33362208
has title: EJB injection not working

http://stackoverflow.com/q/22086827
has title: How to Update Graphics Quickly in a JPanel
has comment: http://stackoverflow.com/comment/33505032
has answer: http://stackoverflow.com/a/23948001
type: AnsweredQuestion
tagged with: paint
has comment: http://stackoverflow.com/comment/36895328
upvote count: 1
tagged with: swing
type: Question
tagged with: graphics
has comment: http://stackoverflow.com/comment/33499221
score: 1
has comment: http://stackoverflow.com/comment/33503502
tagged with: java
accepted answer: http://stackoverflow.com/a/23948001
tagged with: jpanel
has comment: http://stackoverflow.com/comment/33504579
has comment: http://stackoverflow.com/comment/33505010
has body: I'm currently in the process of making a 2D turn based strategy game in Java. At this stage in development I am testing out different varieties of AIs. The AIs interact with the game by sending a x and y variable to a function called gameLoop, which would would normally be called by a mouseClicked function. This allows them to directly emulate a human user which has made having them interact with the game much easier. Below is an overview for some of my code: paintComponent() { drawTiles(); drawUnits(); if(unitSelected &amp;&amp; gameState == DISP_MOVE) drawMoveSpots(); } gameLoop(int x, int y) { // various logic based // on the values of x and y // logic may set unitSelected to true or false // may also change gameState bteween normal and displayMoveSpots repaint(); } My issue right now stems from the fact that the AI is executing code faster than repaint happens. When this happens, I start getting errors such as NullPointerException's and ConcurrentModificationException's in my various drawing functions because the logic inside of gameLoop is changing variables faster than repaint can happen. If I add in a manual delay to how often the AI calls gameLoop or only have 2 humans playing, the errors disappear. From my research and reading of the Java docs, I understand that repaint returns immediately and all the graphics calls are put onto the EventQueue until Java decides that there are enough calls to warrant an actual repaint. The only solution I have been able to find so far is putting the logic code that happens in gameLoop into a anonymous runnable class and call the code using SwingUtilities.invokeAndWait, but this is not a valid solution for me, because this causes actual human interaction from clicking to bug out. I have considered using a lock to provide mutual exclusion to gameLoop's logic section/repaint (so only one can execute at a time), but I'm not sure if this is a good practice when dealing with Java graphics. At this point I'm open to any suggestion…
downvote count: 0
answer count: 1
favorite count: 0

http://stackoverflow.com/q/22083915
has comment: http://stackoverflow.com/comment/33493557
has title: Java method parameter for creating new object of different class
has answer: http://stackoverflow.com/a/22083973
type: Question
has comment: http://stackoverflow.com/comment/33493595
has answer: http://stackoverflow.com/a/22084010
has body: I have searched high and low for a solution to this problem, and finally signed up here to see if someone can point me to what is undoubtedly a really simple solution that is evading me. I'm working on MIT's OpenCourse to teach myself Java and am stumped on this problem. I have two classes, Library and Book. The program keeps track of books created for each library, their location, and whether or not they are checked out. I am given the main method for Library that cannot be edited. Instead its methods must be built to produce the desired output. The issue I am having is determining the argument syntax to pass to a method in Library that creates a new Book in the main method of Library. Relevant Library Code: package mitPractice; public class Library { String library_address; static String library_hours = "Libraries are open daily from 9AM to 5PM"; Book[] catalog; //List of Methods for Libraries public Library(String address) { library_address = address; } public static void printOpeningHours() { System.out.println(library_hours); } public void addBook(/*unsure what parameter to add here*/) { catalog[ (catalog.length + 1)] = //unknown parameter } public static void main(String[] args) { //Create two libraries Library firstLibrary = new Library("10 Main St."); Library secondLibrary = new Library("228 Liberty St."); //Add four books ***This block of code is the problem and is uneditable firstLibrary.addBook(new Book("A Game of Thrones")); firstLibrary.addBook(new Book("Rama")); firstLibrary.addBook(new Book("Understanding Space")); firstLibrary.addBook(new Book("Way of the Clans")); So my question is how to make the method compatible with the code given in the main method? I have attempted numerous combinations for arguments to pass to addBook() and none seem to deliver. Book code: package mitPractice; public class Book { Boolean isCheckedOut = false; String book_title; public Book(String title) { book_title = title; } public void Borrow() { isCheckedOut = true; } pub…
answer count: 3
has answer: http://stackoverflow.com/a/22084950
downvote count: 0
has comment: http://stackoverflow.com/comment/33493630
favorite count: 0
has comment: http://stackoverflow.com/comment/33493566
accepted answer: http://stackoverflow.com/a/22084010
has comment: http://stackoverflow.com/comment/33493568
type: AnsweredQuestion
score: 2
upvote count: 2
possible better answer: http://stackoverflow.com/a/22083973
tagged with: java

http://stackoverflow.com/a/22058178
type: Answer
has comment: http://stackoverflow.com/comment/33447645
has comment: http://stackoverflow.com/comment/33447867
downvote count: 0
score: 5
has body: Well it depends on how you want to achieve it... You could... Provide the required number of fields (10 in your example) and a JButton, so that until all the fields are filled out, clicking the button will simply provide the user with a message and re-focus the invalid field... You could... Provide the user with a single field (and label) and button. Until they fill out the field, pressing the button prompts them and re-focuses the field. When the user fills out the required information and clicks the button, you increment a counter, reset the field and carry on until your counter reaches it's limit... You could... Use a JTable which has only one column and five rows...this is simplified (depending on your perspective) solution to the first solution...
answers question: http://stackoverflow.com/q/22058121
has comment: http://stackoverflow.com/comment/33447685
upvote count: 5
has comment: http://stackoverflow.com/comment/33448107

identifier
tag name: identifier
type: Tag
tags question: http://stackoverflow.com/q/22008782

http://stackoverflow.com/comment/33432663
type: Comment
has text: Each (actual) Activity needs its own class file.
type: QuestionComment
comment on: http://stackoverflow.com/q/22034854
score: 0

http://stackoverflow.com/comment/33570642
type: Comment
has text: This seems to be the same as my idea. Although if the order of patterns is important, I would use a LinkedHashMap or a List of pairs.
comment on: http://stackoverflow.com/a/22126437
type: AnswerComment
score: 0

http://stackoverflow.com/q/22161117
type: AnsweredQuestion
tagged with: astyanax
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/22161131
score: 0
has title: How to run Netflix Astyanax in linux
answer count: 1
tagged with: cassandra
tagged with: linux
has answer: http://stackoverflow.com/a/22161131
has body: I'm a newbie in running Java code in Linux environment. I'm trying to get the Astyanax to work on the linux machine. I followed the instruction on https://github.com/Netflix/astyanax/wiki/Getting-Started I have cloned the code from github, and ./gradlew build runs successfully. I'm trying to run the AstClient in the astyanax-examples. I tried the following command: java -cp "/home/shbash6/astyanax/astyanax-examples/build/libs/;/home/shbash6/astyanax/astyanax-cassandra/build/libs/;/home/shbash6/astyanax/astyanax-core/build/libs/;/home/shbash6/astyanax/astyanax-thrift/build/libs/" com.netflix.astyanax.examples.AstClient under holder: /home/shbash6/astyanax/astyanax-examples/build/classes/main but I got the following exception: Exception in thread "main" java.lang.NoClassDefFoundError: com/netflix/astyanax/examples/AstClient Caused by: java.lang.ClassNotFoundException: com.netflix.astyanax.examples.AstClient 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.netflix.astyanax.examples.AstClient. Program will exit. Could anyone tell me how to fix this issue? Thanks!
tagged with: command-line

http://stackoverflow.com/q/22012756
tagged with: datetime
type: AnsweredQuestion
has title: Java Joda - Infinite iterations when trying to loop through date, month and year
tagged with: java
type: Question
tagged with: jodatime
has answer: http://stackoverflow.com/a/22012829
score: 0
tagged with: sql
accepted answer: http://stackoverflow.com/a/22012829
has body: I have to create tables for each day of every month between a specific date range (For eg. 2012-01-30 to 2013-04-30). I'm trying to do this using three for loops and DateTime isBefore method, however my loop runs infinitely (although the date, month and year are incremented as how its supposed to be). A snippet of the code that I wrote below, DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm"); DateTime startDate = dtf.parseDateTime(startDateTime); DateTime endDate = dtf.parseDateTime(endDateTime); try{ for(DateTime y=startDate;y.isBefore(endDate);y=y.plusYears(1)) { for(DateTime month=startDate;startDate.isBefore(endDate);month=month.plusMonths(1)) { for(DateTime date=startDate;startDate.isBefore(endDate);date=date.plusDays(1)){ String sqlStmt = "CREATE TABLE IF NOT EXISTS... ... } } } } catch (SQLException e) { StackTraceElement stack = e.getStackTrace()[2]; } My tables are getting created as how I want them so there is no issue with the sqlstmt that I'm trying to execute, just that the loop doesn't terminate once it encounters the endDate. I'm new to Java so not quite sure what I'm doing wrong here. Any suggestions would be really helpful!!! Thanks!
answer count: 1

http://stackoverflow.com/a/22069772
has comment: http://stackoverflow.com/comment/33517264
has comment: http://stackoverflow.com/comment/33517270
type: Answer
has comment: http://stackoverflow.com/comment/33595794
answers question: http://stackoverflow.com/q/22041026
score: 1
has comment: http://stackoverflow.com/comment/33473248
has comment: http://stackoverflow.com/comment/33519811
upvote count: 1
has comment: http://stackoverflow.com/comment/33470329
has body: You don't have an open session at that point, so the code has no way to reach the database. I'm guessing you have a transaction on your UserService (usually you put it on the service layer) and since you're accessing the lazy property outside of the service layer, your transaction and session are closed. By default, the session binds to a transaction. Either: Put this code in the session as well Make sure all required fields are populated before you leave the transaction Make this code transactional (with propagation on the inner transaction) use OpenSessionInView (warning: here be dragons)
downvote count: 0

http://stackoverflow.com/a/22154101
score: 0
type: Answer
answers question: http://stackoverflow.com/q/22153869
has body: Maybe is not a JSP problem. Have you tried doing that in the page, directly? &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt; ... &lt;/head&gt; Also, try to save the page in UTF-8 format

http://stackoverflow.com/comment/33649827
comment on: http://stackoverflow.com/a/22158042
type: AnswerComment
score: 0
has text: I solved it by myself. it was enough to remove the recursion loop from the two methods and create an iteration in the main ().
type: Comment

http://stackoverflow.com/comment/33446699
type: AnswerComment
comment on: http://stackoverflow.com/a/22057739
score: 0
type: Comment
has text: @Cuder_VN Could you give a sample string that didn't match?

http://stackoverflow.com/comment/33388785
comment on: http://stackoverflow.com/q/22025097
score: 0
type: Comment
type: QuestionComment
has text: @mangusta new array? please can you till me where :(

http://stackoverflow.com/comment/33593135
has text: The how would my `getFromDatabaseA` method will look like? Can you show me an example of that as well if possible?
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22139447

http://stackoverflow.com/q/22089221
answer count: 1
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22093055
has title: How to read the urls and html components used in the selenium test case
tagged with: java
tagged with: selenium
has comment: http://stackoverflow.com/comment/33504420
type: Question
score: 0
has body: my selenium test code looks like below. @Before public void setUp() throws Exception { driver = new FirefoxDriver(); baseUrl = "http://localhost:8080/"; driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); } @Test public void testSeleJunit() throws Exception { driver.get(baseUrl + "/"); driver.findElement(By.linkText("New Item")).click(); driver.findElement(By.id("name")).clear(); driver.findElement(By.id("name")).sendKeys("i18n1"); driver.findElement(By.name("mode")).click(); driver.findElement(By.id("ok-button")).click(); } From java code how can i get the url and the locators for which the test case is written?

http://stackoverflow.com/a/22145387
upvote count: 2
has comment: http://stackoverflow.com/comment/33615251
downvote count: 0
answers question: http://stackoverflow.com/q/22145206
has body: I would suggest using a tab navigation or navigation spinner instead of creating new activities. But if you really want to use separate activities, you could try putting this in the activity tags of your manifest file: android:launchMode="singleTop" http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
type: Answer
has comment: http://stackoverflow.com/comment/33623251
score: 2

http://stackoverflow.com/comment/33480289
type: Comment
type: QuestionComment
has text: Ok, so I want to see what `createRequest` does? What is `method`?
score: 0
comment on: http://stackoverflow.com/q/22076276

http://stackoverflow.com/q/22027274
score: 1
tagged with: java
has body: I can't get working JAVAmail propertly my BeanDefinition looks like this: true false The localhost:8889 is forwarded and its 100% working server when I try to send email i get such an error (full log): 17:01:26,887 INFO [stdout] (http-localhost-127.0.0.1-8080-1) DEBUG: JavaMail version 1.4.4 17:01:26,889 INFO [stdout] (http-localhost-127.0.0.1-8080-1) DEBUG: successfully loaded resource: /META-INF/javamail.default.providers 17:01:26,889 INFO [stdout] (http-localhost-127.0.0.1-8080-1) DEBUG: Tables of loaded providers 17:01:26,890 INFO [stdout] (http-localhost-127.0.0.1-8080-1) DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]} 17:01:26,891 INFO [stdout] (http-localhost-127.0.0.1-8080-1) DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]} 17:01:2…
has title: JavaMail sending with smtp.auth = false ERROR: Invalid Addresses
tagged with: jakarta-mail
answer count: 1
tagged with: email
downvote count: 0
accepted answer: http://stackoverflow.com/a/22028725
favorite count: 0
tagged with: spring
type: AnsweredQuestion
upvote count: 1
has answer: http://stackoverflow.com/a/22028725
type: Question

http://stackoverflow.com/a/22114792
answers question: http://stackoverflow.com/q/22114268
type: Answer
has body: Yes it expects a regex. You need to escape the brackets (and the dots but it makes little difference in this case). The test below passes: @Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = "'authority' Uri should have at least one segment in the path \\(i.e. https://&lt;host&gt;/&lt;path&gt;/...\\)") public void test() { String input = "'authority' Uri should have at least one segment in the path (i.e. https://&lt;host&gt;/&lt;path&gt;/...)"; throw new RuntimeException(input); }
upvote count: 4
type: AcceptedAnswer
downvote count: 0
score: 4
accepted answer of: http://stackoverflow.com/q/22114268

http://stackoverflow.com/comment/33595928
score: 0
comment on: http://stackoverflow.com/a/22140972
type: Comment
has text: remove `if(event.getAction() == MotionEvent.ACTION_UP)` and just do what you want
type: AnswerComment

http://stackoverflow.com/comment/33390365
type: AnswerComment
comment on: http://stackoverflow.com/a/22021686
type: Comment
has text: FYI, Swing components are double buffered by default
score: 0

http://stackoverflow.com/comment/33479764
type: AnswerComment
comment on: http://stackoverflow.com/a/22076263
type: Comment
has text: dear str is string and bytes is array of byte of that string.How can you make both same.
score: 0

http://stackoverflow.com/a/22061757
has comment: http://stackoverflow.com/comment/33453316
type: Answer
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/22061461
upvote count: 3
has body: From a quick glance you can see that shell sort looks slower by having more loops. Brute force, you can put a system.out.println in the innermost loop to see how many comparisons are made. 3 Loops of shellsort for(int seqi = seqLen - 1; seqi >= 0; seqi--) for(int n = 0; n &lt; length; n+=nth) while(j > 0 &amp;&amp; a[j] &lt; a[j - nth]) 2 Loops of insertion for(int i = 1; i &lt; length; i++) while(j > 0 &amp;&amp; x &lt; a[j-1])
has comment: http://stackoverflow.com/comment/33453087
has comment: http://stackoverflow.com/comment/33454217

http://stackoverflow.com/comment/33376015
type: AnswerComment
comment on: http://stackoverflow.com/a/22017167
type: Comment
score: 0
has text: Which of the ways do you recommend for my purpose? :)

http://stackoverflow.com/comment/33508949
type: Comment
type: QuestionComment
has text: But only if `key = null` results in a boolean expression and therefore only if `key` is of `Boolean` type.
comment on: http://stackoverflow.com/q/22092775
score: 0

http://stackoverflow.com/comment/33420113
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22041026
has text: why `singleSession` is set to `false`? it have look at [this](http://docs.spring.io/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.html#setSingleSession(boolean))

http://stackoverflow.com/comment/33896310
has text: @dystroy is right. This is off topic. Go to vendor page and look for. This just looks like an advertisement and should be removed.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22066224
score: 0

http://stackoverflow.com/comment/33677925
comment on: http://stackoverflow.com/q/22136168
type: Comment
has text: @user3203425 I know Jetty has several configuration options for the pool. I'd start checking there.
type: QuestionComment
score: 0

http://stackoverflow.com/comment/33430758
has text: Here's the relevant JLS Section: [Section 15.11.2](http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.11.2).
type: AnswerComment
comment on: http://stackoverflow.com/a/22048781
type: Comment
score: 1

http://stackoverflow.com/a/22057561
downvote count: 0
has body: Make sure that you didn't put the same instance of the object in all positions of the array list - in other words add the same element over and over again. That's what would probably cause the behavior you're seeing.
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/22057540
type: Answer
has comment: http://stackoverflow.com/comment/33447227

http://stackoverflow.com/comment/33476475
score: 0
type: Comment
has text: @SotiriosDelimanolis Yes. I think I should move one test to a different class, should I?
type: QuestionComment
comment on: http://stackoverflow.com/q/22068711

http://stackoverflow.com/comment/33542622
comment on: http://stackoverflow.com/a/22111097
has text: this String s = "uestions?action=maximum&p043366329446409=08315891235072667&city="; String p0 = s.replaceAll(".*&(p0.+?=.+?)&.*", "$1"); System.out.println(p0); works fine for me
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/22040554
score: 2
downvote count: 0
has body: I had to use Method.POST instead of GET, and in the worker task servlet, use doPost(). I believe the request was too large for a GET. The problem was Google did not provide a useful error message, and instead used a cryptic one.
upvote count: 2
answers question: http://stackoverflow.com/q/22039341
type: Answer

http://stackoverflow.com/comment/72943883
score: 0
has text: The `compareTo` implementation returns 0 in the end. It should be `r`, right?
type: AnswerComment
comment on: http://stackoverflow.com/a/22123743
type: Comment

http://stackoverflow.com/comment/33624095
score: 0
type: Comment
has text: Each time the user guesses a number the msg label for gtf should be set (in each if-statement) and the user should be able to enter another number. This should repeat until time == 9 or guess == number (number is the randomly generated number). This wasn't the issue in the original post, I know...
comment on: http://stackoverflow.com/a/22150794
type: AnswerComment

http://stackoverflow.com/comment/33518899
score: 0
has text: DSO is a monster that TC created some years ago and convinced a lot of companies that was the future of **distributed caches**. Some poor decision makers bought that snake oil, and developers cried; somtimes DSO does very little and sometimes too much to hide the complexity of distributed systems. Some years later, TC realised the error and acquired Ehcache as the new interface for TC and deprecated DSO. </RandOver> DSO stands for **Distributed Shared Objects** and is a horrible thing that can hijack your application and transforms it to a distributed one - What can go wrong?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22073110

http://stackoverflow.com/q/22009068
possible better answer: http://stackoverflow.com/a/22009404
has comment: http://stackoverflow.com/comment/33359260
type: AnsweredQuestion
has title: use sum and multiplication of a BigInteger
tagged with: biginteger
has answer: http://stackoverflow.com/a/22009443
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/22009443
has comment: http://stackoverflow.com/comment/33360299
type: Question
has answer: http://stackoverflow.com/a/22009404
has comment: http://stackoverflow.com/comment/33359676
has comment: http://stackoverflow.com/comment/33359985
tagged with: arraylist
answer count: 2
has comment: http://stackoverflow.com/comment/33359240
upvote count: 1
downvote count: 0
linked to: http://stackoverflow.com/q/1783912
favorite count: 0
has comment: http://stackoverflow.com/comment/33359470
has comment: http://stackoverflow.com/comment/33359791
has body: I've come across a situation where I have to perform sum and multiplication of the elements of an ArrayList and for this normally I use: sum+=a.get(i)*b.get(i); which gives me the exact output I want, but here in my case I've got to do the same with ArrayList of BigInteger type, I've tried it with the below statement, but it is not working as expected. sum=(a.get(i).multiply(b.get(i))).add(sum); please let me know how I can do it. Thanks.

http://stackoverflow.com/q/22093842
has title: How to design a class correctly
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
type: Question
tagged with: oop
has answer: http://stackoverflow.com/a/22094423
accepted answer: http://stackoverflow.com/a/22094423
has body: I have a particular case that I don't have really clear how to move to code. Let's say I have a class "Survey". The survey has an array of "Question"s. I also have a class "Person". Finally there are the answers to those questions that are gathered in a "Answer" class. The "Person" has associated a "Survey" and an array of "Answer"s (where each answer has associated a question). So my question is, is this the correct way to do it? I think the design is lousy and I am not separating concerns pretty well. I can say that both the "Survey" and the "Answer"s objects shouldn't be members of "Person". And I should create a third object that gathers the information between the "Person", the "Answer" and the "Survey". Although, this approach sounds like Relational-entity theory using a table to make a M:N:S relation in the end. What should I do? What do you think it could be a nice/good approach? Thanks. Here's the code in Java. Forget about Encapsulation. class Person{ String name; String age; Survey survey; Answers[] answers; } class Survey{ Question[] listOfQuestions; } class Question{ String questionString; } class Answer{ Question question; String answer; }
upvote count: 1
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33510380

http://stackoverflow.com/comment/33542929
type: AnswerComment
comment on: http://stackoverflow.com/a/22111280
type: Comment
has text: fyi a short(ish) way to get them into an array is: String[] words = str.split( " " );
score: 0

http://stackoverflow.com/comment/33368496
type: Comment
comment on: http://stackoverflow.com/a/22009157
has text: This shares exactly the same problem with the original query.
type: AnswerComment
score: 0

http://stackoverflow.com/a/22132774
has body: Should be lastNumber = testArray[counter2]; testArray[counter2] = testArray[counter1]; testArray[counter1] = lastNumber;
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/22132598
has comment: http://stackoverflow.com/comment/33582061
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/33582178

http://stackoverflow.com/a/22119345
score: 1
has comment: http://stackoverflow.com/comment/33557095
type: Answer
upvote count: 1
has body: Java does not have pass-by-reference; rather, all you ever have are references to objects, and those references must be passed by value. So your code is roughly equivalent to something like this in C++: class A { private: B *bInA = NULL; C *cInA = NULL; public: void foo(someValue) { cInA-&gt;foo(bInA, someValue); } static void main() { A *myA = new A(); myA-&gt;foo(xyz) // myA-&gt;bInA-&gt;value should be equal to xyz } } int main() { A::main(); return 0; } class B { ... } class C { public: void foo(bInA, someValue) { bInA = new B(); // defeats the point of having passed in a bInA bInA-&gt;value = someValue; } } (Except that the C++ code has memory leaks, since you allocate some things without freeing them, whereas in Java that's not an issue.)
has comment: http://stackoverflow.com/comment/33557736
answers question: http://stackoverflow.com/q/22119202
downvote count: 0

http://stackoverflow.com/q/22068056
type: Question
has answer: http://stackoverflow.com/a/23106019
tagged with: ant
has body: I'm trying to compile Hadoop and there's a Maven error in an ant plugin. I've never used Maven, or ant, and the error doesn't seem to give any indication of where the error is. The error output is at the end of the post. I've searched the pom files for maven-antrun-plugin (there are 54 pom.xml files with that string). The error suggests it's in the one under hadoop-common but in that file there are several maven-antrun-plugin occurrences. I have no idea which one is the problem, and the Maven error obscures the actual error message that whatever command is failing gives. How do I: Find exactly which line is causing the error Get the actual error output instead of Maven's useless error Here's the error: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (make) on project hadoop-common: An Ant BuildException has occured: exec returned: 2 -&gt; [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (make) on project hadoop-common: An Ant BuildException has occured: exec returned: 2 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555) at org.apache.maven.cli.MavenCli.doMain(…
tagged with: hadoop
answer count: 3
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/22068258
has answer: http://stackoverflow.com/a/24661121
type: UnansweredQuestion
score: 1
tagged with: java
upvote count: 1
tagged with: maven
has title: Compiling Hadoop native - finding error in Maven plugin

http://stackoverflow.com/q/22072889
has comment: http://stackoverflow.com/comment/33474432
type: UnansweredQuestion
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33472896
has body: I've been playing around with this problem, trying to sort out this multidimensional array but I keep on getting the wrong output. The array is sorted, except for the first element. Everything is in order, apart from the first element in the array. The first element in the sorted array, is also the first element in the array before it's sorted, which is sNamesLongitude[0][0] . The string sNamesLongitude[2][306] array has two rows. The first row holds the names of stations of the London underground, the second row holds its corresponding longitude. I'm trying to sort out the array so the stations with the lowest value for its longitude comes first in the array, and the last value will have the highest value for its longitude, while keeping their corresponding name (row 1), together with its longitude. String[][] temp = new String[2][1]; for (int a = 0; a &lt; sNamesLongitude[0].length - 1; a++) { if ((Double.parseDouble(sNamesLongitude[1][a])) &gt; (Double.parseDouble(sNamesLongitude[1][a + 1]))) { temp[0][0] = sNamesLongitude[0][a]; temp[1][0] = sNamesLongitude[1][a]; sNamesLongitude[0][a] = sNamesLongitude[0][a + 1]; sNamesLongitude[1][a] = sNamesLongitude[1][a + 1]; sNamesLongitude[0][a + 1] = temp[0][0]; sNamesLongitude[1][a + 1] = temp[1][0]; a=0; }
upvote count: 1
has answer: http://stackoverflow.com/a/22072969
has answer: http://stackoverflow.com/a/22074745
type: Question
tagged with: sorting
has comment: http://stackoverflow.com/comment/33474130
answer count: 2
has title: Sorting a multidimensional array, lowest to highest, only the first element remains unsorted
tagged with: arrays
downvote count: 0
favorite count: 0
tagged with: multidimensional-array
has comment: http://stackoverflow.com/comment/33474196

http://stackoverflow.com/q/22046474
upvote count: 2
type: UnansweredQuestion
has body: I'm currently running into a problem with Java generics, where the type of the parameter T has to be determined at runtime. Here's the class having a type parameter T: public class Something&lt;T&gt; { T value; public Something(T value) { this.value = value; } ... //some other methods } And here's a method in another class, where an instance of Something should be created, but where the type of T depends on the dynamic type of the given object: public void create(Object o) { //this is not working, since there is no getType() method Something&lt;o.getType()&gt; s = new Something(); } Is there a way to determine the dynamic type of o and pass it as type parameter to the Something-class? It is no option to make use of an if-cascade using instanceof, since there are many possibilities what o might be.
score: 2
has answer: http://stackoverflow.com/a/22046548
has comment: http://stackoverflow.com/comment/33426401
has comment: http://stackoverflow.com/comment/33426967
tagged with: java
has comment: http://stackoverflow.com/comment/33430632
has answer: http://stackoverflow.com/a/22046807
type: Question
has comment: http://stackoverflow.com/comment/33427370
has comment: http://stackoverflow.com/comment/33427736
downvote count: 0
has answer: http://stackoverflow.com/a/22046543
has comment: http://stackoverflow.com/comment/33426282
has title: How to set type of generic Java class at runtime?
tagged with: generics
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/22046742

http://stackoverflow.com/q/22040470
accepted answer: http://stackoverflow.com/a/23437461
has answer: http://stackoverflow.com/a/23437461
has body: I'm trying to use Errai 3 new features which is JBoss AS integration, however I am getting this error: [ERROR] Unable to load server class 'org.jboss.errai.cdi.server.gwt.JBossLauncher' [ERROR] java.lang.ClassNotFoundException: org.jboss.errai.cdi.server.gwt.JBossLauncher [ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:366) [ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:355) [ERROR] at java.security.AccessController.doPrivileged(Native Method) [ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:354) [ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:425) [ERROR] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) [ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:358) [ERROR] at java.lang.Class.forName0(Native Method) [ERROR] at java.lang.Class.forName(Class.java:270) [ERROR] at com.google.gwt.dev.DevMode$ArgHandlerServer.setString(DevMode.java:118) [ERROR] at com.google.gwt.util.tools.ArgHandlerString.handle(ArgHandlerString.java:26) [ERROR] at com.google.gwt.util.tools.ToolBase.processArgs(ToolBase.java:238) [ERROR] at com.google.gwt.dev.ArgProcessorBase.processArgs(ArgProcessorBase.java:29) [ERROR] at com.google.gwt.dev.DevMode.main(DevMode.java:310) The POM configuration is this: WARN App.html -Xmx1500m -XX:CompileThreshold=7000 -XX:MaxPermSize=1000m -Derrai.jboss.home=${errai.jboss.home} -Derrai.jboss.javaagent.path=${settings.localRepository}/org/jboss/errai/errai-client-local-class-hider/${errai.devmode.version}/errai-client-local-class-hider-${errai.devmode.version}.jar src/main/webapp <compileSourcesArtifacts> <compileSourcesArtifact>org.drools:guvnor-api</compileSourcesArtifact> <compileSourcesArtifact>org.drools:droolsjbpm-ide-common</compileSourcesArtifact> <compileSourcesArtifact>com.mycompany:models</compileSourcesArtifact> </compileSourcesArtifacts> false org.jboss.errai.cdi.server.gwt.JBossLauncher true webapp/App.html <gwtSdkFirstInClasspath>true</gwtSdkFirstInClasspath> false Wh…
type: AnsweredQuestion
tagged with: java
tagged with: wildfly
type: Question
tagged with: gwt
tagged with: jboss
score: 0
tagged with: errai
has title: Cannot run Errai Dev Mode with JBoss AS or Wildfly
answer count: 1

http://stackoverflow.com/comment/35590964
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/22090510
has text: @NaveenRamawat I found the culprit: it is the eclipse JAXB Validator. If I disable it in the Window | Preferences | Validation pane, the error is no longer generated.

http://stackoverflow.com/q/22010727
has comment: http://stackoverflow.com/comment/33363578
has title: Cannot initialize Integer variable
has answer: http://stackoverflow.com/a/22010728
has answer: http://stackoverflow.com/a/22010857
has comment: http://stackoverflow.com/comment/33363969
possible better answer: http://stackoverflow.com/a/22010857
tagged with: initialization
favorite count: 0
tagged with: integer
upvote count: 2
has comment: http://stackoverflow.com/comment/33364143
accepted answer: http://stackoverflow.com/a/22010728
has comment: http://stackoverflow.com/comment/33362362
downvote count: 1
has body: This is a self-answered question! I'm trying to initialize an Integer variable with a value, but it's not working as expected. It gives me different errors. What I've tried so far: public class Integer { public static void main(String[] args) { Integer num1 = 42; // Type mismatch: cannot convert from int to Integer Integer num2 = (Integer)42; // Cannot cast from int to Integer Integer num3 = new Integer(42); // The constructor Integer(int) is undefined } } What's the issue here? How can I set the value of my Integer properly?
type: Question
type: AnsweredQuestion
tagged with: naming-conventions
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33362516
has comment: http://stackoverflow.com/comment/33363283
tagged with: class
answer count: 2

http://stackoverflow.com/q/22017474
upvote count: 3
type: UnansweredQuestion
has body: I'm trying to deploy a RESTful application with Netbeans to a remote server (with domain name "agdata.se") by following this guide. Once I've built and deployed, then entering the url "http://agdata.se:8080/WebTest/test-resbeans.html" I get the following error message: "Cannot access WADL: Please restart your RESTful application, and refresh this page." When I look in the project folder and unzip the war file, there's no wadl to be found. It's like Netbeans never created one. I created the project (let's call it project A) using dedicated folders. I choosed Java EE 6Web and JavaServer Faces as the framework. I didn't configure the framework so I didn't choose PrimeFaces or any other of the components. I then made a "RESTFful web service from a database" by rightclicking the project node. I created the datasource, just like the guide said, since I use a MySQL-database and not a Derby. I left "Generate Named Query Annotations for Persistent Fields" checked. I didn't check "Use Jersey Specific Features". Then, I created another Web Application, also with Faces as framework. Letäs call this project B. I run "Test RESTful Web Services" and check "Web Test Client in Project". I then choose project B and I can deploy and build it without any errors. I then enter the REST-test url into Firefox and it says it cannot access the WADL file. Again, there is no such file in the project folder when I look into the war file. Just to be clear, this is a remote server I'm deploying to, not localhost. The server is Ubuntu 13, I'm on a Mac OSX. Thankful for all the help I can get!
score: 3
tagged with: java
type: Question
has title: Netbeans does not give me wadl file
downvote count: 0
tagged with: glassfish
favorite count: 0
tagged with: rest
tagged with: netbeans
has comment: http://stackoverflow.com/comment/82188638
answer count: 0

http://stackoverflow.com/q/22149766
has comment: http://stackoverflow.com/comment/33611240
answer count: 2
tagged with: microfocus
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33657844
has comment: http://stackoverflow.com/comment/33611247
has answer: http://stackoverflow.com/a/22158649
has answer: http://stackoverflow.com/a/22150498
tagged with: java
score: 0
has title: Calling a Java Program from Cobol
type: Question
tagged with: cobol
has body: I'm trying to communicate Java and Cobol. I need to call a Java program (with paramaters) from Cobol. I read some documentation from Microfocus: http://supportline.microfocus.com/documentation/books/nx40/dijafc.htm http://supportline.microfocus.com/documentation/books/nx40/dijaco.htm But I didn't find a real solution, because I need to call an entire program and not a Java Class. Thanks in advance.

http://stackoverflow.com/q/22058223
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/33448592
has comment: http://stackoverflow.com/comment/33447915
answer count: 0
type: Question
tagged with: java
has title: My phone always loses connection with Android Device Chooser and says it's unknown/offline
has body: I'm not sure why, but my phone always loses the connection with the Android Virtual Device manager when I plug it in. Initially, it recognizes my phone, but after around 10 seconds or so it loses connection and says it's offline and unknown. What I see when I plug it in initially is on the right, and the left shows what I see when I wait about 10 seconds or so (not even long enough to install my app). Any ideas? P.S. When I first plug it in, it says "Connected as an installer" in my notification area, but after a little while it says "Connected as a media device." I have a feeling something here is the culprit, but can't figure it out.
score: 0

http://stackoverflow.com/comment/33388330
type: Comment
type: QuestionComment
has text: Do you mean that you've hard-coded configuration details into your Java?
comment on: http://stackoverflow.com/q/22006534
score: 0

http://stackoverflow.com/comment/33384452
has text: @JeroenVannevel You can just paste the link why you have posted the explanation in the comment ?
comment on: http://stackoverflow.com/q/22022921
type: Comment
score: 0
type: QuestionComment

http://stackoverflow.com/q/22064705
has title: java.lang.NoClassDefFoundError: and other error
downvote count: 0
favorite count: 0
has body: I have created a file java named "cancelladir" that is in a directory name "cancelladir", when I write, in my ubuntu shell, "javac cancelladir.java" It create a cancelladir.class but when I try to execute the file java with the command "java cancelladir " there are some error like this: Exception in thread "main" java.lang.NoClassDefFoundError: cancelladir (wrong name: cancelladir/cancelladir) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) 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:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) I have already set the classpath at export CLASSPATH=.:/home/lisa/graphhopper/graphhopperAndrea/web/src/main/webapp/cancelladir and try to recompile but nothing change. What is the problem?? what I have to do?
has comment: http://stackoverflow.com/comment/33458328
has comment: http://stackoverflow.com/comment/33458875
has answer: http://stackoverflow.com/a/22065273
has comment: http://stackoverflow.com/comment/33458429
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22064827
upvote count: 1
has comment: http://stackoverflow.com/comment/33458226
type: Question
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33458591
answer count: 2

http://stackoverflow.com/comment/33482785
type: Comment
type: QuestionComment
has text: Try with a lower case `s` in `FS`. That would be more java bean conventional.
comment on: http://stackoverflow.com/q/22078111
score: 0

http://stackoverflow.com/comment/33520078
has text: Try visting this hope this help: http://www.oracle.com/technetwork/middleware/ias/jsf-jpa-tutorial-095959.html
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22098252

http://stackoverflow.com/comment/33403728
type: Comment
comment on: http://stackoverflow.com/a/22033614
has text: hmm, i think this question is not related to Android, it is more on the server side not on the client side anymore.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33553078
comment on: http://stackoverflow.com/a/22104166
type: AnswerComment
type: Comment
has text: @Justin How you add a method is up to you and your development team, including how you agree on interface changes, how you run source control, and what your release cycle is. I would add an empty, documented method to QAService, write a test in QAServiceTest to help me know when the future implementation works, and mock/stub the expected behavior wherever I mock QAService (which is almost definitely not within QAServiceTest).
score: 0

http://stackoverflow.com/comment/33770912
type: AnswerComment
has text: That would depend upon your regex and what kind of groups you've used in it. Care to share more details?
type: Comment
comment on: http://stackoverflow.com/a/22163671
score: 0

http://stackoverflow.com/q/22086119
has comment: http://stackoverflow.com/comment/33497720
has comment: http://stackoverflow.com/comment/101306267
type: Question
has comment: http://stackoverflow.com/comment/33497425
has body: I want to run multiple CMD commands in maven using single pom.xml. I am using this plugin but its is not working org.eclipse.m2e lifecycle-mapping 1.0.0 <lifecycleMappingMetadata> org.apache.maven.plugins maven-dependency-plugin [1.0.0,) unpack <ignore /> </lifecycleMappingMetadata> org.codehaus.mojo exec-maven-plugin 1.2 run a backup pre-integration-test exec yourscript.sh May I know how can I do that?
has answer: http://stackoverflow.com/a/22086816
accepted answer: http://stackoverflow.com/a/22086816
linked to: http://stackoverflow.com/q/3491937
score: 0
has title: Execute cmd command using maven pom.xml file
answer count: 1
tagged with: cmd
tagged with: pom.xml
has comment: http://stackoverflow.com/comment/33497494
has comment: http://stackoverflow.com/comment/101306310
has comment: http://stackoverflow.com/comment/33502784
tagged with: maven
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33497618

http://stackoverflow.com/comment/45284300
type: QuestionComment
comment on: http://stackoverflow.com/q/22152089
has text: Its crap and I feel banging my head and asking this question WHY YOU NOT EVALUATE my expressions? I wish I could use some other IDE but at the moment stuck with it...
score: 0
type: Comment

http://stackoverflow.com/q/22135041
type: Question
possible better answer: http://stackoverflow.com/a/22135073
has answer: http://stackoverflow.com/a/22135073
score: 0
answer count: 2
has title: Can't find cause of NullPointerException, log not outputting as desired
has body: I'm getting the following error: 03-02 18:11:00.307: E/AndroidRuntime(2228): FATAL EXCEPTION: main 03-02 18:11:00.307: E/AndroidRuntime(2228): Process: com.dionsoft.dailymacrotracker, PID: 2228 03-02 18:11:00.307: E/AndroidRuntime(2228): java.lang.RuntimeException: Unable to resume activity {com.dionsoft.dailymacrotracker/com.dionsoft.dailymacrotracker.MainActivity}: java.lang.NullPointerException 03-02 18:11:00.307: E/AndroidRuntime(2228): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2788) 03-02 18:11:00.307: E/AndroidRuntime(2228): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2817) 03-02 18:11:00.307: E/AndroidRuntime(2228): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250) 03-02 18:11:00.307: E/AndroidRuntime(2228): at android.app.ActivityThread.access$800(ActivityThread.java:135) 03-02 18:11:00.307: E/AndroidRuntime(2228): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 03-02 18:11:00.307: E/AndroidRuntime(2228): at android.os.Handler.dispatchMessage(Handler.java:102) 03-02 18:11:00.307: E/AndroidRuntime(2228): at android.os.Looper.loop(Looper.java:136) 03-02 18:11:00.307: E/AndroidRuntime(2228): at android.app.ActivityThread.main(ActivityThread.java:5017) 03-02 18:11:00.307: E/AndroidRuntime(2228): at java.lang.reflect.Method.invokeNative(Native Method) 03-02 18:11:00.307: E/AndroidRuntime(2228): at java.lang.reflect.Method.invoke(Method.java:515) 03-02 18:11:00.307: E/AndroidRuntime(2228): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 03-02 18:11:00.307: E/AndroidRuntime(2228): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 03-02 18:11:00.307: E/AndroidRuntime(2228): at dalvik.system.NativeStart.main(Native Method) 03-02 18:11:00.307: E/AndroidRuntime(2228): Caused by: java.lang.NullPointerException 03-02 18:11:00.307: E/AndroidRuntime(2228): at com.dionsoft.dailymacrotracker.MainActivity.onResume(MainAct…
tagged with: nullpointerexception
has comment: http://stackoverflow.com/comment/33586018
tagged with: android
has answer: http://stackoverflow.com/a/22135074
accepted answer: http://stackoverflow.com/a/22135074
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33586234

http://stackoverflow.com/comment/33490705
score: 0
type: AnswerComment
type: Comment
has text: Yep. That's the nature of threaded programming @htorque. If one threads modifies the list, the other threads need to see that modification. You could use something like a `ConcurrentSkipList` if you want higher performance on the updates.
comment on: http://stackoverflow.com/a/22082157

http://stackoverflow.com/comment/33363973
score: 0
type: Comment
type: QuestionComment
has text: No. I knew why this exception occurs in my case. I just need way to avoid this exception and continue to proceed data.
comment on: http://stackoverflow.com/q/22010899

http://stackoverflow.com/q/22106509
accepted answer: http://stackoverflow.com/a/22150864
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33609301
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has title: Create multiple JPA persistent entities from one JSON using Jersey?
type: Question
tagged with: jersey
answer count: 1
tagged with: jpa
has comment: http://stackoverflow.com/comment/33535486
score: 0
tagged with: rest
has body: perhaps someone could point me in the right direction, i'v lurking around for a solution for too long.. I am using jersey to get a json sent to a REST service from POST data, and create an persistent entity to be inserted into my DB. With something like this: @POST @Path("/create") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response createRecord(Element element) throws Exception{ violations = validator.validate(element); if (violations.size() &gt; 0) { jsonResponse.setSuccess(false); jsonResponse.setMessage("TODO error message"); jsonResponse.setValidationError(this.getValidationErrorList()); } else { try { em.persist(element); em.flush(); } catch (PersistenceException e) { System.out.println(e.getMessage()); jsonResponse.setSuccess(false); jsonResponse.setMessage("TODO error"); } } jsonResponse.setSuccess(true); jsonResponse.setMessage("Success!"); return Response.ok().entity(new ObjectMapper().writeValueAsString(jsonResponse)).build(); } However i'd like to construct multiple entities from one json like this: [ { "usrcre": 0, "usrmod": 0, "datmod": null, "vaecleint": 40, "vaeelecle": "1fdsfds", "vaevalcle": "fdsf", "vaedsc": "dsfdsf" }, { "usrcre": 0, "usrmod": 0, "datmod": null, "vaecleint": 41, "vaeelecle": "1TEST", "vaevalcle": "0003", "vaedsc": "fdgfdgfdg" }, { "usrcre": 0, "usrmod": 0, "datmod": null, "vaecleint": 42, "vaeelecle": "1TEST", "vaevalcle": "0004", "vaedsc": "Valeur 0004gfdgfdg" }, { "usrcre": 0, "usrmod": 0, "datmod": null, "vaecleint": 43, "vaeelecle": "1TEST", "vaevalcle": "0005", "vaedsc": "Valeur 0005fdgfdgd" } ] I'v tried using something like: public Response createRecord(List&lt;Element&gt; elements) throws Exception and then trying to iterate in this list and persist every element, but I get a: java.lang.IllegalArgumentException: argument type mismatch as soon as my method signature includes a list or an array. Am I missing something? Update: Here's the stack trace when I tried to access a List (I'm …
has answer: http://stackoverflow.com/a/22150864

http://stackoverflow.com/comment/33508696
type: AnswerComment
has text: I have got this in my PATH system variables %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;"C:\Program Files\Common Files\EMC";C:\Program Files\Java\jdk1.6.0_41\bin;D:\username-Software\Android\sdk\platforms;D:\username-Software\Android\sdk\platform-tools;C:\Program Files\apache-ant-1.9.3\bin;D:\username-Software\Android\sdk\tools;
score: 0
comment on: http://stackoverflow.com/a/22092583
type: Comment

http://stackoverflow.com/q/22086633
favorite count: 0
type: UnansweredQuestion
answer count: 0
score: 1
tagged with: java
upvote count: 1
tagged with: gradle
has title: how do i make Intellij Idea recognize the generated resources from a custom gradle task?
type: Question
tagged with: intellij-idea
downvote count: 0
has body: I have a Gradle task that generates a project.properties file and places it in the resources output dir for the main sourceSet in each project that has the JavaPlugin applied (or extension of). compileJava depends on this task however this dependency does not carry over into the Intellij-Idea IDE when I run tests (the project.properties file does not generate on rebuild), and thus causes null pointer exceptions when trying to access this file through Class.getResource(). How can i configure intellij to run this task and produce the necessary files? Is there a way of hooking it into ant so that a normal ant soandso build from intellij in the pre-processing section of artifact generation triggers this task? I would prefer a way that includes direct integration with gradle.

http://stackoverflow.com/comment/33533876
type: Comment
type: QuestionComment
has text: It is supposed to actually print the values and return to the main method which formats it correctly.
comment on: http://stackoverflow.com/q/22106167
score: 0

http://stackoverflow.com/q/22028675
accepted answer: http://stackoverflow.com/a/22028771
upvote count: 5
possible better answer: http://stackoverflow.com/a/22029072
answer count: 2
has answer: http://stackoverflow.com/a/22029072
has body: I am trying to use DecimalFormat to format double numbers to just print the number with 2 decimal places if it has fractional part else i want to print number as it is. When number is small, below code works fine but with big numbers, It's not working as expected. DecimalFormat df = new DecimalFormat("#.##"); //have tried just # too double d1 = 56789d; System.out.println(df.format(d1)); //works fine - prints 56789 double d2 = 1234567879123456789d; System.out.println(df.format(d2)); // does not work Second outputs 1234567879123456770 while I want 1234567879123456789. For double values with decimal part, I just want to retain two decimal points. Any suggestions on what's going wrong?
downvote count: 0
favorite count: 0
score: 5
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33395273
has answer: http://stackoverflow.com/a/22028771
type: Question
has title: Using DecimalFormat to format big double numbers

http://stackoverflow.com/q/22083012
tagged with: java
type: Question
has body: I searched after which are the system properties for the default locale. I found many places something like that: user.language (it worked) and user.region (wont work). After a deeper search I found a user.country (which kinda worked - returned with the result what supposed to be returned by the user.region). So how is that? Those reference are all wrong or did I miss something?
has title: System properties: user.region or user.country
has comment: http://stackoverflow.com/comment/33492271
accepted answer: http://stackoverflow.com/a/22083339
has comment: http://stackoverflow.com/comment/33492200
has answer: http://stackoverflow.com/a/22083339
answer count: 1
downvote count: 0
favorite count: 0
score: 2
type: AnsweredQuestion
upvote count: 2

http://stackoverflow.com/q/22098982
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33520115
tagged with: multithreading
upvote count: 1
downvote count: 1
type: Question
accepted answer: http://stackoverflow.com/a/22099359
tagged with: java
linked to: http://stackoverflow.com/q/1250643
possible better answer: http://stackoverflow.com/a/22099541
has body: What i need is a tool/class that acts like CoundDownLatch but can be counted up and down. Whenever a task is executed it will counted up, when a task is done it is counted down. There can be multiple tasks running parallel, and one thread should wait until no task is executing/ the counter is at 0. I looked into the Phaser class, but i don't know if it provides what i am looking for, maybe it can be used to solve this puzzle?
has answer: http://stackoverflow.com/a/22099541
score: 0
answer count: 2
favorite count: 0
has title: What API can I use to to await the completion of tasks
has answer: http://stackoverflow.com/a/22099359

http://stackoverflow.com/q/22084982
has comment: http://stackoverflow.com/comment/33772444
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33497812
has title: Can i stop the malicious reading the class files via "java.io" function,with NATIVE code(tool)?
has comment: http://stackoverflow.com/comment/33495520
tagged with: intercept
tagged with: java
has comment: http://stackoverflow.com/comment/33563120
tagged with: methods
downvote count: 1
has body: we'd defend against the code crackers who can operate on the whole operation system who may read the encoded class-file via "java.io" and save the copy we'd protect java-based application's intellectual property this requirement was raised by several customers, so it has realistic value. Simplex Java-JDK-JVM solution like securityManager without native code/tool can NOT be accepted because it's easy to be bypassed, since cracker have the admin privilege on the OS in this scenario.
has comment: http://stackoverflow.com/comment/33758882
has comment: http://stackoverflow.com/comment/33773429
type: Question
tagged with: native
has comment: http://stackoverflow.com/comment/33562970
upvote count: 0
has comment: http://stackoverflow.com/comment/33555074
score: -1
tagged with: java-io
has comment: http://stackoverflow.com/comment/33495468
has answer: http://stackoverflow.com/a/22085031
has comment: http://stackoverflow.com/comment/33508166
answer count: 1
favorite count: 0

http://stackoverflow.com/comment/33430911
type: Comment
has text: Errr... HTML & XML? There are various extensions available to do HTML - https://addons.mozilla.org/en-US/firefox/addon/web-developer/ is one. Also [this](http://validator.w3.org/) site.
comment on: http://stackoverflow.com/q/22048950
score: 0
type: QuestionComment

http://stackoverflow.com/comment/33385510
score: 0
comment on: http://stackoverflow.com/q/22023391
has text: I was always told that the JPanel goes int he JFrame because the JFrame is the a heavy weight component. Actual you do not even have to put the JPanel in the JFrame but I think you will find that it is convent to have at least one Panel in the JFrame in case you want to do some graphics programming. The paintComponent() will let you do that. Onto FreeChart i have used that some for a project a while back but my bose had the documentation and it was much easier than. I think you need the docuementation to make it easy going with this third party vendor software. But JFreeCharts are look nice
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33504138
type: Comment
has text: Element data type may be float.It's depends on datasets.
comment on: http://stackoverflow.com/a/22088570
score: 0
type: AnswerComment

http://stackoverflow.com/q/22131409
type: UnansweredQuestion
tagged with: file
has answer: http://stackoverflow.com/a/22131688
has title: Rename file and overwrite it again
tagged with: java
has body: I'm trying to rename file on my gallery I'm using following steps getting file path from device then rename the path , but it doesn't rename it on local path I want to overwrite it with new name picturePath = cursor.getString(columnIndex);// real pic path on my device after getting it from gallery File photo = new File(picturePath); File newFile= new File(picturePath,"hhhhhhh"); photo.renameTo(newFile);
type: Question
has comment: http://stackoverflow.com/comment/33579938
score: 0
tagged with: android
answer count: 1
has comment: http://stackoverflow.com/comment/33580313

http://stackoverflow.com/a/22049424
score: 3
downvote count: 0
has body: There has probably been an issue with the packaging of storm-starter.jar: this jar should not contain the sl4j implementation. In order to package the storm-starter example (https://github.com/nathanmarz/storm-starter), run the following command from the root folder (where the m2-pom.xml is present): mvn -f m2-pom.xml package This should produce this file in the target/ folder: storm-starter-0.0.1-SNAPSHOT-jar-with-dependencies.jar Then, in order to deploy it to the cluster (indeed, through Nimbus), you need to tell to the storm jar command the fully qualified name of the class that contains the main() that provides the topology definition, like this (make sure you use the one with "-with-dependencies"): usr/local/storm/bin/storm jar storm-starter-0.0.1-SNAPSHOT-jar-with-dependencies.jar storm.starter.ExclamationTopology
answers question: http://stackoverflow.com/q/22046988
upvote count: 3
has comment: http://stackoverflow.com/comment/33433923
type: Answer

http://stackoverflow.com/a/22090163
downvote count: 0
has comment: http://stackoverflow.com/comment/33873419
has comment: http://stackoverflow.com/comment/33590758
answers question: http://stackoverflow.com/q/22032045
upvote count: 3
has comment: http://stackoverflow.com/comment/33862808
has body: To get rid of the JDBC driver warning, run the following on application shutdown: String url = "your JDBC url"; Driver driver = DriverManager.getDriver(url); DriverManager.deregisterDriver(driver); If you are using Spring beans, you can put this in the destroy() method of a DisposableBean. In a servlet environment, you can use a ServletContextListener: public class CleanupListener implements ServletContextListener { public void contextDestroyed(ServletContextEvent arg0) { // enter cleanup code here } public void contextInitialized(ServletContextEvent arg0) { } } Set it up in web.xml: com.example.CleanupListener
type: Answer
has comment: http://stackoverflow.com/comment/33602724
score: 3

http://stackoverflow.com/q/22095543
answer count: 1
has comment: http://stackoverflow.com/comment/33540895
score: -1
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33515632
has comment: http://stackoverflow.com/comment/33514087
tagged with: selenium-webdriver
has answer: http://stackoverflow.com/a/22128730
upvote count: 0
tagged with: java
has title: Selenium webdriver,Java - Filling form opened in new tab
downvote count: 1
has body: I click on image, it opens form in new tab and there are some radio buttons to select and finish the form. I am able to open new tab and pass control to it but not able to click on radio buttons and finish form.I tried many way.
type: Question

http://stackoverflow.com/comment/80143988
score: 25
comment on: http://stackoverflow.com/a/40934100
type: AnswerComment
type: Comment
has text: This is a clean solution. it may have boiler template but the interface can be the inner class of the entity. Making it quite clean.

http://stackoverflow.com/comment/33531147
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22104803
has text: See the [javadoc](http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html). It explains (near the top of the page) when this exception would be raised.
score: 0

http://stackoverflow.com/comment/33462240
comment on: http://stackoverflow.com/a/22065763
has text: I found a better resource helpful in this context : http://www.javabeat.net/watchservice-api-java7-monitor-directory/
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33602680
type: Comment
has text: oh sweet lord. I gotto get some rest. Thanks bro.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/22145013

http://stackoverflow.com/a/22126808
has comment: http://stackoverflow.com/comment/33570944
score: 8
has body: No way to do that with arrays, because they don't override equals() and hashCode(). You should define your own class wrapping the array, which would override equals() and hashCode() or use a List&lt;Integer&gt; as key instead.
has comment: http://stackoverflow.com/comment/33571006
downvote count: 0
upvote count: 8
answers question: http://stackoverflow.com/q/22126787
type: Answer
has comment: http://stackoverflow.com/comment/33570934

http://stackoverflow.com/a/22012946
has body: Please take a look at this link here which explains how to use ExecutorService in java. It can be something like: ExecutorService executorService = Executors.newFixedThreadPool(10); MyDataLoader myDataLoader1 = new MyDataLoader("c:/file1"); MyDataLoader myDataLoader2 = new MyDataLoader("c:/file2"); MyDataLoader myDataLoader3 = new MyDataLoader("c:/file3"); executorService.execute(myDataLoader1); executorService.execute(myDataLoader2); executorService.execute(myDataLoader3); executorService.shutdown(); You can write MyDataLoader class like: public class MyDataLoader implements Runnable { String fileName = null; public MyDataLoader(String fileName) { this.fileName = fileName; } public void run() { //Your logic to parse file and insert the data in DB. } } Hope this helps.
answers question: http://stackoverflow.com/q/22012602
upvote count: 2
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/comment/33391332
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22026049
has text: public static void printOnLines(int n, int s) { s=0; for(int i=0; i<=s; i+=3) { for(int j=1; j<=n-1; j++) { System.out.print(i+j + ", "); } System.out.print("10"); System.out.println(); } }
type: Comment

http://stackoverflow.com/a/22033695
type: Answer
answers question: http://stackoverflow.com/q/22028593
has body: public static Integer[] freqs(String[] data) { HashMap&lt;String, Integer&gt; myMap = new HashMap&lt;String, Integer&gt;(); for (String s : data) { if (!myMap.containsKey(s)) { myMap.put(s, 0); } myMap.put(s, myMap.get(s) + 1); } return new TreeMap&lt;String, Integer&gt;(myMap).values().toArray(new Integer[myMap.size()]); }
score: 0

http://stackoverflow.com/comment/33599395
comment on: http://stackoverflow.com/q/22142952
type: QuestionComment
has text: json-simple-1.1.1.jar from https://code.google.com/p/json-simple/
type: Comment
score: 0

interceptor
tags question: http://stackoverflow.com/q/22072895
tags question: http://stackoverflow.com/q/22165444
tags question: http://stackoverflow.com/q/22148006
tags question: http://stackoverflow.com/q/22062311
tag name: interceptor
tags question: http://stackoverflow.com/q/22167012
tags question: http://stackoverflow.com/q/22119280
type: Tag
tags question: http://stackoverflow.com/q/22165356

http://stackoverflow.com/a/22033800
upvote count: 1
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/22033556
score: 1
has body: You need to create a statement from the connection before use it to executeQuery().... Statement statement = connection.createStatement();

http://stackoverflow.com/comment/33455734
type: Comment
comment on: http://stackoverflow.com/a/22062841
has text: @Dennis Yes and no. Depends on what data he wants to handle and how frequent. Since he's looking at byte arrays, I assume performance and GC matters in this case, which put all XML/JSON/Protocol Buffer in embarrassing situation. Some people might think Protobuf high performance, but if you look at its Java implementation, a lot of temp objects are generated during serialization process. Of course if performance isn't a concern, anything is OK - but I doubt the OP would look at byte format in the first place.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33585231
has text: In Java you cannot have output variables, so you need the array to get the value, or better yet, you can define a data type that can get the result from the output and fill the result from C++. Would this work for you?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22132632
score: 0

http://stackoverflow.com/a/22120919
answers question: http://stackoverflow.com/q/22120663
score: 0
type: Answer
has body: You are mismanaging the variable 'check'. You are setting it to true to exit the loop, and also to skip the authentication process. Try using two different variables for these part to avoid this type of confusion.

http://stackoverflow.com/a/22021199
score: 0
has body: It will hang around util collected by the GC. (thus holding to unmanaged resources (files, sockets etc)
type: Answer
answers question: http://stackoverflow.com/q/22021140

http://stackoverflow.com/comment/33489516
comment on: http://stackoverflow.com/q/22080557
has text: I do not see any problem to have database setup on jenkins sever and running junit test cases against the database.
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/22046439
score: 0
answers question: http://stackoverflow.com/q/22046082
type: Answer
has body: First, as another answer state it, you should not use != to compare strings, but equals. Then, split takes a regexp and is a weird way of converting a String into an array of one-character string. I think it will be better to simply take the corresponding char array and use Character.getNumericValue char[] charArray = number.toCharArray(); for (char c: charArray ) { result += Character.getNumericValue(numb); } Be carrefull, the code above does not perform any check to make sure your initial string contains only digit characters. If there are such characters the code will not fail but will produce unexpected result.

http://stackoverflow.com/comment/33494278
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22084301
score: 0
has text: Ummm not exactly sure what that is?

http://stackoverflow.com/comment/33520947
comment on: http://stackoverflow.com/a/22099331
has text: @febri23 Added an explaination and a suggestion about how this could be solved.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/32714940
has body: Below code work for me in web.xml file WebService org.glassfish.jersey.servlet.ServletContainer jersey.config.server.provider.packages com.example.demo.webservice //Package unit:WidgetPU persistence/widget 1 WebService /webservices/*
upvote count: 5
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/22022114
score: 5

http://stackoverflow.com/comment/33532260
has text: Have you considered a tool like [jdbcdslog] (https://code.google.com/p/jdbcdslog/) to log the stack trace of each SQL call? I'd do that and review the stack traces for anything that could be managing transactions.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22103483

http://stackoverflow.com/comment/33587568
type: QuestionComment
score: 2
comment on: http://stackoverflow.com/q/22135739
has text: Show your complete code.
type: Comment

http://stackoverflow.com/q/22160141
has title: JSTL for display purposes
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22160229
tagged with: java
type: Question
tagged with: jstl
has body: is JSTL core/functions are only for display purposes? like javascript can't it be used to display to a input field instead of mixing javascript and JSTL. when i try to fill a select element with options i ended up with this. function fill(){ var select=document.getElementById("sel"); &lt;c:foreach items="${value}" var="op"&gt; var option=document.createElement("option"); option.text='${op.optionname}'; select.add(option); &lt;/c:foreach&gt; } what i am trying to do here is to fill a select element with options when a button is clicked.is there a way to achieve this using only jstl? i am a bit confuse using jstl.
tagged with: javascript
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/22161309

http://stackoverflow.com/comment/33623493
type: QuestionComment
has text: So you're instantiating a stream in every thread without synchronizing the writes?
score: 0
comment on: http://stackoverflow.com/q/22155518
type: Comment

http://stackoverflow.com/comment/44952034
comment on: http://stackoverflow.com/q/22027000
has text: There's a discussion site for BrightspotCMS [here](http://community.brightspotcms.com/) that, while it doesn't have a lot of content yet, is worth asking questions on.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33547980
comment on: http://stackoverflow.com/a/22114102
has text: @user1282256 I don't see why you would want to reimplement methods that have already been implemented by the common libraries.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33532276
type: Comment
has text: Tcpmon runs as a "man in the middle" between your client and the server: have you set a tcp port were it can listen your request and then (after having dumped it) redirect it to the server's tcp port?
comment on: http://stackoverflow.com/a/22104702
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33529988
type: AnswerComment
comment on: http://stackoverflow.com/a/22104013
score: 0
type: Comment
has text: One example of the kind of problem that can arise is when inheritance is involved. For example, if you had several different subclasses of University, then you would need different constructors for each one. Then you have the complexity of figuring out which constructor should be used. The essential problem is that the inheritance is determined at runtime, but a copy constructor is defined at compile time. Of course, there are ways to cope, but it can get confusing and awkward. For this reason, cloning is often easier to implement and debug.

http://stackoverflow.com/comment/33527576
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/22101593
has text: That works perfectly. I see I don't even need that for loop when I use this solution and it's much simpler.
type: Comment

http://stackoverflow.com/comment/33612775
type: QuestionComment
has text: More information needed - what are your consistency requirements? Do all objects need to be updated with one line before the next line is processed, for example?
score: 0
comment on: http://stackoverflow.com/q/22150647
type: Comment

http://stackoverflow.com/q/22118099
has comment: http://stackoverflow.com/comment/33555166
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33555330
answer count: 1
tagged with: jzmq
downvote count: 0
has comment: http://stackoverflow.com/comment/33554989
favorite count: 0
has comment: http://stackoverflow.com/comment/33554741
has body: I have a java application using an external dll (zmq). When I run it in debug mode in Eclipse it's all fine. However, when I export the application as Runnable JAR file then trying to run it, I'm getting that error referencing the dll. Following my research on this site I configured the build path for JRE System Library, added that path of the folder containing the dll to Native library location, but I'm still getting that error. Is there anything I need to do further? Or different? Thanks.
has comment: http://stackoverflow.com/comment/33554888
score: 2
upvote count: 2
type: UnansweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/24133465
has comment: http://stackoverflow.com/comment/33555135
has comment: http://stackoverflow.com/comment/33555251
has title: java.lang.UnsatisfiedLinkError: no jzmq in java.library.path

http://stackoverflow.com/comment/33576481
type: AnswerComment
has text: Could you give me an example of implementation, for example, add a side effect "se1" to drug "Aspirin" on normal java? I am confused of how to use Map
type: Comment
comment on: http://stackoverflow.com/a/22129547
score: 0

http://stackoverflow.com/comment/33627838
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22158538
has text: Oh my apologies. I didn't take that into consideration.

http://stackoverflow.com/comment/33399316
type: QuestionComment
has text: posted the entire class
score: 0
comment on: http://stackoverflow.com/q/22031047
type: Comment

http://stackoverflow.com/comment/33486144
type: Comment
has text: @CSpadawan i use Eclipse, but i found the following on google: https://netbeans.org/kb/docs/java/debug-visual.html and fyi: i love Eclipse, feel free to give it a trial!
comment on: http://stackoverflow.com/a/22078798
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33507385
comment on: http://stackoverflow.com/q/22090558
score: 0
type: Comment
type: QuestionComment
has text: Clearly your Java server has a resource leak, probably a socket leak, somewhere.

http://stackoverflow.com/comment/33377767
has text: @user3351552: have you overriden `.equals` and `.hashcode`?
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22018427
score: 0

http://stackoverflow.com/comment/33578362
comment on: http://stackoverflow.com/q/22130797
has text: You need to do it under administrative account. Make sure the UAC is off.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33609591
score: 0
type: AnswerComment
type: Comment
has text: I know what I've done above is bad practice, was planning to refactor later, probably by having it in the constructor. But this looks like a better solution, thanks.
comment on: http://stackoverflow.com/a/22147624

http://stackoverflow.com/comment/33397509
comment on: http://stackoverflow.com/a/22029624
type: AnswerComment
has text: Solution found, pretty close to what you suspected. Thank you very much for your help!
score: 0
type: Comment

http://stackoverflow.com/q/22129252
has answer: http://stackoverflow.com/a/22129390
has body: I was torn between posting here and math.stackexchange.com but opted for here as it's equally programming related and I've not used math.stackexchange.com before. Basically I have 6 different items I'd like to 'drop' based on a percentage but I have no idea how to go about implementing this. Math isn't my strong suit either which doesn't help. Anyway, the percentages for items 1 through 6 are as follows: 1%, 0.85%, 0.1%, 0.05%, 0.01%, 0.001% so item 1 has a 1% chance to drop, item 2 has a 0.85% chance to drop etc. And I one want 1 item to drop per run, if none of these 'chances' are met then a default item will be used instead. Consider these 6 items bonus items. So far i've tried this: Random rn = new Random(); int x = rn.nextInt(100)+1; if(100%x==0)//1% { } if(100%(x*100)==0) //0.1% { } which doesn't seem like a fair calculation and this: Random rn = new Random(); int x = rn.nextInt(100000)+1; if(100%x==0)//1% { } if(8500%x==0) //0.1% { } which seems even worse. I was thinking of using a random number for each item but thats a lot of RNG as it'll be running in a game loop. I've tried to keep this question as direct as possible to avoid debate etc so I'm not looking for the best solution, simply one that works - if any other information is needed, I'm happy to answer as long as it's n2k to help me with this problem =)
type: AnsweredQuestion
score: 2
upvote count: 2
tagged with: math
tagged with: java
has comment: http://stackoverflow.com/comment/33575416
type: Question
accepted answer: http://stackoverflow.com/a/22129390
possible better answer: http://stackoverflow.com/a/22129331
has answer: http://stackoverflow.com/a/22129331
has comment: http://stackoverflow.com/comment/33575362
answer count: 2
downvote count: 0
favorite count: 0
has title: How to calculate a drop rate based on percentage

http://stackoverflow.com/a/22113695
has comment: http://stackoverflow.com/comment/33579426
answers question: http://stackoverflow.com/q/22113385
has comment: http://stackoverflow.com/comment/33547605
type: Answer
has comment: http://stackoverflow.com/comment/33547116
has comment: http://stackoverflow.com/comment/33579572
has comment: http://stackoverflow.com/comment/33579446
has comment: http://stackoverflow.com/comment/33579368
has comment: http://stackoverflow.com/comment/33547706
upvote count: 1
has comment: http://stackoverflow.com/comment/33579269
downvote count: 0
has body: Use URI templates: URLEncoder.encode() does not work. Usage of the library above: final URITemplate template = new URITemplate("http://dsxsd.com/def/" + "fss/default/files/{filename}"); final VariableMap vars = VariableMap.newBuilder() .addScalarValue("filename", "10 رسم الصباح - 1.mp3") .freeze(); System.out.println(template.toString(vars)); Output: http://dsxsd.com/def/fss/default/files/10%20%D8%B1%D8%B3%D9%85%20%D8%A7%D9%84%D8%B5%D8%A8%D8%A7%D8%AD%20-%201.mp3
score: 1

http://stackoverflow.com/q/22151173
score: 1
type: Question
tagged with: android
has body: I have this code witch returns the content of a file: private ArrayList&lt;String&gt; readFromFile1(Context context) { ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;(); try { ObjectInputStream ois = new ObjectInputStream( context.openFileInput("jokesNames2.bjk")); try { list = (ArrayList)ois.readObject(); } catch (ClassNotFoundException e) { e.printStackTrace(); } ois.close(); } catch (IOException e) { Log.e("log activity", "Can not read file: " + e.toString()); } I'm calling it like that: System.out.println("FILE CONTENT: " + readFromFile1(this)); and everything runs just purfect. Now In another activity I'm using almost the same code, but it wont run. Here it is: @SuppressLint("NewApi") public class FavoriteJokes extends Activity { public static ArrayAdapter&lt;String&gt; adapter; public static ListView listView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_favorite_jokes); final GlobalsHolder globals = (GlobalsHolder)getApplication(); TextView text = (TextView) findViewById(R.id.txtJoke); text.setText(globals.getList().get(globals.clickedPosition)); ArrayList&lt;String&gt; jokeNamesList = new ArrayList&lt;String&gt;(); jokeNamesList.addAll(readFromFile1(this)); System.out.println("FILE CONTENT: " + readFromFile1(this)); globals.setFavJokeNamesList(readFromFile1(this)); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.favorite_jokes, menu); return true; } /* Read file's content */ private ArrayList&lt;String&gt; readFromFile1(Context context) { ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;(); try { ObjectInputStream ois = new ObjectInputStream( context.openFileInput("jokesNames2.bjk")); try { list = (ArrayList)ois.readObject(); } catch (ClassNotFoundException e) { e.printStackTrace(); } ois.close(); } catch (IOException e) { Log.e("log act…
tagged with: android-activity
favorite count: 0
accepted answer: http://stackoverflow.com/a/22151304
has title: Can't read the same file in another activity
upvote count: 1
answer count: 1
tagged with: java
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/22151304

http://stackoverflow.com/a/22018455
has comment: http://stackoverflow.com/comment/33377175
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/22018305
has comment: http://stackoverflow.com/comment/33376085
upvote count: 2
has comment: http://stackoverflow.com/comment/33411903
has body: This code works. I had to add a simple button to trigger the proc_Login call, I tested with netcat -l -p 8546 on my server (debian), I got 5 'asaadsasdasd' each time I pressed the button. (I used the port 8546 because it was already opened on my firewall). Of course I added &lt;uses-permission android:name="android.permission.INTERNET" /&gt; in the AndroidManifest.xml file. Maybe your server code closes the socket after receiving a line. Note also you don't need a Thread, an AsyncTask would be more appropriate, though for the example it works. MainActivity.java: package com.defranoux.testtcpsend; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class MainActivity extends Activity { private CClient mClient; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mClient = new CClient(); Thread myThready = new Thread(mClient); myThready.start(); Button button1 = (Button) findViewById(R.id.button1); button1.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { proc_Login(arg0); } }); } @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; } public void proc_Login(View v) { for (int i=0; i&lt;5; i++) mClient.Send("asaadsasdasd"); } } CClient.java: package com.defranoux.testtcpsend; import java.io.*; import java.net.Socket; import java.net.UnknownHostException; public class CClient implements Runnable { private Socket socket; private String ServerIP = "&lt;my server ip goes here&gt;"; private static final int ServerPort = 8546; @Override public void run() { try { socket = new Socket(ServerIP, ServerPort); } catch(Exception e) { System.out.print("Whoops! It didn't work!:"); System.out.print(…
has comment: http://stackoverflow.com/comment/33376466
has comment: http://stackoverflow.com/comment/33380138
has comment: http://stackoverflow.com/comment/33377408
type: Answer

http://stackoverflow.com/a/22067101
type: Answer
score: 0
has body: for @Autowired annotation, you just need to have a class with those annotations: @Configuration @PropertySource("classpath:myFile.properties") @ComponentScan("com.company.package") The @Configuration is used by Spring to tell it's a class for configuration (it replaces the xml files that you talked about, xml conf file is Spring 2, annotation is new with Spring 3 and 4) The @ComponentScan manage the IOC (@Autowire) The @PropertySource load the prop file Then the class to initialized at startup with the prop file: @Component("myFileProperties") public class MyFileProperties{ @Value("${app.name}") private String appName; public String getAppName() { return appName; } public void setAppName(String appName) { this.appName= appName; } } Take a look here if you want it can inspire you (a conf file in a web context that I developped): https://github.com/ebrigand/RSSLiker/blob/master/src/main/java/com/mrm/rss/init/WebAppConfig.java
answers question: http://stackoverflow.com/q/22066691

http://stackoverflow.com/q/22064530
possible better answer: http://stackoverflow.com/a/22064600
tagged with: inheritance
has comment: http://stackoverflow.com/comment/33457851
has body: I know I can do do the following : String className = "A"; Object o= Class.forName(className).newInstance(); But consider this case (simplification): class Parent { public void action() {...}; } class A extends Parent { @Override public void action() {...}; } class B extends Parent { @Override public void action() {...}; } class C extends Parent { @Override public void action() {...}; } Now I would like to create a class that can be either of those 3 cases. If I use the above code and create an Object, I wouldn't be able to call the action method. I would like to be able to create an object that extends Parent from a string. In my actuall case I have multiple different parents, and the class is extented from a class that's extended from a class and about 4 layers of inhertiance. Would regular casting work?
accepted answer: http://stackoverflow.com/a/22064617
type: AnsweredQuestion
has title: How to create custom class from variable? (not Object)
tagged with: oop
score: 0
tagged with: java
has answer: http://stackoverflow.com/a/22064600
has answer: http://stackoverflow.com/a/22064617
type: Question
has comment: http://stackoverflow.com/comment/33457867
answer count: 2

http://stackoverflow.com/a/22072016
downvote count: 0
type: Answer
score: 1
upvote count: 1
has body: 2400000000 is too large to store in an int. It would be more appropriate to use a long which has a minimum value of -2^63 and maximum value of 2^63 - 1 which your number is well within the range of. more info here
answers question: http://stackoverflow.com/q/22070903

http://stackoverflow.com/comment/33497294
comment on: http://stackoverflow.com/q/22085935
score: 0
type: Comment
type: QuestionComment
has text: I've added photos of the book with the pseudo code! =)

http://stackoverflow.com/q/22140619
tagged with: java.util.concurrent
type: Question
has answer: http://stackoverflow.com/a/22140762
possible better answer: http://stackoverflow.com/a/22140670
has answer: http://stackoverflow.com/a/22140670
has title: Restricting method execution from other class method
answer count: 2
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/22140762
type: AnsweredQuestion
score: 2
upvote count: 2
has body: Somebody asked me this question and I am not able to find out the solution, I have a class A with method a1 and a2: Class A {a1() a2()}: and a class B with method b1 and b2: Class B {b1() b2()} Considering multithreading environment i want to stop execution of b1 when a1 is called and same applies for b2 and a2. Both the objects are independent. Is this possible?
tagged with: java
tagged with: multithreading

http://stackoverflow.com/comment/33449515
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22059347
has text: I assume you didnt use semicolon(using tht could cause this) in your query string!
score: 0

http://stackoverflow.com/a/22091904
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33778361
has comment: http://stackoverflow.com/comment/33735544
has comment: http://stackoverflow.com/comment/33735770
accepted answer of: http://stackoverflow.com/q/22089653
has comment: http://stackoverflow.com/comment/33731312
has comment: http://stackoverflow.com/comment/33881256
has comment: http://stackoverflow.com/comment/33968319
answers question: http://stackoverflow.com/q/22089653
has comment: http://stackoverflow.com/comment/33855877
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33977233
has comment: http://stackoverflow.com/comment/33736606
type: Answer
has body: You can actually read these values from AD over LDAP from the Configuration tree. If you read the following object: CN=Partitions,CN=Configuration,DC=your,DC=domain,DC=com that will contain an attribute called uPNSuffixes. This attribute contains only the extra suffixes not the default one (you will have to get that from the domain name itself I guess). Rule is, if the uPNSuffixes attribute is not available, only the default UPN suffix is valid. EDIT: a simple example would be this: public List&lt;String&gt; getUpnSuffixes( LdapContext ctx, String domainName ) { // Domain name should be in DC=you,DC=domain,DC=com format String domConfig = "CN=Partitions,CN=Configuration," +domainName ; List&lt;String&gt; names = new ArrayList&lt;String&gt;(); // Dirty hack to get the default suffix names.add( domainName.replaceAll( "DC=", "" ).replaceAll( "," , "." ); // Read the configuration Attributes attrs = ctx.getAttributes( domConfig , new String[] { "uPNSuffixes" } ); Attribute attr = attrs.get( "uPNSuffixes" ); for ( int i=0; i&lt;attr.size(); i++ ) { names.add( attr.get(i) ); } // Now you have all the suffixes in the "names" list. return names; } Note that you will probably have to catch NamingException for the ctx.getAttributes() and attr.get() calls. EDIT 2: if you want the reverse, search for the uPNSuffixes attribute value: public String getDomainFromUpnSuffix( LdapContext ctx, String uPNSuffix ) { String filter = "(&amp;(CN=Partitions)(uPNSuffixes=" + uPNSuffix + "))" ; // Find the configuration for this suffix NamingEnumeration&lt;SearchResult&gt; results = ctx.search( "", filter, null ); while ( results.hasMore() ) { SearchResult result = results.next(); return result.getNameInNamespace(); } return null; }
has comment: http://stackoverflow.com/comment/33869362

http://stackoverflow.com/q/22080928
tagged with: jsp
favorite count: 0
linked to: http://stackoverflow.com/q/924451
linked to: http://stackoverflow.com/q/10418624
has body: This code used to work fine, but I just overhauled a lot of the underlying Java code and now it no longer works. I have a bean with values: &lt;c:forEach items="${actionBean.appliedJobs}" var="aJob" varStatus="loop"&gt; ${aJob} &lt;/c:forEach&gt; This prints out: 14513=APPLIED 14535=APPLIED 14515=APPLIED 14514=APPLIED. appliedJobs is populated in Java as a HashMap&lt;Long, String&gt;. I also have code that accesses this array using a variable jobId which is of type Integer. ${jobId} //This prints correctly as 14513 ${actionBean.appliedJobs[jobId]} //Prints nothing, is likely null ${actionBean.appliedJobs[14513]} //This prints correctly as APPLIED The third line in the above block prints fine because 14513 is interpreted as a Long, I think. I'm aware of the Long/Integer jstl issues as described here and here, but the fact that this code used to work is what's throwing me off. EDIT: For now, I've created a getter() for jobId that returns a Long jobId instead of Integer jobId and that has circumvented the issue, but I'd still like to know the root cause.
tagged with: stripes
has comment: http://stackoverflow.com/comment/46913322
has comment: http://stackoverflow.com/comment/46930534
tagged with: el
type: UnansweredQuestion
upvote count: 1
type: Question
score: 1
tagged with: java
has title: Accessing HashMap<Long,String> in JSP with Integer key no longer works
has answer: http://stackoverflow.com/a/22081094
tagged with: jstl
downvote count: 0
answer count: 1

blend
tags question: http://stackoverflow.com/q/22152844
type: Tag
tag name: blend

http://stackoverflow.com/q/22101116
has comment: http://stackoverflow.com/comment/33531125
upvote count: 2
has comment: http://stackoverflow.com/comment/33528122
linked to: http://stackoverflow.com/q/18680813
has comment: http://stackoverflow.com/comment/33524344
has answer: http://stackoverflow.com/a/22114116
has comment: http://stackoverflow.com/comment/33525659
type: AnsweredQuestion
has body: I am trying to execute a hibernate query. After I created the query, "query.getQueryString()" prints like below: select a from com.mycompany.model.dwh.Instruction a where a.custBillAcctId = :accountId Then when I am trying to set parameter: query.setParameter("accountId", new BigDecimal(accountId)); I get: org.hibernate.QueryParameterException: could not locate named parameter [accountId] I print "query.getNamedParameters()", it seems empty. Hibernate somewhat can't detect :accountId. I tried different things, setting by parameter index, etc. All failed. I did it millions of times in JEE-Hibernate, but I failed with Spring-Hibernate. Environment: Eclipse-Jetty hibernate: 4.1.9.Final springframework: 3.2.1.RELEASE @Entity @Table(name = "TALIMAT") public class Instruction implements Serializable { private static final long serialVersionUID = 1L; @Id @Column(name = "TALIMAT_ID") @GenericGenerator(name="kaugen" , strategy="increment") @GeneratedValue(generator="kaugen") private Long key; @Id @Column(name = "CUST_BILL_ACCT_ID") private BigDecimal custBillAcctId; .... @Column(name = "STATUS") private String status; @Temporal(TemporalType.DATE) @Column(name = "INSERT_DATE") private Date insertDate; Here is my code: try { Session session = sessionFactory.getCurrentSession(); Query query = session.createQuery("select a from " + Instruction.class.getName() + " a where a.custBillAcctId = :accountId "); System.out.println("getNamedParameters: "); for(String g:query.getNamedParameters()){ System.out.println(g + "\n"); } query.setParameter("accountId", new BigDecimal(accountId)); } catch (Exception e1) { e1.printStackTrace(); } Thanks
has comment: http://stackoverflow.com/comment/33524022
tagged with: java
tagged with: hibernate
type: Question
answer count: 1
downvote count: 0
accepted answer: http://stackoverflow.com/a/22114116
favorite count: 0
linked to: http://stackoverflow.com/q/12433499
has title: hibernate can't detect named parameter
score: 2

http://stackoverflow.com/a/22073541
has comment: http://stackoverflow.com/comment/33482346
has comment: http://stackoverflow.com/comment/33481921
has body: My problem is that i am trying to retrieve value of radiobutton in String format. In first place this line won't even compile: String i1type = i1bg.isSelected(); Because: ButtonGroup.isSelected(ButtonModel model) requires a ButtonModel as argument. This method returns a boolean which you're trying to assig to a String variable. You can achieve your goal by implementing an ActionListener as described in How to Use Buttons, Check Boxes, and Radio Buttons tutorial and attaching this action listener to your radio buttons. For instance: ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JRadioButton radioButton = (JRadioButton)e.getSource(); String selectedOption = radioButton.getText(); System.out.println(selectedOption ); } }; i1r1.addActionListener(actionListener); i1r2.addActionListener(actionListener); ... If the value you need and radio buttons text may differ then you can use putClientProperty() method (inherited from JComponent) as exemplified in this answer.
accepted answer of: http://stackoverflow.com/q/22072834
score: 2
has comment: http://stackoverflow.com/comment/33482034
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/22072834
has comment: http://stackoverflow.com/comment/33481660
upvote count: 2
has comment: http://stackoverflow.com/comment/33479874
type: Answer

http://stackoverflow.com/comment/33544101
score: 0
comment on: http://stackoverflow.com/q/22111857
type: QuestionComment
type: Comment
has text: What do you want to do with parsed data?

orbeon
tags question: http://stackoverflow.com/q/22075578
type: Tag
tag name: orbeon

http://stackoverflow.com/q/22069052
has comment: http://stackoverflow.com/comment/33492809
type: AnsweredQuestion
tagged with: java
tagged with: jboss
type: Question
has title: Login to Jboss 7.1.1 Final admin console with Java
has comment: http://stackoverflow.com/comment/33467983
score: 0
answer count: 1
tagged with: jboss7.x
has body: I need to login into Jboss admin console using a Java program. I have searched for a whole day but didn't find a single clue about how to do it. I tries using HttpClient 4.0 , but , it ended which error : "Unexpected end of File". Please upload any code fragment if you have . Or may be, there should be any configuration which should be there in Jboss server itself. Any help would be appreciated.. Thanks in advance
has answer: http://stackoverflow.com/a/22095415
accepted answer: http://stackoverflow.com/a/22095415

weblogic
tags question: http://stackoverflow.com/q/22167518
tags question: http://stackoverflow.com/q/22019003
tags question: http://stackoverflow.com/q/22070267
tags question: http://stackoverflow.com/q/22074082
tags question: http://stackoverflow.com/q/22076188
tag name: weblogic
type: Tag
tags question: http://stackoverflow.com/q/22026736

http://stackoverflow.com/q/22020716
has body: I am using library that has public void method init() with System.out.println() in it. And in my implementation I can only access method init() which is void, but unable to get output from sout to my gui component JTextarea. Is it possible to catch it (with InputStream or with some other way)? Any help is appreciated. thanks
score: 2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33380200
tagged with: java
accepted answer: http://stackoverflow.com/a/22266384
type: Question
possible better answer: http://stackoverflow.com/a/22021537
has comment: http://stackoverflow.com/comment/33380306
has answer: http://stackoverflow.com/a/22266384
answer count: 3
downvote count: 0
has answer: http://stackoverflow.com/a/22021458
favorite count: 0
has answer: http://stackoverflow.com/a/22021537
upvote count: 2
linked to: http://stackoverflow.com/q/868111
tagged with: swing
has comment: http://stackoverflow.com/comment/33382398
has title: How to populate Jtextarea from void method with system.out.println?

http://stackoverflow.com/q/22069548
upvote count: 3
has body: I want to pass a string array to the class which is being scheduled and called by the Scheduler object. The scheduler class is as follows : String stuff[]={"",""} JobDetail job = JobBuilder.newJob(HelloJob.class) .withIdentity("job", "group1").build(); job.getJobDataMap().put(HelloJob.data, stuff); Trigger trigger = TriggerBuilder .newTrigger() .withSchedule( CronScheduleBuilder.cronSchedule(time)) .build(); //schedule it Scheduler scheduler = new StdSchedulerFactory().getScheduler(); System.out.println("Before starting"); scheduler.start(); scheduler.scheduleJob(job, trigger); passing the array to : public class HelloJob implements Job { static String data[]; public void execute(JobExecutionContext context) throws JobExecutionException { System.out.println("Job"); } } the job interface : public interface Job { void execute(JobExecutionContext context) throws JobExecutionException; } Is there any solution to pass the array?
answer count: 1
favorite count: 0
has title: How to pass an array as a parameter in quartz scheduling in java
type: UnansweredQuestion
score: 3
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/23148027
type: Question
tagged with: arrays

http://stackoverflow.com/q/22030447
has answer: http://stackoverflow.com/a/22030575
has answer: http://stackoverflow.com/a/22030522
has comment: http://stackoverflow.com/comment/33398156
answer count: 2
has comment: http://stackoverflow.com/comment/33398133
downvote count: 0
has comment: http://stackoverflow.com/comment/33398143
favorite count: 0
accepted answer: http://stackoverflow.com/a/22030522
has comment: http://stackoverflow.com/comment/33398184
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33398203
score: 1
tagged with: java
has title: Best way to hash multiple keys in java
upvote count: 1
type: Question
tagged with: hashmap
possible better answer: http://stackoverflow.com/a/22030575
has comment: http://stackoverflow.com/comment/33398220
has body: I have a set of four numbers and they together make up a key. So, a unique combination of them should correspond lead to one value. What is the best way to prepare a hashmap for this purpose. The options are - 1) Make a unique key through concatenating them into a string 2) Make a unique key through adding them up (multiplying some of them with powers of 10 to avoid duplication). 3) Make a class that has the four numbers as fields and hash an instance of the class. And if it is the third, I can't figure out how to implement this approach (assuming it is possible). The code below should print 2, but prints nothing. AdjFactor a = new AdjFactor(2,3,4,5); AdjFactor b = new AdjFactor(3,3,4,5); HashMap&lt;AdjFactor,Double&gt; factrs = new HashMap&lt;&gt;(); factrs.put(a, 1d); factrs.put(b, 2d); AdjFactor c = new AdjFactor(1,3,4,5); AdjFactor d = new AdjFactor(3,3,4,5); if(factrs.containsKey(c)){ System.out.println(factrs.get(c)); } if(factrs.containsKey(d)){ System.out.println(factrs.get(d)); } Here is my AdjFactor class - public class AdjFactor { public int demo; public int month; public int year; public int site; AdjFactor(int demo1,int month1,int year1,int site1){ this.demo = demo1; this.month = month1; this.year = year1; this.site = site1; } public boolean equals(AdjFactor a, AdjFactor b){ if(a.demo==b.demo &amp;&amp; a.month==b.month &amp;&amp; a.year==b.year &amp;&amp; a.site==b.site)return true; else return false; } }

http://stackoverflow.com/comment/33584068
has text: @libik Matt Ball ("Thanks you so much")*n
type: Comment
score: 0
comment on: http://stackoverflow.com/a/22133720
type: AnswerComment

http://stackoverflow.com/comment/33498143
comment on: http://stackoverflow.com/q/22073371
type: Comment
type: QuestionComment
score: 0
has text: @jdb, this doesn't help for some unknown reason...

http://stackoverflow.com/q/22133210
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33583299
tagged with: java
score: -1
answer count: 2
upvote count: 0
tagged with: arrays
favorite count: 0
has answer: http://stackoverflow.com/a/22133318
tagged with: merge
has comment: http://stackoverflow.com/comment/33583224
has comment: http://stackoverflow.com/comment/33582957
type: UnansweredQuestion
has title: Output only gives last number in array instead of all?
has answer: http://stackoverflow.com/a/22133409
has comment: http://stackoverflow.com/comment/33583092
has body: I'm taking an AP java class. The assignment is to have two arrays set to store up to 10,000 integers. That's easy enough. But that's not where I need help. It has the user input what numbers to store in each array, entering one integer at a time. Entering a negative number, such as -4, is what tells the program to stop entering numbers into that array. So if you enter -1 into arrayone, instead of adding it it's going to move onto arraytwo. In arraytwo it'd move on to the next bit. What I'm having trouble with is the output. This is my code: import java.io.*; import static java.lang.System.*; import java.util.Scanner; import java.lang.Math; class Main{ public static void main (String str[]) throws IOException { Scanner scan = new Scanner(System.in); int arrayone [] = new int[10000]; int arraytwo [] = new int[10000]; { for (int i = 0; i &lt; arrayone.length; i++) { System.out.println("Enter integers "); while(arrayone[i] &gt;= 0) { arrayone[i] = scan.nextInt(); } { System.out.println("\nEnter the values for the second array, up to 10000 values, enter a negative number to quit"); while(arraytwo[i] &gt;= 0) { arraytwo[i] = scan.nextInt(); } } System.out.println("First Array:\n"); System.out.print(arrayone[i] + " "); break; } } } } While not done yet, the code, when run, needs to have an output like this: First Array: (any entered integers for arrayone in numerical order) Second Array: (any entered integers for arraytwo in numerical order) Merged Array: (combined integers from arrayone and arraytwo in numberical order) My trouble is this: So far I have it set to only output what's in arrayone, except it only outputs one number: the final one you enter....which is a negative number and I don't want stored. Any guidance I could have would be awesome. Thank you!

http://stackoverflow.com/q/22130558
tagged with: scala
type: UnansweredQuestion
upvote count: 7
has answer: http://stackoverflow.com/a/22131385
type: Question
linked to: http://stackoverflow.com/q/10131873
score: 7
tagged with: java
answer count: 2
tagged with: null
has title: Implicit wrap of Java Null
tagged with: implicit
downvote count: 0
favorite count: 0
has body: I need to access a large set of Java interfaces from Scala. These interfaces have methods that might return Null, and I want to convert them to Option[T] I found other answers that describe Option.apply() like these How to implicitly wrap a value that can be null or an array into an Scala Option Option-izing Java getters However, this requires that for each Java interface, I manually create a Scala wrapper. Like this... class ScalaFoo extends JavaFoo { def bar = Option(super.bar) } That seems messy, hard to maintain, and prone to error. I don't want all that extra code that does nothing, and I want to automatically wrap all my Java interfaces, so that if one changes, the wrapper also changes. Surely, there is a way to do this with implicits, isn't there?
has answer: http://stackoverflow.com/a/22130724
linked to: http://stackoverflow.com/q/10048403

http://stackoverflow.com/q/22086273
possible better answer: http://stackoverflow.com/a/22086315
type: AnsweredQuestion
tagged with: maven
tagged with: android-async-http
type: Question
tagged with: java
score: 0
answer count: 2
accepted answer: http://stackoverflow.com/a/22289632
has title: build jar from loopj android-async-http source
tagged with: jar
has comment: http://stackoverflow.com/comment/33538979
has answer: http://stackoverflow.com/a/22086315
has answer: http://stackoverflow.com/a/22289632
has body: I'm trying to build a jar from the https://github.com/loopj/android-async-http source code but have been unsuccessful. I also tried including the source as a library in my android project in android studio but was unable to. I want to build from source because the jar's available in maven and in the github repo are too old and I want to use and test some of the new features available in the source. How can I either build the jar and include the jar in my android studio project or simply properly include the source in my android studio project?
tagged with: android

http://stackoverflow.com/a/22173167
has body: Looping though the TableModel and using getValueAt() in a ListSelectionListener is a reasonable approach, although your listener will be invoked for each change. It's not clear where you're having trouble; you can Concatenate the selected values using StringBuilder. Accumulate the selected values in a List&lt;String&gt;. Maintain the selection in your TableModel, as shown here using Set&lt;Integer&gt;. Operate on the selection in the ItemHandler of a TableCellRenderer, as shown here.
answers question: http://stackoverflow.com/q/22168662
downvote count: 0
type: Answer
score: 2
upvote count: 2

http://stackoverflow.com/q/22075820
answer count: 1
has body: I need to make application for calculating some parameters for Network. So I need to make GUI where user can design own network. For example draw rooters (to do this user need to select icon for rooter and then place rooter on sketch), define some parameters for rooter, than draw line (that represent link between rooters) and define parameter for link. This is all. What you suggest me to use for this purpose?
has comment: http://stackoverflow.com/comment/33478423
has answer: http://stackoverflow.com/a/22076024
has title: GUI for cross platform
type: AnsweredQuestion
tagged with: user-interface
downvote count: 0
score: 1
favorite count: 0
type: Question
accepted answer: http://stackoverflow.com/a/22076024
has comment: http://stackoverflow.com/comment/33488795
tagged with: java
has comment: http://stackoverflow.com/comment/33478797
tagged with: cross-platform
upvote count: 1

http://stackoverflow.com/comment/33495690
score: 1
comment on: http://stackoverflow.com/q/22085046
type: Comment
type: QuestionComment
has text: I need to make alterations to the byte sequence every now and then so it wont be a good idea to do it like that as i would have to rebuild the sequence over and over instead of just adding/swapping the new value to the required index posission

http://stackoverflow.com/comment/33479580
comment on: http://stackoverflow.com/q/22076426
score: 0
has text: Take a look [here](http://stackoverflow.com/questions/21274346/how-can-you-extend-java-to-introduce-passing-by-reference).
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33626326
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22157525
has text: Didn't work for me, also I need to use the redirect so the url changes.

http://stackoverflow.com/a/22038765
type: Answer
upvote count: 3
answers question: http://stackoverflow.com/q/22037736
score: 3
has body: Consider using PropertiesUtil, an utility class created exactly for this case: int port = PropertiesUtil.toInteger(properties.get(PROXY_PORT), 8080); The second parameter is the default value.
downvote count: 0

http://stackoverflow.com/a/22136093
type: Answer
downvote count: 0
score: 1
has body: You've got a few issues here: sb.getBytes() does not do what you think it does. What you are expecting is a byte array containing { 0xff, 0xfe, 0x7a, 0x50 }. What you are getting is a byte array containing { 0x46, 0x46, 0x46, 0x45, 0x37, 0x61, 0x35, 0x30 } (assuming you're using UTF-8). Your choices here would be to either initialise the byte array manually, like so: byte[] b = new byte[]{ (byte) 0xff, (byte) 0xfe, (byte) 0x7a, (byte) 0x50 }; Or to parse the string correctly. I'm not sure exactly how you'd go about that, but it should be doable (and there will likely be an open-source library to do it for you). The output javax.crypto.spec.SecretKeySpec@183a2 is not writing out the value of the key. All you're seeing is the toString output of the SecretKeySpec, which follows the format &lt;fully-qualified-class-name&gt;@&lt;hashcode&gt; (see here for details on the toString() method), so the numbers you're seeing, 183a2, are just the hashcode of the SecretKeySpec object, which must not be the key - that would very insecure. To see the value of the key it's holding, you'd need to call the SecretKeySpec#getEncoded() method. Note that just calling System.out.println(byteArray) will not display the content of the byte array - it will just display the class name and hashcode again. You'll need to either iterate through the array and print out the elements one-by-one, or use another tool to compare the two arrays.
accepted answer of: http://stackoverflow.com/q/22135353
upvote count: 1
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22135353

http://stackoverflow.com/a/22154242
has comment: http://stackoverflow.com/comment/33621871
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33625186
has body: What i use to do is to find it in "Navigator tab" in NetBeans. I dont know other way. If you click on it in navigator, component becomes selected in design view.
accepted answer of: http://stackoverflow.com/q/22153609
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22153609
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/33622666

http://stackoverflow.com/q/22018910
type: Question
has comment: http://stackoverflow.com/comment/33376646
possible better answer: http://stackoverflow.com/a/22019026
has body: I have a couple of classes, one of which needs to count how many times object has been created (int fields called lastId). In c++ we had to initialize static fields value in main class and then we were able to correctly use that static field in other classes and count how many objects have been created. What about java? Where do I have to initialize static fields value. Also, I know how to count if object has been created, but what about if object has been deleted? There are no destructors in java, so how can this job be done?
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/22020363
accepted answer: http://stackoverflow.com/a/22019038
tagged with: static
tagged with: field
has answer: http://stackoverflow.com/a/22019038
has answer: http://stackoverflow.com/a/22019026
type: AnsweredQuestion
has title: Where to initialize static fields in java?
tagged with: java

http://stackoverflow.com/a/22022814
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33384110
has comment: http://stackoverflow.com/comment/33384565
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/33384715
accepted answer of: http://stackoverflow.com/q/22022751
upvote count: 1
answers question: http://stackoverflow.com/q/22022751
has body: The first one declares a variable of type TailList. The second one declares a variable of type TailList, and initializes it with a new instance of TailList. Regarding the second question: s is an instance of SList. SList doesn't extend TailList, so it is not a TailList. Casting it to TailList won't magically make it a TailList.
has comment: http://stackoverflow.com/comment/33384131

http://stackoverflow.com/a/22086715
score: 2
accepted answer of: http://stackoverflow.com/q/22086660
answers question: http://stackoverflow.com/q/22086660
has comment: http://stackoverflow.com/comment/33498515
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: I'm guessing a little, but I think your code was supposed to be this. public void processTransactions(Scanner transFile){ while (transFile.hasNext()){ String key = transFile.next(); int value = transFile.nextInt(); for(i = 0; i &lt; ids.length; i++){ finalInventory[i] = startingInventory[i]; if(ids[i].equals(key)){ finalInventory[i] += value; } } } } You only want to do the next() and the nextInt() once per iteration of the while loop. Currently, you are repeating the next() in every iteration of the for loop, which really isn't what you want. Note that this isn't the most efficient solution to your problem, but it will take away your error. Also, you haven't specified the type of ids, but I've assumed that it's a String[].
has comment: http://stackoverflow.com/comment/33498554
upvote count: 2
has comment: http://stackoverflow.com/comment/33498827

http://stackoverflow.com/comment/33509733
has text: possible duplicate of [PreparedStatement with list of parameters in a IN clause](http://stackoverflow.com/questions/3107044/preparedstatement-with-list-of-parameters-in-a-in-clause)
comment on: http://stackoverflow.com/q/22092704
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/q/22036492
has answer: http://stackoverflow.com/a/22036603
type: Question
has answer: http://stackoverflow.com/a/22037024
tagged with: min
tagged with: max
score: 0
tagged with: http://stackoverflow.com/tag/csv
has comment: http://stackoverflow.com/comment/33413558
has title: How to find min and max value for each column in the entire csv file
possible better answer: http://stackoverflow.com/a/22036603
has body: How to find min and max value for each column (except albhabet values)in a csv file. I want to get each columns min and max values 5.3,3.6,1.6,0.3,Iris-setosa 4.9,3.3,1.6,0.3,Iris-setosa 4.9,3.3,1.3,0.3,Iris-setosa 4.6,3.3,1.6,0.0,Iris-setosa col 1, min = 4.6 ,max = 5.3 col 2, min = 3.3 ,max = 3.6 col 3, min = 1.3 ,max = 1.6 col 4, min = 0.0 ,max = 0.3 What I did is ,I iterated through each line and stored each column in a hashmap {1=[5.3,4.9,4.9,4.6],2=[3.6,3.3,3.3,3.3],3[1.6,1.6,1.3,1.6],4[0.3,0.3,0.3,0.0]} Then I calculated for (Map.Entry&lt;String, List&lt;String&gt;&gt; entry : map.entrySet()) { // Iterating through values String key = entry.getKey(); List&lt;String&gt; values = entry.getValue(); min = Double.parseDouble(Collections.min(values)); max = Double.parseDouble(Collections.max(values)); } But when large data is coming it is not better to hold that much data in hashmap Then find the min and max How can I find min/max in other way. Update String line[] = value.split(delimit); for(int i=0;i&lt;line.length -1;i++){ if (Double.parseDouble(line[i] ) &lt; min) { min = Double.parseDouble(line[i] ); } if (Double.parseDouble(line[i] ) &gt; max) { max = Double.parseDouble(line[i] ); } } Not getting the expected result. Solution :Calculating min and max of columns in a csv file
has answer: http://stackoverflow.com/a/22037071
accepted answer: http://stackoverflow.com/a/22037071
has answer: http://stackoverflow.com/a/22038449
has comment: http://stackoverflow.com/comment/33411747
answer count: 4
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/a/22056779
score: 0
answers question: http://stackoverflow.com/q/22055271
has comment: http://stackoverflow.com/comment/33484581
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22055271
has comment: http://stackoverflow.com/comment/33491851
has comment: http://stackoverflow.com/comment/33445320
type: Answer
has body: Why not use indexOf? For example: String text = new Scanner( new File("test.txt") ).useDelimiter("\\A").next(); String key = "jumps"; if (Arrays.asList(text.split("[\\s]")).indexOf(key) != -1) System.out.println("Match"); else System.out.println("No match"); The nice thing about this solution is that it also gives you which word in the sequence it is; however, it might not be fast for very large Strings. If you really want to use a Regular Expression, you need to use \s, because new lines can be represented by \n, \r, or \r\n and \s can be any of these. So, you would need something like this: EDIT: Use the following regex instead: "(?s:.*\\b"+key+"\\b.*)". if (text.matches("(.|\\s)*\\b"+key+"\\b(.|\\s)*")) System.out.println("Regex: Match"); else System.out.println("Regex: No match"); If you are going to be finding words in very large files, you may want to check out StringSearch. Just download the jar, add it to your classpath, and make sure you import com.eaio.stringsearch.*; BNDMWildcards bndm = new BNDMWildcards(); int bndmIdx = 0; int stopIdx = text.length(); boolean isFound = false; while(!isFound &amp;&amp; (bndmIdx = bndm.searchString(text, bndmIdx, stopIdx, "."+key+".")) != -1){ char[] textChars = text.toCharArray(); if(Character.isWhitespace(textChars[bndmIdx]) &amp;&amp; Character.isWhitespace(textChars[bndmIdx+key.length()+1])){ System.out.println("BNDM: Match"); isFound = true; } } if(!isFound) System.out.println("BNDM: No match"); I am not sure speed-wise how this method compares to the other two. My guess is it will take longer for short text, but be faster when the text is very long. EDIT: The previous regex contains the possibility to cause a StackOverflowException (perfect for this site!)- a problem I should have seen. That is because it is creating an enormous number of sub-expressions as it attempts to search text. An alternative regex you can try is "(?s:.*\\b"+key+"\\b.*)". This enabled DOTALL, forcing the . to match all characters. It should o…
has comment: http://stackoverflow.com/comment/33447440

http://stackoverflow.com/a/22052527
score: 0
answers question: http://stackoverflow.com/q/22052336
type: Answer
has body: I wouldn't recommend inheritance, creating a single class common code is really good for reusability however, take on count that each class extending from your base class will be allocating duplicated memory for things with the same purpose, google do not recommend it unless really necessary and the advantages you are getting out of it are really clear, you should take a look at the Singleton design patterns, this seems like a good example of when to implement it, basically you will have 1 single instance that does the job among different components without having to allocate new objects every time, just reusing the one already created. Hope it helps! Regards!

http://stackoverflow.com/comment/33404638
comment on: http://stackoverflow.com/q/22034269
type: Comment
type: QuestionComment
has text: Why do you pass the bytes through base64 encode/decode before encrypting/decrypting?
score: 3

http://stackoverflow.com/a/22163640
type: Answer
accepted answer of: http://stackoverflow.com/q/22163197
answers question: http://stackoverflow.com/q/22163197
upvote count: 2
score: 2
type: AcceptedAnswer
downvote count: 0
has body: First, you may want to take a look at How to Use the Focus Subsystem, paying attention to Validating Input which might help. Second, as pointed out by @eatSleepCode, you're not actually parsing the text of the field, but are simply formatting an existing Date, so it will never throw an exception... simple_format = new SimpleDateFormat(Date_format_text.getText()); // This is simply formatting the dates... String ss = simple_format.format(dates); Instead, you need to use something more like... String test = "02/01/20"; String format = "dd/MM/yyyy"; SimpleDateFormat sdf = new SimpleDateFormat(format); sdf.setLenient(false); try { Date date = sdf.parse(test); if (!sdf.format(date).equals(test)) { throw new ParseException(test + " is not a valid format for " + format, 0); } } catch (ParseException ex) { ex.printStackTrace(); } What this does, is test's the parser capabilities of the formatter, but also checks the input against what the resulting parsed Date would be formatted to, if these don't match it throws a ParseException. This is the closes I've been able to get to a strict parser... Also, YYYY used to represent the week in year, not the year...

http://stackoverflow.com/comment/33644749
has text: i am using a default.keystore file does it got expired after one year,because suddenly its stopped working.
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22168117

http://stackoverflow.com/q/22052137
downvote count: 0
tagged with: java
has body: When creating java.util.logging.Logger the name parameter is typically the name of the class where it is used. When it is created in an anonymous class how is it typically named? Is there a convention for it?
type: Question
has comment: http://stackoverflow.com/comment/33436471
has comment: http://stackoverflow.com/comment/33436425
upvote count: 3
has comment: http://stackoverflow.com/comment/33436462
favorite count: 0
has title: Is there a Logger naming convention for anonymous classes?
answer count: 0
type: UnansweredQuestion
score: 3

http://stackoverflow.com/comment/33405149
type: Comment
comment on: http://stackoverflow.com/a/22008972
has text: @AJ. I provided the answer keeping programmers in mind who are finding difficult to use custom look and feel package in their project( my friend who is actually is). But whatever you said is absolutely right for deployment. optionally, we can export the necessary jars with our app right?
type: AnswerComment
score: 0

http://stackoverflow.com/a/22038505
score: 17
has comment: http://stackoverflow.com/comment/134940132
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/135040739
has comment: http://stackoverflow.com/comment/138099562
type: Answer
has body: The two integer markers (I) shouldn't have a following semicolon. Try: (Ljava/lang/String;Ljava/lang/String;II)V Edit: The best way to work is probably to use "javap -s" to have java print the signatures for you. Also make sure you read and understand this page
accepted answer of: http://stackoverflow.com/q/22038466
has comment: http://stackoverflow.com/comment/33411770
answers question: http://stackoverflow.com/q/22038466
has comment: http://stackoverflow.com/comment/33444539
has comment: http://stackoverflow.com/comment/33411881
upvote count: 17
has comment: http://stackoverflow.com/comment/68079589

http://stackoverflow.com/comment/127064420
type: Comment
has text: Remember that Stack Overflow isn't just intended to solve the immediate problem, but also to help future readers find solutions to similar problems, which requires understanding the underlying code. This is especially important for members of our community who are beginners, and not familiar with the syntax. Given that, **can you [edit] your answer to include an explanation of what you're doing** and why you believe it is the best approach?
type: AnswerComment
score: 2
comment on: http://stackoverflow.com/a/71905804

http://stackoverflow.com/comment/33546516
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22113310
score: 0
has text: You write several objects at once in the ObjectOutputStream, and you read objects from the ObjectInputStream until you get an exception signalling the end of the stream. Or easier, you write a single List<Person> to the stream, and read a single List<Person> from the stream.

http://stackoverflow.com/comment/33693313
score: 0
type: Comment
has text: Strangly enough, That did the trick! Thanks a million! Just curious on one thing: 'words' doesn't have any whites, so why does the element need to 'remove whites'?
comment on: http://stackoverflow.com/a/22147301
type: AnswerComment

http://stackoverflow.com/comment/33807521
type: Comment
score: 0
has text: It's quite difficult to help you with so less information. A new question would help a lot
comment on: http://stackoverflow.com/a/22172166
type: AnswerComment

http://stackoverflow.com/comment/33866439
score: 0
type: QuestionComment
has text: It is more like a network issue instead of CXF issue.
type: Comment
comment on: http://stackoverflow.com/q/22147457

http://stackoverflow.com/q/22129843
tagged with: java
tagged with: sharedpreferences
has comment: http://stackoverflow.com/comment/33578333
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33576935
has comment: http://stackoverflow.com/comment/33576878
type: Question
has answer: http://stackoverflow.com/a/22130268
answer count: 2
has title: how to add shared preferences to tic tac toe Android game?
has comment: http://stackoverflow.com/comment/33578698
score: 0
tagged with: android
type: UnansweredQuestion
has body: I have a tic tac toe game app created in a table layout with 9 buttons in three rows for the game, a textview which displays who's turn it is and a new game button at the bottom. I want to add shared preferences to the code so the game doesn't keep restarting if i swtich orientations. I know i need an onPause and onResume method but I am not sure what goes in the methods. Can someone please help with the methods to implement shared preferences? Below is most of the code for the game: private SharedPreferences prefs; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tic_tac_toe); //get references to the widgets square1 = (Button) findViewById(R.id.square1); square2 = (Button) findViewById(R.id.square2); square3 = (Button) findViewById(R.id.square3); square4 = (Button) findViewById(R.id.square4); square5 = (Button) findViewById(R.id.square5); square6 = (Button) findViewById(R.id.square6); square7 = (Button) findViewById(R.id.square7); square8 = (Button) findViewById(R.id.square8); square9 = (Button) findViewById(R.id.square9); messageTextView = (TextView) findViewById(R.id.messageTextView); square1.setOnClickListener(this); square2.setOnClickListener(this); square3.setOnClickListener(this); square4.setOnClickListener(this); square5.setOnClickListener(this); square6.setOnClickListener(this); square7.setOnClickListener(this); square8.setOnClickListener(this); square9.setOnClickListener(this); prefs = PreferenceManager.getDefaultSharedPreferences(this); }; @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; } protected void onPause(){ } public void onResume() { super.onResume(); } @Override public void onClick(View v) { boolean flag; String lbl = messageTextView.getText().toString(); Button btn = (Button) v; if (btn.getText().toString().equals("")){ if (l…
has answer: http://stackoverflow.com/a/22130180
tagged with: tic-tac-toe

http://stackoverflow.com/q/22070340
answer count: 2
has answer: http://stackoverflow.com/a/22178538
tagged with: tomcat
downvote count: 0
possible better answer: http://stackoverflow.com/a/22070578
favorite count: 0
has answer: http://stackoverflow.com/a/22070578
accepted answer: http://stackoverflow.com/a/22178538
tagged with: web-services
has title: How does tomcat 6 choose the order to deploy WAR files
type: AnsweredQuestion
score: 1
tagged with: java
linked to: http://stackoverflow.com/q/20008355
upvote count: 1
type: Question
has body: I have a suite of web applications deployed as a number of WAR files. I have this code deployed to a number of VMs and is working well. My devops team created a new VM that is basically a copy of the others, and one of the web apps is throwing an exception at start time. The error is shown below. When comparing the environments, I noticed that VM with error is deploying the apps in a different order than the other servers. I think there may something there. How do I force tomcat deploy the webapps in a specified order, which happens to be alphabetic order on the other VMs? Just for further edification, we are using Jenkins to build and deploy the code, so I am 100% certain this same code and libraries are working well in pretty much a duplicate Linux/Tomcat environment. Feb 27, 2014 8:33:03 AM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 395 ms Feb 27, 2014 8:33:03 AM org.apache.catalina.core.StandardService start INFO: Starting service Catalina Feb 27, 2014 8:33:03 AM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/6.0.37 Feb 27, 2014 8:33:03 AM org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive appmgmt20.war Feb 27, 2014 8:33:05 AM org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive ROOT.war Feb 27, 2014 8:33:06 AM org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive appmgmt10.war Feb 27, 2014 8:33:07 AM org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive lbprobe.war Feb 27, 2014 8:33:07 AM org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive travel.war 2014-02-27 08:33:08 ERROR ContextLoader:227 - Context initialization failed org.springframework.beans.factory.BeanDefinitionStoreException: Parser configuration exception parsing XML from ServletContext resource [/WEB-INF/classes/edu/cornell/finsys/webservices.x…

http://stackoverflow.com/comment/33410563
comment on: http://stackoverflow.com/a/22037409
score: 0
type: Comment
has text: -1 Because of the suggestion of abstract class that the default method should replace.
type: AnswerComment

http://stackoverflow.com/comment/33598194
type: AnswerComment
score: 0
type: Comment
has text: I am using a component written by me, it is a spring-jpa style liked component, but it only support placeholder now. @Query(value="update User set count = count + ?2 where id = ?1", writing=true) public void addCount(Long id, int count);
comment on: http://stackoverflow.com/a/22142325

http://stackoverflow.com/q/22078592
score: 2
type: AnsweredQuestion
tagged with: cookies
has comment: http://stackoverflow.com/comment/33484938
tagged with: java
tagged with: http
type: Question
tagged with: jsoup
has comment: http://stackoverflow.com/comment/33484708
has comment: http://stackoverflow.com/comment/33484292
accepted answer: http://stackoverflow.com/a/22116429
has title: How to use Jsoup to login my university website?
answer count: 1
downvote count: 0
favorite count: 0
upvote count: 2
has body: I am trying to come up with a Android app that needs some information on the university inner website. I have been trying to use Jsoup to login the website programmatically. Here is the code I have now: import org.jsoup.Connection; import org.jsoup.Connection.Method; import org.jsoup.Jsoup; //import org.jsoup.helper.Validate; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; //import org.jsoup.select.Elements; import java.io.IOException; import java.util.Map; public class Test { public static void main(String[] args) { Document doc; try { Connection.Response res = Jsoup .connect( "https://sso.bris.ac.uk/sso/login?service=https%3A%2F%2Fwww.cs.bris.ac.uk%2FTeaching%2Fsecure%2Funit-list.jsp%3Flist%3Dmine") .execute(); Map&lt;String, String&gt; cookies = res.cookies(); System.out.println(cookies.keySet()); Document fakepage = res.parse(); Element fakelt = fakepage.select("input[name=lt]").get(0); Element fakeexecution = fakepage.select("input[name=execution]") .get(0); Element fake_eventID = fakepage.select("input[name=_eventId]").get( 0); System.out.println("Hello World!"); System.out.println(fakelt.attr("value")); System.out.println(fakeexecution.toString()); System.out.println(fake_eventID.toString()); // System.out.println(cookies.get("JSESSIONID")); String url="https://sso.bris.ac.uk/sso/login?service=https%3A%2F%2Fwww.cs.bris.ac.uk%2FTeaching%2Fsecure%2Funit-list.jsp%3Flist%3Dmine"; System.out.println(url); Connection newreq = Jsoup .connect(url) .cookies(cookies).data("lt", fakelt.attr("value")).followRedirects(true).header("Connection", "keep-alive") .header("Refer", " https://sso.bris.ac.uk/sso/login?service=https%3A%2F%2Fwww.cs.bris.ac.uk%2FTeaching%2Fsecure%2Funit-list.jsp%3Flist%3Dmine") .header("Content-Type","application/x-www-form-urlencoded;charset=UTF-8") .userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:27.0) Gecko/20100101 Firefox/27.0") .data("lt",fakelt.attr("value")) .data("execution", fakeexecution.attr("value")) .data("_e…
has answer: http://stackoverflow.com/a/22116429

http://stackoverflow.com/q/22054594
type: Question
has answer: http://stackoverflow.com/a/22082866
tagged with: java
score: -1
has comment: http://stackoverflow.com/comment/33443850
answer count: 2
downvote count: 1
tagged with: jsp
favorite count: 0
has body: I have scoured the internet for multiple hours trying desperately to figure out how to place a JFreeChart in a JSP page. Nothing works. I am not sure why, I am not very good at JSP, so maybe its because I am missing something. I am using netbeans with glassfish. How to display line graph using JFreeChart in jsp? I feel that the above link has promise. I tried it, but to no avail. all I get is a little image box with an x in it. http://jspmaster.blogspot.com/p/bar-charts.html I also tried the above link. Its a different strategy. I get the same stupid little image box with an x in it. At this point I just want to show an empty graph. I'll deal with specifics later, but I can't even do that. Would there be any reason why this doesn't work? Am I missing something so simple? Perhaps someone could recommend another technology I could use for displaying bar charts on a web page. I was thinking ASP.net would be a lot easier. Thanks, Jake
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22065967
has title: JFreeChart in JSP doesn't work
upvote count: 0
linked to: http://stackoverflow.com/q/665222
tagged with: jfreechart

http://stackoverflow.com/comment/33582062
has text: @AdamArold: I was so convinced with their approch because it make sense after all: the noob implementation of factory need to be changed each time so it not flexible and tightly coupled with concrete classes
comment on: http://stackoverflow.com/q/22131430
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22099370
has body: You could simplify your code: while column.contains(valueToDelete) { column.remove(valueToDelete); } You're not going to be able to speed up your ArrayList iteration, especially if your list is not sorted. You're stuck at O(n) for this problem. If you sorted it and inserted logic to binary search for the item to remove until it is no longer found, you could speed up access. This next suggestion isn't directly related to the time it takes, but it will cause you problems. You should never compare String objects for equality using the == operator. This will cause a comparison of their pointer values. Use this instead: if (iterator.next().equals(valueToDelete))
has comment: http://stackoverflow.com/comment/33522009
downvote count: 0
has comment: http://stackoverflow.com/comment/33522324
type: Answer
answers question: http://stackoverflow.com/q/22099153
score: 1
upvote count: 1

http://stackoverflow.com/comment/33473924
type: Comment
has text: Have a look at the Apache Commons lang library, specifically StringUtils.replace(String text, String searchString, String replacement) - http://commons.apache.org/proper/commons-lang/javadocs/api-3.2.1/index.html
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22073250

http://stackoverflow.com/comment/33608577
has text: Second will be more efficient then 1 but it also depend on the requirement.If only single method require bufferedWriter object then you can use first option inside the method.In second option you have to make sure about NPE
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22148487

http://stackoverflow.com/comment/33590499
type: QuestionComment
has text: ispContext is probably null, that is usually the cause for this error.
comment on: http://stackoverflow.com/q/22137947
score: 0
type: Comment

http://stackoverflow.com/a/22133910
type: Answer
has body: Java arrays don't have an "add" method. They are not objects. You want to say deck[i*13+j] = new Card(numberList[j], suitList[i]); Assuming you have defined the card class somewhere with that constructor.
answers question: http://stackoverflow.com/q/22133845
accepted answer of: http://stackoverflow.com/q/22133845
score: 0
type: AcceptedAnswer

http://stackoverflow.com/a/22099507
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/22098959
has body: Here are a couple of the more well known existing WEB Framework modules within node: HAPI by Walmart Express If Walmart is happy with NodeJS to use it during Black Friday, I would think most folks might be able to live with results.
upvote count: 1

http://stackoverflow.com/q/22041921
favorite count: 0
has body: I declared a simple class with this method amongst others : public void setDate(final Date date); when i get the parameters : List&lt;Class&lt;?&gt;&gt; params = new ArrayList&lt;Class&lt;?&gt;&gt;(); params.addAll(Arrays.asList(method.getParameterTypes())); I verify that it is final : System.out.println("isFinal : " + Modifier.isFinal(params.get(0).getModifiers())); But i get a false : isFinal : false But clearly i declared it to be final. What is the problem ?
possible better answer: http://stackoverflow.com/a/22042012
has answer: http://stackoverflow.com/a/22042012
has answer: http://stackoverflow.com/a/22042077
accepted answer: http://stackoverflow.com/a/22042077
downvote count: 0
has title: java Reflect Modifiers parameters
type: Question
tagged with: parameters
type: AnsweredQuestion
tagged with: reflection
score: 1
tagged with: java
answer count: 2
upvote count: 1

http://stackoverflow.com/comment/33595184
has text: If there is IPv6 or multiple interfaces that would not be adequate, but +1 because maybe that's all the OP needed.
type: Comment
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/22140727

http://stackoverflow.com/q/22044097
tagged with: https
type: Question
has answer: http://stackoverflow.com/a/22046412
tagged with: ssl
tagged with: grails
score: 0
tagged with: groovy
answer count: 1
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33425888
has title: How can i create https connection with self-signed certificate on grails?
tagged with: java
has body: i am using grails 2.2.2. I must get info from backend via https. I have 2 files(certificates) - *.p12 and *.cer Thank you for your responce!

http://stackoverflow.com/a/22118166
type: Answer
upvote count: 1
has body: Here is the best answer for netbeans; then I'll use the pom.xml from there: Daryl Nickerson Joined: 23 May 2013 Posts: 1 PostPosted: Thu May 23, 2013 4:50 pm Post subject: Had the same problem, Brian's suggestion worked Reply with quote Had the same problem, Brian's suggestion worked. (NetbBeans IDE 7.3) To clarify, right-click the Libraries folder in the project viewer, select properties, in Project Properties window, select Libraries, click Add Jar/Folder button, select ALL jar files in your source folder (ctrl-a), not just the folder, and click Open to add them. This may be overkill, but it worked and I was able to compile and run. Thanks, Brian. Good on Daryl on netbeans news group!
accepted answer of: http://stackoverflow.com/q/22104782
answers question: http://stackoverflow.com/q/22104782
type: AcceptedAnswer
downvote count: 0
score: 1

http://stackoverflow.com/q/22007400
type: AnsweredQuestion
downvote count: 0
tagged with: java
has body: I have a set of classes from third party library which I don't have access to the source. I need to add some common behavior on these objects by using a design pattern. How do I apply Decorator or Visitor pattern to these objects? These objects have no common base class. These are either plain objects or having uncommon interfaces. I cannot add a common interface to these classes because these classes are not part of my project. How do I add common behavior to these classes without checking ‘instance of’ in a single method.
has comment: http://stackoverflow.com/comment/33399106
type: Question
has comment: http://stackoverflow.com/comment/33356415
accepted answer: http://stackoverflow.com/a/22007489
upvote count: 2
answer count: 1
has answer: http://stackoverflow.com/a/22007489
favorite count: 0
has title: Design Pattern : Applying behavior on objects of different family
tagged with: design-patterns
score: 2

http://stackoverflow.com/q/22125720
favorite count: 0
has comment: http://stackoverflow.com/comment/33569268
upvote count: 2
has comment: http://stackoverflow.com/comment/33568986
has body: I want to make my JTable unEditable but i want to add JButton to to it and the column of the button must be editable for the press event so how can i make this only column editable? here is my table model code: DefaultTableModel model = new DefaultTableModel(); model.setColumnIdentifiers(new String[]{ "IDemp", "empNumber", "Fname","Lname", "BirthDate", "Address", "email", "Button" } ); //TableCellRenderer buttonRenderer = new JTableButtonRenderer(); for(int i=0;i&lt;emps1.size();i++) { model.addRow(new Object[]{String.format("%d",emps1.get(i).getIDemp()), String.format("%d",emps1.get(i).getEmpNumber()),emps1.get(i).getFname(), emps1.get(i).getLname(),emps1.get(i).getBirthDate(), emps1.get(i).getAddress(), emps1.get(i).getEmail().getEmailAddress()}); } and here is my jtable: JTable emps=new JTable(model); emps.getColumn("Button").setCellRenderer(new ButtonRenderer()); emps.getColumn("Button").setCellEditor(new ButtonEditor(new JCheckBox())); How could I make the "Button" column editable and the others not? *And if you have better way to add JButton to the JTable it will be great."
tagged with: swing
tagged with: jbutton
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22125792
has comment: http://stackoverflow.com/comment/33569129
score: 1
tagged with: java
downvote count: 1
has comment: http://stackoverflow.com/comment/33569095
accepted answer: http://stackoverflow.com/a/22125792
type: Question
has title: how to Make only one column editable in JTable
has comment: http://stackoverflow.com/comment/33569121
has comment: http://stackoverflow.com/comment/33569147
tagged with: jtable
has comment: http://stackoverflow.com/comment/33569215
answer count: 1
has comment: http://stackoverflow.com/comment/33569158

http://stackoverflow.com/a/22057548
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33446588
has body: XML comments are treated as nodes like any other XML node (elements, etc.) and the whitespace that formats the XML nicely is treated as Text nodes. So your question is really how to maintain those comment and text nodes as you use something like JixB to construct your Java objects from the XML. I don't don't know whether JixB maintains the nested comment and text nodes so that when you persist the data as XML the comments and formatting remains the same. If you're going directly against the Dom, though, you can know that those extra nodes exist in the DOM and take care to maintain them as you update the XML as well as insert new comment and text nodes to add that formatting style around newly added data.
has comment: http://stackoverflow.com/comment/33449721
answers question: http://stackoverflow.com/q/22057305
upvote count: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22057305

http://stackoverflow.com/q/22060894
has body: I hear about 'sugaring' and 'desugaring' more often in Java 8, what do these terms mean? Are they conceptual or syntactical? Some examples: Default iterated loop resugaring to java Observations about syntactic sugar in compilation.
score: 131
favorite count: 0
has answer: http://stackoverflow.com/a/63677232
upvote count: 133
has answer: http://stackoverflow.com/a/23862145
possible better answer: http://stackoverflow.com/a/22194425
has answer: http://stackoverflow.com/a/22194425
tagged with: semantics
tagged with: java-8
answer count: 4
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/11404218
has answer: http://stackoverflow.com/a/22060916
tagged with: java
downvote count: 2
type: Question
has title: What are "sugar", "desugar" terms in context of Java 8?
accepted answer: http://stackoverflow.com/a/22060916

http://stackoverflow.com/comment/33516028
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22096587
has text: You need to make one row with max possible no of imageviews(3 in your case) and one checkbox now inside getview() those imgviews you dont want for that row make theme Gone

http://stackoverflow.com/q/22140213
has title: super class field is not assigned to any value when spy() the real object
has comment: http://stackoverflow.com/comment/33594583
type: AnsweredQuestion
has body: Following are my classes class Parent{ private AddressService addressService = ServiceLocator.getService(AddressService.class); protected void doSomeJob(){ addressService.doThat(); } } class Child extends Parent{ protected void doSomeJob(){ super.doSomeJob(); } } @RunWith(PowerMockRunner.class) @PrepareForTest({ServiceLocator.class}) class ChildTest{ @Test public void doSomeJob(){ PowerMockito.mockStatic(ServiceLocator.class); AddressService addressService = Mockito.mock(AddressService.class); PowerMockito.when(ServiceLocator.getService(AddressService.class)).thenReturn(addressService); Child original = new Child(); Child spiedObj = PowerMockito.spy(original); spiedObj.doSomeJob(); } } Here ServiceLocator.getService() is a static method which look-up and returns the bean from application context. So, I mocked that static class and ask to return AddressService.class instance when it ask for ServiceLocator.getService(AddressService.class). For my unit test when I spy()/mock() Child class that addressSerive instance have not assigned any value. But when I create a instance using new operator, I can see mock AddressService is assigned to the field. What am I missing here and how can I assigne value to that parent field when I do spy() on it's child instance? Thanks
downvote count: 0
has answer: http://stackoverflow.com/a/22249693
score: 1
accepted answer: http://stackoverflow.com/a/22249693
tagged with: java
has comment: http://stackoverflow.com/comment/33594645
tagged with: unit-testing
type: Question
tagged with: mockito
has comment: http://stackoverflow.com/comment/33598046
has comment: http://stackoverflow.com/comment/33602511
upvote count: 1
answer count: 1
tagged with: junit
favorite count: 0
tagged with: powermock

http://stackoverflow.com/q/22066481
downvote count: 0
has answer: http://stackoverflow.com/a/23157844
has answer: http://stackoverflow.com/a/55881599
favorite count: 0
has answer: http://stackoverflow.com/a/46448459
type: Question
has answer: http://stackoverflow.com/a/39476256
has answer: http://stackoverflow.com/a/49872777
tagged with: rx-java
has answer: http://stackoverflow.com/a/38185496
score: 99
has body: I am using rxjava in my Android app to handle network requests asynchronously. Now I would like to retry a failed network request only after a certain time has passed. Is there any way to use retry() on an Observable but to retry only after a certain delay? Is there a way to let the Observable know that is is currently being retried (as opposed to tried for the first time)? I had a look at debounce()/throttleWithTimeout() but they seem to be doing something different. Edit: I think I found one way to do it, but I'd be interested in either confirmation that this is the correct way to do it or for other, better ways. What I am doing is this: In the call() method of my Observable.OnSubscribe, before I call the Subscribers onError() method, I simply let the Thread sleep for the desired amount of time. So, to retry every 1000 milliseconds, I do something like this: @Override public void call(Subscriber&lt;? super List&lt;ProductNode&gt;&gt; subscriber) { try { Log.d(TAG, "trying to load all products with pid: " + pid); subscriber.onNext(productClient.getProductNodesForParentId(pid)); subscriber.onCompleted(); } catch (Exception e) { try { Thread.sleep(1000); } catch (InterruptedException e1) { e.printStackTrace(); } subscriber.onError(e); } } Since this method is running on an IO thread anyway it does not block the UI. The only problem I can see is that even the first error is reported with delay so the delay is there even if there's no retry(). I'd like it better if the delay wasn't applied after an error but instead before a retry (but not before the first try, obviously).
has answer: http://stackoverflow.com/a/27094967
has answer: http://stackoverflow.com/a/57730148
has answer: http://stackoverflow.com/a/25292833
has answer: http://stackoverflow.com/a/52723012
has answer: http://stackoverflow.com/a/68783675
tagged with: java
upvote count: 99
has answer: http://stackoverflow.com/a/70095217
possible better answer: http://stackoverflow.com/a/42786446
has answer: http://stackoverflow.com/a/67171923
has title: rxjava: Can I use retry() but with delay?
has answer: http://stackoverflow.com/a/42786446
linked to: http://stackoverflow.com/q/61352701
has answer: http://stackoverflow.com/a/38429101
has answer: http://stackoverflow.com/a/38431584
has answer: http://stackoverflow.com/a/79536260
has answer: http://stackoverflow.com/a/50220807
accepted answer: http://stackoverflow.com/a/25292833
answer count: 18
type: AnsweredQuestion

http://stackoverflow.com/a/22082070
has comment: http://stackoverflow.com/comment/33490862
type: Answer
has body: The problem with doing %10 then / 10 is that it looks at the LEAST significant digit first. for example, for input = 167, you have these steps: digit = 167 % 10 = 7 input = 167 / 10 = 16 digit = 16 % 10 = 6 input = 16 /10 = 1 digit = 1 % 10 = 1 input = 1 / 10 = 0 So you see, you end up with 7 first, 6, second, and 1 third. The easiest way to fix this is to use a stack. if (number == 0) { return "Zero"; } // special case if (number &lt; 0) { // Handle negatives. num.append("Negative"); number = -number; } List&lt;Integer&gt; stack = new ArrayList&lt;Integer&gt;(); while (number != 0) { stack.add(number % 10); number /= 10; } while (!stack.isEmpty()) { int digit = stack.remove(stack.size() - 1); // Pop off the stack. if (num.length() != 0) { // Add space if necessary. num.append(' '); } num.append(txt[digit]); } return num.toString();
has comment: http://stackoverflow.com/comment/33490968
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/22081772
has comment: http://stackoverflow.com/comment/33491255
downvote count: 0

http://stackoverflow.com/comment/33577517
has text: I don't really understand how you are trying to do the substitution. In any case, if the `println` doesn't take effect, the only logical conclusion I have is that nothing is getting synced.
comment on: http://stackoverflow.com/q/22122213
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/q/22131029
has answer: http://stackoverflow.com/a/22131421
downvote count: 2
has answer: http://stackoverflow.com/a/22131077
tagged with: java
has answer: http://stackoverflow.com/a/22131057
upvote count: 4
has answer: http://stackoverflow.com/a/22131049
answer count: 4
type: AnsweredQuestion
score: 2
has title: Reading strings from a file to an arraylist with java
favorite count: 0
tagged with: arraylist
type: Question
has comment: http://stackoverflow.com/comment/33578837
possible better answer: http://stackoverflow.com/a/22131421
accepted answer: http://stackoverflow.com/a/22131049
has body: I am trying to read Strings from a file which are separated with a semicolon and put them in an arrayList. Here is my code: public ArrayList&lt;String&gt; readFile() throws IOException{ lines=new ArrayList&lt;String&gt;(); BufferedReader reader = new BufferedReader(new FileReader("D:\\input.txt")); String line = null; while ((line = reader.readLine()) != null) { inputs = line.split(";"); } reader.close(); for (String in : inputs) { lines.add(in); } System.out.println(lines.size()); return lines; } When I run it, the size of the ArrayList returned is a very small number. The expected number is bigger. Any suggestions?

http://stackoverflow.com/a/22147037
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/22146598
has comment: http://stackoverflow.com/comment/33609346
type: Answer
has comment: http://stackoverflow.com/comment/33616542
score: 1
has comment: http://stackoverflow.com/comment/33607448
has body: The tomcat cannot find the referenced files ... That is because the pathnames are incorrect unless the JVM's current directory is the parent directory of the "WebContent" directory. When you use FileInputStream to open a file, relative pathname are resolved relative to the current directory of the JVM when it was launched. ... and someone said use getResourceAsStream, but that is for servlets. No. That's not correct either. That method is not "for servlets". The purpose of that method is to open a resource that is on the class / classloader's classpath. If your "WebContent/StopWords/stop-words-english1.txt" is in the webapp's "/WEB-INFO/classes" or in a JAR file in "/WEB-INFO/lib", then getResourceAsStream will find it. In your case, it seems like you are talking about the "WebContent" directory that corresponds to the default servlet. In that case, read this Q&amp;A - How can I get real path for file in my WebContent folder?. So if you are trying to access those files from within a JSP, it seems as if you should be writing this: new FileReader("WebContent/StopWords/stop-words-english1.txt") as this: new FileReader(getServletContext().getRealPath( "/StopWords/stop-words-english1.txt"))
upvote count: 1
accepted answer of: http://stackoverflow.com/q/22146598

http://stackoverflow.com/comment/33702057
comment on: http://stackoverflow.com/a/22152940
has text: @GloryOfSuccess thanks, I just wrote the code out of my mind. Fixed the compilation errors.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33446139
type: QuestionComment
comment on: http://stackoverflow.com/q/22057490
score: 0
has text: Try using `getClass().getResource("images/flower.png")` or `getClass().getResource("/images/flower.png")` and call `super.paintComponent` before doing any custom painting and use `this` as the image observer parameter to `drawImage`
type: Comment

http://stackoverflow.com/a/22161789
has body: IMO, in your newly written class, you tried to call the getWebDriver() method statically: DriverManager.getWebDriver() instead of creating an instance of DriverManager firstly: new DriverManager().getWebDriver() This would cause a compilation error since initially, DriverManager#getWebDriver() is an instance method, not a class method (thereby static). Therefore, Eclipse probably helped you (with your involontary approbation surely) by making the method static in order to compile successfully. For more information about static concept: click here.
has comment: http://stackoverflow.com/comment/33633177
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33633171
answers question: http://stackoverflow.com/q/22161754
type: Answer
accepted answer of: http://stackoverflow.com/q/22161754
downvote count: 0
score: 1

http://stackoverflow.com/comment/33510805
type: AnswerComment
score: 0
type: Comment
has text: you can call java executable from exec() in parent process written in C
comment on: http://stackoverflow.com/a/22093157

http://stackoverflow.com/a/22106225
score: 3
type: AcceptedAnswer
downvote count: 0
has body: I haven't the answer for the Application overriding but I propose a solution for your broader goal: |-- src | +-- debug | +-- java | +-- mypackage | +-- Modules.java | +-- MockModule.java | +-- main | +-- java | +-- mypackage | +-- MainModule.java | +-- release | +-- java | +-- mypackage | +-- Modules.java src/debug/java/mypackage/Modules.java public final class Modules { public static List&lt;Object&gt; getModules(App application) { ArrayList&lt;Object&gt; modules = new ArrayList&lt;Object&gt;(); modules.add(new MainModule(application)); modules.add(new MockModule()); return modules; } } src/debug/java/mypackage/MockModule.java @Module( overrides = true, library = true, injects = { MainActivity.class }) public class MockModule { @Provides MyType buildMock() { return //... } } src/release/java/mypackage/Modules.java public final class Modules { public static List&lt;Object&gt; getModules(App application) { ArrayList&lt;Object&gt; modules = new ArrayList&lt;Object&gt;(); modules.add(new MainModule(application)); return modules; } } src/main/java/mypackage/App.java public class App extends Application { private ObjectGraph graph; @Override public void onCreate() { super.onCreate(); graph = ObjectGraph.create(Modules.getModules(this).toArray()); } public void inject(Object object) { graph.inject(object); } } Let me know if it works for you. This technique was presented by Jake Wharton in his Android Apps with Dagger presentation
upvote count: 3
answers question: http://stackoverflow.com/q/22104862
type: Answer
has comment: http://stackoverflow.com/comment/33535065
accepted answer of: http://stackoverflow.com/q/22104862

http://stackoverflow.com/a/22094095
has comment: http://stackoverflow.com/comment/33515489
upvote count: 1
type: Answer
has body: At a time only one return works. When return item executes it actually returns the control to the statement line from where this method was called. In this case return null will not get execute. And when For loop executed whole and nothing happened at that time return null statement will get execute. So at a time only one return statement will get execute, no matter if there is more than one return statements in a method.
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/22093994

http://stackoverflow.com/q/22132135
possible better answer: http://stackoverflow.com/a/22132259
has answer: http://stackoverflow.com/a/22132259
linked to: http://stackoverflow.com/q/921471
type: AnsweredQuestion
has title: Using tokenizer to count number of words in a file?
tagged with: java
has comment: http://stackoverflow.com/comment/33580854
tagged with: stringtokenizer
type: Question
has answer: http://stackoverflow.com/a/22132281
answer count: 2
has body: I am making a program that makes an user choose a file then the program reads from the file. Now I've been told to make the program using bufferedreader and string tokenizer. So far I got program opening the file and counting the number of lines. But the number of words is not so easy. This is my code so far: int getWords() throws IOException { int count = 0; BufferedReader BF = new BufferedReader(new FileReader(f)); try { StringTokenizer words = new StringTokenizer(BF.readLine()); while(words.hasMoreTokens()) { count++; words.nextToken(); } BF.close(); } catch(FileNotFoundException e) { } return count; } Buffered reader can only read a line at a time but I don't know how to make it read more lines.
tagged with: bufferedreader
score: 0
accepted answer: http://stackoverflow.com/a/22132281
has comment: http://stackoverflow.com/comment/33580931
has comment: http://stackoverflow.com/comment/33580918

http://stackoverflow.com/q/22154831
downvote count: 0
favorite count: 0
tagged with: eclipse-kepler
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22192102
upvote count: 3
type: Question
has comment: http://stackoverflow.com/comment/33620624
has title: Difference Between Eclipse Juno and Eclipse Kepler
score: 3
tagged with: java
tagged with: eclipse
accepted answer: http://stackoverflow.com/a/22192102
has comment: http://stackoverflow.com/comment/33620819
has body: What is the difference between eclipse juno and eclipse kepler, I have done a web project in juno. can I import it in to kepler ?
answer count: 1

http://stackoverflow.com/comment/33590185
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22137452
score: 1
has text: I don't know what the OP really wants. But a formula that multiplies the value by 100 in some cases, and not in others, is almost certainly wrong, because then the value won't be in a consistent unit.

http://stackoverflow.com/comment/33436100
score: 0
type: QuestionComment
has text: logcat window coming ;) wait a second plz ;) thx everyone
type: Comment
comment on: http://stackoverflow.com/q/22051816

http://stackoverflow.com/a/63634228
upvote count: 5
has comment: http://stackoverflow.com/comment/132491072
downvote count: 0
answers question: http://stackoverflow.com/q/22021970
type: Answer
has body: Syntax: implementation 'groupId:artifactId:version' If this is what you have to import in your Android Studio Project... // Maven : Add these dependecies to your pom.xml (java6+) // // org.glassfish.jersey.core // jersey-client // 2.8 // // // org.glassfish.jersey.media // jersey-media-json-jackson // 2.8 // then it translates to this... implementation 'org.glassfish.jersey.core:jersey-client:2.8' implementation 'org.glassfish.jersey.media:jersey-media-json-jackson:2.8'
score: 5

http://stackoverflow.com/q/22127067
upvote count: 1
has answer: http://stackoverflow.com/a/22131018
score: 1
tagged with: java
type: Question
answer count: 2
downvote count: 0
has title: Formal notation for code translations by compiler
has body: I'm designing a DSL which translates to Java source code. Are their notations which are commonly used to specify the semantics/translation of a compiler? Example: DSL: a = b = c = 4 Translates into: Integer temp0 = 4; Integer a = temp0; Integer b = temp0; Integer c = temp0; Thanks in advance, Jeroen
has answer: http://stackoverflow.com/a/22131279
has comment: http://stackoverflow.com/comment/33571458
tagged with: formal-languages
tagged with: compiler-construction
favorite count: 0
tagged with: dsl
type: UnansweredQuestion

http://stackoverflow.com/a/22042727
answers question: http://stackoverflow.com/q/22042570
score: 0
upvote count: 1
type: Answer
has body: int noneZeroCount= 0; for (int i = 0; i &lt; frame.length; i++) { if (frame[i]!=0) { noneZeroCount++; } } final int[] sorted = new int[noneZeroCount]; // You got size of non zero elements in array now run copy loop
downvote count: 1

http://stackoverflow.com/a/22069443
answers question: http://stackoverflow.com/q/22062124
score: 2
type: AcceptedAnswer
downvote count: 0
type: Answer
upvote count: 2
has body: The Google Protocol Buffers(GPB) Message implementation also offers a writeTo method. ByteArrayOutputStream is very close to what you are looking for, however, whenever you access the internal byte array, it creates a new copy, which doesn't sound like what you are looking for. However, if you create your own OutputStream implementation, similar to ByteArrayOutputStream, you could control the lifecycle of the internal byte array, or DirectByteBuffer. This should allow you to increase performance and reduce short-lived objects. writeTo void writeTo(OutputStream output) Serializes the message and writes it to output. This is just a trivial wrapper around writeTo(CodedOutputStream). This does not flush or close the stream. NOTE: Protocol Buffers are not self-delimiting. Therefore, if you write any more data to the stream after the message, you must somehow ensure that the parser on the receiving end does not interpret this as being part of the protocol message. This can be done e.g. by writing the size of the message before the data, then making sure to limit the input to that size on the receiving end (e.g. by wrapping the InputStream in one which limits the input). Alternatively, just use writeDelimitedTo(OutputStream). Throws: IOException throws IOException
accepted answer of: http://stackoverflow.com/q/22062124

pretty-urls
type: Tag
tags question: http://stackoverflow.com/q/22067742
tag name: pretty-urls

http://stackoverflow.com/q/22130316
answer count: 1
tagged with: jtextarea
type: UnansweredQuestion
tagged with: user-interface
has body: I have done a GUI in Java with a JTextArea. It is filled with the content of a file. When I select words with the mouse on the textarea, a new frame pops up on which I do some operations on the selected words. To do these operations, I need to know the line number of the selected text... Does someone know how to get the line number? (I look to some methods on the classes JTextArea and MouseListener, but i dont know how to do that...) Thanks ;)
type: Question
has comment: http://stackoverflow.com/comment/33577302
has title: How to know the line number when you select on line on a JTextArea? [JAVA]
has comment: http://stackoverflow.com/comment/33577666
has answer: http://stackoverflow.com/a/22133239
score: 0
tagged with: mouselistener
tagged with: java
tagged with: swing
linked to: http://stackoverflow.com/q/5518451

http://stackoverflow.com/a/22166065
answers question: http://stackoverflow.com/q/22166019
type: Answer
score: 1
upvote count: 1
downvote count: 0
has body: I think you need to change your prepareStatement from this: ... R_BillDate_d=? and R_PatBillNo_v=?"); to something like this: ... R_BillDate_d=?, R_PatBillNo_v=?");

http://stackoverflow.com/q/22100795
has answer: http://stackoverflow.com/a/22101007
has comment: http://stackoverflow.com/comment/33523510
tagged with: libraries
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22101206
possible better answer: http://stackoverflow.com/a/22100855
tagged with: java
tagged with: eclipse
tagged with: http://stackoverflow.com/tag/mp3
has title: FileNotFoundException: Playing an mp3 file with Java/Eclipse
type: Question
has body: I am trying to play an mp3 using an external mp3 library and everything is fine until it comes to finding the file. I have imported the file into eclipse as seen in the below image. And here is my error: enProblem playing file mpthreetest.mp3 java.io.FileNotFoundException: mpthreetest.mp3 (The system cannot find the file specified) java.lang.NullPointerException Any help would be appreciated.
score: 0
tagged with: nullpointerexception
has answer: http://stackoverflow.com/a/22100855
answer count: 3
linked to: http://stackoverflow.com/q/15350392
accepted answer: http://stackoverflow.com/a/22101206

http://stackoverflow.com/a/22074155
has comment: http://stackoverflow.com/comment/42157463
has comment: http://stackoverflow.com/comment/33475277
type: Answer
score: 1
has body: There's a couple of ways to do this, but you probably want a ListView, with a CursorAdapter. The CursorAdaptertakes a Cursor as an input, and shows how an individual row looks. The CursorAdapterwould look something like this: private class SpecialCursorAdapter extends CursorAdapter { public SpecialCursorAdapter(Context context, Cursor c, int flags) { super(context, c, flags); //Any other major setup needs to happen here. } @Override public void bindView(View v, Context context, Cursor cursor) { //Take the view as given in newView, and populate it with the dat afrom cursor. } @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { LinearLayout row = (LinearLayout) mInflater.inflate( R.layout.data_row, parent, false); //Inflate the row return row; } } The Cursor is populated with a standard query, there's plenty of resources how to do that. You get the ListView pointer from the inflated XML code, and do this: ListView listvew=...; Cursor cursoer=...; SpecialCursorAdapter adapter=new SpecialCursorAdapter(this,cursor,0); listview.setAdpater(adapater); I regularly use this for very large data sets like this, and it works quite well.
answers question: http://stackoverflow.com/q/22074071
upvote count: 1
downvote count: 0

http://stackoverflow.com/comment/75835177
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22096166
score: 1
has text: Possible duplicate of [Java How to store the audio data in a byte array.](https://stackoverflow.com/questions/13169044/java-how-to-store-the-audio-data-in-a-byte-array)

http://stackoverflow.com/q/22090521
has body: for example i have following code String[] subject = new String[6]; subject[1] = JOptionPane.showInputDialog(null, "Enter subject"); String[] subject[1]=new String[6]; it will not work.There is any other way to do this?
tagged with: arrays
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22090774
has answer: http://stackoverflow.com/a/22090657
type: Question
has title: How can an element of a string array be used as a variable of another string array in java?
score: 0
tagged with: java
has answer: http://stackoverflow.com/a/22090550
answer count: 3

http://stackoverflow.com/q/22156845
tagged with: android
has comment: http://stackoverflow.com/comment/33624624
linked to: http://stackoverflow.com/q/8612652
tagged with: onclicklistener
has body: Can I set an onClickListener for every word in the TextView on Android? There are multiple lines in a textView can I add a listener to every word? What are the techniques that I could use? Is it possible or do I need to start from scratch?
tagged with: java
score: 0
has title: TextView Word OnClickListner
linked to: http://stackoverflow.com/q/11601139
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33624593
tagged with: user-interface
answer count: 0
tagged with: textview
type: Question

memory
tags question: http://stackoverflow.com/q/22114834
tags question: http://stackoverflow.com/q/22026435
tag name: memory
tags question: http://stackoverflow.com/q/22110151
tags question: http://stackoverflow.com/q/22152704
tags question: http://stackoverflow.com/q/22015365
tags question: http://stackoverflow.com/q/22145260
tags question: http://stackoverflow.com/q/22089524
tags question: http://stackoverflow.com/q/22027712
tags question: http://stackoverflow.com/q/22081505
tags question: http://stackoverflow.com/q/22122166
tags question: http://stackoverflow.com/q/22148487
tags question: http://stackoverflow.com/q/22031810
type: Tag
tags question: http://stackoverflow.com/q/22138549

http://stackoverflow.com/comment/33433006
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22047067
has text: That works. Thank you @lc . Btw I couldn't figured out what was the issue in code? May be point#2. Am I right? Please enlighten the issue in the code. I have included the quote around query in sys.err.out().

http://stackoverflow.com/a/22157662
type: Answer
has comment: http://stackoverflow.com/comment/33627133
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/22157521
upvote count: 1
has comment: http://stackoverflow.com/comment/33626271
has comment: http://stackoverflow.com/comment/33627172
has comment: http://stackoverflow.com/comment/33626078
has body: One way to do this is to compile a Java class for each different expression, with a single static method that implements the function. See this question. So, for example, if all your functions just use one variable x, then you could generate a .java file looking like this... class Expression { static double apply(double x) { return /* expression here */; } } Then compile and load that class as in the cited question, get the apply() method with reflection, and call it whenever you want to compute that expression. (Alternately, have your compiled classes implement an interface, create instances of them, and avoid the reflection) Admittedly, this is not particularly friendly to your memory usage if you end up with thousands of such classes...

http://stackoverflow.com/q/22128696
type: UnansweredQuestion
tagged with: android
has answer: http://stackoverflow.com/a/22129734
score: 2
tagged with: java
has answer: http://stackoverflow.com/a/22129814
tagged with: eclipse
type: Question
has comment: http://stackoverflow.com/comment/33574667
answer count: 2
downvote count: 0
has title: android developer alert dialog + listview function
has body: I wrote some code which implements the listView inside alertDialog. now when i want to implement some function on the listview I didnt succeed doing it. here is the code to he alertDialog: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Select Name"); ListView modeList = new ListView(this); String[] stringArray = new String[] {"red" , "green" , "blue"}; ArrayAdapter&lt;String&gt; modeAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, android.R.id.text1, stringArray); modeList.setAdapter(modeAdapter); builder.setView(modeList); final Dialog dialog = builder.create(); dialog.show(); how can i implement a function on a clicked item?
tagged with: android-listview
linked to: http://stackoverflow.com/q/2397106
favorite count: 0
upvote count: 2

http://stackoverflow.com/comment/33602814
score: 0
type: AnswerComment
has text: Thanks but the file associations look fine in preferences and when I double click a .java file in the Project Explorer it brings up the Java editor correctly. This problem only occurs in the Search window. I can only assume that there must be corruption of a settings file for the search module.
comment on: http://stackoverflow.com/a/22143936
type: Comment

http://stackoverflow.com/comment/33373127
score: 0
type: Comment
has text: Or make getter methods for them...
comment on: http://stackoverflow.com/a/22016889
type: AnswerComment

http://stackoverflow.com/comment/34072336
has text: Thank you very much for answering, but I already know that. My problem is that I want it to be resizable when you hover over the window border (I don't know how to describe it, I hope you know what I mean) so that the user can change the size like he wants.
type: AnswerComment
comment on: http://stackoverflow.com/a/22334355
type: Comment
score: 0

http://stackoverflow.com/comment/33550440
has text: `Mainly the for loop is what is confusing me` that doesn't help us because beside creating temporary variable and returning it loop is only part left. Have you tried iterating over this code on paper? Just take pen and write which line of code will do with variables.
score: 0
comment on: http://stackoverflow.com/q/22115576
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33402502
type: QuestionComment
has text: can't possible untill you loads all username in javascript
score: 2
comment on: http://stackoverflow.com/q/22033076
type: Comment

http://stackoverflow.com/a/22116216
answers question: http://stackoverflow.com/q/22116175
downvote count: 0
type: Answer
upvote count: 1
score: 1
has body: What the compile time error says is right "This exception is never thrown from the try statement body". You don't have anything which throws MyException

timer
tag name: timer
tags question: http://stackoverflow.com/q/22046832
tags question: http://stackoverflow.com/q/22086542
tags question: http://stackoverflow.com/q/22036331
tags question: http://stackoverflow.com/q/22008763
tags question: http://stackoverflow.com/q/22059165
type: Tag
tags question: http://stackoverflow.com/q/22034032
tags question: http://stackoverflow.com/q/22120261
tags question: http://stackoverflow.com/q/22141861
tags question: http://stackoverflow.com/q/22025534
tags question: http://stackoverflow.com/q/22135806
tags question: http://stackoverflow.com/q/22074746
tags question: http://stackoverflow.com/q/22072796

http://stackoverflow.com/a/22104319
has body: Does it mean Thread.sleep() puts the current Thread to sleep? Yes. Only the current thread can do that. What if t1 wants to put t to sleep. that shouldn't be possible correct? Right. You can set a volatile boolean flag that will cause another thread to call Thread.sleep(...) but another thread can't cause a thread to sleep. volatile boolean shouldSleep = false; ... // check this flag that might be set by another thread to see if I should sleep if (shouldSleep) { Thread.sleep(...); }
has comment: http://stackoverflow.com/comment/33530322
score: 9
has comment: http://stackoverflow.com/comment/33530217
upvote count: 9
has comment: http://stackoverflow.com/comment/33530798
has comment: http://stackoverflow.com/comment/33530259
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33530836
has comment: http://stackoverflow.com/comment/33530670
has comment: http://stackoverflow.com/comment/33666972
type: Answer
answers question: http://stackoverflow.com/q/22104283
has comment: http://stackoverflow.com/comment/33530611
accepted answer of: http://stackoverflow.com/q/22104283

http://stackoverflow.com/comment/34246351
type: Comment
has text: Make sure you're using it as the response handler for the get response and not the find response.
comment on: http://stackoverflow.com/a/22178150
score: 0
type: AnswerComment

http://stackoverflow.com/a/22135720
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22135648
type: Answer
upvote count: 6
downvote count: 0
has body: Hypothesis: somewhere in your matching groups, there is a valid group reference in the form "$n" where n cannot match any group in the original Pattern. Hence the error: "illegal group reference". Solution: use "$2" instead of concatenating .group(2) etc. Ie instead of writing: "\\\\pochhammer{"+ pochhammer.group(2) + "}{" + pochhammer.group(3) + "}" write: "\\\\pochhammer{$2}{$3}" Side note: no need to escape parens in a character class; [^)] works just as well as [^\)], and it is easier to read ;)
score: 6
accepted answer of: http://stackoverflow.com/q/22135648

http://stackoverflow.com/comment/33477438
has text: u can only remove if(object instanceof Person) , other than that like type cast all that u have to do
type: AnswerComment
comment on: http://stackoverflow.com/a/22075182
type: Comment
score: 0

http://stackoverflow.com/comment/33516801
comment on: http://stackoverflow.com/q/22097296
type: Comment
type: QuestionComment
score: 3
has text: I am afraid this is a primarily opinion based question, and probably too broad to answer. BigDecimal is robust enough to handle almost anything your likely to throw at it, but we have no idea what your application does or needs to do.

google-cloud-endpoints
tags question: http://stackoverflow.com/q/22153910
tags question: http://stackoverflow.com/q/22031302
type: Tag
tags question: http://stackoverflow.com/q/22146362
tags question: http://stackoverflow.com/q/22155920
tag name: google-cloud-endpoints
tags question: http://stackoverflow.com/q/22069195
tags question: http://stackoverflow.com/q/22130227
tags question: http://stackoverflow.com/q/22161519

http://stackoverflow.com/q/22052709
has comment: http://stackoverflow.com/comment/33438767
score: 0
has title: 100 Random Circles
has comment: http://stackoverflow.com/comment/33437918
has comment: http://stackoverflow.com/comment/33440370
has comment: http://stackoverflow.com/comment/33437633
type: UnansweredQuestion
has body: After I compiled the previous code it worked but now I cant get the circumference of the circles to change to a different color of whats inside the circle. Any suggestions. public void paintComponent(Graphics g) { super.paintComponent(g); Dimension d = getSize(); for(int i = 0; i &lt; 100; ++i) { Color color = new Color(generator.nextInt(255), generator.nextInt(255), generator.nextInt(255)); g.setColor(color); int circleSize = generator.nextInt(d.width / 4); int x = generator.nextInt(d.width - circleSize); int y = generator.nextInt(d.height - circleSize); g.fillOval(x, y, circleSize, circleSize); color = new Color(generator.nextInt(255), generator.nextInt(255), generator.nextInt(255)); g.setColor(color); g.drawArc(x, y, circleSize, circleSize, 0, 360); } } }
has comment: http://stackoverflow.com/comment/33437696
has comment: http://stackoverflow.com/comment/33438020
tagged with: swing
has answer: http://stackoverflow.com/a/22053049
tagged with: java
has comment: http://stackoverflow.com/comment/33438125
tagged with: jpanel
type: Question
has comment: http://stackoverflow.com/comment/33438231
answer count: 1

http://stackoverflow.com/q/22005734
possible better answer: http://stackoverflow.com/a/22005870
has title: Transfer data from one Mysql table to another with an extra column having a string
has answer: http://stackoverflow.com/a/22006764
has body: I have a Mysql table called register and i want to transfer all the details from register to login table with an extra column which has a password auto generated. this is my Servlet where i have autogenerated password: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String passWord=Long.toHexString(Double.doubleToLongBits(Math.random())); System.out.println(passWord); String Id=request.getParameter("id"); int id=Integer.parseInt(Id); AffiliateApproveService approve=new AffiliateApproveService(); approve.affiliateApprove(id,passWord); } Here i have generated an alphanumeric password for column PassWord as a String "passWord" how to assign passWord to PassWord column.... This is my service class: public class AffiliateApproveService { public void affiliateApprove(int id,String passWord) { AffiliateApproveDAO cad=new AffiliateApproveDAO(); DataSource dataSource=new DataSource(); cad.setDataSource(dataSource); cad.insertClient(id); cad.updateClient(id, passWord); cad.deleteClient(id); } And this is my DAO: public class AffiliateApproveDAO { private DataSource dataSource; public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; } Connection conn=null; PreparedStatement statement=null; ResultSet rs=null; public void insertClient(int id) { try{ conn=dataSource.createConnection(); PreparedStatement ps=conn.prepareStatement("insert into login(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); ps.executeUpdate("insert into login ( id, FirstName, LastName, Gender, Category, DateOfBirth, Age, Address, Country, State, city, PinCode, UserName, EmailId, ContactNo, MobileNo)select id, FirstName, LastName, Gender, Category, DateOfBirth, Age, Address, Country, State, city, PinCode, UserName, EmailId, ContactNo, MobileNo from register where id="+id+" "); ps.setInt(1, id); } catch (SQLException e) { throw new RuntimeException(e); } finally { if (rs != null) try { rs.close(); } catch (SQLException ignore) {…
answer count: 4
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33354571
tagged with: java
accepted answer: http://stackoverflow.com/a/22034678
tagged with: mysql
type: Question
tagged with: jakarta-ee
has comment: http://stackoverflow.com/comment/33355381
has answer: http://stackoverflow.com/a/22006983
score: 0
has comment: http://stackoverflow.com/comment/33353722
tagged with: sql
has answer: http://stackoverflow.com/a/22005870
tagged with: jsp
has answer: http://stackoverflow.com/a/22034678

http://stackoverflow.com/q/22009475
has title: How to reuse framebuffer texture in libgdx
score: 1
type: UnansweredQuestion
upvote count: 1
has comment: http://stackoverflow.com/comment/33364395
has comment: http://stackoverflow.com/comment/64912122
has comment: http://stackoverflow.com/comment/33364540
has comment: http://stackoverflow.com/comment/33364277
has comment: http://stackoverflow.com/comment/33365338
has comment: http://stackoverflow.com/comment/33364460
tagged with: libgdx
has comment: http://stackoverflow.com/comment/33360232
tagged with: java
has answer: http://stackoverflow.com/a/23418767
tagged with: render-to-texture
type: Question
tagged with: framebuffer
has comment: http://stackoverflow.com/comment/33369343
downvote count: 0
answer count: 1
has comment: http://stackoverflow.com/comment/64913664
favorite count: 0
has body: is there a possibility to save the framebuffer to texture. So that i can reuse the framebuffer to create a new texture? com.badlogic.gdx.graphics.glutils.FrameBuffer.getColorBufferTexture() will return the same texture everytime. Edit: I calculate shadow and don't wanna recalculate the static lights. So i want to save the static lights / shadow calculation in a texture. Currently i have to make a new framebuffer for each light to save them. And thats inperformant.
has comment: http://stackoverflow.com/comment/33360805
has comment: http://stackoverflow.com/comment/33361069

http://stackoverflow.com/comment/33406537
type: AnswerComment
comment on: http://stackoverflow.com/a/22035487
type: Comment
has text: see this thread: http://stackoverflow.com/questions/22035176/how-can-i-make-this-into-a-loop
score: 0

http://stackoverflow.com/q/22020382
type: UnansweredQuestion
has title: SetOnCLickListener issue
tagged with: android
has answer: http://stackoverflow.com/a/22021167
score: -2
has comment: http://stackoverflow.com/comment/33379840
has comment: http://stackoverflow.com/comment/33379690
downvote count: 2
type: Question
has answer: http://stackoverflow.com/a/22020577
linked to: http://stackoverflow.com/q/22010883
tagged with: java
answer count: 2
has body: I am having a problem with my setOnClickListener. I can not figure out what the code is i need for it. What i am trying to do is once the item is clicked on in the list view it opens up a new activity. in my code the list view is in the MainActivity. and i want it to open up the Homework activity. So my question is, can anybody help me figure out what i need to put in for it to work correctly and open up Homework.java? when it opens up Homework.java it would show the item clicked in the list view as the header. then nothing in the body. MainActivity.class: public class VideoListTask extends AsyncTask&lt;Void, Void, Void&gt;{ ProgressDialog dialog; protected void onPreExecute (Void result) { dialog.getProgress(); super.onPostExecute(result); } @Override protected Void doInBackground(Void... params) { HttpClient client = new DefaultHttpClient(); //HttpGet getRequest = new HttpGet(feedUrl); Date now = new Date(); HttpGet getRequest = new HttpGet(canvasUrl + "courses? include[]=term&amp;state=available"); getRequest.setHeader("Authorization","Bearer " + canvasApiKey); //uses your key to access your data try { HttpResponse response = client.execute(getRequest); StatusLine statusLine = response.getStatusLine(); int statusCode = statusLine.getStatusCode(); if(statusCode != 200) { return null; } InputStream jsonStream = response.getEntity().getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(jsonStream)); StringBuilder builder = new StringBuilder(); String line; while((line = reader.readLine())!=null) { builder.append(line); } String jsonData = builder.toString(); //JSONObject json = new JSONObject(jsonData); //JSONObject data = json.getJSONObject("data"); //JSONArray items = data.getJSONArray("items"); JSONArray courses = new JSONArray(jsonData); //for(int i =0; i&lt;items.length(); i++) //{ // JSONObject video = items.getJSONObject(i); // videoArrayList.add(video.getString("title")); //} for(int i = 0; i&lt;courses.length(); i++) { JSONObject co…
upvote count: 0
favorite count: 0

http://stackoverflow.com/a/22064875
has comment: http://stackoverflow.com/comment/33459325
type: Answer
has comment: http://stackoverflow.com/comment/33459219
has comment: http://stackoverflow.com/comment/33459050
answers question: http://stackoverflow.com/q/22064825
has body: lLungArray is an array of int but here lLungArray[i][k] you're trying to provide 2 indexes which treats it as an array of arrays and that is plain wrong! Update: Based on your comment, I'd like to know if lLungArray has a 1 in positions 0,1,8,9 and how many instances the 1 appears. Using the above lLungCount should end up at 4. Is that what if(lLungArray[i]==k){ will help me do? I guess this will help you achieve what you want. private void checkHealth() { int[] secondArray = { 0, 1, 8, 9 }; int lLungCount = 0; for (int k : secondArray) { // If the lLungArray elements at the positions specified by the // elements of secondArray is 1 then increment the lLungCount if (lLungArray[k] == 1) { lLungCount++; } } }
score: 0

http://stackoverflow.com/comment/33498199
type: QuestionComment
score: 0
has text: i checked your code and it is working fine, seem like your professor had some issue with class or he did't provide all the classes while compiling. Defining of class means creating class, as you have already created them with name CruiseShip and CargoShip
comment on: http://stackoverflow.com/q/22086506
type: Comment

http://stackoverflow.com/comment/86211063
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22115281
has text: What is the difference between select :war and selecting :exploded?
type: Comment

http://stackoverflow.com/comment/33617708
type: QuestionComment
type: Comment
score: 2
comment on: http://stackoverflow.com/q/22153288
has text: The obtainable answer is that the JLS says so.

http://stackoverflow.com/comment/33372985
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22016366
has text: Yes, I did, it still gives the same error, I have no clue what could be causing this.
type: AnswerComment

http://stackoverflow.com/q/22089584
tagged with: deployment
has comment: http://stackoverflow.com/comment/33504063
answer count: 0
type: UnansweredQuestion
has body: I'm using Java persistence and deploying on Tomcat, but I get an error saying "No Persistence provider for EntityManager named WorxVaultWeb" when running application. Source of this problem is that Tomcat is not deploying META-INF folder and persistence.xml. When I add it manually to deployement location, everything works fine. Why is this happening, and how can I make Tomcat deploy those files.
has title: Tomcat not deploying META-INF
tagged with: java
has comment: http://stackoverflow.com/comment/33503819
has comment: http://stackoverflow.com/comment/33504536
tagged with: persistence.xml
type: Question
tagged with: jpa
has comment: http://stackoverflow.com/comment/33503391
tagged with: tomcat
score: 0

http://stackoverflow.com/a/22092175
has comment: http://stackoverflow.com/comment/33537903
has comment: http://stackoverflow.com/comment/33523987
has body: You can separate the logic for thread execution and controller initializing the executor something like below: public class MapDecoratorQueue { //inject it MyXExecutor myXExecutor; @RequestMapping(method = RequestMethod.GET) public String runTask() { myXExecutor.setRunning(true); return "Task was scheduled to run"; } } //Inject this into MapDecoratorQueue in spring config class MyXExecutor{ private final ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(); private volatile boolean isRunning = false; public MyXExecutor(){ exec.scheduleAtFixedRate( new Runnable(){ @Override public void run() { if(isRunning){ //do stuff } } }, 0, 5, TimeUnit.SECONDS); } public void setRunning(boolean running) { isRunning = running; } } Put your run logic under check of isRunning value. If you don't want to start the executor at all till you get first hit you can use the same approach and you can call a method from controller which will init the Executor if its not initialized. Hope this helps.
downvote count: 0
has comment: http://stackoverflow.com/comment/33538245
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/22086373

http://stackoverflow.com/comment/33587277
type: Comment
type: QuestionComment
has text: Could you be more specific? What do you want to achieve? What do you need these if conditions for?
score: 1
comment on: http://stackoverflow.com/q/22135628

http://stackoverflow.com/comment/33360107
score: 0
has text: Then go n create it at DB end
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22009341

http://stackoverflow.com/comment/33603270
type: Comment
score: 1
type: AnswerComment
has text: +1 [but something is virulent there:-) ... fireTableDataChanged();](http://stackoverflow.com/a/22134415/714968)
comment on: http://stackoverflow.com/a/22142805

http://stackoverflow.com/comment/33376198
score: 0
has text: @pwas yes, this is not going to be easy... Meh, might be a good project to have a go at. I'll need to experiment with `CharsetDecoder`: it doesn't say whether the input `ByteBuffer` is changed at the issue of the decoding operation. If it is, that'll be much easier.
type: AnswerComment
comment on: http://stackoverflow.com/a/22018249
type: Comment

http://stackoverflow.com/comment/33627931
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22157637
type: Comment
has text: Thanks @AlexWien I will clarify that.

http://stackoverflow.com/q/22137387
upvote count: 3
tagged with: java
type: Question
score: 3
has answer: http://stackoverflow.com/a/22137441
accepted answer: http://stackoverflow.com/a/22137441
has answer: http://stackoverflow.com/a/22137646
answer count: 2
downvote count: 0
has title: ProcessBuilder not executing Java class file properly
favorite count: 0
tagged with: processbuilder
tagged with: windows
has body: In a java file I am calling command line statement to execute another java file. This is what I am doing: List&lt;String&gt; paramsExecute = new ArrayList&lt;String&gt;(); paramsExecute.add("java"); paramsExecute.add("-cp"); paramsExecute.add("input\programs\User_K Program1"); paramsExecute.add("1 2 3"); ProcessBuilder builderExecute = new ProcessBuilder(paramsExecute); builderExecute.redirectOutput(new File(a.txt)); builderExecute.redirectError(new File(b.txt)); Execution of one of the Java files is producing b.txt as: Error: Could not find or load main class 1 2 3 Another java file is producing b.txt as: Usage: java [-options] class [args...] ... But, when I am running these statements directly from the command line, it is executing correctly. The folder input\programs\ is in the same path as the src folder. The src folder contains the Java file containing the ProcessBuilder program. I have verified that the .class file is getting created correctly and in the right folder. I am running the program in windows. Any help appreciated!!
possible better answer: http://stackoverflow.com/a/22137646
type: AnsweredQuestion
tagged with: command-line

http://stackoverflow.com/a/22020387
downvote count: 1
upvote count: 0
score: -1
answers question: http://stackoverflow.com/q/22016073
type: Answer
has body: Generally speaking, if you have a project with 1000 classes and each class has 20 functions, thats 20000 functions. Checking input arguments and throwing exceptions for many of the 20000 functions will flood your code with validation checks. I prefer instead to add javadoc to the function saying your input argument to your function cannot be negative (and also, what the function is for). This way, the user (programmer) of your function does not have to examine the content of your function to determine how to use it and what is invalid. Also, his IDE's intellisense will pop up the javadoc message as he is using the function to provide that information. If he violates the javadoc, consider letting the function or one of the functions it calls throw an exception up the the call stack without explicitly doing so, or letting the function not work as expected without throwing an exception. You may consider explicitly thowing an exception if you think providing an invalid input will produce some odd behavior that isn't easy to track down. The javadoc will help him track down the problem without having to specifically throw an exception. Once the business logic is debugged throughly, exceptions being thrown should not happen often unless there is a bug in the business logic. I don't believe exceptions should be part of validating user input. Your user input should be validated throughly before it gets to the business logic, not when it gets to a business logic function. Same argument about validating an uploaded xml document. Check it against an xml schema before passing it to the business logic. Your validation logic should be based on true/false (validation passed), not on throwing an exception for invalid input.

http://stackoverflow.com/q/22053579
has answer: http://stackoverflow.com/a/22065867
accepted answer: http://stackoverflow.com/a/22065867
has title: Xades-BES validation as checksum
has body: I am trying to verify a document signed by xades4j but I'm not interested in a certificate validation. The only thing I need to know is that the document has been signed correctly and nothing has been changed since the signing. I've tried a few different approaches but each one uses PKIXCertificateValidationProvider which requires parameters I'm not interested in like trusted certs. The same is used also in unittests in xades4j sources. I even tried to implement CertificateValidationProvider myself but certificates are needed later on by other classes like ValidationData. Do you have any suggestion how to achieve this with xades4j? Or maybe some other library better documented I could use for validation purposes?
type: AnsweredQuestion
tagged with: java
type: Question
tagged with: xades4j
answer count: 1
score: 0

system-calls
type: Tag
tags question: http://stackoverflow.com/q/22131044
tags question: http://stackoverflow.com/q/22119918
tag name: system-calls

http://stackoverflow.com/comment/33528524
comment on: http://stackoverflow.com/q/22103426
score: 0
type: Comment
type: QuestionComment
has text: Note: The connection string contains username and password, and it works in other java applications

http://stackoverflow.com/a/22077160
type: AcceptedAnswer
has body: If you want to send objects to clients whose classes aren't deployed at the client you need to take a long look at the RMI codebase feature.
type: Answer
accepted answer of: http://stackoverflow.com/q/22056910
answers question: http://stackoverflow.com/q/22056910
score: 0

http://stackoverflow.com/comment/33407054
has text: I'm sorry to tell you you need to specify a projections :/ or a custom (but a not-so-safe custom ResultTransformer)
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22016359

http://stackoverflow.com/q/22148420
type: AnsweredQuestion
has title: How to set a breakpoint on a Class NOT a Line in Eclipse?
tagged with: java
tagged with: eclipse
possible better answer: http://stackoverflow.com/a/39366968
type: Question
has body: I simply would like to start debugging once any function is invoked in a specific set of classes. Is it possible to achieve this in Eclipse ? or do I have to set a breakpoint on each function in each class I want to debug? UPDATE: I didn't ask how to set a breakpoint in eclipse. I would like to debug a class without knowing which function is going to be called. UPDATE 2: (I am going to make my problem more clear) I was requested to fix a bug in an application (Which I didn't implement). I managed to narrow down the related classes to this bug. The problem each class has over 30 functions. And I don't know exactly which functions are invoked. So I was thinking if its possible to set a breakpoint somehow on the class itself in order to start debugging once a function within this class is invoked. I would appreciate any help, Tefa
tagged with: debugging
has answer: http://stackoverflow.com/a/39366968
accepted answer: http://stackoverflow.com/a/22148805
answer count: 2
upvote count: 20
downvote count: 0
has comment: http://stackoverflow.com/comment/88067053
favorite count: 0
score: 20
has answer: http://stackoverflow.com/a/22148805

http://stackoverflow.com/comment/33539288
type: Comment
score: 0
type: AnswerComment
has text: Thank you for quick response. However, I can't agree with you.
comment on: http://stackoverflow.com/a/22109262

http://stackoverflow.com/comment/33599702
type: Comment
comment on: http://stackoverflow.com/a/22143340
score: 1
type: AnswerComment
has text: You'll get a syntax error because you're `components` variable type is not `JRadioButton` or a subtype of it (rather a supertype). It'll fail at compile time.

http://stackoverflow.com/a/22013894
upvote count: 2
type: Answer
has body: It's in the scientific notation. If you don't want it in this notation, you can try public static void main(String[] args) { Double d = Math.pow(3+Math.sqrt(5),12); System.out.println(d); //4.246814719604947E8 System.out.println(new BigDecimal(d).toPlainString()); //424681471.960494697093963623046875 }
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/22013634
has comment: http://stackoverflow.com/comment/33367516

http://stackoverflow.com/comment/69004981
type: Comment
comment on: http://stackoverflow.com/a/22075575
has text: @chipmunk - no it covers only palindromes that are at lest 2 characters long. By wikipedia: "sequence of characters which reads the same backward or forward" so to have a sequence you need at least 2 characters.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33578062
has text: Have you tried so far for that ?
comment on: http://stackoverflow.com/q/22130677
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22141582
answer count: 3
downvote count: 1
has comment: http://stackoverflow.com/comment/33596901
has comment: http://stackoverflow.com/comment/33596974
has comment: http://stackoverflow.com/comment/33596946
favorite count: 0
has title: Access Class Variable on general Object of that class
has answer: http://stackoverflow.com/a/22141781
has comment: http://stackoverflow.com/comment/33596639
has comment: http://stackoverflow.com/comment/33596667
has comment: http://stackoverflow.com/comment/33596867
type: AnsweredQuestion
tagged with: object
possible better answer: http://stackoverflow.com/a/22141615
tagged with: reflection
score: 1
has answer: http://stackoverflow.com/a/22141645
tagged with: java
has answer: http://stackoverflow.com/a/22141615
type: Question
has comment: http://stackoverflow.com/comment/33596853
has body: I have a lots of classes for example this one: public class DepartmentST { public Long id = null; public String name = null; public String comments = null; public Long[] profiles = null; public Boolean default_val = false; } In main class I create objects of those classes and sent it to general method for example: DepartmentST mydepartment = new DepartmentST(); generalMethod(mydepartment); In general Method I want to access to object fields (this my question how?) public generalMethod(Object myObj) { Field[] fields = myObj.getClass().getFields(); for(Field field : fields) { String fieldName = field.getName(); // I want to access that field how can i tell myObj.fielName ? } } I'm new in Java I don't know it's stupid question or not. thanks for any help in advance.
linked to: http://stackoverflow.com/q/13400075
has comment: http://stackoverflow.com/comment/33596827
has comment: http://stackoverflow.com/comment/33596706
tagged with: class
upvote count: 2
accepted answer: http://stackoverflow.com/a/22141781

http://stackoverflow.com/comment/33523122
has text: @user3245604 Do what? What I can do is to give you the following advice. Review your logic and make those variables initialized :)
type: Comment
score: 0
comment on: http://stackoverflow.com/a/22100412
type: AnswerComment

http://stackoverflow.com/comment/33469491
has text: I figured out the problem. It was in the do while method. Thank you for helping me out! :)
comment on: http://stackoverflow.com/a/22070772
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33624274
type: QuestionComment
has text: Don't use Vector class. It's there for legacy support. Do you need your list to be synchronized at all?
comment on: http://stackoverflow.com/q/22156690
score: 0
type: Comment

http://stackoverflow.com/a/22081309
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/22081231
has body: From your code, it looks like you will never reach the case where n == 0. This is why you are entering infinite recursion. Each time you call your function with n + (n - 1) + n, which is essentially 3n - 1. So what you have is f(n) = 3n - 1, and you're passing the result of that into the function itself. Now f(n) = 0 only when n = 1 / 3. Can you see any way where n can ever be 1 / 3? Also, try plotting this function on a graph. What do you see happening to the y values as you keep increasing x (basically n in this case)?
downvote count: 0
type: Answer

http://stackoverflow.com/comment/33814728
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22162736
has text: This has something to do with the EDT and Gnome3 being more agresive to on shutdown.
type: AnswerComment

http://stackoverflow.com/a/22132017
type: Answer
has comment: http://stackoverflow.com/comment/33582294
has comment: http://stackoverflow.com/comment/33585886
answers question: http://stackoverflow.com/q/22131167
has body: Not an answer but a plausible idea for one? for (int i = 0; i &lt; array.length; i++) { // New sublist to store values from 0 to i int[] list = new int[array.length - 1]; for (int j = 0; j &lt; array.length; j++) { list[j] = array[j+1]; } // Here you call this recursively with your Parent list from i+1 // index and working list from 0 to i subsetSum(list, n, goal); } int sum = 0; for (int i = 0; i &lt; array.length; i++) { sum += array[i]; } if (sum == goal) { return true; } return false;
score: 0
has comment: http://stackoverflow.com/comment/33582354

http://stackoverflow.com/a/22022667
has body: You can use this pattern: "((?:&lt;|\\G(?&lt;!\\A))\\s*)(p[0-9]+)(\\s*=\\s*)(v[0-9]+)" To ensure that the pairs are after an opening angle bracket, the pattern start with: (?:&lt;|\\G(?&lt;!\\A)) that means: an opening angle bracket OR at the end of the last match \\G is an anchor for the position immediatly after the last match or the begining of the string (in other words, it is the last position of the regex engine in the string, that is zero at the start of the string). To avoid a match at the start of the string I added a negative lookbehind (?&lt;!\\A) -> not preceded by the start of the string. This trick forces each pair to be preceded by an other pair or by a &lt;. example: String subject = "p5=v5 &lt;p0=v0 p1=v1 p2=v2 p3=v3&gt; p4=v4"; String pattern = "((?:&lt;|\\G(?&lt;!\\A))\\s*)(p[0-9]+)(\\s*=\\s*)(v[0-9]+)"; String result = subject.replaceAll(pattern, "$1$4$3$2"); If you need p and v to have the same number you can change it to: String pattern = "((?:&lt;|\\G(?&lt;!\\A))\\s*)(p([0-9]+))(\\s*=\\s*)(v\\3)"; String result = subject.replaceAll(pattern, "$1$5$4$2"); If parts between angle brackets can contain other things (that are not pairs): String pattern = "((?:&lt;|\\G(?&lt;!\\A))(?:[^\s&gt;]+\\s*)*?\\s*)(p([0-9]+))(\\s*=\\s*)(v\\3)"; String result = subject.replaceAll(pattern, "$1$4$3$2"); Note: all these patterns only checks if there is an opening angle bracket, but don't check if there is a closing angle bracket. If a closing angle bracket is missing, all pairs will be replaced until there is no more contiguous pairs for the two first patterns and until the next closing angle bracket or the end of the string for the third pattern. You can check the presence of a closing angle bracket by adding (?=[^&lt;&gt;]*&gt;) at the end of each pattern. However adding this will make your pattern not performant at all. It is better to search parts between angle brackets with (?&lt;=&lt;)[^&lt;&gt;]++(?=&gt;) and to perform the replacement of pairs in a callback…
type: AcceptedAnswer
score: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/22021129
answers question: http://stackoverflow.com/q/22021129
has comment: http://stackoverflow.com/comment/33385675
has comment: http://stackoverflow.com/comment/33385174

http://stackoverflow.com/a/22048447
type: Answer
answers question: http://stackoverflow.com/q/22047237
score: 0
has body: Well I won't give you any code, but maybe some paragraph-form pseudocode and an idea to get you to think outside of the box, since you'll not always have a pre-made method ready for you. As a worst case scenario if you can't find an alternate method, think about how to break it down. What number system is the input formatted in? Is it binary, hexadecimal, decimal? Find out what the possible range of values is for any given number in that number system, and create a block or two of code that will determine which number in that range the number is. In binary we know that a number can either be a 1 or a 0, so for each possible digit in any length of successive digits we know that the only two possible String representations of these numbers is "One" and "Zero". You shouldn't need to use a single method in analyzing the numbers, nor should you need to use a method to concatenate onto the String you are creating. If you try to process the number as the integer it truly represents, you could have any number of possibilities as large as an int datatype can hold (2 to the power of 32 = 4294967296 possible combinations of numbers - with that many possibilities to check, you would LITERALLY be better off writing a program to write that block of your program!!), but if you process the int digit by digit, you can have - at WORST - 10 possible combinations(0-9 inclusive) multiplied by the number of digits, up to a maximum of 10 digits in an int(in decimal form). Moreover, in the former case, you would have to check for every single number in one giant absurd iteration. In the latter case, you only need to check 10 values, and iterate 1-10 times inclusive depending on the amount of digits in the number.

http://stackoverflow.com/comment/33620243
type: Comment
comment on: http://stackoverflow.com/a/22154225
has text: do you have `iFrameMain` defined ?
score: 0
type: AnswerComment

http://stackoverflow.com/a/22066378
has comment: http://stackoverflow.com/comment/33464213
has body: You can easily create a class that extends OutputStream since this only requires one method to be implemented. Sample, untested code: public final class ByteBufferOutputStream extends OutputStream { private final ByteBuffer buf; public ByteBufferOutputStream(final int size) { buf = ByteBuffer.allocateDirect(size); } @Override public void write(final int b) throws IOException { if (buf.remaining() == 0) throw new IOException("buffer is full"); buf.put((byte) (b &amp; 0xff)); } } Then just pass an instance of that class to your API. You'll also probably want to override the other write methods since ByteBuffer has dedicated methods to write byte arrays.
accepted answer of: http://stackoverflow.com/q/22065482
answers question: http://stackoverflow.com/q/22065482
upvote count: 1
type: AcceptedAnswer
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/33464410
score: 1

http://stackoverflow.com/comment/33452025
type: AnswerComment
comment on: http://stackoverflow.com/a/22050343
type: Comment
has text: You said "But note that broker will not wait for all consumers to receive publication before removing it from a topic" i think you meant that broker will deliver it from its side but does not wait for acknowledgement from consumer whether it received it or not ?
score: 0

http://stackoverflow.com/q/22152204
has body: I see that there are a ton of generic data structures provided in Java. They all implement List, so they can be used almost interchangeably, but when would I want to use each? Personally, I stick to LinkedList because it's something I'm "familiar" with. I'm not asking for an explanation of every single structure, but can you explain some of the more common ones and give their uses, as well as compare and contrast the uses of "Vector-like" structures?
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22152268
upvote count: 1
linked to: http://stackoverflow.com/q/322715
has comment: http://stackoverflow.com/comment/33615778
tagged with: java
duplicate of: http://stackoverflow.com/q/322715
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/22152272
tagged with: data-structures
has comment: http://stackoverflow.com/comment/33615749
score: 0
answer count: 2
linked to: http://stackoverflow.com/q/1386275
has comment: http://stackoverflow.com/comment/33615748
favorite count: 0
has title: When to use each Java Collections data structure
has comment: http://stackoverflow.com/comment/33615750

http://stackoverflow.com/q/22114834
downvote count: 5
tagged with: http://stackoverflow.com/tag/c
has title: explain what happened (C program)
tagged with: operating-system
favorite count: 0
possible better answer: http://stackoverflow.com/a/22115132
score: -4
has answer: http://stackoverflow.com/a/22115132
has answer: http://stackoverflow.com/a/22115064
type: AnsweredQuestion
tagged with: java
has body: Assume that a system has a 64-bit virtual address with an 8-kb page size. Write a C- program that is passed a virtual address (in decimal) on the command line and have it output the page number and offset for the given address. As an example, your program would run as follows: ./a.out 8219986 The program would output: The address 8219986 contains: Page number: 1003 Offset = 3410 All computation must be done in binary. #include &lt;stdio.h&gt; int main(int argc,char *argv[]) { unsigned long long int MappedAdress = atoll(argv[1]); unsigned long long int page = MappedAdress; unsigned long long int offset = MappedAdress; //print long long address printf("The MappedAdress %llu contains:\n",MappedAdress); //shift to right 13 bit to retrive pages, then print page = page &gt;&gt; 13; printf("Page Number : %llu\n",page); //since it's 64-bit opr. Add offset AND 1FFF , offset = offset &amp; 0x1FFF; //print the offset printf("Offset = %llu\n\n",offset); return 0; } Can anyone explain to me what just happened here ? and what to shall I do to write such a program but in Java as long as I have no background in C language?
upvote count: 1
tagged with: memory
has comment: http://stackoverflow.com/comment/33548936
tagged with: computer-science
type: Question
has comment: http://stackoverflow.com/comment/33548919
answer count: 2
accepted answer: http://stackoverflow.com/a/22115064

http://stackoverflow.com/q/22118238
has comment: http://stackoverflow.com/comment/33555652
favorite count: 0
has body: I've got the following code: public class LobbyView extends JPanel { this.setLayout(new MigLayout()); private final JTextArea chatWindowMessage = new JTextArea(); private final JScrollPane chatWindow = new JScrollPane(chatWindowMessage); LobbyView(Window sentWindow) { chatWindow.setViewportView(chatWindowMessage); chatWindow.setPreferredSize(new Dimension(300, 300)); chatWindow.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); chatWindowMessage.setLineWrap(true); chatWindowMessage.append("test" + "\n"); chatWindowMessage.append("test 2" + "\n"); this.add(chatWindow, "pos 180px 75px"); this.add(chatMessage, "pos 180px 380px"); } } The code results in the following JScrollPane: How do I force the JTextArea to the bottom of the JScrollPane so it looks like this (N.B. I use MigLayout):
type: UnansweredQuestion
tagged with: swing
has answer: http://stackoverflow.com/a/22118451
has title: Force JTextArea to the bottom of JScrollPane
has answer: http://stackoverflow.com/a/22118394
downvote count: 0
score: 1
tagged with: java
type: Question
linked to: http://stackoverflow.com/q/16800125
answer count: 2
tagged with: jscrollpane
tagged with: jtextarea
has comment: http://stackoverflow.com/comment/33555342
upvote count: 1

http://stackoverflow.com/q/22138131
has comment: http://stackoverflow.com/comment/33590898
has comment: http://stackoverflow.com/comment/33590861
has answer: http://stackoverflow.com/a/22138181
type: Question
tagged with: jpanel
has body: I am trying to write a program with JPanels and for the life of me, I can't seem to get the JPanels to go into the proper positions. I don't have a clue what I am doing wrong. Here is some of the code I have so far: package mainGUIWindowFrames; import javax.swing.*; import javax.swing.border.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.util.*; public class CustomerWindow extends JFrame { //Attribute private JTextField textTF; private JButton copyButton; private JLabel copyLabel; private Border panelEdge; //Constructor public CustomerWindow() { this.setBounds(100,100,800,600); panelEdge = BorderFactory.createEtchedBorder(); JPanel mainPanel = new JPanel(new BorderLayout(5, 5)); mainPanel.add(createCustomerPanel(), BorderLayout.NORTH); mainPanel.add(createCustomerInfoPanel(), BorderLayout.EAST); mainPanel.add(createSearchPanel(), BorderLayout.WEST); } //Operational Methods public JPanel createCustomerPanel() { JPanel customerPanel = new JPanel(); JLabel customerL = new JLabel("Clients",SwingConstants.CENTER); customerL.setForeground(Color.blue); customerL.setFont(new Font("Copperplate Gothic Bold",Font.BOLD,48)); customerPanel.add(customerL); customerPanel.setBorder(panelEdge); return customerPanel; } public JPanel createCustomerInfoPanel() { JPanel infoPanel = new JPanel(); infoPanel.setBorder(panelEdge); JLabel infoL = new JLabel("Clients",SwingConstants.CENTER); infoL.setForeground(Color.blue); infoL.setFont(new Font("Copperplate Gothic Bold",Font.BOLD,48)); infoPanel.add(infoL); //add a text field textTF = new JTextField(50); infoPanel.add(textTF); //add a button copyButton = new JButton("Copy Text"); copyButton.addActionListener(new ButtonListener()); infoPanel.add(copyButton); copyLabel = new JLabel("-----------------"); infoPanel.add(copyLabel); return infoPanel; } public JPanel createSearchPanel() { JPanel lowerPanel = new JPanel(); JLabel label = new JLabel("Text Transferred from JList:"); //the spot where the data sh…
has comment: http://stackoverflow.com/comment/33591016
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/33595316
tagged with: grid-layout
has answer: http://stackoverflow.com/a/22138180
tagged with: swing
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22138180
has title: Why aren't the Jpanels working?
possible better answer: http://stackoverflow.com/a/22138181
tagged with: java

http://stackoverflow.com/a/22070181
score: 3
upvote count: 3
downvote count: 0
answers question: http://stackoverflow.com/q/22069334
has body: Presenting the actions of your two threads side-by-side: Thread 1 Thread 2 o.readX(); // 0 o.writeX(1); o.readY(); // 1 o.writeY(1); o.readX(); // must be 1 There is a strict happens-before ordering of any arbitrarily chosen pair of invocations of your Semaphore methods because they both go through an acquire-release cycle on the same shared Semaphore instance. We have: o.writeX(1) by Thread 2 happens-before o.writeY(1); o.writeY(1) by Thread 2 happens-before o.readY() -&gt; 1 by Thread 1; o.readY() by Thread 1 happens-before the second o.readX() by Thread 1; therefore o.writeX(1) by Thread 2 happens-before the second o.readX() by Thread 1; therefore the result of the second o.readX() must be 1.
type: Answer

http://stackoverflow.com/comment/33371013
type: QuestionComment
has text: If you really wanted to use the handshake for that, you get into trouble...haha, no, you needed to change the http://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure *red field*.
comment on: http://stackoverflow.com/q/22015412
score: 0
type: Comment

http://stackoverflow.com/comment/53073921
has text: If we set <property name="oneIndexedParameters" value="true"> then what is <constructor-arg name="page" value="????" /> correct value? If I give 1 then all 0th index values will be missing...Is it ok to give 0th index?
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/22143995
type: Comment

http://stackoverflow.com/q/22015880
has body: Over the years, our project has used many different libraries. I'm pretty sure some of them are not used anymore, while others are obsolete and should be upgraded. I am looking for tool to find which libraries (jar files) are no longer used and can be removed. I could also use some help to find out which libraries should be upgraded -- at least when I swap jar file with newer version, I would like to get report saying that there are now incompatibilities (wrong method signatures, unknown classes, ...). Is there tool like that? We don't use Maven or Ivy or any other dependency management system. We have tests, but they don't cover everything.
linked to: http://stackoverflow.com/q/19099121
answer count: 2
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/33371585
has answer: http://stackoverflow.com/a/22016071
has comment: http://stackoverflow.com/comment/33371534
type: UnansweredQuestion
tagged with: dependency-management
score: 4
has title: Removing unused libraries without breaking the code
tagged with: java
has answer: http://stackoverflow.com/a/22016035
type: Question
upvote count: 4
tagged with: jar

http://stackoverflow.com/q/22102881
has answer: http://stackoverflow.com/a/23380259
type: Question
has title: Why doesn't my java code decrypt db files correctly?
has comment: http://stackoverflow.com/comment/33530110
tagged with: java
linked to: http://stackoverflow.com/q/8856874
has body: I am trying to decrypt whatsapp database file with java code. Checked whatsapp_xtract code which is using Python to decrypt. I believe this is the decryption part of the code: from Crypto.Cipher import AES code = "346a23652a46392b4d73257c67317e352e3372482177652c" if PYTHON_VERSION == 2: code = code.decode('hex') elif PYTHON_VERSION == 3: code = bytes.fromhex(code) ipher = AES.new(code,1) decoded = cipher.decrypt(open(options.infile,"rb").read()) decodedfile = options.infile.replace(".db.crypt","")+".plain.db" output = open(decodedfile,"wb") output.write(decoded) output.close() This code works well and I can open bd file with SqLiteBrowser. Here is my java code: public class Crypto { public FileInputStream mIn; public FileOutputStream mOut; public Crypto(String fileIn, String fileOut, String key) { try { mIn = new FileInputStream(new File(fileIn)); mOut = new FileOutputStream(new File(fileOut)); decrypt(mIn, mOut, key); } catch (Exception e) { e.printStackTrace(); } } public static void decrypt(InputStream in, FileOutputStream out, String password) { try { // byte[] iv = new byte[IV_LENGTH]; byte[] iv = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); in.read(iv); System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;red" + Arrays.toString(iv)); String s = "346a23652a46392b4d73257c67317e352e3372482177652c"; byte[] sBytes = hexStringToByteArray(s); byte[] bytes = new BigInteger(s, 16).toByteArray(); SecretKeySpec keySpec = new SecretKeySpec(sBytes, "AES"); Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding", "BC"); // "AES/CFB8/NoPadding";"AES/CBC/PKCS5Padding"; // //"AES/ECB/PKCS5Padding" IvParameterSpec ivSpec = new IvParameterSpec(iv); cipher.init(Cipher.DECRYPT_MODE, keySpec);// , ivSpec); //cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec); in = new CipherInputStream(in, cipher); byte[] buf = new byte[iv.length]; int numRead = 0; while ((numRead = in.read(buf)) &gt;= 0) { Strin…
has comment: http://stackoverflow.com/comment/33527653
has comment: http://stackoverflow.com/comment/33830187
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/33864491
favorite count: 0
has comment: http://stackoverflow.com/comment/33527555
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33535398
has comment: http://stackoverflow.com/comment/33530140
has comment: http://stackoverflow.com/comment/33527879
has comment: http://stackoverflow.com/comment/33527780
score: 1
tagged with: encryption
upvote count: 1
has comment: http://stackoverflow.com/comment/33535504

http://stackoverflow.com/q/22127264
has title: MYSQL Transactions using BasicDataSource
score: 0
answer count: 1
accepted answer: http://stackoverflow.com/a/22127370
has comment: http://stackoverflow.com/comment/33572056
has body: I am using Apache BasicDataSource to handle my database code - simply i just create methods to do particular tasks that access the database. An example can be seen below; /** * Update a users display name * @param userid the user id to update for * @param displayName the display name to change too * @return true if update suceeded */ public static boolean updateDisplayName(String userid, String displayName){ Connection conn = null; String sql = "update UserAccount set displayname = ? where userid = ? "; try { conn = source.getConnection(); PreparedStatement st = conn.prepareStatement(sql); st.setString(1,displayName); st.setString(2,userid); st.executeUpdate(); return true; } catch (Exception e) { logger.warn("An error occured when updating the display name for " + userid, e); } finally{ closeConnection(conn); } return false; } I have had a google around and can't seem to find any examples of how to use transactions. Please could someone advise me on how this might be done? Thanks
type: AnsweredQuestion
tagged with: transactions
tagged with: java
tagged with: database
tagged with: mysql
type: Question
has comment: http://stackoverflow.com/comment/33572016
has answer: http://stackoverflow.com/a/22127370

http://stackoverflow.com/a/22043125
has body: Using Google GSON, it's quite simple: JSONObject result = new JSONObject(); result.put("columnHeadersKeys", JSONObject.NULL); JSONArray headers = new JSONArray(); JSONObject obj = new JSONObject(); obj.put("id", 1); obj.put("name", "abcd"); headers.put(obj); obj = new JSONObject(); obj.put("id", 2); obj.put("name", "xyz"); headers.put(obj); result.put("rowHeaders", headers); JSONArray data = new JSONArray(); obj = new JSONObject(); obj.put("id", 1); obj.put("rowId", "R1"); obj.put("status", "PASSED"); data.put(obj); obj = new JSONObject(); obj.put("id", 2); obj.put("rowId", "R2"); obj.put("status", "PASSED"); data.put(obj); result.put("data", data); String output = result.toString(); Note that the entire creation of the object can be chained in one statement - however I find it easier to read when it's split out.
score: 3
answers question: http://stackoverflow.com/q/22042794
downvote count: 0
type: Answer
upvote count: 3

http://stackoverflow.com/comment/33453327
has text: In which line of code is `ArrayIndexOutOfBoundException` reported?
type: QuestionComment
type: Comment
score: 2
comment on: http://stackoverflow.com/q/22061923

http://stackoverflow.com/a/22151379
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/33614436
has body: You could use SharedPreferences (kind of a persistence layer). Or you could pass data through Intent.
answers question: http://stackoverflow.com/q/22151131

http://stackoverflow.com/q/22143652
tagged with: interface
has body: I am new in Java. I am implementing Comparator interface &amp; i am having a compareTo function below:- public int compare(Object o1, Object o2) { Map.Entry e1 = (Map.Entry) o1; Map.Entry e2 = (Map.Entry) o2; return ((Comparable) e1.getValue()).compareTo(e2.getValue()); } I am not be able to understand what does this line means Map.Entry e1 = (Map.Entry) o1; What is the use of two Map.Entry ?? Why Comparable in type casting ?? Someone please give me a reference so that i can figure it out. Thanks. Edited:- Here is my whole class,i am having a HashMap I want to sort by values using Generic class,hence writing this class package via; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; public class SortMap&lt;K, V&gt; { public Map&lt;K, V&gt; getSortedMap(Map&lt;K, V&gt; mapToSort) { List&lt;Map.Entry&gt; list = new ArrayList&lt;Map.Entry&gt;(mapToSort.entrySet()); Collections.sort(list, new Comparator() { @Override public int compare(Object o1, Object o2) { Map.Entry e1 = (Map.Entry) o1; Map.Entry e2 = (Map.Entry) o2; return ((Comparable) e2.getValue()).compareTo(e1.getValue()); } }); Map sortedMap = new LinkedHashMap(); for(Iterator i=list.iterator();i.hasNext();) { Map.Entry entry=(Map.Entry)i.next(); sortedMap.put(entry.getKey(), entry.getValue()); } System.out.println(list); return sortedMap; } }
has comment: http://stackoverflow.com/comment/33601976
has comment: http://stackoverflow.com/comment/33600484
score: 0
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22146057
tagged with: compareto
has comment: http://stackoverflow.com/comment/33601076
has title: What is comparable type casting & Map.Entry?
has comment: http://stackoverflow.com/comment/33600393
tagged with: comparator
has comment: http://stackoverflow.com/comment/33600145
tagged with: compare
answer count: 1
linked to: http://stackoverflow.com/q/12947088
has comment: http://stackoverflow.com/comment/33601228
has comment: http://stackoverflow.com/comment/33600158
has comment: http://stackoverflow.com/comment/33600624
type: UnansweredQuestion

http://stackoverflow.com/q/22094700
tagged with: java
has comment: http://stackoverflow.com/comment/33512064
score: 0
tagged with: radio-button
upvote count: 1
downvote count: 1
has answer: http://stackoverflow.com/a/22094794
favorite count: 0
has comment: http://stackoverflow.com/comment/33511967
answer count: 5
has title: RadioButton If statement
tagged with: android
has answer: http://stackoverflow.com/a/22094912
has answer: http://stackoverflow.com/a/22095006
accepted answer: http://stackoverflow.com/a/22095006
has answer: http://stackoverflow.com/a/22094789
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22094899
possible better answer: http://stackoverflow.com/a/22094794
has body: I am checking how Radio button is working .. In my code I uses 2 radio buttons and when one is selected ... as I accept and another as not selected..when I am running the application is crashing and in logcat it is saying the error is null pointer exception and I am giving my code below .. please check MainActiivyt public class MainActivity extends Activity { RadioGroup group1; RadioButton button1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); group1 = (RadioGroup) findViewById(R.id.rg1); int selected = group1.getCheckedRadioButtonId(); button1 = (RadioButton) findViewById(selected); if ("I Accept".equals(button1.getText().toString())) { Toast.makeText(this,"Correct!",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(this,"Incorrect.",Toast.LENGTH_SHORT).show(); } } } 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" tools:context=".MainActivity" &gt; &lt;RadioGroup android:id="@+id/rg1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" &gt; &lt;RadioButton android:id="@+id/radioButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="onRadioButtonClicked" android:text="I Accept" /&gt; &lt;RadioButton android:id="@+id/radioButton2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="19dp" android:text="Not Accept" android:onClick="onRadioButtonClicked" /&gt; &lt;/RadioGroup&gt; &lt;Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textView1" android:layout_marginTop="124dp" android:layout_toRightOf="@+id/rg1" android:text="Button" /&gt; &lt;TextView android:id="@+id/textView1" android:layout_width="wra…
has comment: http://stackoverflow.com/comment/33512015
type: Question

http://stackoverflow.com/comment/33567476
comment on: http://stackoverflow.com/q/22124885
has text: Isn't `index = sentence.indexOf(c)` just the same thing as `i`?
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33536154
comment on: http://stackoverflow.com/q/22107417
score: 0
type: Comment
type: QuestionComment
has text: a `char` that consists of 6 other chars?!? @fge

http://stackoverflow.com/q/22007341
has answer: http://stackoverflow.com/a/66488110
has body: I am using Spring JPA to perform all database operations. However I don't know how to select specific columns from a table in Spring JPA? For example: SELECT projectId, projectName FROM projects
possible better answer: http://stackoverflow.com/a/40934100
has comment: http://stackoverflow.com/comment/124318481
has answer: http://stackoverflow.com/a/53817222
score: 281
has answer: http://stackoverflow.com/a/76217974
has answer: http://stackoverflow.com/a/38246793
has comment: http://stackoverflow.com/comment/46332264
has answer: http://stackoverflow.com/a/29020641
answer count: 22
has comment: http://stackoverflow.com/comment/134620273
has comment: http://stackoverflow.com/comment/46372031
linked to: http://stackoverflow.com/q/12618489
has answer: http://stackoverflow.com/a/78771592
has answer: http://stackoverflow.com/a/47108979
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/41015492
has answer: http://stackoverflow.com/a/43513384
has answer: http://stackoverflow.com/a/56197177
has answer: http://stackoverflow.com/a/53955183
has answer: http://stackoverflow.com/a/22007664
has answer: http://stackoverflow.com/a/22007585
has title: Spring JPA selecting specific columns
tagged with: java
has answer: http://stackoverflow.com/a/45055628
has answer: http://stackoverflow.com/a/75800093
has answer: http://stackoverflow.com/a/25844097
type: Question
has answer: http://stackoverflow.com/a/43855964
has answer: http://stackoverflow.com/a/78734644
has comment: http://stackoverflow.com/comment/40437106
has answer: http://stackoverflow.com/a/71536531
has answer: http://stackoverflow.com/a/77325566
tagged with: jpa
downvote count: 0
has answer: http://stackoverflow.com/a/40934100
has comment: http://stackoverflow.com/comment/46283903
has comment: http://stackoverflow.com/comment/33356333
favorite count: 0
upvote count: 281
linked to: http://stackoverflow.com/q/2430655
accepted answer: http://stackoverflow.com/a/22007664
has answer: http://stackoverflow.com/a/75021309
tagged with: spring-data-jpa

http://stackoverflow.com/comment/33394035
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22027984
has text: You also have the class name and variable named declared the same. What is grades[index] supposed to be if grades is the name of the class?
score: 0

http://stackoverflow.com/q/22028853
has title: ArrayIndexOutOfBoundsException - Does not an array initialized to default values by itself? (Java)
has comment: http://stackoverflow.com/comment/33395621
has comment: http://stackoverflow.com/comment/33395514
tagged with: java
has comment: http://stackoverflow.com/comment/33395522
has body: I have an array of objects of type, let's say, Object. Object[] array = new Object[M]; As far as I know, when you specify the length of the array to be M (where M some number), it is created an array with M default values for this type of array. For example, if I had an array int[], there would be M zeroes. Now that I have an array with objects, I expect to have M null objects, from index 0 up to index M-1. However, when I assign for the first time a value at index M-1: array[M-1] = obj; I get a java.lang.ArrayIndexOutOfBoundsException: M Obviously I misunderstand something, but I don't know what it is ... Could you help me figure that out? EDIT: I put my comment below, might help. Assume that I have an array of ints, e.g. int[] array = new int[3]; When this statement runs, I think - please correct me if I am wrong - that if I will print my array I will get [0, 0, 0], i.e. I will have zeroes (the standard value for int[] arrays) at indexes 0, 1, and 2 (since I defined a length 3). Now if I try to do for example: array[2] = 5 I should get [0, 0, 5] and not an ArrayIndexOutOfBoundsException since the index already exists upon allocation - it is a fixed array, not a dynamic one that starts from size zero and grows up to capacity (or even more)! That's exactly what I did in my code - only difference, I have objects instead of ints. Therefore, IF what I say is right, then somewhere else is the problem in my code and I should post it in another question. EDIT 2: Please check Cache Implemented Using an Array - ArrayIndexOutOfBoundsException (Java)
has comment: http://stackoverflow.com/comment/33396592
type: Question
has comment: http://stackoverflow.com/comment/33395682
has answer: http://stackoverflow.com/a/22028882
tagged with: indexoutofboundsexception
has comment: http://stackoverflow.com/comment/33395560
score: 0
has comment: http://stackoverflow.com/comment/33395556
tagged with: arrays
linked to: http://stackoverflow.com/q/22029459
answer count: 1
has comment: http://stackoverflow.com/comment/33395625
has comment: http://stackoverflow.com/comment/33395550
has comment: http://stackoverflow.com/comment/33395594
type: UnansweredQuestion

http://stackoverflow.com/comment/44893192
score: 0
has text: This has nothing to do with fonts. It is showing the mapping of certain Unicode characters to HTML entities.
comment on: http://stackoverflow.com/q/22031091
type: QuestionComment
type: Comment

http://stackoverflow.com/q/22051060
score: 5
accepted answer: http://stackoverflow.com/a/22051142
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/102284637
tagged with: maven-plugin
favorite count: 0
tagged with: maven
has answer: http://stackoverflow.com/a/22051142
tagged with: maven-surefire-plugin
linked to: http://stackoverflow.com/q/4053474
tagged with: build
type: AnsweredQuestion
has body: I want to aggregate all surefire reports in separate modules. In my folder there are several module and I want to generate aggregated surefire report of all those modules. I could do this when I execute following command inside the my parent folder. mvn surefire-report:report -Daggregate=true I want to do the same operation when I execute mvn clean install inside my parent folder. For that I have to change the parent folder pox.xml file. I found it can be using following maven plugin <build> <plugins> org.apache.maven.plugins maven-surefire-report-plugin 2.7.2 true ............... But when I execute mvn clean install There is no result. In addition to add the plugin to the pom.xml is there any other steps to do ? Or is this path correct ? Thanks,
upvote count: 5
tagged with: java
has title: How to execute maven plugin in given phase
type: Question

http://stackoverflow.com/q/22142456
tagged with: java
tagged with: methods
has answer: http://stackoverflow.com/a/22142771
type: Question
has answer: http://stackoverflow.com/a/22142521
tagged with: int
score: 0
has answer: http://stackoverflow.com/a/22142856
accepted answer: http://stackoverflow.com/a/22142856
has title: java reading int from file, original method not working looking for something new
has body: how can i read int from my file and save it to an arraylist int. The number in the file can either be separated by a comma or a space. I have a code here, but this has a problem(cannot read the first number beginning from the second row). I already abandoned this method and is looking for something new. Thanks for the help. The file looks like this: 1,2,3 4,7 8 10 8 7,5,4 0 I just posted this here, so you guys know I do have a method. ArrayList&lt;Integer&gt; listtwo = new ArrayList&lt;&gt;(); try { file = new Scanner(new File(filename+".txt")).useDelimiter(",| "); } catch (FileNotFoundException e) { e.printStackTrace(); } while(file.hasNext()){ if (file.hasNextInt()){ listtwo.add(file.nextInt()); }else{ file.next(); } } for (Integer i: listtwo) System.out.println(i);
possible better answer: http://stackoverflow.com/a/22142792
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22142792

http://stackoverflow.com/a/22067512
answers question: http://stackoverflow.com/q/22067414
has body: An stackoverflowerror occurs whenever a specific part of the memory ("the stack") runs out. Basically you have ran out of memory allocated to your program in general without asking for any additional memory so your program crashes. Specifically the stack is used for all things related towards calling functions and threads so you could in theory you could even run out of memory by making a new thread (although you would first need to nearly fill it with function calls). Additionally the recursion does not need to be infinite just very large. public int foo(int i){ if (i=0) return 0; return (foo(i-1)+foo(i-1)%1000); } and then calling foo (10000) would result in a stackoverflow without being infinite. If you are more interested in finding out about the stack I would suggest how recursion works within a more low level language such as assembly where you can really see what your machine is doing (note that learning this will take quite a lot of afford but will make you a better programmer ).
score: 0
type: Answer

http://stackoverflow.com/q/22144038
has comment: http://stackoverflow.com/comment/33604397
has body: I'm trying to monitor a group of computer resources online. In order to do that, i'm using JFreechart and try to use multithreading in order to gain performance. Here is my code: class osGenel extends JPanel implements Runnable { String name; private static DefaultValueDataset[] DATASET; Integer VALUE,iii,sayac; Thread t; private static Sessionn[] obj; osGenel(String s,DefaultValueDataset valuedataset,Double n,Double w,Double c,int i) { name = s; iii=i; t = new Thread(this, name); this.setLayout(new GridLayout()); DATASET[iii]=valuedataset; MeterPlot meterplot = new MeterPlot(DATASET[iii]); meterplot.setDialShape(DialShape.CIRCLE); meterplot.setRange(new Range(0.0D, 100D)); meterplot.addInterval(new MeterInterval("Normal", new Range(0.0D, n), Color.lightGray, new BasicStroke(2.0F),Color.GREEN)); meterplot.addInterval(new MeterInterval("Warning", new Range(n, w), Color.lightGray, new BasicStroke(2.0F), Color.YELLOW)); meterplot.addInterval(new MeterInterval("Critical", new Range(w, c), Color.lightGray, new BasicStroke(2.0F), Color.RED)); meterplot.setNeedlePaint(Color.darkGray); meterplot.setDialBackgroundPaint(Color.white); meterplot.setDialOutlinePaint(Color.gray); meterplot.setMeterAngle(260); meterplot.setTickLabelsVisible(true); meterplot.setTickLabelFont(new Font("Dialog", 1,25)); meterplot.setTickLabelPaint(Color.darkGray); meterplot.setTickSize(5D); meterplot.setBackgroundPaint(Color.black); meterplot.setTickPaint(Color.lightGray); meterplot.setValuePaint(Color.black); meterplot.setValueFont(new Font("Dialog", 1, 0)); JFreeChart chart = new JFreeChart(s, JFreeChart.DEFAULT_TITLE_FONT, meterplot, true); this.add(new ChartPanel(chart, false)); t.start(); } public void run() { try { for (int i = 100; i &gt; 0; i--) { System.out.println(iii + ". Thread running"); Random r=new Random(); DATASET[iii].setValue(r.nextInt(100)); Thread.sleep(3000); } } catch (InterruptedException e) { System.out.println(name + "Interrupted"); } System.out.println(name + " Out."); } pu…
score: 0
answer count: 2
tagged with: thread-sleep
has answer: http://stackoverflow.com/a/22144510
has answer: http://stackoverflow.com/a/22144478
possible better answer: http://stackoverflow.com/a/22144510
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22144478
tagged with: java
tagged with: multithreading
has comment: http://stackoverflow.com/comment/33601708
has title: Multithreading in JFreeChart
tagged with: swing
tagged with: jfreechart
type: Question

http://stackoverflow.com/q/22163978
tagged with: generics
has title: How to instantiate generic class and call a method
score: 2
type: AnsweredQuestion
downvote count: 0
type: Question
tagged with: java
has comment: http://stackoverflow.com/comment/33636927
tagged with: switch-statement
upvote count: 2
answer count: 2
possible better answer: http://stackoverflow.com/a/22165030
has answer: http://stackoverflow.com/a/22164121
has answer: http://stackoverflow.com/a/22165030
accepted answer: http://stackoverflow.com/a/22164121
favorite count: 0
has body: Right now I have 4 classes which have common method to be called depending on the case as given in below example. Class1 class1 = new Class1(); Class1 class2 = new Class2(); Class1 class3 = new Class3(); Class1 class4 = new Class4(); MyEnum enum = MyEnum.valueOf(getString()); //getString() will return String "c1" or "c2" or .... switch(s) { case c1 : class1.add(); break; case c2 : class2.add(); break; case c3 : class3.add(); break; case c4 : class4.add(); break; } since there is a possibility of new classes later, I want to make the class initialization and method call generic. Please let me know the best way to achieve it. thanks in advance for suggestions.

http://stackoverflow.com/comment/33392552
comment on: http://stackoverflow.com/q/22026512
score: 0
type: QuestionComment
type: Comment
has text: It works fine for me. Are you sure that EL expression is in the view resolved from `home`?

http://stackoverflow.com/comment/33445638
type: Comment
has text: @jmcmahon- regarding Edit 2, could you please tell me how to do that?
comment on: http://stackoverflow.com/a/22050685
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33455306
type: AnswerComment
has text: Well, this answser sounds right to me. It is a corporate proxy so I am sure it is not an "attack", but the interception CA sounds plausible to me. Issue is that I cannot use the InstallCert as it makes a "native" ssl Socket that is not detected by the proxy settings. Is there a way to adapt the InstallCert program to be able to connect through the proxy? Or, is there another way of doing it?
type: Comment
comment on: http://stackoverflow.com/a/22059814
score: 0

http://stackoverflow.com/q/22008060
has answer: http://stackoverflow.com/a/22009374
accepted answer: http://stackoverflow.com/a/22009374
tagged with: composition
linked to: http://stackoverflow.com/q/22003666
has body: Note: I couldn't get formatting to work inside a code block for italics and things, so there is some makeshift markup to attempt to convey the meaning. Also the html escape character for a filled diamond would not work. Hopefully it still makes sense I have a project in my Java class where I need to create a GUI program that basically models a small inventory database. The main focus is to create it in an object oriented manner. So basically before getting started I've mapped out a simplified UML which just specifies the classes, composition and inheritance without defining variables or methods - implementing those will be easy but I want to make sure I have a solid heirarchial structure of good object oriented design before I start adding in the details. So if you could please take the time to look over my project structure and let me know if there's anything I should change, omit or add. The project will basically be a makeshift video game store application that simply reads and writes records to a text file, and the administrator managing the database should have a graphical interface to navigate, add, delete, and edit records. I will spruce it up nicely with some great functionality, but for right now, I'm only focused on making sure my structure is good. **list of classes** DatabaseRecord &lt;abstract&gt; VideoGameDatabaseRecord DatabaseNavigator Database &lt;abstract&gt; VideoGameDatabase Game &lt;abstract&gt; VideoGame &lt;abstract&gt; (superclass for platform-specific video games) XBoxGame PlaystationGame NintendoGame etc for all subclasses that would pertain to the needs of the inventory I'm still a little new to UML modelling, so I hope I've used conventions properly, and where text-based UML caused conventions to be impossible to follow, I hope the meaning is still clear with "a" and "c" inside diamonds to indicate aggregation or composition, and a capital "A" to indicate an abstract class (italics wouldn't show inside code markdown) ------A----- 0..* ---…
has comment: http://stackoverflow.com/comment/33363367
type: AnsweredQuestion
tagged with: oop
tagged with: java
has title: In need of critique for UML overview of project structure
tagged with: uml
linked to: http://stackoverflow.com/q/18813549
linked to: http://stackoverflow.com/q/22046222
type: Question
possible better answer: http://stackoverflow.com/a/22046725
has comment: http://stackoverflow.com/comment/33369031
tagged with: inheritance
has comment: http://stackoverflow.com/comment/33382823
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/22046725

http://stackoverflow.com/q/22115118
has answer: http://stackoverflow.com/a/22115228
score: 1
tagged with: java
type: Question
tagged with: hadoop
answer count: 1
downvote count: 0
has title: REST API conflicting with Hadoop
favorite count: 0
tagged with: rest
type: UnansweredQuestion
upvote count: 1
has body: This is the error I am getting. com.sun.jersey.api.container.ContainerException: A root resource, class org.apache.hadoop.hdfs.server.datanode.web.resources.DatanodeWebHdfsMethods, has a non-unique URI template / I am using Hadoop and REST API. This is how I am initialising REST API in web.xml ServletAdaptor com.sun.jersey.server.impl.container.servlet.ServletAdaptor 1 ServletAdaptor /RESTMOB/CALL/* I have tried removing the Hadoop JARs and it works, but I need those Hadoop JARs so what's the alternative. Thanks in advance

http://stackoverflow.com/comment/33626224
comment on: http://stackoverflow.com/a/22157739
score: 0
type: AnswerComment
type: Comment
has text: I've tried this, but it have the same output as ealier. im quite sure that problem is with: 'c.connectedFinancialAnalyst.completed is null or c.connectedFinancialAnalyst.completed = false'

size
tags question: http://stackoverflow.com/q/22166799
type: Tag
tag name: size

google-maps
tags question: http://stackoverflow.com/q/22054311
tag name: google-maps
tags question: http://stackoverflow.com/q/22122647
tags question: http://stackoverflow.com/q/22117552
tags question: http://stackoverflow.com/q/22041710
tags question: http://stackoverflow.com/q/22117197
tags question: http://stackoverflow.com/q/22008707
tags question: http://stackoverflow.com/q/22082278
tags question: http://stackoverflow.com/q/22106120
tags question: http://stackoverflow.com/q/22010326
tags question: http://stackoverflow.com/q/22047943
tags question: http://stackoverflow.com/q/22054649
tags question: http://stackoverflow.com/q/22160198
tags question: http://stackoverflow.com/q/22122401
tags question: http://stackoverflow.com/q/22050636
tags question: http://stackoverflow.com/q/22070050
tags question: http://stackoverflow.com/q/22031646
type: Tag
tags question: http://stackoverflow.com/q/22147802
tags question: http://stackoverflow.com/q/22116134
tags question: http://stackoverflow.com/q/22167081

http://stackoverflow.com/a/22164807
has comment: http://stackoverflow.com/comment/33654006
type: Answer
has comment: http://stackoverflow.com/comment/33666696
downvote count: 0
score: 1
has body: Simply create multiple properties file one for each enviroment to store the environment specific settings. Please have a look at below post to read the properties file at the time of server start-up. Retrieve Init parameters outside servlet EDIT I want to write a property in my static html file which will be read by gwt. If the property is dev gwt should load test1.gwt.xml if property is prod gwt should load test2.gwt.xml. Sample code that is written in your welcome file (index.jsp). &lt;!-- Read environment attribute from application --&gt; &lt;% String evn = application.getAttribute("env"); %&gt; &lt;% if("prod".equalsIgnoreCase(env)) { %&gt; &lt;script type="text/javascript" src="myproject/test2.nocache.js"&gt;&lt;/script&gt; &lt;% } else { %&gt; &lt;script type="text/javascript" src="myproject/test1.nocache.js"&gt;&lt;/script&gt; &lt;% } %&gt; Note: You can use JavaServer Pages Standard Tag Library instead of Scriptlets.
has comment: http://stackoverflow.com/comment/33653914
answers question: http://stackoverflow.com/q/22134141
has comment: http://stackoverflow.com/comment/33666353
has comment: http://stackoverflow.com/comment/33656308
upvote count: 1
has comment: http://stackoverflow.com/comment/33655653

quartz-scheduler
tags question: http://stackoverflow.com/q/22123429
type: Tag
tags question: http://stackoverflow.com/q/22157843
tags question: http://stackoverflow.com/q/22038265
tags question: http://stackoverflow.com/q/22164912
tags question: http://stackoverflow.com/q/22006829
tag name: quartz-scheduler
tags question: http://stackoverflow.com/q/22059898
tags question: http://stackoverflow.com/q/22067239

http://stackoverflow.com/a/22086275
score: 3
has body: You can try using String.format(): return String.format("|%3d|", some_variable); This method works similarly to System.out.printf()
upvote count: 3
accepted answer of: http://stackoverflow.com/q/22086252
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22086252
has comment: http://stackoverflow.com/comment/33497862
type: Answer
downvote count: 0

http://stackoverflow.com/a/22130698
has body: Change to terms.setContentView(R.layout.terms_conditions_dialog); btnDecline = (Button) terms.findViewById(R.id.btnDecline); btnAccept = (Button) terms.findViewById(R.id.btnAccept); The buttons belong to the Dialog. You need to find views in that view hierarchy. findViewById looks for a view in the current view hierarchy. The Buttons btnDecline and btnAccept do not belong to register.xml. They belong to terms_conditions_dialog.xml which is the layout for the Dialog.
accepted answer of: http://stackoverflow.com/q/22130677
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/22130677
type: Answer
score: 2
upvote count: 2

http://stackoverflow.com/comment/33414425
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22039199
has text: Isn't convert a template method here. I see Template Method Pattern!!
type: Comment

http://stackoverflow.com/q/22090558
type: Question
has title: Tcp Socket starts dropping connection after a time period in java
has answer: http://stackoverflow.com/a/22091188
score: 0
has comment: http://stackoverflow.com/comment/34424656
answer count: 1
has comment: http://stackoverflow.com/comment/33505034
tagged with: linux
type: UnansweredQuestion
tagged with: sockets
tagged with: tcp
tagged with: java
has comment: http://stackoverflow.com/comment/33507385
has body: I have a java server which listens for client requests. It is a multi threading environment. After a time period server starts rejecting the new connections and also drops already created established connections. Java Server is running on linux machine. Can Anyone help whether it is machine issue or code issue. linux have 1677216 tcp_wmem and tcp_rmem.

http://stackoverflow.com/comment/33564935
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/22123472
type: Comment
has text: You have to make sure posibles_terrenos and terrenos_validos are correctly initialized.

http://stackoverflow.com/a/23956554
type: Answer
upvote count: 11
has comment: http://stackoverflow.com/comment/85733651
score: 11
has body: I have the same problem, i read the url with an properties file: String configFile = System.getenv("system.Environment"); if (configFile == null || "".equalsIgnoreCase(configFile.trim())) { configFile = "dev.properties"; } // Load properties Properties properties = new Properties(); properties.load(getClass().getResourceAsStream("/" + configFile)); //read url from file apiUrl = properties.getProperty("url").trim(); URL url = new URL(apiUrl); //throw exception here URLConnection conn = url.openConnection(); dev.properties url = "https://myDevServer.com/dev/api/gate" it should be dev.properties url = https://myDevServer.com/dev/api/gate without "" and my problem is solved. According to oracle documentation Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a specification string or the string could not be parsed. So it means it is not parsed inside the string.
answers question: http://stackoverflow.com/q/22093864
downvote count: 0

http://stackoverflow.com/q/22119045
has title: Android not getting Json result
score: 0
has comment: http://stackoverflow.com/comment/33557405
has comment: http://stackoverflow.com/comment/33556879
answer count: 3
has comment: http://stackoverflow.com/comment/33558069
has answer: http://stackoverflow.com/a/22119205
linked to: http://stackoverflow.com/q/4737841
has comment: http://stackoverflow.com/comment/33556620
has comment: http://stackoverflow.com/comment/33556683
has comment: http://stackoverflow.com/comment/33557456
has comment: http://stackoverflow.com/comment/33558672
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22119792
tagged with: android
has comment: http://stackoverflow.com/comment/33557265
has answer: http://stackoverflow.com/a/22119729
has comment: http://stackoverflow.com/comment/33557483
has comment: http://stackoverflow.com/comment/33556835
has comment: http://stackoverflow.com/comment/33557755
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has comment: http://stackoverflow.com/comment/33557618
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33557319
has comment: http://stackoverflow.com/comment/33560370
type: Question
has comment: http://stackoverflow.com/comment/33558391
has body: Here is my code. This is just a snippet of the whole application. It makes a HTTP request and gets train data from septa. The code is correct as it works in a java project. One note, when I try to do the simple http request part in a separate java class and run it as a java file. In the run it gives me a Fatal Error: Invalid Layout of java.lang.String at value. I tried looking at the thread at this forum. Nothing works. No idea why this is happening. The code was working before! package com.cs275.septaassignment; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.net.HttpURLConnection; import android.app.Activity; import android.os.Bundle; import android.os.AsyncTask; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; import com.google.gson.*; import java.util.ArrayList; public class TrainInfo extends Activity { protected static String startStation; protected static String endStation; private ListView listView;//ListView for the output private ArrayAdapter&lt;String&gt; adapter;//Adapter to interact with the ListView protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.train_infolayout); startStation = this.getIntent().getExtras().getString("fromStation"); endStation = this.getIntent().getExtras().getString("toStation"); ArrayList&lt;String&gt; trainInfo = new ArrayList&lt;String&gt;(); adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, trainInfo);//initializing the ArrayAdapter listView = (ListView)findViewById(R.id.train_listView); listView.setAdapter(adapter);//Linking the adapter adapter.setNotifyOnChange(true);//This ensures that the changes in data so the UI components can refresh themselves TrainData trainSchedule = new TrainData(); trainSchedule.execute(); } public class TrainData extends AsyncTask&lt;Void,Void,Void&gt; { ArrayList&lt;String&gt; nextTrains; protected void onP…
has comment: http://stackoverflow.com/comment/33557282
has comment: http://stackoverflow.com/comment/33557684
has comment: http://stackoverflow.com/comment/33558053

http://stackoverflow.com/comment/33516752
has text: Yes, "static final" is a constant and should be all upper case (underscores are allowed), regular members should be in camel back with a lower case first character. Btw, do you really want this to be constant? Could the entity manager factory ever need to change during the VM lifetime?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22092586

http://stackoverflow.com/comment/33439707
has text: The first solution to that could work.. But I'd have to create a whole extra class and I don't think that's very efficient. Is the way I'm doing it possible?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22052457
score: 0

http://stackoverflow.com/a/22010860
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33365222
accepted answer of: http://stackoverflow.com/q/22010614
type: Answer
has body: You just include index for table also. For 1st table By.xpath("//table[1]//td[contains(text(),'Pearl')]/preceding-sibling::td") For 2nd table By.xpath("//table[2]//td[contains(text(),'Pearl')]/preceding-sibling::td")
answers question: http://stackoverflow.com/q/22010614
score: 0

http://stackoverflow.com/comment/33416127
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22040852
has text: Iterating is not possible?
score: 0

http://stackoverflow.com/comment/33493680
has text: I think you get it all - is there a way that will work? Perhaps we can call `values` through reflection and make a singleton Map - I don't know at this time.
type: Comment
score: 0
comment on: http://stackoverflow.com/a/22083796
type: AnswerComment

http://stackoverflow.com/comment/33541859
comment on: http://stackoverflow.com/a/22087251
score: 0
has text: Looks like a correct answer to me, except one thing: Use a[`BigDecimal`](http://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html) object rather than a `double` primitive. A `double` is floating-point which trades accuracy for speed. Creating the double may introduce extra digits in the decimal fraction. As the [Java Tutorial](http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html) says: `[double] should never be used for precise values, such as currency`.
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33569232
has text: reducing stacktrace size is something affecting the logs, "The other solution is to check the name before persisting" is affecting the code? Are you coding something using stacktraces???
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22125881
type: QuestionComment

http://stackoverflow.com/q/22053306
has answer: http://stackoverflow.com/a/25103839
has comment: http://stackoverflow.com/comment/39033762
has comment: http://stackoverflow.com/comment/33438733
score: 15
upvote count: 15
answer count: 2
has comment: http://stackoverflow.com/comment/39034721
has comment: http://stackoverflow.com/comment/39153434
tagged with: assertions
downvote count: 0
favorite count: 0
tagged with: exception
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/39033849
has title: Using AssertionError and assertions in java
has body: I use assertions in Java in a standard way, having them turned on in my IDE. So they are not part of production release. Lately I have been seeing code examples with throw new AssertionError() and I started thinking about the situation where AssertionError should be used instead of assertion. My guess is that main difference is the optionality of asserts so they don't slow down the production performance and so they can occur quite often in the code, but fixing hardly reproducible bugs reported from users is harder. For AssertionError, the exact opposite applies. I also find AssertionError more practical in places in code where the execution should not get, instead of using assert false //We should not be here. Especially if the return value is required. For example: int getFoo(AnEnum a){ if (a == AnEnum.ONE) return bar(); else if (a == AnEnum.TWO) return SOME_VALUE; //else assert false; //throw new AssertionError(); return -1; //not necessary when usin AssertionError } Is my reasoning correct? What are the other differences/use cases/best practices/limitations of either approach? In regards to providing a description in the AssertionError - Should it be provided or is the mere fact that it is an Error (and of assertion type) enough to be more or less sure that stack trace will be provided in case of found bugs?
has answer: http://stackoverflow.com/a/25087136
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33439037

http://stackoverflow.com/a/22024229
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33387032
has body: Don't use "? extends I" in your variable declaration. It adds no semantic value and is the source of your issue. You see the compiler is refusing to assume that the '?' in one declaration is identical to the '?' in another. This is natural since there is no guarantee that they are. I would dispense with the '?' altogether: interface I {} public class Test { TableView&lt;I&gt; table; Test(ObservableList&lt;? extends I&gt; list) { table = new TableView&lt;&gt;(); table.setItems(list); } }
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/22024056

http://stackoverflow.com/a/22135126
has comment: http://stackoverflow.com/comment/33586216
has comment: http://stackoverflow.com/comment/33586602
downvote count: 0
has comment: http://stackoverflow.com/comment/33586239
has comment: http://stackoverflow.com/comment/33586531
type: Answer
has comment: http://stackoverflow.com/comment/33587521
score: 1
has comment: http://stackoverflow.com/comment/33586601
upvote count: 1
has body: Probably, the reason is that by definition a function is supposed to have exactly one output. http://en.wikipedia.org/wiki/Function_(mathematics)
has comment: http://stackoverflow.com/comment/43676497
has comment: http://stackoverflow.com/comment/33586319
answers question: http://stackoverflow.com/q/22135035

http://stackoverflow.com/a/22880342
has body: You can use keyTyped event instead. From the documentation of InputListener, in contrast to keyUp and keyDown events which provide a keycode, keyTyped event provides you with the character converted from the keycode which can be directly used in your case. Good luck.
score: 4
has comment: http://stackoverflow.com/comment/34912633
type: AcceptedAnswer
type: Answer
upvote count: 4
has comment: http://stackoverflow.com/comment/34912493
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22082621
answers question: http://stackoverflow.com/q/22082621

http://stackoverflow.com/q/22015158
has title: Status from wire: INVALID_KEY status: null Google drive
possible better answer: http://stackoverflow.com/a/24395470
type: Question
has answer: http://stackoverflow.com/a/24395470
tagged with: java
has body: I am creating a Google Drive Integration in my existing app. I have followed Google Drive Integration instructions. I have created Oauth 2.0 client key for android using sha1 and package name. I am just using code from below link for testing purpose but I can't make it run. Tutorial But each time I try upload file I am getting below exception. 02-25 18:18:40.703: W/GLSActivity(1853): [anc] Status from wire: INVALID_KEY status: null 02-25 18:18:40.703: W/GLSActivity(1853): [anc] Status from wire: INVALID_KEY status: null 02-25 18:18:40.703: I/GLSUser(1853): GLS error: INVALID_KEY skypatel7@gmail.com oauth2:https://www.googleapis.com/auth/drive 02-25 18:18:40.710: W/GLSActivity(1853): [anc] Status from wire: Unknown status: UNKNOWN 02-25 18:18:40.710: W/System.err(24843): com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAuthIOException 02-25 18:18:40.718: W/System.err(24843): at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:224) 02-25 18:18:40.718: W/System.err(24843): at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:859) 02-25 18:18:40.718: W/System.err(24843): at com.google.api.client.googleapis.media.MediaHttpUploader.executeUploadInitiation(MediaHttpUploader.java:352) 02-25 18:18:40.718: W/System.err(24843): at com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:266) 02-25 18:18:40.718: W/System.err(24843): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:408) 02-25 18:18:40.718: W/System.err(24843): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:328) 02-25 18:18:40.718: W/System.err(24843): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:449) 02-25 18:18:40.718: W/System.err(24843): at com.sk…
answer count: 3
downvote count: 0
has answer: http://stackoverflow.com/a/22092602
favorite count: 0
has comment: http://stackoverflow.com/comment/37709087
tagged with: android
accepted answer: http://stackoverflow.com/a/22092602
score: 2
tagged with: google-drive-api
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/28157363
tagged with: google-drive-android-api
upvote count: 2

android-actionbar
type: Tag
tags question: http://stackoverflow.com/q/22044641
tags question: http://stackoverflow.com/q/22035942
tag name: android-actionbar
tags question: http://stackoverflow.com/q/22048106
tags question: http://stackoverflow.com/q/22008588

http://stackoverflow.com/a/22102053
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22101947
score: 0
has comment: http://stackoverflow.com/comment/33527787
has body: You need to implement Comparable. public class GEN implements Comparable&lt;GEN&gt; { int[][] mark=new int[TIMELIMIT][N+1]; int[][] dimark=new int[TIMELIMIT][N+1]; int time=0; int[] touched=new int[N+1]; int compareTo(GEN obj) { // compareTo returns a negative number if this is less than obj, // a positive number if this is greater than obj, // and 0 if they are equal. return this.time - obj.time; } } public GEN[] gend=new GEN[GENNUM]; By implementing Comparable, you are then able to use Arrays.sort() to sort your array once it is populated with GEN objects. The sort function uses compareTo to determine the proper ordering of the objects. Thus, once you've implemented Comparable, you only need to write: Arrays.sort(gend);
type: Answer
answers question: http://stackoverflow.com/q/22101947
has comment: http://stackoverflow.com/comment/33525894
has comment: http://stackoverflow.com/comment/33532448

http://stackoverflow.com/comment/33567413
has text: Please format the code example. It is unreadable.
comment on: http://stackoverflow.com/q/22124885
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22159664
type: Answer
score: 3
upvote count: 3
has body: You are attempting to an an integer (i)--specifically the index of the for loop--to an ArrayList&lt;T&gt;. A list of T is not a list of ints, hence the compiler is not allowing you to do this. You need to do something like this: list.add(someTObject); The only way to make an integer work is to declare T as Number: And since you are passing a Number into GenerateList (which is a function and really should be lowercase: generateList), I suspect you perhaps want this to be public class Generator&lt;N extends Number&gt; { public ArrayList&lt;N&gt; GenerateList(N n) { //N, not Number ArrayList&lt;N&gt; list = new ArrayList&lt;&gt;(); for (int i = 0; i &lt; n.intValue(); i++) { //Must be n.intValue() list.add(n); //THIS WORKS FOR N } return list; } } and then in the using class, declare &lt;N&gt; as Integer: Generator&lt;Integer&gt; intGen = new Generator&lt;Integer&gt;(); intGen.GenerateList(3); I'm not sure what the for-terminator should be now, but I can't imagine i &lt; n.intValue() is right.
downvote count: 0
answers question: http://stackoverflow.com/q/22159564

http://stackoverflow.com/comment/33506689
comment on: http://stackoverflow.com/q/22089554
score: 0
has text: @Flawyte Suppose u have saved a contact as 123456789 and added it to your blacklist.If u receive a call from that contact as +33123456789,it wont block.Works perfectly if the contact was saved with +31,
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/80423297
type: AnswerComment
has text: This is literally copied directly from the question.
type: Comment
comment on: http://stackoverflow.com/a/46368810
score: 1

program-entry-point
tags question: http://stackoverflow.com/q/22051031
tag name: program-entry-point
tags question: http://stackoverflow.com/q/22093274
tags question: http://stackoverflow.com/q/22135762
type: Tag
tags question: http://stackoverflow.com/q/22150650
tags question: http://stackoverflow.com/q/22039952

http://stackoverflow.com/a/22073709
has comment: http://stackoverflow.com/comment/33476923
has comment: http://stackoverflow.com/comment/33511806
has comment: http://stackoverflow.com/comment/33514500
has comment: http://stackoverflow.com/comment/81013131
score: 18
has body: I am fairly sure that your code simply leaks and eventually runs out of connections. do { CloseableHttpResponse resp = httpClient.execute(httpGet); try { // Do what you have to do // but make sure the response gets closed no matter what // even if do not care about its content } finally { resp.close(); } } while (nextPage);
upvote count: 18
accepted answer of: http://stackoverflow.com/q/22069821
has comment: http://stackoverflow.com/comment/33512385
has comment: http://stackoverflow.com/comment/33499859
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22069821
downvote count: 0
has comment: http://stackoverflow.com/comment/33514231
has comment: http://stackoverflow.com/comment/33514613
type: Answer
has comment: http://stackoverflow.com/comment/33481059

http://stackoverflow.com/a/22093669
answers question: http://stackoverflow.com/q/22093306
has body: This kind of conditions are suitable for loop ... until structure, as others said you never enter the loop so use : for(int i = 0; i == 16; i++) { ... } or if you insist on a structure like loop... until(cond.) or do-while(!cond.) : int i = 0; do{ if(i == i) { System.out.println("true"); check = true; } else{ check = false; } }while( ++i != 16 ); that is not readable at all (at least I think so) and I think it's not convenient for any Java programmer.
score: 0
type: Answer

http://stackoverflow.com/a/22167243
answers question: http://stackoverflow.com/q/22157957
score: 2
has comment: http://stackoverflow.com/comment/33689379
downvote count: 0
has body: Ha, found one! Look in the JavaEE 7 API: The interface javax.websocket.MessageHandler.Whole should be what you are looking for.
upvote count: 2
type: Answer

http://stackoverflow.com/comment/33427894
type: Comment
has text: You shouldn't be needing to do that, what is your disconnect logic?
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22046752

http://stackoverflow.com/q/22109202
score: 0
answer count: 1
has body: I have a query as follow: select(SELECT sum(Frequency) FROM omid.entity_epoch_data where DataitemType=0 and EntityID in(SELECT EntityID FROM omid.entity where PartyID=2) and EpochID in( SELECT ID FROM omid.epoch where StartDateTime&gt;='2013-11-01' and EndDateTime&lt;='2013-11-30'))/ (select count(*) from omid.entity where PartyID=2); when I run it in my sql it works but when I run it in java I get some sql error. My code is set up truly since when I replace this query with something else it works so it shows that something is wrong with the logic of using this query Can anyone help?
has answer: http://stackoverflow.com/a/22109404
has comment: http://stackoverflow.com/comment/33539198
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33539178
type: Question
has comment: http://stackoverflow.com/comment/33539668
has comment: http://stackoverflow.com/comment/33539161
tagged with: java
tagged with: mysql
has comment: http://stackoverflow.com/comment/33539243
has title: query works in mysql but it does not work in java

http://stackoverflow.com/q/22037326
downvote count: 0
tagged with: textview
favorite count: 0
tagged with: drag-and-drop
tagged with: android
has comment: http://stackoverflow.com/comment/33411160
has title: Android drag drop multiple textviews
has comment: http://stackoverflow.com/comment/33410319
type: AnsweredQuestion
score: 3
has answer: http://stackoverflow.com/a/22326851
linked to: http://stackoverflow.com/q/18725601
upvote count: 3
tagged with: java
has body: I'm currently making an android application for the game battleship. I have made model classes for my ships in the form of a viewgroup with multiple textviews in this viewgroup (4 for battleship, 2 for submarine and so on) My field consists of a TableLayout with multiple (10x10) textviews with a background of water. I am now trying to implement a drag and drop where this viewgroup could be dropped into multiple textviews, currently only the textview my mouse is on contains the viewgroup (or at least it takes the same background as the viewgroup i'm dropping) Is there any way to drop my viewgroup, or something else where i can insert multiple textviews or other type of views, into multiple views on my field update: my fields are now relativelayouts so my ship is actually being put on them rather than the background being recoloured, but if i put my ship, which is 4 times the size of one of the fields on my board, it just puts it on one field and moves the rest of the fields 3 places to the right (so let's say the view of my ship is 40px and my field is 10px, the first 10px of my ship is locked on a relativelayout (or field) and the other 30px of my ship is pushing the field apart, so there is a 30px black space between the column where i put my ship and where the next column is) EDIT: I'm currently developping on android api level 14 if this helps in any way
type: Question
accepted answer: http://stackoverflow.com/a/22326851
tagged with: viewgroup
answer count: 1

http://stackoverflow.com/a/28866014
answers question: http://stackoverflow.com/q/22118004
has body: I've manage run Tomcat with JMX (Tomcat 8, Windows) by: add -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false run with admin permissions
score: 4
upvote count: 4
has comment: http://stackoverflow.com/comment/119952062
downvote count: 0
type: Answer

http://stackoverflow.com/comment/33636757
has text: The whole point of multi-threading is to get simultaneous action. The main thread and the other threads will rotate in execution. If you called the .join() method on your threads, that will ensure that the other threads finish executing before the main thread continues.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22163922
type: Comment

http://stackoverflow.com/comment/33436425
has text: If the class is long enough to need a separate logger, it probably shouldn't be anonymous.
comment on: http://stackoverflow.com/q/22052137
type: QuestionComment
score: 8
type: Comment

http://stackoverflow.com/a/22130180
type: Answer
answers question: http://stackoverflow.com/q/22129843
has comment: http://stackoverflow.com/comment/33579529
has comment: http://stackoverflow.com/comment/33578169
score: 0
has body: For example @override protected void onResume() { super.onResume(); square1.setText(pref.getString("square1", "")); square1.setTag("square1"); // you can define view tag in xml layout /* * to square9 */ } @Override public void onClick(View v) { pref.edit().putString((String)v.getTag(),currentPlayer).commit(); if (currentPlayer.equal("X") currentPlayer = "O"; else currentPlayer = "X"; } and don't forget to reset value before start a new game

http://stackoverflow.com/comment/33602100
has text: @AbstractChaos true, as long as "do something" does not involve `List#add(...)`
score: 5
type: QuestionComment
comment on: http://stackoverflow.com/q/22144671
type: Comment

http://stackoverflow.com/comment/33648455
score: 0
type: Comment
has text: @Akhil please change your component scan base package value to com.quest.*
type: AnswerComment
comment on: http://stackoverflow.com/a/22166772

http://stackoverflow.com/q/22009964
has comment: http://stackoverflow.com/comment/33361290
tagged with: java
has comment: http://stackoverflow.com/comment/33695838
has comment: http://stackoverflow.com/comment/33361263
type: Question
has title: OnStart () is called after OnStop() and that is making problems for my aplication
score: 0
has answer: http://stackoverflow.com/a/22010040
answer count: 2
tagged with: android
has comment: http://stackoverflow.com/comment/33361055
has body: First I would like to say that I am sorry for the vague title. I didn't know what else to name this question. I have 2 activities (ActivityA, ActivityB). In ActivityA I have overridden the onStop() function and I change value X in a singleton. When I go to ActivityB and onStart() is called I check the value X. The problem is that onStart() is called before onStop() and the value I check in the onStart() function is still the old value before onStop() changes it. I know why onStart() is called before onStop(). What I am asking you guys is an alternative solution to this problem I am currently having. I need to save a value in ActivityA before I close it and I need to check for the same value in ActivityB. ActivityB can be accessed from several other activities not just ActivityA. And the otehr activities dont change the value. SOLVED I changed onStop() to onPause() That worked. Thanks guys!
has comment: http://stackoverflow.com/comment/33361086
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33360983
has comment: http://stackoverflow.com/comment/33361060
has answer: http://stackoverflow.com/a/22010119

http://stackoverflow.com/a/22294775
has comment: http://stackoverflow.com/comment/34690760
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/34657972
upvote count: 2
accepted answer of: http://stackoverflow.com/q/22151686
has body: Theoretically there is no restriction as you could easily store images as binary in Kafka Queue. But there could be other issues .. I would try to put some thought on this There is a message.max.bytes parameter in the consumer config and the default value is 1000000. This is done actually to prevent brokers from running out of memory because the consumer does not have option for streaming a message and has to allocate memory to be able to read the message. A workaround could be to compress messages in Kafka in order to save spaces. The most suitable condition I could find is to write your own client implementation by passing pre-allocation of send&amp;receive buffers, providing zero-copy file transfer over Kafka as seen in this discussion. You need to check if it is possible to make such effort to achieve the same.
type: Answer
answers question: http://stackoverflow.com/q/22151686
score: 2
downvote count: 0

http://stackoverflow.com/q/22028501
tagged with: java
has body: I'm pretty new to Java and this website, and I'm sorry if this question has already been asked but if it isn't to hard, an answer would be extremely helpful.
linked to: http://stackoverflow.com/q/363681
tagged with: prng
type: Question
downvote count: 4
upvote count: 0
answer count: 1
duplicate of: http://stackoverflow.com/q/363681
score: -4
has title: How can I generate random numbers between 0 and a user input number?
has comment: http://stackoverflow.com/comment/33394972
has comment: http://stackoverflow.com/comment/33394905
favorite count: 0
has comment: http://stackoverflow.com/comment/33394912
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22028721

http://stackoverflow.com/q/22135386
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33586878
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/22135523
has comment: http://stackoverflow.com/comment/33586689
score: 0
has comment: http://stackoverflow.com/comment/33586687
answer count: 1
has title: Problems decoding printed bytearray
has body: I am printing a byte array of image in my code. I am trying to debug it by printing it but this is the output i am seeing in console- 03-02 13:49:03.764 25818-25848/com.example.listviewandroid I/System.out﹕ [B@41484350tehe repub size: 0 What does this mean? is it getting the byte array here or what? public void getImage(byte[] data) { try { imagedata = data; System.out.print(data); // imgTakenPhoto.removeAllViews(); Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length); imgTakenPhoto.setImageBitmap(bmp); imgTakenPhoto.setVisibility(ImageView.VISIBLE); frameLayout.setVisibility(View.GONE); } catch (Exception e) {} } I am trying to find out what is in "Data" here
has answer: http://stackoverflow.com/a/22135523

http://stackoverflow.com/comment/33396900
type: QuestionComment
comment on: http://stackoverflow.com/q/22029359
has text: you mean closing tag sign (>)? Yes, it is part of it.
score: 0
type: Comment

http://stackoverflow.com/comment/33531341
score: 0
comment on: http://stackoverflow.com/q/22104161
has text: Apart from @DavidWallace's correct answer there is a dirty little trick: You can put something at the start of the string before the ` `, e.g. a space. Of course this changes the alignment.
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22152407
tagged with: eclipse
type: Question
answer count: 2
upvote count: 0
has comment: http://stackoverflow.com/comment/33619361
score: -3
has answer: http://stackoverflow.com/a/22152450
has comment: http://stackoverflow.com/comment/33625661
tagged with: android
has answer: http://stackoverflow.com/a/22152506
has title: onPause in eclipse gives syntax error and void is invalid type
has body: I'm using the onPause method in my activity, but I'm receiving the following errors: Syntax error, insert ";"to complete LocalVariableDeclarationStatement void is an invalid type for the variable onPause Code: public class MusicActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_music); final MediaPlayer MP = MediaPlayer.create(MusicActivity.this, R.raw.burntumber); Button burntumberPlay = (Button) findViewById(R.id.start1Button); burntumberPlay.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { MP.start(); } }); Button burntumberStop = (Button) findViewById(R.id.stop1Button); burntumberStop.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { MP.pause(); MP.seekTo(0); } }); @Override protected void onPause{ super.onPause(); MP.stop(); MP.release(); }; } } EDIT: public class MusicActivity extends Activity { MediaPlayer MP = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_music); MP = MediaPlayer.create(MusicActivity.this, R.raw.burntumber); Button burntumberPlay = (Button) findViewById(R.id.start1Button); burntumberPlay.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { MP.start(); } }); Button burntumberStop = (Button) findViewById(R.id.stop1Button); burntumberStop.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //MP.stop(); //won't restart when start() is run again MP.pause(); //MP.seekTo(0); } }); } @Override protected void onPause{ super.onPause(); MP.stop(); MP.release(); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.music, menu); return true; } } Errors: Syntax error, insert ";" to complete FieldDeclaration The annotation…
favorite count: 0
has comment: http://stackoverflow.com/comment/33616130
type: UnansweredQuestion
tagged with: java
downvote count: 3

http://stackoverflow.com/a/22144818
upvote count: 3
has body: It is sometimes expected that a List&lt;Object&gt; would be a supertype of a List&lt;String&gt; , because Object is a supertype of String . This expectation stems from the fact that such a type relationship exists for arrays: Object[] is a supertype of String[] , because Object is a supertype of String . (This type relationship is known as covariance .) The super-subtype-relationship of the component types extends into the corresponding array types. No such a type relationship exists for instantiations of generic types. (Parameterized types are not covariant.) Check here for more details
downvote count: 0
answers question: http://stackoverflow.com/q/22144671
type: Answer
score: 3

http://stackoverflow.com/comment/33369834
type: QuestionComment
comment on: http://stackoverflow.com/q/22014233
has text: Propably a duplicate: http://stackoverflow.com/questions/11537103/how-to-handle-print-dialog-in-selenium
score: 0
type: Comment

http://stackoverflow.com/q/22033027
downvote count: 0
tagged with: adt
has answer: http://stackoverflow.com/a/22071639
has title: How to open a project in eclipse ADT and automatically import LIbrary Projects dependencies
tagged with: android
score: 1
favorite count: 0
has answer: http://stackoverflow.com/a/22033281
type: UnansweredQuestion
answer count: 4
has answer: http://stackoverflow.com/a/22058618
tagged with: java
has body: Just started developing android apps using Eclipse ADT. I've never used Eclipse before so not sure if this is an ADT specific question or an eclipse question. So I started by creating a new project. I have another project that I would like to use as a project library, so I copied that into the libs folder. My project now looks something like this MyApp libs OtherProject res src ... I then imported the OtherProject as an existing project and set it as a library. Now my package explorer contains two projects: MyApp, and OtherProject I then right-clicked --> Properties on my main project, went to Android, and then added the other project as a library. Everything works. I pushed it to a repository and then cloned it to a separate folder to verify that everything still works. Now, I'm not sure what to do here to open the project, so I went and imported the newly checked out project, but it says its missing the OtherProject dependency, and I can see that it wasn't automatically added to the package explorer. What is the proper way to open a project?
has answer: http://stackoverflow.com/a/22033244
upvote count: 1
has comment: http://stackoverflow.com/comment/33402493
tagged with: eclipse
type: Question
has comment: http://stackoverflow.com/comment/33425281

http://stackoverflow.com/comment/33503647
has text: I've copied your code into an empty project. And it works fine, I can see the camera preview in surfaceview. That's weird. My phone is Android 4.0.3. Maybe you should try another phone.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22088995

http://stackoverflow.com/a/22019301
score: 0
has body: I am assuming you are using Eclipse. If you go to the Android Virtual Device Manager, select Device Definitions... pick the device you are using as the emulator. you can Edit the settings for this on the right-hand side. Select check the boxes next to Portrait enabled and landscape enabled to toggle orientation off and on. However, you do not say whether or not your app is ACTUALLY supposed to be in landscape orientation, or if it is the emulator displaying the app in landscape..
type: Answer
answers question: http://stackoverflow.com/q/22018128

http://stackoverflow.com/comment/33436690
comment on: http://stackoverflow.com/a/22051142
has text: There was a conflict as my sub module also has 'surefire-report' plugin included. Then it works fine,Tnx
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33498377
type: QuestionComment
has text: I didn't understand what he meant by not compiling as I believe my program runs. Thank you very much for your comment. I will talk to my professor.
comment on: http://stackoverflow.com/q/22086506
score: 0
type: Comment

http://stackoverflow.com/comment/33467353
score: 0
type: AnswerComment
has text: I do think it reasonable for an interface to have protected methods as part of the interface. Not my fault the java designers didn't ask me. :)
type: Comment
comment on: http://stackoverflow.com/a/22069583

http://stackoverflow.com/comment/33680331
type: QuestionComment
has text: Current java version is $ java -version java version "1.6.0_30" OpenJDK Runtime Environment (IcedTea6 1.13.1) (rhel-4.1.13.1.el5_10-x86_64) OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
score: 0
comment on: http://stackoverflow.com/q/22081505
type: Comment

http://stackoverflow.com/a/22139044
has body: private ArrayList&lt;BinItem&gt; myContents; You just declared myContents and never initialized it. Hence it is null. Initialize it while declaring it. private List&lt;BinItem&gt; myContents= new ArrayList&lt;BinItem&gt;(); Or you can do it just before using it. Without initialization your line myContents.add(b); at runtime looks like null.add(b);
score: 0
answers question: http://stackoverflow.com/q/22139037
type: Answer

http://stackoverflow.com/comment/35550244
has text: Seems your eclipse jaxb plugin pointing incompatible jaxb-ri files ..
comment on: http://stackoverflow.com/q/22090510
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22056265
type: Question
tagged with: processing
has answer: http://stackoverflow.com/a/22056335
answer count: 1
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/22056335
type: AnsweredQuestion
score: 1
tagged with: java
has body: I'm programming in Processing, and trying to get a rectangle to appear at the location of the mouse and stay there every time the mouse is clicked. However, when I run the program and click the mouse, the rectangle only stays for second, before it disappears. Is there another way to write it so that the rectangle isn't dependent on the mouse being clicked to exist? Here is my code: void setup() { size(250, 350); } void draw() { background(255); fill(255); tileAp(); } void tileAp() { fill(0); if(mousePressed &amp;&amp; mouseX &lt;= 250 &amp;&amp; mouseX &gt;= 0 &amp;&amp; mouseY &gt;= 0 &amp;&amp; mouseY &lt;= 250) { drawM(true); } else { } } void drawM(boolean b) { if(b == true) { rect(mouseX, mouseY, 25, 25); } }
upvote count: 1
has title: How do I draw a rectangle every time the mouse is clicked in a certain area?

http://stackoverflow.com/q/22158168
tagged with: class
answer count: 1
tagged with: language-agnostic
favorite count: 0
has answer: http://stackoverflow.com/a/22196670
type: AnsweredQuestion
score: 1
tagged with: java
tagged with: hibernate
tagged with: uml
has body: I have a relational model where entities usually have relationships with two qualifiers, start_date and end_date, so to keep a history of past relationships. When presented with the task of creating a data model with Hibernate, I faced the problem of dealing with these relationships that break the usual many-to-many relationship case. For instance let's say a user can have a certain access permission (which is in fact a real case), and we want to model the history of permissions a user has had: | USER | | has_permission | | PERMISSION | |--------| |----------------| |------------| | userId |------|userId |------|permissionId| | user | |permissionId | |permission | ---------- |start_date | ------------- |end_date | ------------------ Now how would you do this in a class model? What one would do in a regular case, creating a User class with a list of Permissions is no longer valid. Given that I have lots of entities, I don't want to end up with lots of "HasX" classes that only hold up another reference plus the startDate and the endDate. Whats the common way to solve this problem? I use Hibernate, but I guess the answer would be language-agnostic.
upvote count: 1
accepted answer: http://stackoverflow.com/a/22196670
has title: Modeling qualified relations in Hibernate
type: Question
downvote count: 0

http://stackoverflow.com/a/22087132
accepted answer of: http://stackoverflow.com/q/22087039
answers question: http://stackoverflow.com/q/22087039
type: AcceptedAnswer
has body: The tabCount variable is inside the while loop therefore it is getting reset for every iteration i.e. it will always be 0 try public static void processLine(String text) { Scanner data = new Scanner(text); int tabCount = 0; while (data.hasNext()){ String str = "hi"; str = data.next(); System.out.print(str + " "); if (str.equals("{")) { tabCount++; System.out.println(); for (int i = 0; i &lt; TAB_SIZE * tabCount; i++){ System.out.print(" "); } } }
upvote count: 3
type: Answer
downvote count: 0
score: 3

http://stackoverflow.com/comment/33622533
comment on: http://stackoverflow.com/a/22155235
type: Comment
has text: @DSquare Thank you for fixing my code! I tried changing the alignment to setAlignmentX(Component.RIGHT_ALIGNMENT) but it didn't work. Could you please tell me why it did not work?
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33414175
type: QuestionComment
has text: http://ui-programming.blogspot.in/2011/01/java-swing-date-picker-dialog-to-select.html
comment on: http://stackoverflow.com/q/22039652
score: 0
type: Comment

http://stackoverflow.com/comment/33447429
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22058087
has text: @mbroshi i didn't pay attention to return part xD
score: 0

http://stackoverflow.com/comment/33644933
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22168643
has text: I'm guessing you want to return a `List<Map<String, Object>>`
score: 0

http://stackoverflow.com/comment/33385751
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22023669
has text: Thanks I tested this but it yields the same result. Is there a way to check what space is denoted with?
type: Comment

http://stackoverflow.com/comment/33617425
has text: I knew this would require some serious handwaving at the compiler. Is there any better reason why you have to do this and not just `Argument<AOCD>.class` than That's The Way It Is?
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22153106

http://stackoverflow.com/q/22167659
type: Question
has answer: http://stackoverflow.com/a/22170620
answer count: 2
tagged with: jpa
downvote count: 0
tagged with: guice-persist
favorite count: 0
has title: @Transactional annotation not starting transaction (Guice Persist)
accepted answer: http://stackoverflow.com/a/22170620
has body: I am trying to create a simple service class with a @Transactional annotated method using Guice Persist: public class TestServiceImpl implements TestService { @Inject private Provider&lt;EntityManager&gt; entityManager; @Override @Transactional public Long createEvent(String name) { Event event = new Event(name); System.out.println("Is transaction active? " + entityManager.get().getTransaction().isActive() ); entityManager.get().persist(event); return event.getId(); } } Unfortunately no transaction is created by Guice Persist. Log output can be seen here: http://pastebin.com/Mh5BkqSC Note the print on line 450: Is transaction active? false The result is that nothing is stored in the database: mydb=# \d List of relations Schema | Name | Type | Owner --------+--------------------+----------+---------- public | events | table | postgres public | hibernate_sequence | sequence | postgres (2 rows) mydb=# select * from events; id | name ----+------ (0 rows) mydb=# I setup the application in the following way: public static void main(String[] args) { Injector injector = Guice.createInjector(new TestModule(), new JpaPersistModule("postgresPersistenceUnit")); PersistService persistService = injector.getInstance(PersistService.class); persistService.start(); TestService serviceToTest = injector.getInstance(TestService.class); Long id = serviceToTest.createEvent("test"); System.out.println("Id: " + id); } As you can see TestService is created by Guice, and I am using the JpaPersistModule, which should be what does the @Transactional wiring. I have created a small Maven project demonstrating the problem: https://github.com/uldall/guice-persist-error
has answer: http://stackoverflow.com/a/36865788
type: AnsweredQuestion
tagged with: transactions
score: 7
tagged with: java
tagged with: hibernate
possible better answer: http://stackoverflow.com/a/36865788
upvote count: 7

http://stackoverflow.com/q/22054820
possible better answer: http://stackoverflow.com/a/22055008
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/22055008
has answer: http://stackoverflow.com/a/22055021
tagged with: java
has body: I'm trying to create a partition function that accepts three parameters: a text string, a pattern string, and an integer k. The goal is to store the contents of the pattern of length m in a string array of k+1 fragments, where each fragment is of length m/k+1 (or as close to). For instance if the string "ABCDEFGHIJKLMNOPQRSTUVWXYZ" is parsed to the method where k = 2 The array should look something like this [ABCDEFGHI, JKLMNOPQ, RSTUVWXYZ] The program runs fine when m/k+1 is divided evenly, however when result produces a remainder the results are off. I’ve noticed that the errors seems to correspond with the remainder of m/k+1 This is the part of the code I'm having problems with: public static String[] partition(String text, String pattern, int k) { String[] fragment = new String[k+1]; int f = k+1; int m = pattern.length(); int fragmentSize = (int)Math.floor(m/f); int lastCharIndex; // cannot partition evenly{ int i = 0; while(i &lt; f) { // set the first partition as the largest if(fragment[i] == fragment[0]) { fragmentSize = (int)Math.ceil(m/f); lastCharIndex = i * fragmentSize; fragment[i] = pattern.substring(lastCharIndex, lastCharIndex+fragmentSize); } else { fragmentSize = (int)Math.floor(m/f); lastCharIndex = i * fragmentSize; fragment[i] = pattern.substring(lastCharIndex, lastCharIndex+fragmentSize); } i++; } return fragment; Using the example above the output I’m currently receiving is [ABCDEFGHI, IJKLMNOP, QRSTUVWX] I have a feeling it has something to do with the explicit cast of fragmentSize, but I can't figure out a way around it. Any help would be much appreciated.
tagged with: partitioning
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22055021
type: Question
has title: Java partition method

http://stackoverflow.com/a/22290078
score: 0
answers question: http://stackoverflow.com/q/22147265
type: Answer
has body: Ok. I think important point already covered that is wait() release the monitor/lock so other thread can come to synchronized block. But I wanted to add 2 important point. 1. when use wait() don't forget to check for condition when or on which you should wait. You might become victim of spurious wakeup calls. Check this link http://handling-thread.blogspot.co.uk/2012/11/what-is-spurious-wakeup-while-wait-in.html 2. If you are considering wait-notify approach I would suggest go for latest solution for the same approach which is using Condition.await-signal For your reference I have updated the code by Condition approach. import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class WaitNotifyExample { /** * @param args */ public static void main(String[] args) { Message msg = new Message("process it"); Waiter waiter = new Waiter(msg); new Thread(waiter, "waiter").start(); Waiter waiter1 = new Waiter(msg); new Thread(waiter1, "waiter1").start(); Notifier notifier = new Notifier(msg); new Thread(notifier, "notifier").start(); //System.out.println("All the threads are started"); } } class Message { final Lock lock = new ReentrantLock(); final Condition msgAvailable = lock.newCondition(); private String msg = null; public Message(String str) { this.msg = str; } public String getMsg() { return msg; } public void setMsg(String str) { this.msg = str; } public void lock() { lock.lock(); } public void await() throws InterruptedException { msgAvailable.await(); } public void unlock() { lock.unlock(); } public void signal() { msgAvailable.signal(); } public void signalAll() { msgAvailable.signalAll(); } } class Waiter implements Runnable { private Message msg; public Waiter(Message m) { this.msg = m; } @Override public void run() { String name = Thread.currentThread().getName(); msg.lock(); try { System.out.println(name + " waiting to get notified at time:" + System.currentTimeMillis() + " Objec…

list
type: Tag
tags question: http://stackoverflow.com/q/22129523
tags question: http://stackoverflow.com/q/22101923
tags question: http://stackoverflow.com/q/22128154
tags question: http://stackoverflow.com/q/22124831
tags question: http://stackoverflow.com/q/22083518
tags question: http://stackoverflow.com/q/22085093
tags question: http://stackoverflow.com/q/22159803
tags question: http://stackoverflow.com/q/22108369
tags question: http://stackoverflow.com/q/22121982
tags question: http://stackoverflow.com/q/22014912
tags question: http://stackoverflow.com/q/22057540
tag name: list
tags question: http://stackoverflow.com/q/22087751
tags question: http://stackoverflow.com/q/22117744
tags question: http://stackoverflow.com/q/22078377
tags question: http://stackoverflow.com/q/22117741
tags question: http://stackoverflow.com/q/22139645
tags question: http://stackoverflow.com/q/22163898
tags question: http://stackoverflow.com/q/22018385
tags question: http://stackoverflow.com/q/22053412
tags question: http://stackoverflow.com/q/22127734
tags question: http://stackoverflow.com/q/22119327
tags question: http://stackoverflow.com/q/22026635
tags question: http://stackoverflow.com/q/22153206
tags question: http://stackoverflow.com/q/22083104
tags question: http://stackoverflow.com/q/22064916
tags question: http://stackoverflow.com/q/22026683

http://stackoverflow.com/q/22165991
has comment: http://stackoverflow.com/comment/33640288
upvote count: 1
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/22166561
has comment: http://stackoverflow.com/comment/33640230
score: 0
has body: How to separate the components from the sql method? I need to get this set of code separated from the rest. I am having difficulty because it linked. Component droplabel = new DropTargetTextArea("test", "testing"); JLabel cellLabel = new JLabel(icon); JPanel cellPanel = new JPanel(new BorderLayout()); cellPanel.add(cellLabel, BorderLayout.NORTH); cellPanel.add(droplabel, BorderLayout.CENTER); gridPanel.add(cellPanel); ////full code connection = getConnection(); try { statement = (PreparedStatement) connection .prepareStatement("select image from image"); result = statement.executeQuery(); while (result.next()) { byte[] image = null; image = result.getBytes("image"); Image img = Toolkit.getDefaultToolkit().createImage(image); ImageIcon icon = new ImageIcon(img); Component droplabel = new DropTargetTextArea("test", "testing"); JLabel cellLabel = new JLabel(icon); JPanel cellPanel = new JPanel(new BorderLayout()); cellPanel.add(cellLabel, BorderLayout.NORTH); cellPanel.add(droplabel, BorderLayout.CENTER); gridPanel.add(cellPanel); } }
answer count: 2
favorite count: 0
type: UnansweredQuestion
has title: separate two sets of code
has comment: http://stackoverflow.com/comment/33640706
tagged with: components
has answer: http://stackoverflow.com/a/22166516
has comment: http://stackoverflow.com/comment/33640318
tagged with: java

http://stackoverflow.com/q/22101984
has comment: http://stackoverflow.com/comment/33525881
type: Question
has comment: http://stackoverflow.com/comment/33525887
upvote count: 0
has comment: http://stackoverflow.com/comment/33525716
has answer: http://stackoverflow.com/a/22102171
answer count: 1
has body: This loop is only looping twice... int currentPosition = 10; int nextPosition; do { nextPosition = currentPosition + 1; sectionSem[nextPosition].P(); // wait for the section ahead to be // free trackSections[nextPosition] = "[A" + trainName + "]"; // move // forward trackSections[currentPosition] = "[..]"; // clear section vacated // record the train activity theTrainActivity.addMovedTo(nextPosition); sectionSem[currentPosition].V(); // signal the section you vacated // now free currentPosition += 1; } while (currentPosition &lt; 18); Any idea why? It should be looping 8 times?!
favorite count: 0
has title: do while loop - only looping twice - should be looping 8 times
has comment: http://stackoverflow.com/comment/33525786
accepted answer: http://stackoverflow.com/a/22102171
downvote count: 3
has comment: http://stackoverflow.com/comment/33525805
has comment: http://stackoverflow.com/comment/33525785
type: AnsweredQuestion
tagged with: java
score: -3

http://stackoverflow.com/comment/33493100
has text: Also your code does not compile.
comment on: http://stackoverflow.com/q/22083429
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22021970
tagged with: java
has answer: http://stackoverflow.com/a/63634228
has answer: http://stackoverflow.com/a/22022349
accepted answer: http://stackoverflow.com/a/22022349
score: 46
has body: I want to try this library in my android project. I am using Android Studio 0.4.6. The README.markdown file tells me to insert this inside pom.xml: keytwo.net Keytwo.net Repository http://audiobox.keytwo.net io.socket socket.io-client 0.2.1 The problem is that I do not have any pom.xml. I created one in my project root directory and synced gradle settings but it does nothing. Till now I only used already compiled .jar files or used the gradle compile function. How can I use this library in my project?
answer count: 2
downvote count: 0
favorite count: 0
upvote count: 46
tagged with: android
has title: Add java library to Android Studio project with maven repository
tagged with: android-studio
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/63634228
tagged with: maven
tagged with: gradle
type: Question

http://stackoverflow.com/comment/33570759
type: Comment
comment on: http://stackoverflow.com/a/22094423
has text: Ok, thanks, that looks well. The thing is I was looking for a way around to avoid the person from holding a reference to the answers (so we can separate concerns correctly and assign the members to the correct objects) and create a third class that manages the user, the question and the answer (kind of a Model class) so that we can avoid mingling things that do not belong to certain objects. But perhaps that solution does not exist or is kind of "weird" (weird we might say?). Anyways If you come up with another solution (aka Design Pattern), I'd be glad to hear it :)
score: 0
type: AnswerComment

http://stackoverflow.com/q/22012602
has comment: http://stackoverflow.com/comment/33365402
favorite count: 0
tagged with: parsing
has comment: http://stackoverflow.com/comment/33365397
has comment: http://stackoverflow.com/comment/33366117
tagged with: multithreading
upvote count: 1
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22013203
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22012839
linked to: http://stackoverflow.com/q/453018
possible better answer: http://stackoverflow.com/a/22012946
type: Question
has body: I have a method to parse txt file and saving datas to database. Method named: parseFileAndSaveToDB(String fileAddress); This file are big (100 000 rows) so inserting datas into DB are very long. Can anyone help me with do this in multithreading?? I think that each thread can use this method with each files forexample: parseFileAndSaveToDB("c:/file1");//thread 1 parseFileAndSaveToDB("c:/file2");//thread 2 parseFileAndSaveToDB("c:/file3");//thread 3 parseFileAndSaveToDB("c:/file4");//thread 4 But how to do it with multithreads?? And is it good idea?
has answer: http://stackoverflow.com/a/22012946
has comment: http://stackoverflow.com/comment/33365832
has comment: http://stackoverflow.com/comment/33365541
has answer: http://stackoverflow.com/a/22012904
downvote count: 0
has title: Java parsing txt file multithreading
accepted answer: http://stackoverflow.com/a/22012839
has comment: http://stackoverflow.com/comment/33365337

http://stackoverflow.com/q/22102334
possible better answer: http://stackoverflow.com/a/22102527
has comment: http://stackoverflow.com/comment/33526691
has comment: http://stackoverflow.com/comment/33526595
linked to: http://stackoverflow.com/q/2156120
has answer: http://stackoverflow.com/a/22102527
has comment: http://stackoverflow.com/comment/33526486
tagged with: clone
has answer: http://stackoverflow.com/a/22104305
tagged with: java
has comment: http://stackoverflow.com/comment/33526499
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/22102507
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33526609
type: Question
has title: Cloning different objects in Java
has comment: http://stackoverflow.com/comment/33526555
has body: I have two database tables which are mirror images of each other. The reason for this is one table stores "CURRENT" values and the other tables saves "ARCHIVED" values. I use hibernate as the ORM tool. The tables have 20 columns each . The business requirement is that the values in the "current" table gets house-keeped at specific intervals to "archive" table. It is cumbersome to copy the values from "current" object to "archive" object. Is there a way in JAVA to clone objects of different types (current object to archive object)? The elements of the objects are identical.
accepted answer: http://stackoverflow.com/a/22102507
answer count: 3
upvote count: 1

dreamweaver
type: Tag
tag name: dreamweaver
tags question: http://stackoverflow.com/q/22035204

push-notification
tags question: http://stackoverflow.com/q/22148356
tags question: http://stackoverflow.com/q/22098961
tags question: http://stackoverflow.com/q/22068820
type: Tag
tags question: http://stackoverflow.com/q/22092773
tag name: push-notification
tags question: http://stackoverflow.com/q/22110624

methods
tags question: http://stackoverflow.com/q/22118184
tags question: http://stackoverflow.com/q/22123972
tags question: http://stackoverflow.com/q/22153445
tags question: http://stackoverflow.com/q/22160928
tags question: http://stackoverflow.com/q/22044525
tags question: http://stackoverflow.com/q/22055452
tags question: http://stackoverflow.com/q/22079429
tags question: http://stackoverflow.com/q/22084735
tags question: http://stackoverflow.com/q/22043994
tags question: http://stackoverflow.com/q/22109197
tags question: http://stackoverflow.com/q/22089027
tag name: methods
tags question: http://stackoverflow.com/q/22078231
tags question: http://stackoverflow.com/q/22142456
tags question: http://stackoverflow.com/q/22056770
tags question: http://stackoverflow.com/q/22119883
tags question: http://stackoverflow.com/q/22054028
type: Tag
tags question: http://stackoverflow.com/q/22136195
tags question: http://stackoverflow.com/q/22057252
tags question: http://stackoverflow.com/q/22148860
tags question: http://stackoverflow.com/q/22037373
tags question: http://stackoverflow.com/q/22021758
tags question: http://stackoverflow.com/q/22137724
tags question: http://stackoverflow.com/q/22049667
tags question: http://stackoverflow.com/q/22011835
tags question: http://stackoverflow.com/q/22103263
tags question: http://stackoverflow.com/q/22119441
tags question: http://stackoverflow.com/q/22153140
tags question: http://stackoverflow.com/q/22026020
tags question: http://stackoverflow.com/q/22061764
tags question: http://stackoverflow.com/q/22084982
tags question: http://stackoverflow.com/q/22120122
tags question: http://stackoverflow.com/q/22054755
tags question: http://stackoverflow.com/q/22089898
tags question: http://stackoverflow.com/q/22116246
tags question: http://stackoverflow.com/q/22027276
tags question: http://stackoverflow.com/q/22077914
tags question: http://stackoverflow.com/q/22084301
tags question: http://stackoverflow.com/q/22110855
tags question: http://stackoverflow.com/q/22050391
tags question: http://stackoverflow.com/q/22119046
tags question: http://stackoverflow.com/q/22056883
tags question: http://stackoverflow.com/q/22030937

http://stackoverflow.com/a/22032946
has comment: http://stackoverflow.com/comment/33533245
type: Answer
accepted answer of: http://stackoverflow.com/q/22032877
score: 0
answers question: http://stackoverflow.com/q/22032877
has body: You are picking random player from the list and adding to the same list. Another thing you are adding the choice outside of your loop. Also you are never initializing protected ArrayList&lt;Player&gt; players; So it is always null which is an instance variable. When you are calling pickPlayers() function players is a local variable.
type: AcceptedAnswer

http://stackoverflow.com/q/22031751
has body: Am trying to delete all files in a folder and its content. Am using the below code File deltmpfile = new File(destinationpt); deltmpfile.delete(); please answer
has answer: http://stackoverflow.com/a/22031777
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/33400369
downvote count: 5
has title: how to delete all files in a folder using default java package
favorite count: 0
type: UnansweredQuestion
score: -4
tagged with: java
has answer: http://stackoverflow.com/a/22031794
upvote count: 1

qlikview
tags question: http://stackoverflow.com/q/22034583
tag name: qlikview
type: Tag

http://stackoverflow.com/comment/33540995
has text: for android:name="com.google.android.gcm.GCMBroadcastReceiver" i have changed it to android:name="com.iotproj.clandestine".GCMBroadcastReceiver", still not working
score: 0
comment on: http://stackoverflow.com/a/22110245
type: AnswerComment
type: Comment

http://stackoverflow.com/a/22020381
answers question: http://stackoverflow.com/q/22020123
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/33380397
accepted answer of: http://stackoverflow.com/q/22020123
score: 1
has comment: http://stackoverflow.com/comment/33380519
upvote count: 1
has body: You are going to have difficulty sorting your arrays as-is because you currently store your data in parallel arrays: distancearray[i][0]=Double.parseDouble(array[i][0]); distancearray[i][1]=Double.parseDouble(array[i][2]); distancearray[i][3]=Distance; You can sort distancearray[n] but that will give you nonsense results. Instead what you should do is create a small class that implements Comparable (comparing based on distance) that holds your three values, then work with an array of those classes: class DistanceInfo implements Comparable&lt;DistanceInfo&gt; { public double a; public double b; public double distance; public DistanceInfo (double a, double b, double distance) { this.a = a; this.b = b; this.distance = distance; } @Override public int compareTo (DistanceInfo d) { return Double.compare(distance, d.distance); } } // then: DistanceInfo[] distancearray = new DistanceInfo[array.length]; // and you can load it using the constructor: for (int i = 0; i &lt; array.length) { double a = Double.parseDouble(array[i][0]); double b = Double.parseDouble(array[i][1]); distancearray[i] = new DistanceInfo(a, b, Distance); } (The fields can be made final if you wish to specify that they cannot be modified after construction.) Now, Arrays.sort() will sort distancearray based on distance: Arrays.sort(distancearray, null); You could also use an ArrayList&lt;DistanceInfo&gt; instead, the idea is the same except you sort with Collections.sort(). In general, for this reason (among others) it is usually better to use a class to store all information about an object as opposed to parallel arrays. As an aside, you may want to consider using this class for array as well, it will simplify your code a bit (you can modify displaymarkers to take a DistanceInfo, and you can also avoid parsing the same double more than once).

http://stackoverflow.com/comment/33356689
score: 0
comment on: http://stackoverflow.com/q/22007128
type: QuestionComment
type: Comment
has text: @ArneBurmeister i have learned that there are two kind of programmers which hate instance of and which don't and i am non :D some compare instance of with go-to

http://stackoverflow.com/comment/33429798
has text: I updated my post to answer some of your questions. But I still don't understand your problem exactly. This is a trivial I/O operation and it shouldn't require a 3rd-party library.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22021462
type: Comment

http://stackoverflow.com/comment/33406540
type: Comment
type: QuestionComment
has text: Suggest if there is any other way to commit or import into svn using java
comment on: http://stackoverflow.com/q/22035383
score: 0

http://stackoverflow.com/q/22149201
downvote count: 0
has comment: http://stackoverflow.com/comment/33610258
favorite count: 0
has title: Multiple tests with multiple throws
has comment: http://stackoverflow.com/comment/33610253
tagged with: throw
type: AnsweredQuestion
upvote count: 1
type: Question
tagged with: testing
has answer: http://stackoverflow.com/a/22149379
score: 1
tagged with: java
has body: I would like to create a method that will test different things and throw an error depending on the issue (and then exit the program). I am not really familiar with throwing exception... Is this method a good way to program it? private static void testConnexions() throws IOException, Exception { File file = null; Socket socket; try { // Test access to the repository: file = new File(pdfRepository); if (!file.canRead()) throw new SecurityException(); if (!file.canWrite()) throw new SecurityException(); if (!file.exists()) throw new SecurityException(); if (!file.isDirectory()) throw new SecurityException(); // Connection to Filenet: connexion = new FilenetConnexion(filenetURI, objectStoreName, stanza, dossierRacine, userName, password); connexion.connect(); // Connection to a socket: socket = new Socket(serveurCV, portCV); // Initialize the JavaMail Session: Properties props = System.getProperties(); if (serveurSMTP != null) props.put("mail.smtp.host", serveurSMTP); Session session = Session.getInstance(props, null); } catch (SecurityException e) { e.getMessage(); e.printStackTrace(); } catch (UnknownHostException e) { e.getMessage(); e.printStackTrace(); } catch (IOException e) { e.getMessage(); e.printStackTrace(); } catch (Exception e) { e.getMessage(); e.printStackTrace(); } } I would like to catch a message detailed enough to know if the repository can't be written in, or if the System.getProperties() got an error, etc. Thank you in advance for your help! EDIT: Here is the solution I chose among all your contributions, hoping it can help someone: private static void testConnexions() { File file = null; Socket socket; // Test access to the repository: try { file = new File(pdfRepository); if (!file.canRead()) throw new SecurityException(pdfRepository + " can't be read."); if (!file.canWrite()) throw new SecurityException(pdfRepository + " can't be written."); if (!file.exists()) throw new SecurityException(pdfRepository + " doesn't exist."); if (!file.isDirectory…
has answer: http://stackoverflow.com/a/22149525
has comment: http://stackoverflow.com/comment/33611530
has comment: http://stackoverflow.com/comment/33610066
answer count: 2
possible better answer: http://stackoverflow.com/a/22149379
accepted answer: http://stackoverflow.com/a/22149525

http://stackoverflow.com/comment/33595856
type: QuestionComment
comment on: http://stackoverflow.com/q/22140776
score: 0
has text: @EbadSaghar: Ok, shouldn't be a problem then.
type: Comment

http://stackoverflow.com/comment/33591778
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22138185
has text: It works fine on some servers.So I think there might be something wrong about the environment,like java or resin config

http://stackoverflow.com/q/22150076
tagged with: semantic-web
score: 0
has body: I have designed some rules and am wondering what the reasoner is is returned by the Jena's GenericRuleReasonerFactory (as shown in the following code)? Is it Racer, Pellet, or HermiT? Reasoner reasoner = GenericRuleReasonerFactory.theInstance().create(configuration);
answer count: 1
favorite count: 0
tagged with: http://stackoverflow.com/tag/rdf
has comment: http://stackoverflow.com/comment/33626779
type: AnsweredQuestion
tagged with: jena-rules
tagged with: java
has answer: http://stackoverflow.com/a/22157397
accepted answer: http://stackoverflow.com/a/22157397
upvote count: 1
has comment: http://stackoverflow.com/comment/33626829
downvote count: 1
type: Question
tagged with: jena
has title: What kind of reasoner is produced by GenericRuleReasonerFactory?

http://stackoverflow.com/comment/33642672
comment on: http://stackoverflow.com/q/22167192
score: 0
type: Comment
type: QuestionComment
has text: I'm using 4.1.2(API level 16).

http://stackoverflow.com/a/28607636
answers question: http://stackoverflow.com/q/22083207
has body: Install the newest version of eclipse (E.g. Luna) (Fine for EE too). Install the WindowBuilder plug-in through help->Install new software by providing the link "http://dl.google.com/eclipse/inst/d2wbpro/latest/4.2". Update the plug-in through Help->Check for updates. Cheers. :) Shevon Silva.
score: 0
type: Answer

http://stackoverflow.com/q/22117643
linked to: http://stackoverflow.com/q/3066590
score: 1
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33557761
has body: Hi I am doing a project for my university and i am developing a robot which could use ACO(Ant Colony Optimization) for finding a shortest route out of the maze.I am using a finch robot and I am trying to build a GUI for the path travelled by the robot. I am recording a path in an arrayList in a form of x-y co-ordinates and trying to display the path recorded in some form of display(like a moving dot in specified co-ordinate). Since I am a beginner in using graphics or visuals in java i am having trouble creating a display.Can you suggest what tool could i use to track the path of the robot?Currently I am programming in Java in Eclipse.Thank in advance.
linked to: http://stackoverflow.com/q/14886232
tagged with: japplet
upvote count: 1
has comment: http://stackoverflow.com/comment/33553922
has title: Tools for building a GUI for the given co-ordinates
favorite count: 0
answer count: 0
downvote count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33579450
tagged with: swing

http://stackoverflow.com/q/22054629
type: Question
answer count: 2
has body: I am gettine error when running my java application. My application is bundled in a .jar file. It means xsd file is in the .jar file. Error: class path resource [classpath*:myschema.xsd] cannot be opened because it does not exist source of the error: @Value("classpath*:myschema.xsd") private Resource xsdFile; public boolean validateXML()() throws IOException { boolean isValidXMLFile = false; Source xmlFile = new StreamSource(new File(xmlDataFile)); SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = null; File outXsdFile = new File("autogenpath.xsd"); InputStream is =xsdFile.getInputStream(); OutputStream out=new FileOutputStream(outXsdFile); IOUtils.copy(is, out); try { schema = schemaFactory.newSchema(outXsdFile); } catch (SAXException e1) { e1.printStackTrace(); isValidXMLFile = false; log.debug("Error reading schema " + e1.getMessage()); } try { Validator validator = schema.newValidator(); validator.validate(xmlFile); log.debug(xmlFile.getSystemId() + " is valid"); isValidXMLFile = true; } catch (SAXParseException e) { isValidXMLFile = false; log.debug(xmlFile.getSystemId() + " is NOT valid"); log.debug("Reason\t\t: " + e.getLocalizedMessage()); log.debug("Line Number \t: " + e.getLineNumber()); log.debug("Column Number\t: " + e.getColumnNumber()); log.debug("Public Id\t: " + e.getPublicId()); } catch (SAXException e) { isValidXMLFile = false; log.debug(xmlFile.getSystemId() + " is NOT valid"); log.debug("Reason\t: " + e.getLocalizedMessage()); } finally{ try{ out.close(); }catch(Exception e){ e.printStackTrace(); } } return isValidXMLFile; }
tagged with: jar
accepted answer: http://stackoverflow.com/a/22054855
tagged with: xsd
has title: error finding class path file in jar file
score: 0
has answer: http://stackoverflow.com/a/22055072
has answer: http://stackoverflow.com/a/22054855
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22055072
tagged with: java

http://stackoverflow.com/q/22035553
tagged with: java
type: Question
possible better answer: http://stackoverflow.com/a/22036290
has answer: http://stackoverflow.com/a/22054677
accepted answer: http://stackoverflow.com/a/22054677
tagged with: date
answer count: 3
has answer: http://stackoverflow.com/a/51510605
downvote count: 0
favorite count: 0
has body: I want to display a stored date (timezone is UTC) formatted with the user's timezone (may vary per each user and is stored in profile). The solution I came up with is the following one and I want to know if this is the best way to do it, or if there is another, maybe simpler solution. Timezone set to UTC with: -Duser.timezone=UTC Controller, Freemarker-Template, HandlerInterceptor: Controller: @Controller @RequestMapping("/test") public class TestController { @RequestMapping public String dateTest(Model model){ final Date date = new Date(); model.addAttribute("formattedDate", new SimpleDateFormat("hh:mm:ss").format(date)); model.addAttribute("date", date); return "test"; } } Freemarker-Template: &lt;#setting time_zone="${currentTimeZone}"&gt; UTC Time: ${formattedDate}&lt;br/&gt; Localized time for timezone &lt;i&gt;${currentTimeZone}&lt;/i&gt;: ${date?time} HandlerInterceptor: public class TimezoneHandlerInterceptor extends HandlerInterceptorAdapter{ @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { //Only for testing, in production something like: //final String currentUserTimezone = userService.getCurrentUser().getTimezoneId(); final String currentUserTimezone = "Europe/Berlin"; modelAndView.addObject("currentTimeZone", currentUserTimezone); } } Output: UTC Time: 08:03:53 Localized time for timezone Europe/Berlin: 09:03:53 So is there a more standard or even out of the box way to achieve the same result? Thanks for your help.
has answer: http://stackoverflow.com/a/22036290
tagged with: freemarker
score: 6
tagged with: spring
upvote count: 6
tagged with: spring-mvc
type: AnsweredQuestion
has title: Best way to handle user specific date/timezone conversion with Spring MVC + Freemarker

http://stackoverflow.com/a/22062965
answers question: http://stackoverflow.com/q/22062803
type: Answer
has body: I think you need to loop over all items in listaBanesave and check if each meets the criteria and, if none of them do, return null. Currently your code returns null if the first item does not meet the criteria - i.e. it could be rewritten as: public Banesa gjejBanese(int nrBaneses) { if(listaBanesave.length == 0) return null; return (listaBanesave[0].getNrBanesa() == nrBaneses) ? listaBanesave[0] : null; } Presumably this isn't what you want. public Banesa gjejBanese(int nrBaneses) { for (int i = 0; i &lt; listaBanesave.length; i++) { if (listaBanesave[i].getNrBanesa() == nrBaneses) { return listaBanesave[i]; } } return null; } So check each item in the loop; it if matches, return it. Otherwise, once the loop is finished, you know you have no match - the return null.
score: 0

http://stackoverflow.com/comment/33385458
comment on: http://stackoverflow.com/q/22023292
type: Comment
has text: what is the difference between onDraw() and dispatchDraw(). as far as I'm aware they are both called when the instance is added to the screen?
score: 0
type: QuestionComment

http://stackoverflow.com/comment/33592385
comment on: http://stackoverflow.com/q/22138851
has text: @JerryJeremiah okay so I did what you said and that fixes repeated "not in array" 50 times, but once I insert say 25 and 25 is in the array it just does nothing, although it doesn't terminate the program goes nowhere
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/33624666
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22154154
has text: "defaults to a time in history": it uses the time zone offset that was in force at the date to convert.
type: Comment

jscrollpane
tags question: http://stackoverflow.com/q/22145630
tag name: jscrollpane
tags question: http://stackoverflow.com/q/22118238
tags question: http://stackoverflow.com/q/22040701
type: Tag
tags question: http://stackoverflow.com/q/22043452
tags question: http://stackoverflow.com/q/22071173
tags question: http://stackoverflow.com/q/22100605
tags question: http://stackoverflow.com/q/22131947

http://stackoverflow.com/q/22025029
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33388846
upvote count: 1
has comment: http://stackoverflow.com/comment/33403327
tagged with: boxlayout
type: Question
has answer: http://stackoverflow.com/a/22042842
linked to: http://stackoverflow.com/q/5621338
has comment: http://stackoverflow.com/comment/33389670
tagged with: layout
has title: JButton Appears on One Computer, But Not Others (BorderLayout)
downvote count: 0
has comment: http://stackoverflow.com/comment/33389501
answer count: 1
tagged with: preferredsize
has comment: http://stackoverflow.com/comment/33389538
has comment: http://stackoverflow.com/comment/33389618
has comment: http://stackoverflow.com/comment/33388443
favorite count: 0
type: UnansweredQuestion
has body: I am new to Swing. I am building a JFrame with a JScrollPane inside it using Eclipse IDE. Inside of the JScrollPane is a JPanel in Border Layout. I tried to add a JButton (called "submitAnswers") to the JFrame using the code below, but for some reason the button only appears at the end of the frame on my computer, but not on other computers (my friend tried it on his Mac and I tried it on a separate Windows OS like mine). Some proposed solutions that I have tried and from other sites that have not worked include: Use the pack() method. Reason: since the preferred size of the JPanel is much longer in height than the JFrame (hence I employed a JScrollPane), packing the JFrame only causes the text to be not visible on the desktop. Place button on content JPanel. Reason: I don't know. It just wouldn't appear on another desktop computer or my friend's mac computer. Use BorderLayout.SOUTH instead of BorderLayout.PAGE_END. Reason: There was absolutely no change. The button would still be visible on my computer, but invisible on others. Place button directly on JFrame. Reason: I don't know. In addition, my JFrame is nested within a static method; hence, I've only included the relevant code for the specific method I'm having issues with. Has anyone had this issue before? I would really appreciate your insight. Code: public static void createTestPage() { JFrame testFrame = new JFrame("testing...1,2,3"); //Customizes icon to replace java icon try { testFrame.setIconImage(ImageIO.read(new File("src/icon.png"))); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //Centers location of introFrame to center of desktop Dimension screenDimensions = Toolkit.getDefaultToolkit().getScreenSize(); testFrame.setLocation(screenDimensions.width / 16,screenDimensions.height / 14); //Size and display the introFrame. Insets insets = testFrame.getInsets(); //Format size of screen itself testFrame.setSize(1200 + insets.left + insets.right, 400 + insets.top + 25…
has comment: http://stackoverflow.com/comment/33389473
tagged with: swing
linked to: http://stackoverflow.com/q/12226198
linked to: http://stackoverflow.com/q/17874717
has comment: http://stackoverflow.com/comment/33389542

http://stackoverflow.com/q/22066070
tagged with: resultset
answer count: 1
tagged with: connector
has title: Result set used as an instance variable
has body: In a program, the connector, preparedstatement and resultset are used as instance variables and closed every time after its use in a separate method as given below and then reused by creating a new connector object, assigning it to con for the subsequent calls. Is it safe to do this or is it better to create separate connector objects locally in methods and closing it in finally block? private void closeObjects() throws Exception{ if(rs!=null){ rs.close(); rs=null; } if(preparedstmt!=null){ preparedstmt.close(); preparedstmt=null; } if(con!=null){ con.close(); con=null; } } I actually did face an issue where using as instance variables when I ran the program the first time, it failed giving an error Result set not open but started working after on the second run onwards. [Apologies for not displaying the whole code]
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33460391
tagged with: java
tagged with: prepared-statement
type: Question
has answer: http://stackoverflow.com/a/22066707
has comment: http://stackoverflow.com/comment/33461604
score: 0

http://stackoverflow.com/q/22089104
has answer: http://stackoverflow.com/a/22143316
accepted answer: http://stackoverflow.com/a/22143316
type: AnsweredQuestion
downvote count: 0
has comment: http://stackoverflow.com/comment/33502688
score: 1
favorite count: 0
type: Question
has title: Directory not creating other than WEB-INF & META-INF in WAR using Maven pom.xml
has body: I need to create war for my spring framework project using maven(pom.xml) mvn clean install command. My Project SpringMVC folder contains jsp and src folder all folder in src is creating inside the web-inf but i need to create jsp and other folder outside web-inf. pom.xml build tag code SpringMVC maven-compiler-plugin resource2 In war file jsp folder not creating near web-inf. I don't know what else to try. My Expected Output Folder Structure SpringMVC.war |-- META-INF | |-- MANIFEST.MF | `-- maven | `-- com.example.projects | `-- documentedproject | |-- pom.properties | `-- pom.xml |-- WEB-INF | |-- classes | | |-- com | | | `-- example | | | `-- projects | | | `-- SampleAction.class | | `-- images | | `-- sampleimage.jpg | `-- web.xml |-- external-resource.jpg |-- image2 | `-- external-resource2.jpg |-- index.jsp `-- jsp `-- websource.jsp
answer count: 2
tagged with: web-applications
upvote count: 1
tagged with: maven
tagged with: directory-structure
tagged with: spring
linked to: http://stackoverflow.com/q/1873140
possible better answer: http://stackoverflow.com/a/22089723
has answer: http://stackoverflow.com/a/22089723
has comment: http://stackoverflow.com/comment/33502905
tagged with: java

http://stackoverflow.com/q/22148782
has answer: http://stackoverflow.com/a/22173462
linked to: http://stackoverflow.com/q/14794885
tagged with: maven-plugin
upvote count: 12
downvote count: 0
has answer: http://stackoverflow.com/a/24500630
linked to: http://stackoverflow.com/q/3187879
tagged with: maven
has answer: http://stackoverflow.com/a/29948481
type: Question
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33609711
has answer: http://stackoverflow.com/a/25945539
tagged with: java
has answer: http://stackoverflow.com/a/30101601
has title: Unable to connect to the Eclipse Luna Market
tagged with: eclipse
score: 12
has comment: http://stackoverflow.com/comment/33609537
has comment: http://stackoverflow.com/comment/33615280
accepted answer: http://stackoverflow.com/a/22173462
possible better answer: http://stackoverflow.com/a/24500630
has answer: http://stackoverflow.com/a/29842479
answer count: 6
tagged with: eclipse-plugin
has comment: http://stackoverflow.com/comment/56154991
favorite count: 0
has body: I cant connect my Eclipse Luna distribution to the market for install Maven 2 pluggin. This my configuration : Eclipse : - Eclipse Luna M5 Release, I configured a proxy My computer : - Windows XP 32bits this is the error message : !SESSION 2014-03-03 14:55:53.568 ----------------------------------------------- eclipse.buildId=4.4.0.I20140123-1600 java.version=1.6.0_29 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=fr_FR Framework arguments: -product org.eclipse.epp.package.standard.product Command-line arguments: -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.standard.product !ENTRY org.eclipse.core.net 1 0 2014-03-03 14:56:01.676 !MESSAGE System property http.proxyHost is not set but should be &lt;myProxy_url&gt;. !ENTRY org.eclipse.core.net 1 0 2014-03-03 14:56:01.692 !MESSAGE System property http.proxyPort is not set but should be &lt;myProxy_port&gt;. !ENTRY org.eclipse.core.net 1 0 2014-03-03 14:56:01.692 !MESSAGE System property https.proxyHost is not set but should be &lt;myProxy_url&gt;. !ENTRY org.eclipse.core.net 1 0 2014-03-03 14:56:01.692 !MESSAGE System property https.proxyPort is not set but should be &lt;myProxy_port&gt;. !ENTRY org.eclipse.core.net 1 0 2014-03-03 14:56:01.692 !MESSAGE System property https.proxyHost is not set but should be &lt;myProxy_url&gt;. !ENTRY org.eclipse.core.net 1 0 2014-03-03 14:56:01.708 !MESSAGE System property https.proxyPort is not set but should be &lt;myProxy_port&gt;. !ENTRY org.eclipse.epp.mpc.ui 4 0 2014-03-03 14:56:14.988 !MESSAGE Cannot open Eclipse Marketplace !STACK 1 org.eclipse.core.runtime.CoreException: Cannot install remote marketplace locations: Bad HTTP Request: http://marketplace.eclipse.org/catalogs/api/p at org.eclipse.epp.internal.mpc.ui.commands.MarketplaceWizardCommand.execute(MarketplaceWizardCommand.java:101) at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:290) at org.eclipse.ui.internal.handlers.E4HandlerProxy.…

http://stackoverflow.com/a/22116818
has comment: http://stackoverflow.com/comment/33552540
answers question: http://stackoverflow.com/q/22116299
score: 0
type: Answer
has body: Since 1.5, all Method reflection methods are varargs for the parameter values/types. This looks wrong: method.invoke(obj, null); If there are no parameters, call it thus: method.invoke(obj); Simlarly, this: Method method = cls.getDeclaredMethod(test.getName(), noparams); can/should be just Method method = cls.getDeclaredMethod(test.getName());

http://stackoverflow.com/comment/33445097
comment on: http://stackoverflow.com/a/22055876
type: Comment
has text: It's part of a project so I need to implement my bSearch in the insertInOrder method.
score: 0
type: AnswerComment

http://stackoverflow.com/q/22147596
type: Question
has answer: http://stackoverflow.com/a/22148023
has title: CMS-initial-mark took 800+ ms, it it normal?
linked to: http://stackoverflow.com/q/10669482
has comment: http://stackoverflow.com/comment/33607195
has comment: http://stackoverflow.com/comment/33608003
has body: GC setting is: Min, max, total JVM size (-Xms -Xmx) JVM_SIZE="-Xms24g -Xmx24g" New Generation Sizes (-Xmn) JVM_SIZE_NEW="-Xmn2g" Type of Garbage Collector to use JVM_GC_TYPE="-XX:+UseConcMarkSweepGC -XX:+UseParNewGC" Tuning options for the above garbage collector JVM_GC_OPTS="-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=75 -XX:SurvivorRatio=8 -XX:+CMSParallelRemarkEnabled -XX:+CMSScavengeBeforeRemark -XX:+UseCMSCompactAtFullCollection -XX:+CMSClassUnloadingEnabled" Maybe 24g is too bigger for CMS? 2014-03-03T19:34:10.687+0800: 74.121: [GC [1 CMS-initial-mark: 1431731K(23068672K)] 3170863K(24956160K), 0.8289630 secs] [Times: user=0.83 sys=0.00, real=0.83 secs] Total time for which application threads were stopped: 0.8294730 seconds
answer count: 1
downvote count: 0
favorite count: 0
type: UnansweredQuestion
score: 1
tagged with: java
tagged with: garbage-collection
upvote count: 1

http://stackoverflow.com/comment/33408451
comment on: http://stackoverflow.com/a/22036572
type: AnswerComment
type: Comment
has text: @th1rdey3: I've given a better (IMO) alternative to *either* of the pieces of code you've got at the moment, assuming the image file is already in the format you want.
score: 1

http://stackoverflow.com/comment/33575194
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22115924
has text: Depends on what you want to limit. If your data set is small you could just iterate over end nodes and pick the ones you like. If you have more data and want to do fancier stuff you could look into traversal descriptions, see http://docs.neo4j.org/chunked/2.0.1/tutorial-traversal.html

http://stackoverflow.com/comment/33623939
score: 0
type: AnswerComment
has text: You mean I have to pass the document to "Commanders" too? I'm new at this. Could you please be more explanatory and specific?
type: Comment
comment on: http://stackoverflow.com/a/22155847

http://stackoverflow.com/a/22095096
has body: use File file=new File(System.getProperty("user.dir")+"\\src\\HordingDept\\report2.jrxml");
type: AcceptedAnswer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33513395
accepted answer of: http://stackoverflow.com/q/22094989
type: Answer
has comment: http://stackoverflow.com/comment/33543869
answers question: http://stackoverflow.com/q/22094989
upvote count: 1
has comment: http://stackoverflow.com/comment/33512899

http://stackoverflow.com/a/22160470
type: Answer
has body: There are a number of problems... You're mouseDragged event handler is adding the same Rectangle to the a ArrayList, over and over again, increasing the counter value along with it. This is not required. All you need to do is add the Rectangle on the mousePressed event. When mouseReleased is called, you could evaluate the Rectangle to check if the size is greater than 0x0 and remove it if it's not (ie remove any Rectangle whose size is 0x0) Don't rely on the counter variable, it's too easy for the value to become misaligned with the size of the a List. Instead, rely on a.size instead. The switch statement in your ActionListener is evaluating the matching case, but also all the following cases below it. This is a feature of switch. If you don't want to evaluate the following cases, you need to add a break at the end of each case (or where ever you want to "break" the processing). For example, when you click Draw Intersections, it is also evaluating Union, Clear Image and Save Image cases... You could try using something like... switch (arg0.getActionCommand()) { case "Intersections": intersect = intersections.isSelected(); break; case "Union": uni = union.isSelected(); break; case "Clear Image": drawingArea.clearImage(); break; case "Save Image": drawingArea.saveImage(); break; } instead... Logic Errors in Painting Code... There's also a logic area with your intersect paint code, where it is comparing a rectangle with itself, which ends up painting the whole rectangle. Instead of if (a.get(h).overlaps(a.get(j))) { You might consider using if (!a.get(h).equals(a.get(j)) &amp;&amp; a.get(h).overlaps(a.get(j))) { This is possibly occurring in you union painting logic as well, but I didn't really check that Works fine for me... import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.Ac…
has comment: http://stackoverflow.com/comment/33631215
upvote count: 1
has comment: http://stackoverflow.com/comment/33631526
has comment: http://stackoverflow.com/comment/33631311
has comment: http://stackoverflow.com/comment/33631195
score: 1
accepted answer of: http://stackoverflow.com/q/22160245
has comment: http://stackoverflow.com/comment/33631329
answers question: http://stackoverflow.com/q/22160245
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33631362
downvote count: 0

http://stackoverflow.com/comment/33639188
comment on: http://stackoverflow.com/a/22165288
has text: no need for square brackets...abc,def is ok. But i am not getting it. , should be added in encodedimageByteArray string, after iterating each image.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33487865
type: Comment
score: 0
has text: This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment).
type: AnswerComment
comment on: http://stackoverflow.com/a/22080336

http://stackoverflow.com/comment/33544570
comment on: http://stackoverflow.com/a/22112344
score: 0
type: Comment
has text: Yes. Either a real SDCard that is inserted into the device for extended storage or a software partition of the device's internal storage that acts and appears to Android as an SDCard.
type: AnswerComment

http://stackoverflow.com/q/22054028
has answer: http://stackoverflow.com/a/22054210
tagged with: java
has answer: http://stackoverflow.com/a/22054494
has answer: http://stackoverflow.com/a/22054233
downvote count: 0
has comment: http://stackoverflow.com/comment/33440412
tagged with: string
has answer: http://stackoverflow.com/a/22054317
has comment: http://stackoverflow.com/comment/33442689
favorite count: 0
has answer: http://stackoverflow.com/a/22054246
has answer: http://stackoverflow.com/a/22114490
has comment: http://stackoverflow.com/comment/33440505
answer count: 10
has title: Replacing if statement with for loop (Java)
has comment: http://stackoverflow.com/comment/33440028
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22054248
has comment: http://stackoverflow.com/comment/33440167
has answer: http://stackoverflow.com/a/22054171
upvote count: 3
accepted answer: http://stackoverflow.com/a/22054317
has answer: http://stackoverflow.com/a/22054211
has answer: http://stackoverflow.com/a/22054194
tagged with: methods
has body: I was working on a project and one of the comments that I received was that my if statement was too long. I agree with this but I'm still confused how to replace it with a for loop that was suggested. It has been driving me crazy. The project was to analyse the consonants in a sentence and report back if they are in it. Here is my code that I used. The project has been since marked so this is more of a "where is my mistake/ where can this be improved question". if ((userInput.contains("b"))||(userInput.contains("c"))||(userInput.contains("d"))|| (userInput.contains("f"))||(userInput.contains("g"))||(userInput.contains("h"))|| (userInput.contains("j"))||(userInput.contains("k"))||(userInput.contains("l"))|| (userInput.contains("m"))||(userInput.contains("n"))||(userInput.contains("p"))|| (userInput.contains("q"))||(userInput.contains("r"))||(userInput.contains("s"))|| (userInput.contains("t"))||(userInput.contains("v"))||(userInput.contains("w"))|| (userInput.contains("x"))||(userInput.contains("y"))||(userInput.contains("z"))) //checking for consonants results += "The input contains consonants"; else results += "The input contains no consonants";
type: Question
possible better answer: http://stackoverflow.com/a/22054171
score: 3

http://stackoverflow.com/q/22041329
has title: Android library (jar) needs functionality from another library
has comment: http://stackoverflow.com/comment/33420038
upvote count: 1
type: AnsweredQuestion
score: 1
tagged with: java-native-interface
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/22147636
downvote count: 0
tagged with: jar
tagged with: android
answer count: 1
has body: I'm trying to write an android library which takes functionality from another library, the problem is in essence there's an in app billing library and I want to write an interface to it as a separate jar library to be included in a project. How can I do this if it's at all possible? If not what are my options? I tried building the classes in my jar library but when I try to invoke functions from the other library I get the following error: AndroidJavaException: java.lang.ExceptionInInitializerError Full logcat: --------- beginning of /dev/log/system --------- beginning of /dev/log/main D/Unity (14530): GL_OES_rgb8_rgba8 GL_OES_EGL_sync GL_OES_fbo_render_mipmap GL_NV_depth_nonlinear GL_NV_draw_path GL_NV_texture_npot_2D_mipmap GL_OE S_EGL_image GL_OES_EGL_image_external GL_OES_vertex_half_float GL_OES_mapbuffer GL_NV_draw_buffers GL_NV_multiview_draw_buffers GL_EXT_Cg_shader GL_EX T_packed_float GL_OES_texture_half_float GL_EXT_texture_array GL_OES_compressed_ETC1_RGB8_texture GL_EXT_texture_compression_latc GL_NV_texture_compre ssion_latc GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_s3tc GL_NV_texture_compression_s3tc GL_EXT_texture_filter_anisotropic GL_NV_get_ tex_image GL_NV_read_buffer GL_NV_shader_framebuffer_fetch GL_NV_copy_image GL_NV_fbo_color_attachments GL_EXT_bgra GL_EXT_texture_format_BGRA8888 GL_ EXT_unpack_subimage GL_NV_pack_subimage GL_NV_texture_compression_s3tc_update GL_NV_read_depth GL_NV_read_stencil GL_NV_uniform_buffer_object GL_EXT_r obustness GL_OES_standard_derivatives GL_NV_EGL_stream_consumer_external GL_NV_3dvision_settings GL_EXT_debug_marker GL_EXT_debug_label GL_NV_ D/Unity (14530): coverage_sample GL_EXT_occlusion_query_boolean GL_NV_timer_query I/Unity (14530): AndroidJavaException: java.lang.ExceptionInInitializerError I/Unity (14530): at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in :0 I/Unity (14530): at UnityEngine.AndroidJNISafe.CallStringMethod (IntPtr obj, IntPtr methodID, UnityEngine.jvalue[] args)…
favorite count: 0
has answer: http://stackoverflow.com/a/22147636

http://stackoverflow.com/comment/33645309
comment on: http://stackoverflow.com/a/22168932
has text: You forget to check the result of `.delete()` and `.rename()`. Also, if you use Java 7, use the new `Files` API...
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/22054293
score: 4
type: Answer
answers question: http://stackoverflow.com/q/22048194
upvote count: 4
accepted answer of: http://stackoverflow.com/q/22048194
has body: What you are doing here is a bidrectional many-to-one, where you want to populate objects on both sides of the relationship. Hibernate will complain if you have a JoinColumn on both sides, so just put it on the "owning" side and add mappedBy to the other side. See this example: public class UserAvatar { ... @ManyToOne @JoinColumn(name="userId") // userId is the name of your database FK column private User user; ... } public class User { ... @OneToMany(mappedBy="user") public List&lt;UserAvatar&gt; avatars; ... } As for the particular error you were getting, I believe that was caused by JoinColumn("id") in User conflicting with the primary key column id. Also see this SO answer.
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/22123875
has comment: http://stackoverflow.com/comment/33565625
has title: Need Java print statement after loop
has answer: http://stackoverflow.com/a/22123961
has body: I am working on the current program and I need the * print statement to print all at once at the end. However, it keeps printing after each number is entered. I am new to java and any assistance would be appreciated. import java.util.Scanner; public class barPrint { public static void main(String args[]) { Scanner input = new Scanner(System.in); int counter = 0; int value = 0; // counter loop for 5 inputs for (counter = 0; counter &lt; 5; counter++){ System.out.print("Input an integer between 1 and 30: "); value = input.nextInt(); while(value &lt; 1 || value &gt; 30){ System.out.print("Input an integer between 1 and 30: "); value = input.nextInt(); } // print the asterisks based on value for (int i = 0; i &lt; value; i++){ System.out.print("*"); } System.out.println(); } System.exit (0); } } Current Output: Input an integer between 1 and 30: 25 ************************* Input an integer between 1 and 30: 22 ********************** Input an integer between 1 and 30: 1 * Input an integer between 1 and 30: 12 ************ Input an integer between 1 and 30: 10 ********** Process finished with exit code 0. Expected Output: Input an integer between 1 and 30: 25 Input an integer between 1 and 30: 22 Input an integer between 1 and 30: 1 Input an integer between 1 and 30: 12 Input an integer between 1 and 30: 10 ************************* ********************** * ************ ********** Process finished with exit code 0.
favorite count: 0
has answer: http://stackoverflow.com/a/22123938
accepted answer: http://stackoverflow.com/a/22123938
has answer: http://stackoverflow.com/a/22123953
answer count: 4
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22123882
upvote count: 2
score: 1
downvote count: 1
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/22123882

http://stackoverflow.com/comment/33520819
score: 1
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22097296
has text: Write the code to accept `java.lang.Number` as input. Then the caller who knows the number can choose the optimal number type for the value, which might be `BigDecimal` but doesn’t have to.

http://stackoverflow.com/comment/33587745
comment on: http://stackoverflow.com/a/22135518
score: 0
type: Comment
has text: You can use recursion http://stackoverflow.com/questions/354875/reversing-a-linked-list-in-java-recursively or instead of has next implements something that check that has previous. The question is about data structure. A linked list is construction that an element has two pointers for next and for previous. If prev is null the is called head, if next is null then we reach the tail.
type: AnswerComment

http://stackoverflow.com/comment/33600276
comment on: http://stackoverflow.com/q/22143307
score: 0
has text: thanks! yes wm.removeView(myView); worked
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22150866
tagged with: sockets
has body: I wish I could create a small application that I print screen the IP address to which the socket is connected. I'm trying this code: public void onClick(View v) { Socket s = new Socket(); String host ="10.10.20.xxxx"; try { s.connect( new InetSocketAddress( host, 6000 ), 1000 ); InetAddress inetAddress = s.getLocalAddress(); String ip = inetAddress.getHostAddress(); //Now, I would like to have printed out the IP-address Toast.makeText(getBaseContext(), ip , Toast.LENGTH_SHORT).show(); //But nothing happens } catch (IOException e) { e.printStackTrace(); } } } But, I have never seen printed the IP address, If is necessary I can create a TextView and inside-It put the string ip. Where am I doing wrong? Thanks!
has comment: http://stackoverflow.com/comment/33809260
tagged with: ip-address
has comment: http://stackoverflow.com/comment/33921292
type: AnsweredQuestion
has title: Print to video Ip-address-from socket
tagged with: java
type: Question
tagged with: ip
accepted answer: http://stackoverflow.com/a/22329589
has comment: http://stackoverflow.com/comment/33921502
score: 0
tagged with: android
answer count: 1
has comment: http://stackoverflow.com/comment/33626963
has comment: http://stackoverflow.com/comment/33648018
has answer: http://stackoverflow.com/a/22329589

http://stackoverflow.com/comment/33671716
type: Comment
comment on: http://stackoverflow.com/a/22161156
score: 0
type: AnswerComment
has text: hi mate, added something similar to what you suggested but cant get it to work. See edit above in OP

http://stackoverflow.com/q/22135383
has title: Data Transfer between requests in Spring MVC
score: 0
answer count: 1
type: UnansweredQuestion
has body: I have a simple wizard controller. When I'm trying to read data from last from, my user properties disappears. Any ideas why its happend and how can I fix it? Here is my controller @Controller public class WizardController { @RequestMapping(method = RequestMethod.GET) public String userForm(User user) { return "form/userForm"; } @RequestMapping(value = "/user", method = RequestMethod.POST) public String processedForm(User user, BindingResult result, ModelMap model) { if (result.hasErrors()) {return "form/userForm";} ArrayList<String> p = new ArrayList<String>(); p.add("add_user"); p.add("delete_user"); model.addAttribute("permissions", p); model.addAttribute("user", user); return "form/permissionForm"; } @RequestMapping(value = "/show", method = RequestMethod.POST) public String show(@ModelAttribute("user") User user, BindingResult result) { if (result.hasErrors()) { System.out.println("Error"); return "show"; } else { System.out.println(user); return "show"; } } } My POJO public class User implements Serializable { private String name; private String email; private String password; private Integer age; private List<String> permissions; ... } userForm.jsp <form:form action="/user" method="post" modelAttribute="user"> <form:errors path="*" cssClass="errorblock" element="div"/> <form:input path="name" placeholder="Name"/> <form:input path="age" placeholder="Age"/> <form:input path="email" placeholder="Email"/> <form:input path="password" placeholder="Password"/> </form:form> permissionForm.jsp <form:form action="/show" method="post" modelAttribute="user"> <form:errors path="*" cssClass="errorblock" element="div"/> <form:select path="permissions"> <form:options items="${permissions}"/> </form:select> </form:form> And show.jsp ${user}
tagged with: spring-mvc
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22139048

http://stackoverflow.com/q/22111857
has comment: http://stackoverflow.com/comment/33544101
has comment: http://stackoverflow.com/comment/33543683
has comment: http://stackoverflow.com/comment/33556674
type: UnansweredQuestion
has title: parse recursively unknown json input structure in java
tagged with: recursion
has comment: http://stackoverflow.com/comment/33544827
upvote count: 3
tagged with: java
tagged with: http://stackoverflow.com/tag/json
downvote count: 2
tagged with: gson
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/33543704
has comment: http://stackoverflow.com/comment/33556779
has answer: http://stackoverflow.com/a/22112388
tagged with: jackson
has comment: http://stackoverflow.com/comment/33544542
linked to: http://stackoverflow.com/q/41360172
score: 1
has answer: http://stackoverflow.com/a/44331104
has body: I'm trying to parse recursively unknown json input structure in java like the format below and trying to rewrite the same structure in another json. Meanwhile I need to validate each &amp; every json key/values while parsing. {"Verbs":[{ "aaaa":"30d", "type":"ed", "rel":1.0, "id":"80", "spoken":"en", "ct":"on", "sps":null },{ "aaaa":"31", "type":"cc", "rel":3.0, "id":"10", "spoken":"en", "ct":"off", "sps":null },{ "aaaa":"81", "type":"nn", "rel":3.0, "id":"60", "spoken":"en", "ct":"on", "sps":null }]} Please advice which json parser I can use for reading and writing unknown json content.
favorite count: 0

http://stackoverflow.com/q/22085970
tagged with: jdbc
tagged with: primefaces
tagged with: java
has comment: http://stackoverflow.com/comment/33678061
type: Question
has body: Good day! Im using JSF 2.1 Primefaces 3.5 Glassfish 3.2.1 public class UserListProvider extends DBConnectionPool{ private List sortList; private String whereClause; private List fieldList; private void getUserList() { List userList = new ArrayList(); UserBean users = null; ResultSetMetaData rsmd = null; try { super.initializeConnection(); conn.setAutoCommit(false); String sortString = createSortStmt(); super.cs = super.conn.prepareCall("{call ROCWEB.USERLIST_DATAPROV(?,?,?)}"); super.cs.setString(1, whereClause); super.cs.setString(2, sortString); super.cs.registerOutParameter(3, OracleTypes.CURSOR); super.cs.execute(); super.rs = (ResultSet) super.cs.getObject(3); //getting the columns rsmd = super.rs.getMetaData(); setFieldList(new ArrayList()); for (int i = 0; i &lt; rsmd.getColumnCount(); i++) { getFieldList().add(rsmd.getColumnLabel(i + 1)); } while (super.rs.next()) { users = new UserBean(); users.setFirstName(rs.getString("firstname")); users.setLastName(rs.getString("lastname")); users.setPassword(rs.getString("password")); users.setEmail(rs.getString("email")); users.setUsername(rs.getString("username")); users.setUsername(rs.getString("username")); users.setUserId(rs.getLong("user_id")); userList.add(users); users = null; } conn.commit(); } catch (Exception ex) { ex.printStackTrace(); try { if (conn != null) { conn.rollback(); } } catch (SQLException sqle) { System.out.println(sqle.getMessage()); } } finally { super.closeAll(); } if (userList.isEmpty()) { userList.add(new UserBean()); } this.setList(userList); } } public class DBConnectionPool extends BasePageBean { public Connection conn; public ResultSet rs; public PreparedStatement ps; public CallableStatement cs; private String whereClause = ""; private String sortClause = ""; public void initializeConnection() { try { Context jdbcContext = new InitialContext(); DataSource ds = ((DataSource) jdbcContext.lookup("jdbc/rocjndi")); DataSource dsCOP = ((DataSource) jdbcContext.lookup("jdbc/COP")); if(this.c…
has comment: http://stackoverflow.com/comment/33624554
has comment: http://stackoverflow.com/comment/33546720
tagged with: glassfish
has answer: http://stackoverflow.com/a/22208010
score: 0
has comment: http://stackoverflow.com/comment/33590672
has comment: http://stackoverflow.com/comment/33677988
answer count: 1
has title: Java Language - java.sql.SQLException: ORA-06550
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33624606

http://stackoverflow.com/a/22057670
score: 5
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33446473
upvote count: 5
type: Answer
has body: This is because the rectangles coordinates are stored as ints, so they can only change, at minimum, by 1 at a time. Since draw runs so often, when moving to the left, it still moves very fast, because it can't move at less than 1 pixel at once. The reason it doesn't move at all to the right is because of rounding. When casting to an int, the double is rounded down. So if your position is 5, and you try to add 0.00001, and then cast it to an int, your position ends up still being 5. If you were to subtract 0.000001, then it would be rounded down to 4, which is why moving to the left works.
downvote count: 0
answers question: http://stackoverflow.com/q/22057529
accepted answer of: http://stackoverflow.com/q/22057529

http://stackoverflow.com/a/22063705
upvote count: 3
has comment: http://stackoverflow.com/comment/33461505
has comment: http://stackoverflow.com/comment/33461563
score: 3
has body: Serialise your objects to xml (or CSV or Json or roll-your-own format) strings. Form your message from those strings. Send your message as bytes. Reverse the process at the receiving end.
has comment: http://stackoverflow.com/comment/33461272
downvote count: 0
answers question: http://stackoverflow.com/q/22061737
has comment: http://stackoverflow.com/comment/33467557
has comment: http://stackoverflow.com/comment/33466205
type: Answer

http://stackoverflow.com/q/22005779
type: UnansweredQuestion
score: -3
upvote count: 0
has answer: http://stackoverflow.com/a/22005842
favorite count: 0
type: Question
tagged with: java
downvote count: 3
answer count: 1
has body: I am filing right now for this big project which I have, it is about to be due in a matter of hours, and my teacher has this textbook on his webpage called Blue Pelican, which I always refer to. My program consists of the user inputting 3 numbers (integers) to get the output from a file. However, when I followed the textbook through, I got 4 errors which I am unable to solve: if (choose == 1) //enemies from the original Kingdom Hearts { System.out.println("In the orginal Kingdom Hearts, there is only one enemy race, which is the Heartless."); System.out.println("Please type the number which corresponds to the Heartless enemy type."); System.out.println("1. Pureblood"); //Gives the display for the user to know she can choose to view Pureblood Heartless. System.out.println("2. Emblum"); //Gives the display for the user to know she can choose to view Emblem Heartless. System.out.println("3. Special Heartless"); int heartless_1 = kH.nextInt(); if (heartless_1 == 1) //gives the chioce to select the Heartless enemy type { Scanner kH1 = new Scanner(new File("KH_Pureblood_Heartless.txt")); int maxIndex = -1; //So that when it's incremented below, the first index is 0. String kh1Purebloods = new String[10000]; //To be safe, more than what's needed is declared just in case. while (kh1.hasNext()) { maxIndex++; kh1Purebloods[maxIndex] = kH1.nextLine(); } kH1.close(); for (int a = 0; a &lt;= maxIndex; a++) { System.out.println(kh1Purebloods[a]); } } The errors I get consist of: E:\3 IB Computer Science SL\Dossier Computer Science IA The Solution\Product\Kingdom_Hearts.java:45: incompatible types found : java.lang.String[] required: java.lang.String String kh1Purebloods = new String[10000]; //To be safe, more than what's needed is declared just in case. ^ E:\3 IB Computer Science SL\Dossier Computer Science IA The Solution\Product\Kingdom_Hearts.java:47: cannot find symbol symbol : method hasNext() location: class kh1 while (kh1.hasNext()) ^ E:\3 IB Computer Science SL\Dossier Co…
has title: Why am I getting these errors with filing in Java?

http://stackoverflow.com/comment/33470803
comment on: http://stackoverflow.com/q/22071785
has text: No reason for the `== false`, just `!isOn`. `booleanValue()` is redundant after the `null` check.
type: Comment
type: QuestionComment
score: 6

http://stackoverflow.com/comment/80730076
comment on: http://stackoverflow.com/a/22043866
type: AnswerComment
has text: There is **no** `onHandleIntent()` in `Service`. It should be `IntentService`.
type: Comment
score: 3

http://stackoverflow.com/q/22035970
tagged with: arraylist
score: 0
has answer: http://stackoverflow.com/a/22036166
has body: For Example: ArrayList1 = {userid1, userid2, userid1, userid4, userid1, userid3, userid2, userid4, userid4, userid4, userid2}; ArrayList2 = {username1, username2, username3, username4}; Mapping these two array so that whenever I call ArrayList1.get(0).getUserName(), it should provide me with username1.
has comment: http://stackoverflow.com/comment/33407349
tagged with: android
accepted answer: http://stackoverflow.com/a/22036188
tagged with: dictionary
answer count: 4
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/22036171
type: Question
has answer: http://stackoverflow.com/a/22036244
tagged with: hashmap
has title: Map two ArrayList with different sizes
possible better answer: http://stackoverflow.com/a/22036171
has answer: http://stackoverflow.com/a/22036188

http://stackoverflow.com/comment/33470754
type: AnswerComment
has text: Tanks for your answer. My problem is that I don't want the user to know the salt, that would be the case by using configuration files. I don't take this as an absolute security, but it's better this way for my application case. Also I want all user of a same version have the same salt, so machine dependent configuration is excluded too.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22069253

http://stackoverflow.com/a/22084402
answers question: http://stackoverflow.com/q/22084373
type: Answer
score: 8
downvote count: 1
upvote count: 9
has body: There is the Math.pow(double a, double b) method. Note that it returns a double, you will have to cast it to an int like (int)Math.pow(double a, double b).

http://stackoverflow.com/comment/33494730
comment on: http://stackoverflow.com/a/22061138
has text: Nope, this will give the same `ranking` array as your method. The `Arrays.sort` will sort the **index** of the scores based on the scores. So in my test case above (I added a test case), the `indexes` array will be `{2, 0, 1}`, referring that `scores[2]` is the smallest, `scores[0]` is the second smallest, and `scores[1]` is the largest. Then it's essentially the same as your `smallestIndex` method, just that the result is already in an array instead of calling the method `n` times. You can check the result of `ranking` to see that it's correct.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/22120261
has body: Trying to make a timer call a method every second. I can't figure out why this code is not working. Code was taken from my activity_main.xml and MainActivity.java activity_main: &lt;ToggleButton android:id="@+id/btnStartStop" android:layout_width="80dp" android:layout_height="50dp" android:layout_alignLeft="@+id/clockDisplay" android:layout_below="@+id/clockDisplay" android:layout_marginLeft="40dp" android:layout_marginTop="0dp" android:textOff="Start" android:textOn="Stop" android:onClick="toggleStartStop" /&gt; MainActivity.java: public void toggleStartStop(View view){ if(((ToggleButton) view).isChecked()){ Timer timer = new Timer("timer", true); TimerTask task = new startTask(); timer.schedule(task, new Date(), 1000); }else{ stopTimer(); } } class startTask extends TimerTask { public void run() { System.out.println("inc secs var"); } }
tagged with: java
has comment: http://stackoverflow.com/comment/33558874
type: Question
has comment: http://stackoverflow.com/comment/33558847
has comment: http://stackoverflow.com/comment/33558842
score: 0
has title: Using java.util.Timer
answer count: 1
tagged with: timer
has answer: http://stackoverflow.com/a/22121297
accepted answer: http://stackoverflow.com/a/22121297
tagged with: android
type: AnsweredQuestion

http://stackoverflow.com/a/22057356
upvote count: 2
type: AcceptedAnswer
type: Answer
score: 2
downvote count: 0
has body: It only implements the DataSource interface, but not the XADataSource interface.
answers question: http://stackoverflow.com/q/22052464
accepted answer of: http://stackoverflow.com/q/22052464

http://stackoverflow.com/q/22095540
type: Question
has body: I believe this is a classic and should have a design pattern, but besides dependency pattern and law of demeter, I can't really see the big picture: To have a good testable and flexible application I want to: Have a single entry into my application during construction time. Have configuration loaded/parsed once and handed over to this entry point. Let this entry point instantiate and configure all dependencies and then orchestrate it into an architecture. And then let everything go over into runtime. Constraint: A few Singleton as possible, best none. Only entry point knows about config, so it's easy to test dependencies Everything (all dependencies) should be easily testable. As few as possible exposed methods only for testing. (Not working) Example: // Main entrypoint public App(Config config) { Dep1 dep1 = new Dep1(config.getDep1Conf()); Dep2 dep2 = new Dep2(config.getDep2Conf()); Dep3 dep3 = new Dep3(config.getDep3Conf()); Dep4 dep4 = new Dep4(config.getDep4Conf()); : this(dep1, dep2, dep3, dep4); } // Entry point for easy testing public App(Dep1 dep1, Dep2 dep2, Dep3 dep3, Dep4 dep4) { this.dep5 = Dep1.newInstance(Dep2); this.dep3 = dep3; this.dep4 = dep4; : } My question: How would a template look like?
score: 0
type: UnansweredQuestion
has title: How to handle dependencies during construction time
has comment: http://stackoverflow.com/comment/33513500
answer count: 0
tagged with: java
has comment: http://stackoverflow.com/comment/33513527
has comment: http://stackoverflow.com/comment/33513453

http://stackoverflow.com/q/22042109
linked to: http://stackoverflow.com/q/21534340
has comment: http://stackoverflow.com/comment/33420875
tagged with: http://stackoverflow.com/tag/xml
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33418721
tagged with: java
has answer: http://stackoverflow.com/a/22043102
tagged with: dom
type: Question
possible better answer: http://stackoverflow.com/a/22042444
score: 0
answer count: 2
has body: I am trying to parse an xml file and would like to get only certain information. ... John Citizen 01/01/1980 "Manager" .... and I have document and now I can print out all the values by looping the NodeList of tag, however, I don't know how to get the specific value, e.g. I want only the last name and the Profession from the list, so my goal is I want to have: "Citizen" and "Manager" Any clue please. thank you
linked to: http://stackoverflow.com/q/13786607
tagged with: parsing
has title: How do I parse this xml in Java using DOM API?
has comment: http://stackoverflow.com/comment/33418577
accepted answer: http://stackoverflow.com/a/22043102
has answer: http://stackoverflow.com/a/22042444

http://stackoverflow.com/comment/33458827
comment on: http://stackoverflow.com/q/22064851
score: 2
has text: Give it a try after a while.
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22059881
type: Answer
has body: If you have this overidden method in your planet class public String toString(){ StringBuilder result = new StringBuilder(); String NEW_LINE = System.getProperty("line.separator"); result.append(" planetProperty1: ").append (planetProperty1).append(NEW_LINE); result.append(" planetProperty2: ").append (planetProperty2).append(NEW_LINE); return result.toString(); } then from the calling class you can iterate over the collection calling System.out.println (planets[i].toString());
answers question: http://stackoverflow.com/q/22059802
score: 0
has comment: http://stackoverflow.com/comment/33450620

http://stackoverflow.com/a/30717466
type: Answer
score: 2
downvote count: 0
has body: The reason the onCreate() is called again isn't always because your device is low in memory, one of the most common reasons is the change in orientation which causes the activity to recreate so you can try putting this in your manifest file: android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden|screenSize" however, if you experiment enough with your code and come to conclusion that it is caused by android destroying the activity because of memory shortage then here is a work around you can use to correctly restore your activity. YourObject mObject; . . . @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); mObject.setImageUri(bla..); //Store image Uri and other values in mObject } @Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); if (mObject != null) { //save your object which contains data like image uri savedInstanceState.putSerializable(KEY, mObject); } } @Override public void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); YourObject obj = (YourObject) savedInstanceState.getSerializable(KEY); if(obj != null) mObject = obj; } and finally, in the onResume, read your stored data back from mObject if its not null @Override protected void onResume() { super.onResume(); if(mObject != null) { //set image to imageView using the stored Uri setImage(imageView, mObject.getImageUri()); } } Sequence: OnResume OnPause OnSaveInstanceState - Here we save our data in bundle OnDestroy - Here we lose all our activity data OnCreate onRestoreInstanceState - Here we restore our saved data from bundle if any OnResume - Here we deal with restored data if any
answers question: http://stackoverflow.com/q/22110262
upvote count: 2

http://stackoverflow.com/a/22040833
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33416082
has comment: http://stackoverflow.com/comment/33416466
has comment: http://stackoverflow.com/comment/33416023
answers question: http://stackoverflow.com/q/22040736
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/33417032
accepted answer of: http://stackoverflow.com/q/22040736
has body: I don't know how to make sure that all the subclass methods are called automatically You have to know what you call and which parameters you use in your methods. At some point in your code you have to manually write which methods and which order you want to call. EDIT : Ah, I probably know what you think about. This is way how to do it : private class Something { public void yeah() { System.out.println(""); } } private class Something2 extends Something{ @Override public void yeah(){ super.yeah(); } } EDIT2 : Ok, this is just guessing, but I think what you probably want is this : private static abstract class Animal{ abstract void sound(); } private static class Dog extends Animal{ @Override void sound() { System.out.println("haf"); } } private static class Cow extends Animal{ @Override void sound() { System.out.println("mooooo"); } } /** * @param args the command line arguments */ public static void main(String[] args) { List&lt;Animal&gt; animals = new ArrayList&lt;&gt;(); animals.add(new Dog()); animals.add(new Cow()); animals.add(new Dog()); animals.add(new Dog()); animals.add(new Dog()); animals.add(new Cow()); animals.add(new Cow()); animals.add(new Cow()); animals.add(new Dog()); animals.add(new Cow()); animals.add(new Dog()); animals.add(new Dog()); animals.add(new Cow()); animals.add(new Dog()); animals.add(new Cow()); animals.add(new Dog()); animals.add(new Dog()); for (Animal animal : animals){ animal.sound(); } } Output : haf mooooo haf haf haf mooooo mooooo mooooo haf mooooo haf haf mooooo haf mooooo haf haf
has comment: http://stackoverflow.com/comment/33417268
has comment: http://stackoverflow.com/comment/33416655
has comment: http://stackoverflow.com/comment/33415948
score: 2

http://stackoverflow.com/comment/33493751
type: Comment
type: QuestionComment
has text: Yes. 25 is the percent sign. And if that was the problem, it wouldn't work in any browser, which isn't the case.
score: 0
comment on: http://stackoverflow.com/q/22078108

http://stackoverflow.com/comment/33455033
type: Comment
score: 1
comment on: http://stackoverflow.com/q/22062019
has text: You may use the debugger of your IDE to check how the stacks are created and to see that each one has it's own copy of them
type: QuestionComment

http://stackoverflow.com/comment/33507470
comment on: http://stackoverflow.com/q/22091974
has text: You are not wrong, JavaFX 2 MediaView does not accept RTP. [Supported protocols are documented](http://docs.oracle.com/javafx/2/api/javafx/scene/media/package-summary.html) and do not include RTP.
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/q/22152823
has answer: http://stackoverflow.com/a/22158746
favorite count: 0
upvote count: 6
has body: I'm new to Netty and to get more familiar with it I'm working on building a simple HTTP server. One thing I want to do is deal with routing based on the URI. I looked around for examples and found a few approaches and wanted to see which made the most sense. Have a "route" handler that will add/remove others based on the URI in the HTTPMessage. This seems inefficient if I have to do this for every single request. Have the "route" handler wrap the HTTPMessage and HTTPContent inside another object that will then be passed in to the appropriate handler. For example, I can have an InfoHandler that extends SimpleChannelInboundHandler and the router InfoHTTPRequest object. This way the pipeline stays fixed and I'm not changing it on the fly - I am creating more objects though. Have a single route handler that just has methods to handle the different endpoints. I can have a handleInfo method, a handleUpdate method, etc with each of those having their own implementation and referencing their own dependencies. PS - I'm using Netty 4.0 and most of my understanding has come from various online research and reading the Netty In Action book.
type: UnansweredQuestion
tagged with: netty
score: 6
has title: How to route requests based on URI in Netty?
tagged with: java
type: Question
answer count: 1
downvote count: 0

memory-leaks
tags question: http://stackoverflow.com/q/22106886
tags question: http://stackoverflow.com/q/22076643
tags question: http://stackoverflow.com/q/22133613
type: Tag
tags question: http://stackoverflow.com/q/22008360
tag name: memory-leaks
tags question: http://stackoverflow.com/q/22067124

http://stackoverflow.com/a/22161638
answers question: http://stackoverflow.com/q/22153678
has comment: http://stackoverflow.com/comment/33679651
score: 0
has body: You're injecting loginDao but not login. Yet you're referencing login. Unless you're initializing login somewhere else, you're going to get a NPE.
type: Answer

http://stackoverflow.com/q/22094406
duplicate of: http://stackoverflow.com/q/4336637
score: -2
tagged with: java
has body: I am building an android app and i want to secure its source code. I am building it by using Java. As i have gone through some answers here which is related to obfuscation of java code and protecting it from reverse engineering. So is it also possible in android development. If yes then how? And if it is not possible then how can we protect apk file from reverse engineering.
tagged with: code-access-security
downvote count: 2
answer count: 1
has title: Is it possible to obfuscate java code and then building an APK file from those java files?
linked to: http://stackoverflow.com/q/4336637
favorite count: 0
has comment: http://stackoverflow.com/comment/33511435
type: UnansweredQuestion
tagged with: reverse-engineering
tagged with: android
upvote count: 0
has answer: http://stackoverflow.com/a/22094420
type: Question

http://stackoverflow.com/q/22153215
score: 1
has comment: http://stackoverflow.com/comment/33617526
tagged with: java
possible better answer: http://stackoverflow.com/a/22153240
has answer: http://stackoverflow.com/a/22153286
has comment: http://stackoverflow.com/comment/33617574
has comment: http://stackoverflow.com/comment/33686695
type: Question
answer count: 2
has body: So i'm trying to write stuff to a file and it works but when i call this method more than once it removes the previous stuff i wrote with the new. So i wonder what should i do so the method wont remove my previous text that i've added to the file and adds the new text to the next line. public static void writetofile(String id, String content) throws IOException { try { FileWriter filewriter = new FileWriter("Random.txt"); BufferedWriter out = new BufferedWriter(filewriter); out.write(id+" "+ content); out.close(); } catch (Exception e) { System.out.println(e.getMessage()); } }
has title: Write text to the next line using Java
favorite count: 0
accepted answer: http://stackoverflow.com/a/22153286
upvote count: 2
has answer: http://stackoverflow.com/a/22153240
downvote count: 1
type: AnsweredQuestion

http://stackoverflow.com/q/22108369
has answer: http://stackoverflow.com/a/22131220
has title: Java: Most efficient way to map properties of one list of objects to another
has comment: http://stackoverflow.com/comment/106805400
tagged with: java
answer count: 6
has answer: http://stackoverflow.com/a/22108713
has answer: http://stackoverflow.com/a/22108434
score: 5
has body: I'm looking for an efficient design pattern to map one list of objects to another list of objects with zero-or-one-to-one relationships between them. I realize this sort of thing is typically done in a relational database, but in this particular case it really needs to be done in the Java application... Let's say the first list contains Foo objects (i.e. List&lt;Foo&gt;): public class Foo { public Integer id; public String barName; } And the second list contains Bar objects (i.e. List&lt;Bar&gt;): public class Bar { public Integer fooId; public String name; } How can I most efficiently map all name properties from Bar to the Foo object where Bar.fooId equals Foo.id? The best I can think of is this: void mapFooBar(List&lt;Foo&gt; fooList, List&lt;Bar&gt; barList) { for (Bar bar : barList) { for (Foo foo : fooList) { if (bar.fooId.equals(foo.id)) foo.barName = bar.name; } } } EDIT: Based on several answers, I have improved my code as follows: void mapFooBar(List&lt;Foo&gt; fooList, List&lt;Bar&gt; barList) { Map&lt;Integer, String&gt; barMap = new HashMap&lt;Integer, String&gt;(); for (Bar bar : barList) barMap.put(bar.fooId, bar.name); for (Foo foo : fooList) if (barMap.containsKey(foo.id)) foo.barName = barMap.get(foo.id); } Is there a better way?
favorite count: 0
has answer: http://stackoverflow.com/a/22108656
has comment: http://stackoverflow.com/comment/33537803
upvote count: 5
has answer: http://stackoverflow.com/a/29836247
tagged with: list
tagged with: mapping
has answer: http://stackoverflow.com/a/22108448
downvote count: 0
type: UnansweredQuestion
tagged with: loops
tagged with: design-patterns
linked to: http://stackoverflow.com/q/6796187
type: Question

http://stackoverflow.com/a/22112304
has body: Best to use an Iterator: final Map&lt;String, String&gt; map = new HashMap&lt;&gt;(); final Iterator&lt;Entry&lt;String, String&gt;&gt; iter = map.entrySet().iterator(); if (!iter.hasNext()) { //map is empty - handle } iter.next(); while (iter.hasNext()) { final Entry&lt;String, String&gt; e = iter.next(); //your code } I prefer it to the boolean approach because you don't need to check the flag in every iteration. This approach also gives the the latitude to consume more than one entry in each iteration as long as you recheck hasNext() before consuming each additional item. P.S. Please stick to Java naming conventions. Your class co should be in PascalCase. Also Co is probably not the best name for a class - try to pick meaningful names for everything from classes to variables.
answers question: http://stackoverflow.com/q/22112212
type: Answer
upvote count: 6
score: 6
downvote count: 0

http://stackoverflow.com/a/22149724
upvote count: 3
answers question: http://stackoverflow.com/q/22149615
score: 3
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: If you have an ascending sorted array arr of length n, the smallest element is found at arr[0] and the largest at arr[n - 1].
accepted answer of: http://stackoverflow.com/q/22149615

http://stackoverflow.com/comment/33483677
type: QuestionComment
comment on: http://stackoverflow.com/q/22078377
has text: I would like to find an element `x` in that `TreeSet`, if it is there, then return it, if it is not there then return the next largest value from the `TreeSet`.
score: 0
type: Comment

http://stackoverflow.com/comment/33506698
has text: Are you sure?! Pattern p = Pattern.compile("^WO"); returns true for "WO.SYNC". even if the input = "WO1231.SYNC", it returns true.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22091332
score: 1

http://stackoverflow.com/comment/33371103
score: 0
comment on: http://stackoverflow.com/q/22015685
type: Comment
type: QuestionComment
has text: Are you using `mvn -U clean install` while building the dependency or while building the main project?

http://stackoverflow.com/comment/33418380
type: AnswerComment
comment on: http://stackoverflow.com/a/22031729
type: Comment
score: 2

http://stackoverflow.com/a/24359981
answers question: http://stackoverflow.com/q/22130547
score: 0
type: Answer
has body: Your controller needs to inherit from a composer such as SelectorComposer&lt;T&gt;. From the ZK manual: To simplify the implementation of the controller part of UI, ZK provides several skeleton implementations. For example, SelectorComposer, as one of the most popular skeletons, wires components, variables and event listeners automatically based on Java annotations you specify. So simply change that line in your code: public class AnalyticsController extends SelectorComposer&lt;BorderLayout&gt;

http://stackoverflow.com/q/22065687
tagged with: timestamp
has body: I want to continuously monitor a folder (say C:/Users/me/csv) for any change in its content - either new files added, or (sub-folder changes doesn't bother me as of now) existing file modified If either of two happens, what is 'the parameter of csv folder' which gets modified? (anything like timestamp which I can compare with previous value of that parameter and trigger loading the csv data again to my collection)
has answer: http://stackoverflow.com/a/22065763
tagged with: java
upvote count: 1
downvote count: 1
type: Question
has title: How to find "last modified time" of a folder in java
score: 0
answer count: 1
favorite count: 0
tagged with: file-handling
type: UnansweredQuestion

http://stackoverflow.com/q/22005115
type: Question
has answer: http://stackoverflow.com/a/22005440
possible better answer: http://stackoverflow.com/a/45753816
has answer: http://stackoverflow.com/a/45753816
answer count: 2
tagged with: tableview
downvote count: 0
has comment: http://stackoverflow.com/comment/33363666
favorite count: 0
has body: I'm trying to find a way to add an image to a JavaFx TableView column that has data in other columns populated from a H2 database via hibernate. The TableView has been designed in JavaFx Scene Builder. This is what I've managed to put together so far: The Controller Class: public class HomeController implements Initializable { @FXML private TableView&lt;NewBeautifulKiwi&gt; KIWI_TABLE; @FXML private TableColumn&lt;NewBeautifulKiwi, Image&gt; KiwiId; @FXML private TableColumn&lt;NewBeautifulKiwi, String&gt; Kiwi; public ObservableList&lt;NewBeautifulKiwi&gt; data; // Initializes the controller class. @Override public void initialize(URL url, ResourceBundle rb) { KiwiId.setCellFactory(new Callback&lt;TableColumn&lt;NewBeautifulKiwi, Image&gt;, TableCell&lt;NewBeautifulKiwi, Image&gt;&gt;() { @Override public TableCell&lt;NewBeautifulKiwi, Image&gt; call(TableColumn&lt;NewBeautifulKiwi, Image&gt; param) { //Set up the ImageView final ImageView imageview = new ImageView(); imageview.setFitHeight(50); imageview.setFitWidth(50); //Set up the Table TableCell&lt;NewBeautifulKiwi, Image&gt; cell = new TableCell&lt;NewBeautifulKiwi, Image&gt;() { public void updateItem(NewBeautifulKiwi item, boolean empty) { if (item != null) { imageview.setImage("arrow.png"); } } }; // Attach the imageview to the cell cell.setGraphic(imageview); return cell; } }); Kiwi.setCellValueFactory(new PropertyValueFactory&lt;NewBeautifulKiwi, String&gt;("Kiwi")); KIWI_TABLE.setItems(gobbledyGook()); } private ObservableList&lt;NewBeautifulKiwi&gt; gobbledyGook() { data = FXCollections.observableArrayList(); Session session = HibernateUtil.getSessionFactory().openSession(); Transaction transaction = null; try { transaction = session.beginTransaction(); List courses = session.createQuery("from KIWI_TABLE").list(); for (Iterator iterator = courses.iterator(); iterator.hasNext();) { NewBeautifulKiwi course = (NewBeautifulKiwi) iterator.next(); System.out.println(course.getKiwi()); data.add(course); } tra…
accepted answer: http://stackoverflow.com/a/22005440
score: 6
has title: How to add an Image into a JavaFx TableView column
upvote count: 6
type: AnsweredQuestion
tagged with: java
tagged with: hibernate
tagged with: javafx

jms
tags question: http://stackoverflow.com/q/22089973
tags question: http://stackoverflow.com/q/22007022
tags question: http://stackoverflow.com/q/22038213
tags question: http://stackoverflow.com/q/22137411
tags question: http://stackoverflow.com/q/22040986
tags question: http://stackoverflow.com/q/22105182
tag name: jms
tags question: http://stackoverflow.com/q/22074082
tags question: http://stackoverflow.com/q/22072394
tags question: http://stackoverflow.com/q/22106700
tags question: http://stackoverflow.com/q/22088873
tags question: http://stackoverflow.com/q/22048537
tags question: http://stackoverflow.com/q/22079761
type: Tag
tags question: http://stackoverflow.com/q/22026736
tags question: http://stackoverflow.com/q/22100830
tags question: http://stackoverflow.com/q/22117709
tags question: http://stackoverflow.com/q/22046638

http://stackoverflow.com/q/22157813
has title: Accessing Hashmap from multiple threads without synchronization
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22157830
downvote count: 0
score: 1
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22157830
tagged with: hashmap
has body: I have a HashMap that I need multiple threads to access. My design is such that each thread will be reading and writing to its own entry in the map: the same map, but no two threads work on the same entry. No one thread will ever need to iterate over the map or call size(). So my question is: do I have to synchronize on the Hashmap or may I just use it with confidence that it will never throw a ConcurrentModificationException? My obvious worry is that synchronizing will create a huge bottleneck.
upvote count: 1
answer count: 1
favorite count: 0
tagged with: multithreading

http://stackoverflow.com/comment/33569700
type: QuestionComment
has text: @camickr - I have modified the code showing the Working and non -working parts of code. It looks almost the same but it doesn't work in the 2nd jFrame. This is what's baffling to me.
score: 0
comment on: http://stackoverflow.com/q/22119889
type: Comment

http://stackoverflow.com/a/22047958
type: Answer
score: 0
answers question: http://stackoverflow.com/q/22047532
has body: Remember, if you just execute the CMD or COMMAND by itself it will start it own "shell" window and will not return. You have to use the /c to tell it to execute the command and return. For Windowz NT and better it should be CMD.exe /c your_command and for Windowsz 95 or worst, it should be COMMAND.com /c your_command and to check use the following Java codes: String os = System.getProperty("os.name").toLowerCase(); if (os.indexOf("windows 9") &gt; -1) { cmd = "CMD.exe /c"; } else if ((os.indexOf("nt") &gt; -1) || (os.indexOf("windows 2000") &gt; -1) || (os.indexOf("windows xp") &gt; -1)) { cmd = "COMMAND.com /c"; }
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22047532

http://stackoverflow.com/comment/33517101
type: QuestionComment
comment on: http://stackoverflow.com/q/22097439
type: Comment
has text: you shouldn't use hashtable at all. use Hashmap or ConcurrentHashMap if it has to be thread safe
score: 4

http://stackoverflow.com/q/22047926
downvote count: 0
score: 4
has answer: http://stackoverflow.com/a/22047990
has body: I have this method to retrieve the objects which are instance of a given class: public class UtilitiesClass { public static final Collection&lt;Animal&gt; get(Collection&lt;Animal&gt; animals, Class&lt;? extends Animal&gt; clazz) { // returns the Animals which are an instanceof clazz in animals } ... } To call the method, I can do something like this: Collection&lt;Animal&gt; dogs = UtilitiesClass.get(animals, Dog.class); That is good, but I would also like to be able to call the method in these two ways: Collection&lt;Animal&gt; dogs = UtilitiesClass.get(animals, Dog.class); or Collection&lt;Dog&gt; dogsTyped = UtilitiesClass.get(animals, Dog.class); What I mean is that I want to be able to store result of the method in a Dog Collection or in an Animal one, because Dog.class extends Animal.class I was thinking in something like this: public static final &lt;T&gt; Collection&lt;T&gt; get(Class&lt;T extends Animal&gt; clazz) { // returns the Animals which are an instanceof clazz } But it does not work. Any hint? Edit: Finally, using @Rohit Jain answer, this is the solution when you call to the UtilitiesClass method: Collection&lt;? extends Animal&gt; dogsAnimals = UtilitiesClass.get(animals, Dog.class); Collection&lt;Dog&gt; dogs = UtilitiesClass.get(animals, Dog.class);
answer count: 3
tagged with: generics
has comment: http://stackoverflow.com/comment/33456421
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22064555
tagged with: java
tagged with: pecs
has title: Producer and Consumer with Generics in Java
has answer: http://stackoverflow.com/a/22065406
type: Question
upvote count: 4

http://stackoverflow.com/q/22117250
tagged with: servlets
type: Question
tagged with: intellij-idea
downvote count: 0
tagged with: jsp
has comment: http://stackoverflow.com/comment/33553336
favorite count: 0
type: UnansweredQuestion
has title: How to configure IntelliJ to run a JSP/Servlet and get the response in a browser like in Eclipse?
has comment: http://stackoverflow.com/comment/33553572
has comment: http://stackoverflow.com/comment/33553406
score: 3
answer count: 0
upvote count: 3
tagged with: java
has body: I think that it is a silly question. But, I couldn't figure it out on my own as I am a novice user of Intellij Idea and new to Software development. In eclipse when I press ctrl + F11, the response from a Servlet or JSP automatically will be opened in a browser after running on the server. But in IntelliJ the following is what I see. When I press alt+F2, I see source code in the browser, but not the response from that JSP. In the project view when I right click on a JSP (I don't see "run on server") : So, my question is How do I configure so that I can directly run(shift+F10) a JSP/Servlet on the server and get the response in a browser like in eclipse?
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33553361

http://stackoverflow.com/comment/33493608
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/22083940
has text: This isn't related to your current problem but you should read [How do I compare strings in Java?](http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java)

jpa
tags question: http://stackoverflow.com/q/22117377
tags question: http://stackoverflow.com/q/22167945
tags question: http://stackoverflow.com/q/22064916
tags question: http://stackoverflow.com/q/22030232
tags question: http://stackoverflow.com/q/22061727
tags question: http://stackoverflow.com/q/22116005
tags question: http://stackoverflow.com/q/22052606
tags question: http://stackoverflow.com/q/22141391
tags question: http://stackoverflow.com/q/22133497
tags question: http://stackoverflow.com/q/22146599
tags question: http://stackoverflow.com/q/22113992
tags question: http://stackoverflow.com/q/22119155
tags question: http://stackoverflow.com/q/22124498
tags question: http://stackoverflow.com/q/22020475
tags question: http://stackoverflow.com/q/22126397
tags question: http://stackoverflow.com/q/22033054
tags question: http://stackoverflow.com/q/22165971
tags question: http://stackoverflow.com/q/22116090
tags question: http://stackoverflow.com/q/22128631
tags question: http://stackoverflow.com/q/22083964
tags question: http://stackoverflow.com/q/22054482
tags question: http://stackoverflow.com/q/22007341
tags question: http://stackoverflow.com/q/22031128
tags question: http://stackoverflow.com/q/22115043
tags question: http://stackoverflow.com/q/22018462
tags question: http://stackoverflow.com/q/22075199
tags question: http://stackoverflow.com/q/22089861
tags question: http://stackoverflow.com/q/22071427
tags question: http://stackoverflow.com/q/22144053
tags question: http://stackoverflow.com/q/22010335
tags question: http://stackoverflow.com/q/22167659
tags question: http://stackoverflow.com/q/22150678
tags question: http://stackoverflow.com/q/22106509
tags question: http://stackoverflow.com/q/22041587
type: Tag
tags question: http://stackoverflow.com/q/22073871
tags question: http://stackoverflow.com/q/22034262
tags question: http://stackoverflow.com/q/22156424
tags question: http://stackoverflow.com/q/22117210
tags question: http://stackoverflow.com/q/22116789
tags question: http://stackoverflow.com/q/22059347
tags question: http://stackoverflow.com/q/22149635
tags question: http://stackoverflow.com/q/22116137
tags question: http://stackoverflow.com/q/22045572
tags question: http://stackoverflow.com/q/22164046
tags question: http://stackoverflow.com/q/22015013
tags question: http://stackoverflow.com/q/22022169
tags question: http://stackoverflow.com/q/22099901
tags question: http://stackoverflow.com/q/22167730
tags question: http://stackoverflow.com/q/22024016
tags question: http://stackoverflow.com/q/22068871
tags question: http://stackoverflow.com/q/22042496
tags question: http://stackoverflow.com/q/22125693
tags question: http://stackoverflow.com/q/22005948
tags question: http://stackoverflow.com/q/22012233
tags question: http://stackoverflow.com/q/22152346
tags question: http://stackoverflow.com/q/22124858
tags question: http://stackoverflow.com/q/22086082
tags question: http://stackoverflow.com/q/22035445
tag name: jpa
tags question: http://stackoverflow.com/q/22045641
tags question: http://stackoverflow.com/q/22137454
tags question: http://stackoverflow.com/q/22120714
tags question: http://stackoverflow.com/q/22052537
tags question: http://stackoverflow.com/q/22089584
tags question: http://stackoverflow.com/q/22016152
tags question: http://stackoverflow.com/q/22111712
tags question: http://stackoverflow.com/q/22098252
tags question: http://stackoverflow.com/q/22035054
tags question: http://stackoverflow.com/q/22126292
tags question: http://stackoverflow.com/q/22010619
tags question: http://stackoverflow.com/q/22080260
tags question: http://stackoverflow.com/q/22034650
tags question: http://stackoverflow.com/q/22047201
tags question: http://stackoverflow.com/q/22039321
tags question: http://stackoverflow.com/q/22026715
tags question: http://stackoverflow.com/q/22165182
tags question: http://stackoverflow.com/q/22098183
tags question: http://stackoverflow.com/q/22154319
tags question: http://stackoverflow.com/q/22085467

http://stackoverflow.com/comment/33383455
comment on: http://stackoverflow.com/a/22022100
score: 0
type: AnswerComment
type: Comment
has text: Like populating the lists, call `get` on your master lists to get the proper lists for each ant, then iterate over both of those lists to get your `x` and `y` values back out.

http://stackoverflow.com/comment/33453273
has text: Your hypothesis more looks like truth. How can I verify it?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22061876
type: AnswerComment

http://stackoverflow.com/a/22125816
has comment: http://stackoverflow.com/comment/33569468
has comment: http://stackoverflow.com/comment/33569122
has comment: http://stackoverflow.com/comment/33569183
upvote count: 4
downvote count: 0
score: 4
has comment: http://stackoverflow.com/comment/33569487
has comment: http://stackoverflow.com/comment/33569088
type: Answer
has body: It is not a bad idea in itself and it will not affect anything. However I think many people will disagree with you regarding the "unreadability" of the normal way of negating things using !. if ( ! list.isEmpty() ) versus if ( not( list.isEmpty() ) ) does not make much of a difference IMHO.
has comment: http://stackoverflow.com/comment/33569321
answers question: http://stackoverflow.com/q/22125768

algorithm
tags question: http://stackoverflow.com/q/22096963
tags question: http://stackoverflow.com/q/22031542
tags question: http://stackoverflow.com/q/22052394
tags question: http://stackoverflow.com/q/22134591
tag name: algorithm
tags question: http://stackoverflow.com/q/22120747
tags question: http://stackoverflow.com/q/22040877
tags question: http://stackoverflow.com/q/22085267
tags question: http://stackoverflow.com/q/22058087
tags question: http://stackoverflow.com/q/22113072
tags question: http://stackoverflow.com/q/22036647
tags question: http://stackoverflow.com/q/22153241
tags question: http://stackoverflow.com/q/22030054
tags question: http://stackoverflow.com/q/22059386
tags question: http://stackoverflow.com/q/22047855
tags question: http://stackoverflow.com/q/22158458
tags question: http://stackoverflow.com/q/22017879
tags question: http://stackoverflow.com/q/22081336
tags question: http://stackoverflow.com/q/22043489
tags question: http://stackoverflow.com/q/22078922
tags question: http://stackoverflow.com/q/22085346
tags question: http://stackoverflow.com/q/22062019
type: Tag
tags question: http://stackoverflow.com/q/22133615
tags question: http://stackoverflow.com/q/22128759
tags question: http://stackoverflow.com/q/22061461
tags question: http://stackoverflow.com/q/22118029
tags question: http://stackoverflow.com/q/22075391
tags question: http://stackoverflow.com/q/22060705
tags question: http://stackoverflow.com/q/22139941
tags question: http://stackoverflow.com/q/22083104
tags question: http://stackoverflow.com/q/22156284
tags question: http://stackoverflow.com/q/22085935
tags question: http://stackoverflow.com/q/22134329
tags question: http://stackoverflow.com/q/22092398
tags question: http://stackoverflow.com/q/22014605
tags question: http://stackoverflow.com/q/22071804
tags question: http://stackoverflow.com/q/22109227

http://stackoverflow.com/q/22155836
has comment: http://stackoverflow.com/comment/33622617
has comment: http://stackoverflow.com/comment/33626197
tagged with: java
tagged with: paragraph
upvote count: 1
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33622680
has answer: http://stackoverflow.com/a/22155971
has body: For example, if I have the following lines of text in a file: this is an example. this is an example. this is an example. this is an example. this is an example this is an example this is an example this is an example this is an example this is an example this is an example this is an example this is an example this is an example this is an example. I want to be able to count these lines as 3 paragraphs. Now my code will count this as 4 paragraphs, as it does not know when a paragraph begins and ends. Scanner file = new Scanner(new FileInputStream("../.../output.txt")); int count = 0; while (file.hasNextLine()) { //whilst scanner has more lines Scanner s = new Scanner(file.nextLine()); if(!file.hasNext()){ break; } else{ file.nextLine(); count++; } s.close(); } System.out.println("Number of paragraphs: "+ count); file.close(); This is what I have so far. It reads lines of text, and treats each line as a single paragraph. I want it to treat lines of text that don't have any empty line between them as 1 paragraph and count all paragraphs in file.
score: 0
answer count: 2
has title: java how to use scanner to read and count paragraph
tagged with: string
favorite count: 0
has answer: http://stackoverflow.com/a/22156123
has comment: http://stackoverflow.com/comment/33624670
type: UnansweredQuestion

http://stackoverflow.com/comment/33605830
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22104152
has text: Your suggestions to differentiate through the message and not through the handler was a legitimate solution to my isssue. In the end I took a different approach because of other business logic related decisions. But I will accept your answer as a viable one. Thank you :)
type: AnswerComment

http://stackoverflow.com/comment/33374636
type: AnswerComment
has text: Unfortunately, search string is not so simple.. My algorithm should handle with any valid regex pattern.
score: 0
comment on: http://stackoverflow.com/a/22017621
type: Comment

http://stackoverflow.com/q/22104008
favorite count: 0
has title: Vert.x fails to "Run your module and see your changes immediately"
tagged with: redeploy
accepted answer: http://stackoverflow.com/a/22299626
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/27607686
has body: I am working with the Vert.x Gradle template hosted at the Vert.x Github space. The build file suggests that there is a runModIDEA target that runs IDEA-built class files so that rebuild/redeploy is not required to pick up changes: runModIDEA - run the module from the project resources in IDEA. This allows you to run the module without building it first! ... yet the task does not exist per ./gradlew tasks. I am not tied to this particular build task per se. I just want a working auto-redeploy solution that enables me to see updates without a two minute rebuild/redeploy cycle. EDIT: I also tried running it directly, pointing to InteliJ IDEA output classpath. It works fine, but doesn't pick up changes. vertx runmod com.mycompany~vert-x-reverse-proxy~1.0.0-final -c conf.json -cp out/production/vert-x-reverse-proxy EDIT: I also tried ./gradlew runmod -m, first changing vertx_classpath.txt so that the IDEA files (out/production) are looked at first. Still no redeploy. In fact, while it was running, I deleted the out directory and it continued working. EDIT: I also tried vertx run com.mycompany.myproject.ReverseProxyVerticle -c conf.json -cp out/production/vert-x-reverse-proxy... same results. It ran as expected but did not pick up changes. Only way to pick up changes was to gradlew clean and re-assemble. EDIT: I have been through these instructions as well.
tagged with: java
has answer: http://stackoverflow.com/a/27607686
upvote count: 1
tagged with: gradle
type: Question
tagged with: intellij-idea
has answer: http://stackoverflow.com/a/22299626
answer count: 2
tagged with: vert.x
downvote count: 0
score: 1

http://stackoverflow.com/a/22087244
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22087101
has comment: http://stackoverflow.com/comment/33522355
type: Answer
accepted answer of: http://stackoverflow.com/q/22087101
has body: This probably requires a bit more information to be specific, but I'll try and run with it. So if you have a server that maintains a list of clients that are connected, you could ideally tag each one with some type of ID when they make a connection into the server. For example lets say you had a server that managed some kind of data and two types of clients could connect: Managers and Customers. Now when a client connects you can setup the server so that it asks the user which they are and verify with a login maybe. Continuing from that you could place all of the types into unique lists and then broadcast to those lists separately. Additionally since you can control the server and client application. You could generate a random ID number/tag/something for each user that connects and store that in a list. Then should the server want to message a unique client you just have to search the list(or hashmap) for that users socket/connection and broadcast to them. I know this answer seems a bit vague but the information provided felt that way.
has comment: http://stackoverflow.com/comment/33500484
score: 0

http://stackoverflow.com/comment/33624509
comment on: http://stackoverflow.com/q/22156876
type: Comment
type: QuestionComment
score: 3
has text: Have you attempted to write a regex?

http://stackoverflow.com/q/22013578
type: Question
has answer: http://stackoverflow.com/a/22014186
upvote count: 6
tagged with: arrays
has body: I have a problem very similar to the link below: PDF to byte array and vice versa The main difference being I am trying to interpret a Socket connection via a ServerSocket containing Binary, rather than a file. This works as expected. However, the problem I am having is that this process is taking quite a long time to read into memory, about 1 minute 30 seconds for 500 bytes (although the size of each stream will vary massively) Here's my code: BufferedInputStream input = new BufferedInputStream(theSocket.getInputStream()); byte[] buffer = new byte[8192]; int bytesRead; ByteArrayOutputStream output = new ByteArrayOutputStream(); while ((bytesRead = input.read(buffer)) != -1) { output.write(buffer, 0, bytesRead); } byte[] outputBytes = output.toByteArray(); //Continue ... and eventually close inputstream If I log it's progress within the while loop within the terminal it seems to log all the bytes quite quickly (i.e. reaches the end of the stream), but then seems to pause for a time before breaking out of the while loop and continuing. Hope that makes sense.
answer count: 3
has title: BufferedInputStream to ByteArrayOutputStream very slow
favorite count: 0
linked to: http://stackoverflow.com/q/1131116
downvote count: 0
has answer: http://stackoverflow.com/a/22013639
accepted answer: http://stackoverflow.com/a/22013639
score: 6
has comment: http://stackoverflow.com/comment/33366895
possible better answer: http://stackoverflow.com/a/22013998
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22013998
tagged with: java

http://stackoverflow.com/comment/33470660
has text: I had a few separate issues getting the JDBC delete statement to work, but that was related to my JDBC Confgiguration Element. In case it is of any use to anyone else, you can set the Query type to "Update Statement" (still not entirely sure what this does) and then write your "DELETE FROM....." SQL in the query itself. Now my tests clean up after each suite has run, which is great!
comment on: http://stackoverflow.com/a/22043926
type: AnswerComment
type: Comment
score: 2

http://stackoverflow.com/comment/33555135
score: 0
type: Comment
type: QuestionComment
has text: Should be. In the Export settings I selected "Package required libraries into generated jar". I also tried to select "Extract required libraries into generated JAR". Got the same error in both cases.
comment on: http://stackoverflow.com/q/22118099

http://stackoverflow.com/comment/33501990
type: AnswerComment
score: 0
type: Comment
has text: Thanks A LOT now its working. Thanks for Saving my Day.... i am new to selenium so bit problem in analyzing the codes
comment on: http://stackoverflow.com/a/22088131

http://stackoverflow.com/comment/33614009
type: AnswerComment
has text: Ah, thank you for mentioning synchronization or else I would have completely forgot to consider that in my implementation, would List list = Collections.synchronizedList(new LinkedList(...)); be the efficient approach then?
type: Comment
comment on: http://stackoverflow.com/a/22150977
score: 0

http://stackoverflow.com/q/22151098
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22151259
downvote count: 0
score: 1
tagged with: java
tagged with: sprite
type: Question
has body: OK so I'm really confused I've rotated sprites before and had no problem such as rotating a boat as it moves through an ocean, but for some reason I'm having a really big problem this time. So I create a texture in an assets file, but not static textures. I load the texture using the following: class Assets{ Texture img; public Assets(){ img = new Texture(Gdx.files.internal("images/PNG.png") And then I call the assets in the main class by calling: Assets assets = new Assets() And then I have a class that is an animator just for this main character because his animation is so different and varied from other characters. class Animations{ Guy MYGUY; Texture firstTexture; ArrayList&lt;Texture&gt; running; Sprite CurrentSprite; public Animations(Texture standingStill, Guy myGuy){ MYGUY = myGuy; firstTexture = standingStill; running = new ArrayList&lt;Texture&gt;(); running.add(firstTexture); CurrentSprite = new Sprite(firstTexture); public void update (int direction, int state){ CurrentSprite.setPosition(MYGUY.X, MYGUY.Y) // I have a switch here, but it does nothing yet because I haven't added in different actions for the character. //However I do have a switch for direction, because that is important right now switch(state){ case Guy.LEFT: CurrentSprite.set rotation(180); //yes there are more, but even rotating 180 won't work correctly } Then I have a renderer class to draw everything, i have the object MyGuy in an object for the world called myLand and I draw it with: myLand.GUY.animation.CurrentSprite(batch); So my problem arises on the rotation, whenever it rotates 180 degrees it seems to always rotate around the coordinates (0, 0) instead of the center of the sprite. So it usually ends up where I move like five to the right, but then if I try to go left it does double the distance backwards, but the camera position stays the same, and the guy usually disappears off the left or right side of the screen.
has comment: http://stackoverflow.com/comment/33614752
tagged with: rotation
has answer: http://stackoverflow.com/a/22168773
possible better answer: http://stackoverflow.com/a/27480731
accepted answer: http://stackoverflow.com/a/22168773
tagged with: libgdx
has answer: http://stackoverflow.com/a/27480731
has comment: http://stackoverflow.com/comment/33614063
answer count: 3
upvote count: 1
tagged with: android
has comment: http://stackoverflow.com/comment/33613767
favorite count: 0
has title: LibGDX problems rotating sprite
has comment: http://stackoverflow.com/comment/33614695

http://stackoverflow.com/a/36218961
answers question: http://stackoverflow.com/q/22137469
has body: I know this question is 2 years old, however I had to find a workaround for a similar problem so it may help someone. Here is what I did to bypass the SSL certificate while calling SOAP services over HTTPS : BaseWLSSLAdapter.setStrictCheckingDefault(false); SSLAdapterFactory.getDefaultFactory().createSSLAdapter(); System.setProperty("org.apache.axis.components.net.SecureSocketFactory", "org.apache.axis.components.net.SunFakeTrustSocketFactory");
downvote count: 0
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/q/22014233
score: 3
upvote count: 3
has body: I have a scenario to verify Print Properties dialog (Windows component) opening up correctly after clicking on Print link. Aware of Robot utility class in Java which can emulate keyboard events like Escape/Enter etc. to operate on that window. Is there any way we can verify the new dialog opened up is a Print dialog - something to verify dialog title i.e. Print or retrieve text from that windows dialog or something else which will confirm dialog to be a Print dialog.
type: Question
tagged with: java
has comment: http://stackoverflow.com/comment/33369834
answer count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33370016
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22016866
has answer: http://stackoverflow.com/a/22029125
linked to: http://stackoverflow.com/q/11537103
tagged with: selenium-webdriver
has title: Selenium WebDriver : Verify Print Window dialog displayed on the page

http://stackoverflow.com/a/22165132
type: Answer
score: 3
upvote count: 3
has body: As I previously mention in comment, you need also native library to make it work. Put it in ${JRE_HOME}/lib/i386 nice article: http://pharos.ece.utexas.edu/wiki/index.php/How_to_Access_Your_Serial_Port_using_Java and quote from article: $ wget http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip Unzip the rxtx archive and install it. The following commands assume your JVM is located in /usr/lib/jvm/java-6-openjdk/ and that you are using a 32-bit x86 computer. You will need to slightly modify these commands if you have a different JVM or system architecture (i.e., 64-bit). $ sudo apt-get install zip $ unzip rxtx-2.1-7-bins-r2.zip $ cd rxtx-2.1-7-bins-r2 $ sudo cp RXTXcomm.jar /usr/lib/jvm/java-6-openjdk/jre/lib/ext/ $ sudo cp Linux/i686-unknown-linux-gnu/librxtx* /usr/lib/jvm/java-6-openjdk/jre/lib/i386/
has comment: http://stackoverflow.com/comment/98322071
downvote count: 0
answers question: http://stackoverflow.com/q/22164784

http://stackoverflow.com/comment/33486360
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22079456
has text: Yes. I don't know for sure, but off the top of my head, I'd guess that the read(-1) is making use of the addDataQueueListener() method of the com.ibm.as400.access.BaseDataQueue class.
score: 0

http://stackoverflow.com/comment/33642612
type: Comment
comment on: http://stackoverflow.com/a/22167212
score: 1
type: AnswerComment
has text: `<T> T getBean(Class<T> requiredType)` is also available

http://stackoverflow.com/comment/37613781
has text: Would be interesting to know if 4.4.3 fixes this. There were a slew of fixes related to BT
comment on: http://stackoverflow.com/q/22022001
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22118394
type: Answer
has body: One way is to add blank lines at the begining, depending on number of rows of JTextArea, and set the caret location to the end of the TextArea using setCaretPosition() method.
answers question: http://stackoverflow.com/q/22118238
score: 0

http://stackoverflow.com/comment/33606617
score: 0
has text: Its could be a completely off java work. PLSQL (Oarcle sql) have methods to use SQLLDR API. You may develop a procedure in plsql and call it by java.
type: Comment
comment on: http://stackoverflow.com/a/22146150
type: AnswerComment

http://stackoverflow.com/a/22087409
score: 1
has body: Please see the description provided for MONTH Constant in Calendar Class. Calendar.MONTH public static final int MONTH Field number for get and set indicating the month. This is a calendar-specific value. The first month of the year in the Gregorian and Julian calendars is JANUARY which is 0; the last depends on the number of months in a year. So if you want to set the date in calendar than use below code snippet. cal.set(2014, Calendar.FEBRUARY, 28); I think it will help you.
answers question: http://stackoverflow.com/q/22087150
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/a/22161571
has comment: http://stackoverflow.com/comment/33635009
has comment: http://stackoverflow.com/comment/33635059
answers question: http://stackoverflow.com/q/22161412
has comment: http://stackoverflow.com/comment/33638773
has comment: http://stackoverflow.com/comment/33637396
has comment: http://stackoverflow.com/comment/33637487
has comment: http://stackoverflow.com/comment/33633139
downvote count: 0
has comment: http://stackoverflow.com/comment/33635571
has comment: http://stackoverflow.com/comment/33676681
has comment: http://stackoverflow.com/comment/33635726
has comment: http://stackoverflow.com/comment/33635526
has comment: http://stackoverflow.com/comment/33635996
has comment: http://stackoverflow.com/comment/33636047
has comment: http://stackoverflow.com/comment/33637354
has comment: http://stackoverflow.com/comment/33635866
has comment: http://stackoverflow.com/comment/33633997
has comment: http://stackoverflow.com/comment/33635915
has comment: http://stackoverflow.com/comment/33634218
has comment: http://stackoverflow.com/comment/33639206
type: Answer
has comment: http://stackoverflow.com/comment/33634177
has comment: http://stackoverflow.com/comment/33634054
has comment: http://stackoverflow.com/comment/33636220
has comment: http://stackoverflow.com/comment/33635839
has comment: http://stackoverflow.com/comment/33635778
has comment: http://stackoverflow.com/comment/33635069
has comment: http://stackoverflow.com/comment/33676271
has comment: http://stackoverflow.com/comment/33636281
upvote count: 3
has body: So, two things, first... public void DropTargetTextArea(String string1, String string2) { Isn't a constructor, it's a method, note the void. This means that it is never getting called. It's also the reason why DropTargetTextArea textArea = new DropTargetTextArea(); works, when you think it shouldn't. Second, you're not maintaining a reference to the values you pass in to the (want to be) constructor, so you have no means to references them later... You could try using something like... private String[] values; public DropTargetTextArea(String string1, String string2) { values = new String[]{string1, string2}; DropTarget dropTarget = new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, this, true); } And then use something like... if (values[0].equals(dragContents) || values[1].equals(dragContents)) { In the drop method. In your dragEnter, dragOver and dropActionChanged methods you have the oppurtunity to accept or reject the drag action using something like dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); or dtde.rejectDrag(); Updated with test code import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.dnd.DnDConstants; import java.awt.dnd.DragGestureEvent; import java.awt.dnd.DragGestureListener; import java.awt.dnd.DragSource; import java.awt.dnd.DragSourceDragEvent; import java.awt.dnd.DragSourceDropEvent; import java.awt.dnd.DragSourceEvent; import java.awt.dnd.DragSourceListener; import java.awt.dnd.DropTarget; import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetEvent; import java.awt.dnd.DropTargetListener; import java.io.IOException; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPane…
has comment: http://stackoverflow.com/comment/33633250
has comment: http://stackoverflow.com/comment/33633164
has comment: http://stackoverflow.com/comment/33633054
has comment: http://stackoverflow.com/comment/33637543
has comment: http://stackoverflow.com/comment/33637409
has comment: http://stackoverflow.com/comment/33635794
score: 3
has comment: http://stackoverflow.com/comment/33636512
has comment: http://stackoverflow.com/comment/33639415
has comment: http://stackoverflow.com/comment/33633886
has comment: http://stackoverflow.com/comment/33636103
has comment: http://stackoverflow.com/comment/33633292
has comment: http://stackoverflow.com/comment/33636423
has comment: http://stackoverflow.com/comment/33633108
has comment: http://stackoverflow.com/comment/33635237
has comment: http://stackoverflow.com/comment/33633170
has comment: http://stackoverflow.com/comment/33634124
has comment: http://stackoverflow.com/comment/33635252
has comment: http://stackoverflow.com/comment/33633379
has comment: http://stackoverflow.com/comment/33633583
has comment: http://stackoverflow.com/comment/33634969

http://stackoverflow.com/comment/33531075
type: Comment
comment on: http://stackoverflow.com/a/22103914
has text: @Jerry Even before my major edit, I explicitly said that the move functions belong inside *Shape*, not Oval. You obviously misread my answer. You can check the revision history if you do not believe me.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33593993
type: QuestionComment
has text: What have you done so far, where is your code ?
comment on: http://stackoverflow.com/q/22139378
score: 1
type: Comment

http://stackoverflow.com/q/22099307
has comment: http://stackoverflow.com/comment/33520756
possible better answer: http://stackoverflow.com/a/22099789
has answer: http://stackoverflow.com/a/22099525
accepted answer: http://stackoverflow.com/a/22099525
tagged with: android
tagged with: fragment
type: AnsweredQuestion
tagged with: tabs
tagged with: java
has title: How to create tabs in a fragment
type: Question
has answer: http://stackoverflow.com/a/22099789
tagged with: android-fragments
score: 0
answer count: 2
has body: I'm creating a project that has a Navigation Drawer using fragment. And I wanted in the first fragment is 3 tabs appear. But I can not create the tabs are displayed in InicioFragment.class. How can I do? InicioFragment.class package com.menuguru; public class InicioFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_inicio, container, false); // getActivity().getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); return rootView; } } With this code the tabs always appear.
has comment: http://stackoverflow.com/comment/33520809

http://stackoverflow.com/a/22062732
has body: While starting an activity, you can send more information to that activity like an integer or String value. It can be send in the following way: Intent addIntent = new Intent(); addIntent.putExtra(String name, String value). So, you can send the name to your new activity. Then you need to get this value in onCreate function using getExtra() function. and can use to fill the editText. Below link will give you more insight: How to use putExtra() and getExtra() for string data
score: 0
has comment: http://stackoverflow.com/comment/33455820
has comment: http://stackoverflow.com/comment/33455673
type: Answer
has comment: http://stackoverflow.com/comment/33484300
answers question: http://stackoverflow.com/q/22062655
has comment: http://stackoverflow.com/comment/33455763
has comment: http://stackoverflow.com/comment/33455727

http://stackoverflow.com/q/22032765
has comment: http://stackoverflow.com/comment/33403581
has comment: http://stackoverflow.com/comment/33403493
has answer: http://stackoverflow.com/a/22044077
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33401970
has comment: http://stackoverflow.com/comment/33403750
has comment: http://stackoverflow.com/comment/33401964
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33402445
type: Question
upvote count: 2
has body: String[] str ={"a", "b","c", "d"}; for (String lists : str) { System.out.println(lists); } in above code while compiling i am getting error like this ERROR in CollectionList.java (at line 19) for (String lists : str) ^^^^^^^^^^^^^^^^^^ Syntax error, 'for each' statements are only available if source level is 1.5 kindly help me out this problem i am using java 1.7.0_51 version, OS linux Deepin Thanks in advance
has comment: http://stackoverflow.com/comment/33402509
answer count: 3
has comment: http://stackoverflow.com/comment/33401949
accepted answer: http://stackoverflow.com/a/22033720
tagged with: java-7
has comment: http://stackoverflow.com/comment/33402431
has title: using 1.7.0_51 but Syntax error, 'for each' statements are only available if source level is 1.5
favorite count: 0
has answer: http://stackoverflow.com/a/22033716
has answer: http://stackoverflow.com/a/22033720
downvote count: 1
has comment: http://stackoverflow.com/comment/33403470
has comment: http://stackoverflow.com/comment/33402501
possible better answer: http://stackoverflow.com/a/22033716
has comment: http://stackoverflow.com/comment/33402459
has comment: http://stackoverflow.com/comment/33402153
has comment: http://stackoverflow.com/comment/33403667
has comment: http://stackoverflow.com/comment/33403478
has comment: http://stackoverflow.com/comment/33401980
has comment: http://stackoverflow.com/comment/33402825
has comment: http://stackoverflow.com/comment/33402455

http://stackoverflow.com/comment/33558444
has text: @John The Android documentation clearly states `Causes the VM to stop running and the program to exit with the given exit status.` for the exit() method. How is it that it exits just the current activity? (source: http://developer.android.com/reference/java/lang/System.html#exit(int))
type: Comment
score: 1
comment on: http://stackoverflow.com/a/22120083
type: AnswerComment

http://stackoverflow.com/comment/33597001
type: Comment
comment on: http://stackoverflow.com/a/22141712
has text: noArgSurvey.displayQuestionStats(i); line 55 on tester
type: AnswerComment
score: 0

http://stackoverflow.com/a/22159629
upvote count: 1
accepted answer of: http://stackoverflow.com/q/22158335
type: Answer
answers question: http://stackoverflow.com/q/22158335
downvote count: 0
score: 1
has body: I don't know anything about Priorizable, which isn't part of the JDK, but unless it extends Comparable you can't use it with PriorityQueue as shown in your title. If it does extend Comparable, that's the only answer you need to your question.
type: AcceptedAnswer

http://stackoverflow.com/a/22097343
has body: You cannot use the mailto as your form action. Your form action must go to back-end code (e.g.: servlet). Change your form as follows: &lt;form role="form" action="/SendEmail" method="get" enctype="text/plain"&gt; &lt;div class="form-group"&gt; &lt;label for="emailinput"&gt;&lt;h4&gt;&lt;span class="glyphicon glyphicon-envelope"&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;E-mail&lt;/h4&gt;&lt;/label&gt; &lt;input class="form-control" type="email" id="emailinput" placeholder="Entrez votre e-mail"&gt; &lt;/input&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="messageinput"&gt;&lt;h4&gt;&lt;span class="glyphicon glyphicon-pencil"&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;Message&lt;/h4&gt;&lt;/label&gt; &lt;textarea class="form-control" id="messageinput" placeholder="Ecrivez votre message" rows="3"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;br/&gt; &lt;div class="text-right"&gt; &lt;button type="submit" class="btn btn-default"&gt; &lt;span class="glyphicon glyphicon-upload"&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;Envoyer &lt;/button&gt; &lt;/div&gt; &lt;/form&gt; For the sample of servlet code. Please refer to this link http://www.tutorialspoint.com/servlets/servlets-sending-email.htm Thanks
type: AcceptedAnswer
downvote count: 0
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/22097071
score: 1
accepted answer of: http://stackoverflow.com/q/22097071

http://stackoverflow.com/q/22111500
type: Question
tagged with: apache
has answer: http://stackoverflow.com/a/22112078
has title: How to ignore proportionality when scaling SVG images using Apache Batik?
has comment: http://stackoverflow.com/comment/127056993
answer count: 1
downvote count: 0
tagged with: batik
favorite count: 0
tagged with: http://stackoverflow.com/tag/svg
upvote count: 2
has body: I am currently trying to creating a custom JComponent (ViewerComponent) that scales and displays a SVG image using apache batik. Currently the ViewerComponent scales the SVG image proportionally; however, I would like for it to scale to fit the size of the component, ignoring proportionality. The code below shows a simple test I have written for the ViewerComponent. How can I modify it the ViewerComponent to behave as I mentioned above? import java.awt.*; import java.awt.event.*; import java.net.*; import javax.swing.*; import org.apache.batik.swing.*; import org.apache.batik.swing.gvt.*; import org.apache.batik.util.*; import org.w3c.dom.svg.*; public final class View extends JPanel { public static final Dimension VIEW_SIZE = new Dimension(2000, 2000); public static final Dimension WINDOW_SIZE = new Dimension(600, 600); public static final String BACKGROUND_IMAGE = "file:///Users/home/Desktop/wiki.svg"; private JScrollPane scrollPane; private ViewerComponent canvas; View() throws URISyntaxException { setUpGUI(); createViewerBasedOnViewportSize(); } private void setUpGUI() throws HeadlessException { setUpView(); setUpScrollPane(); setUpFrame(); } private void setUpView() { this.setPreferredSize(VIEW_SIZE); this.setBackground(Color.WHITE); } private void setUpScrollPane() { scrollPane = new JScrollPane(this); } private void setUpFrame() throws HeadlessException { JFrame frame = new JFrame("SVG Viewer Test"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setContentPane(scrollPane); frame.setPreferredSize(WINDOW_SIZE); frame.setLocationByPlatform(true); frame.pack(); frame.setVisible(true); frame.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { adjustBackgroundComponentScale(); repaint(); } }); } private void adjustBackgroundComponentScale() { if (canvas != null) { Dimension windowSize = calculateWindowSize(); canvas.setFinalViewerSize(windowSize); } } private void createViewerBasedOnViewportSize(…
accepted answer: http://stackoverflow.com/a/22112078
score: 2
type: AnsweredQuestion
tagged with: java
tagged with: scaling

http://stackoverflow.com/a/22023368
downvote count: 0
has body: You can have the entity manager perform a native query. See this page section "Utilizing Native SQL Queries" So your code would look like this: List&lt;SOME_DATA_TYPE&gt; list = (List&lt;SOME_DATA_TYPE&gt;)em.createNativeQuery ("SELECT * FROM table1 a join talbl2 b on a.somefiedd = b.somefield " , some.package.name.SOME_DATA_TYPE.class) .getResultList(); Technically not JPQL but still JPA. It's an idea. Hope that helps.
upvote count: 2
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22022169
type: Answer
answers question: http://stackoverflow.com/q/22022169
score: 2

http://stackoverflow.com/comment/42235255
score: 0
type: AnswerComment
has text: If you can't read the original question or my comments accurately I don't know what good reiterating it all could possibly do. However, fr your further assistance, the OP is getting `'a device attached to the system is not functioning'` whenever he creates a `FileChannel` for the raw disk by any means, and he will get it via your answer too, once he gets over the trivial access problem you mention. I agree that my answer doesn't answer the question either as it doesn't let him perform random access. There evidently is no answer to that.
type: Comment
comment on: http://stackoverflow.com/a/26771479

http://stackoverflow.com/q/22156920
has answer: http://stackoverflow.com/a/22228049
type: Question
linked to: http://stackoverflow.com/q/11756534
tagged with: eclipse-rcp
accepted answer: http://stackoverflow.com/a/22158064
answer count: 2
has body: we have the following problem: In our Eclipse RCP 4 application there are multiple parts and the parts are closable. When the user is closing a part there should be a custom pop-up (depending on some internal part state) which is asking the user if he really wants to close the part or not. It seems to be not that easy to implement in Eclipse RCP 4 or we have just totally overseen something. I'll just give you a short brieifing about the things we tried: Use dirtable with a @persist method in the part. Though the problem is, we don't want this standard eclipse save dialog. So is there a way to override this? public int promptToSaveOnClose(): This seemed to be promising but not for Eclipse 4 or is there a way to integrate it that way? Compare: http://e-rcp.blogspot.de/2007/09/prevent-that-rcp-editor-is-closed.html Our last try was to integrate a custom part listener, simple example shown in the following: partService.addPartListener(new IPartListener() { public void partVisible(MPart part) { } public void partHidden(MPart part) { partService.showPart(part, PartState.ACTIVATE); } public void partDeactivated(MPart part) { } public void partBroughtToTop(MPart part) { } public void partActivated(MPart part) { } }); The problem with this was we are running into a continuous loop. Something similar is posted over here in the last comment: Detect tab close in Eclipse editor So I could write some more about this problem, but I think that's enough for the moment. If you need some more input just give me a hint. Thanks for helping.
downvote count: 0
favorite count: 0
tagged with: e4
type: AnsweredQuestion
score: 2
upvote count: 2
has answer: http://stackoverflow.com/a/22158064
tagged with: java
possible better answer: http://stackoverflow.com/a/22228049
has title: Custom message when closing a part in Eclipse RCP 4

http://stackoverflow.com/comment/33412096
comment on: http://stackoverflow.com/a/22037071
has text: Salah i think he want to save not only the value but all the line. also seconds if in calculateMinAndMax is wrong. @UnmeshaSreeVeni to get all the line, save it when the code save min and max value! because calculateMinAndMax uses an array of string (witch is a string for each column of current line), you have to save the result in an array (size = number of column to check) of array of string (size = number of column)
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/40955572
type: QuestionComment
comment on: http://stackoverflow.com/q/22033052
score: 0
has text: were you able to successfully start the restart process ? I am stuck at a very similar issue. Only that I have to download a file from FTP server and for that I have used retrieveFileStream()
type: Comment

ftp
tags question: http://stackoverflow.com/q/22071632
tags question: http://stackoverflow.com/q/22033052
type: Tag
tags question: http://stackoverflow.com/q/22132736
tags question: http://stackoverflow.com/q/22132044
tags question: http://stackoverflow.com/q/22073757
tags question: http://stackoverflow.com/q/22022737
tag name: ftp
tags question: http://stackoverflow.com/q/22120238
tags question: http://stackoverflow.com/q/22089666

http://stackoverflow.com/comment/33586705
has text: added the screen shots
comment on: http://stackoverflow.com/q/22085346
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33486791
comment on: http://stackoverflow.com/q/22076688
type: QuestionComment
type: Comment
has text: @John: The OP knew more than the question said, because he knew the code didn't successfully compile. Given that he was talking about unexpected compiler behaviour, it would have been very sensible to mention which compiler was being used. (If it were me, I'd have tried a different compiler as well, and reported on the differences.) The original post gave the definite impression that all was fine - that it was running just as any valid code would. The OP *knew* that wasn't the case, but left that out of the question. Still a bad question IMO, and I hope the OP learns to ask better ones.
score: 2

http://stackoverflow.com/a/22024156
answers question: http://stackoverflow.com/q/22023867
type: Answer
has comment: http://stackoverflow.com/comment/33387442
upvote count: 2
has comment: http://stackoverflow.com/comment/33386861
has comment: http://stackoverflow.com/comment/33387215
has comment: http://stackoverflow.com/comment/33386699
has body: The compiler has a limitation of 64 KB for a single method. This is born from the fact that a jump can only go to an absolution byte code position and uses a 16-bit unsigned value. The limitation applies even if you don't have a such a jump. This has a some surprising consequences. While you might not want to have thousands of nested objects defined this way, you might have a generated class with say thousands of ENUM values. These values are created in one static initialiser method and this also has the same limitation, so you can only have about 3K enum values. A more likely limitation is large arrays. When you define an array, it actually generates code to set each and every cell. This is pretty inefficient, but general. It also means you can't define an array in Java, with initialised values, with say 10K hard coded values. Again, this is really only a problem for generated code.
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33387315
has comment: http://stackoverflow.com/comment/33387538

http://stackoverflow.com/a/22007893
has body: To answer the two first questions: Yes it's true, and yes. First there is the time between the timeout expires and the time when the OS notices it, then there the time for the OS to reschedule your process, and lastly there's the time from the process has been "woken up" until it is its turn to run. How long will all this take? There's no way of saying. And as it's all done on the OS level, it doesn't really matter what language you program in. As for a more accurate way? There is none. You can use more high-precision timers, but there is no way of avoiding the lag described above.
type: Answer
upvote count: 2
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/22007644

http://stackoverflow.com/comment/33457840
type: Comment
type: QuestionComment
has text: Read [java basics](http://docs.oracle.com/javase/tutorial/java/nutsandbolts/)
comment on: http://stackoverflow.com/q/22064422
score: 0

http://stackoverflow.com/a/22069491
answers question: http://stackoverflow.com/q/22069400
score: 0
has body: What you want is to enforce a default behavior on your class - in Java, abstract classes are the place to formulate default behavior inherited by all extending classes (see the template method design pattern for an application of this). Interfaces only describe, how your objects externally behave and how they can be used by others.
type: Answer

http://stackoverflow.com/comment/33376636
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22012998
has text: No i have started learning java via online video tutorials of "thenewboston".
score: 0

http://stackoverflow.com/q/22056991
score: 2
type: AnsweredQuestion
upvote count: 2
has comment: http://stackoverflow.com/comment/33445570
has body: hi there now I got a situation here. String myStrings = new String(); myStrings = "10.42.0.1"; char[] charNum = myStrings.toCharArray(); //convert string to char array char checkSum = 0; A： for(int i = 0; i &lt;= 8; i++) { checkSum += charNum[i]; } B： for(int i = 0; i &lt;= 8; i++) { checkSum ＝ checkSum ＋charNum[i]; } compile A: works just what I expect compile B: Type mismatch: cannot convert from int to char Since I know java will convert a+=b to a=char(a+b) implicitly, that why A works fine. But what really concern me is what's wrong with charNum[i]. ok, HeadFirstJava tells me that array is an object, so charNum[i] is a reference variable(4bytes), and I accept that. And charNum[i](reference variable) points to an char(2bytes), and I want to use that char(2bytes) to do arithmetical operation, but it looks like JAVA says NO. When I type checkSum ＝ checkSum＋charNum[i]; ( 2bytes ) = ( 2bytes ) + ( 4bytes ) it means that charNum[i] have 4bytes in memory, and it really confuse me, because I use char(2bytes) to do the math, not charNum[i](reference variable). And if it really use charNum[i](4bytes, reference variable) to do the math, why do I get the right value of checksum? SO can anyone tell me do I mistaken HeadFirstJava or do I miss some concept here? And if you can explain this in detail, that would be highly appreciated. thanks in advance.
has answer: http://stackoverflow.com/a/22057057
has comment: http://stackoverflow.com/comment/33445481
type: Question
tagged with: java
has comment: http://stackoverflow.com/comment/33445651
has comment: http://stackoverflow.com/comment/33445447
has comment: http://stackoverflow.com/comment/33445440
linked to: http://stackoverflow.com/q/8710619
answer count: 2
accepted answer: http://stackoverflow.com/a/22057057
tagged with: arrays
downvote count: 0
duplicate of: http://stackoverflow.com/q/8710619
favorite count: 0
has comment: http://stackoverflow.com/comment/33445610
has title: a = a + b-->cannot convert from int to char. a+=b-->pass
possible better answer: http://stackoverflow.com/a/22057040
has answer: http://stackoverflow.com/a/22057040

http://stackoverflow.com/a/22130688
type: Answer
downvote count: 0
score: 1
has body: I guess EnumSet is what you are looking for: import java.awt.*; import java.awt.event.*; import java.util.*; import java.util.List; import javax.swing.*; enum Receipt { CheeseBurger("Cheese Burger"), BigMac("Big Mac"), BigNTasty("Big n' Tasty"), McSpicy("McSpicy"), QuarterPounderWithCheese("Quarter Pounder with Cheese"), DoubleCheeseburger("Double Cheeseburger"), McChickenSandwich("McChicken Sandwich"); //JCheckBox("Filet-O-Fish"), //JCheckBox("Cheeseburger Deluxe"), //JCheckBox("Burger Mcdo"), //JCheckBox("Chicken Filet with Drinks"), //JCheckBox("Spaghetti with Drinks"), //JCheckBox("Hot Fudge Sundae "), //JCheckBox("Caramel Sundae"), //JCheckBox("Large Mcdo French Fries"), //JCheckBox("Chicken Nuggets with coke"), //JCheckBox("Coke Float"), //JCheckBox("Green Apple Float"), //JCheckBox("Crispy Chicken with rice"), //JCheckBox("Oreo Sundae"); private final String str; private Receipt(String str) { this.str = str; } @Override public String toString() { return str; } } public class GUI2 { private JButton button = new JButton(new AbstractAction("Order Now") { @Override public void actionPerformed(ActionEvent e) { EnumSet&lt;Receipt&gt; r = EnumSet.noneOf(Receipt.class); for (ReceiptCheckBox c: list) { if (c.isSelected()) { r.add(c.getReceipt()); } } JOptionPane.showMessageDialog((JComponent) e.getSource(), r); } }); private List&lt;ReceiptCheckBox&gt; list = new ArrayList&lt;&gt;(Receipt.values().length); public JComponent makeUI() { JPanel p = new JPanel(); for (Receipt r: Receipt.values()) { ReceiptCheckBox c = new ReceiptCheckBox(r); list.add(c); p.add(c); } JPanel panel = new JPanel(new BorderLayout()); panel.add(new JLabel("McDonald's"), BorderLayout.NORTH); panel.add(button, BorderLayout.SOUTH); panel.add(p); return panel; } public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { createAndShowGUI(); } }); } public static void createAndShowGUI() { JFrame f = new JFrame(); f.setDefaultCloseOperation(WindowCon…
upvote count: 1
answers question: http://stackoverflow.com/q/22129517

http://stackoverflow.com/comment/33572932
score: 1
type: Comment
comment on: http://stackoverflow.com/q/22127567
type: QuestionComment
has text: What is the output of `jar tvf ~/glassfish4/glassfish/modules/javax.servlet-api.jar`. Edit your question to answer.

http://stackoverflow.com/a/22054381
downvote count: 0
answers question: http://stackoverflow.com/q/22053385
has comment: http://stackoverflow.com/comment/33528563
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22053385
has comment: http://stackoverflow.com/comment/33528783
has comment: http://stackoverflow.com/comment/33440801
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/33440972
has comment: http://stackoverflow.com/comment/33528008
has comment: http://stackoverflow.com/comment/33528642
score: 2
has comment: http://stackoverflow.com/comment/33440933
has comment: http://stackoverflow.com/comment/33528492
has body: So here's your code changing the BorderLayout with GridBagLayout. The core idea of the GridBagLayout is that you'll have a grid with several rows and columns (of different sizes) and you can place components in each cell. The neat thing about it is that it's very powerful: when you place a component in a cell you can customize the following: How many cells can it span through (vertically, horizontally or both) (gridwidth/gridheight) Where in the cell to put it on: center, top-left, bottom-right... (anchor) The weight of each row/column, this is how much space, proportionally, do they eat when resizing/distribuiting the window. (weightx, weighty) Whether they have to occupy the maximum or the minimum space necessary. (fill) Among other things. The last point was your problem here, BorderLayout was forcing your panel to expand as much as it could. In my code I used fill = NONE and set it at the anchor = LAST_LINE_START so it stays at the bottom left and doesn't expand. You can play with these parameters, all the info is in the tutorial. The key to all of it is to know how is your grid. In this example it's very simple it's just a 1x1. But look at the tutorial: those images with a grid painted in red over them, that's what you have to have in your mind. Other than that and knowing all the variables the only tricky thing is how weights work. import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingUtilities; public class Main { //Settings Panel variables JLabel settingsTitle = new JLabel("Settings"); public Main() { JPanel mainCard = new JPanel(new GridBagLayout()); JPanel settingsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); sett…

http://stackoverflow.com/a/22121926
score: 2
has comment: http://stackoverflow.com/comment/33561978
downvote count: 0
upvote count: 2
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33562202
has comment: http://stackoverflow.com/comment/33561951
accepted answer of: http://stackoverflow.com/q/22121888
type: Answer
has body: Try this (JD-GUI). Have a Mac version and it's nice. It will show to you the code from the class file.
answers question: http://stackoverflow.com/q/22121888

http://stackoverflow.com/comment/33583894
comment on: http://stackoverflow.com/a/22133720
has text: You would find far less questions on the internet if more meaningful and long lasting answers were given to begin with. Answers like yours are precisely why the OP, after failing to learn basic problem solving skills here (at minimum you merely showed him what a `for` loop does), will end up asking yet another unanswered question in the future.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/22143416
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/22166064
downvote count: 0
has body: I have a field filled with an EditText control, it figures: 475759403048575663648495004945757590. What can I use to choose the first 10 numbers from this EditText: and then, insert the numbers 4757594030, in the TextView?
has answer: http://stackoverflow.com/a/22143547
favorite count: 0
tagged with: character
type: UnansweredQuestion
tagged with: android
upvote count: 1
has title: How can I get the first 10 digits from EditText, and set this digits in a TextView?
score: 1
tagged with: java

http://stackoverflow.com/comment/33459225
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22064851
has text: yes..it worked properly. I don't know how it worked automatically...i just restarted my eclipse and its done.
score: 1

http://stackoverflow.com/comment/33611609
type: Comment
comment on: http://stackoverflow.com/q/22149518
has text: A new line is written with bw.newLine(). Are you getting 2 consecutive new lines? If so did you check if sbRec.toString() ends with a new line?
score: 0
type: QuestionComment

http://stackoverflow.com/q/22119371
tagged with: filepath
has body: I am trying to develop a game where it uses a song. The song plays as background music. I am trying to analyse the current frequency of the audio spectrum and output its value. I have used the FFT algorithm to get the frequency, but now I need to get the length of the song. So I am utilising this code: FileHandle filemain = Gdx.files.internal("data/determination.mp3"); File file = new File(filemain.toString()); AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(file); AudioFormat format = audioInputStream.getFormat(); long audioFileLength = file.length(); int frameSize = format.getFrameSize(); float frameRate = format.getFrameRate(); float durationInSeconds = (audioFileLength / (frameSize * frameRate)); But then it returns a FILENOTFOUNDEXCEPTION. using the Gdx.files.internal("data/determination.mp3"); it works fine. but I can't use that in the AudioInputSream declaration as it takes a file, not a file handle. And if I use the file path in the AudioInputStream like I have above, it returns the error. Where am I going wrong? and how can I fix this?
has answer: http://stackoverflow.com/a/22120026
tagged with: audio
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33559908
type: Question
tagged with: libgdx
score: 0
has title: filenotfoundexception when referencing filepath
answer count: 1
accepted answer: http://stackoverflow.com/a/22120026
has comment: http://stackoverflow.com/comment/33559872
has comment: http://stackoverflow.com/comment/33577046

http://stackoverflow.com/comment/33525361
type: Comment
has text: I have test your solution but what i need to do to add more K or more N?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22092523

http://stackoverflow.com/a/22060664
answers question: http://stackoverflow.com/q/22060637
accepted answer of: http://stackoverflow.com/q/22060637
upvote count: 4
type: AcceptedAnswer
downvote count: 0
has body: System.out.println(new Date(1393430400*1000)); in this 1393430400 as int will overflow. Some different value will get multiply by 1000 and for that you will get the Date.But when you do System.out.println(new Date((long)1393430400*1000)); 1393430400 this will be casted to long and the multiplication by 1000 will be long and no overflow.
type: Answer
score: 4
has comment: http://stackoverflow.com/comment/33451572

http://stackoverflow.com/comment/33411201
type: QuestionComment
comment on: http://stackoverflow.com/q/22037793
score: 0
type: Comment
has text: Okay, so have you used this? Can you please help me?

http://stackoverflow.com/a/22100875
type: Answer
has body: Try adding in your extended class constructor that references super class constructor i.e class B extends A { private int b; private double c; B(int b,double c, int superVal) { super(superVal); this.b=b; this.c=c; System.out.println("This is constructor of class B"); } }
score: 0
answers question: http://stackoverflow.com/q/22100730

http://stackoverflow.com/a/22152381
type: Answer
answers question: http://stackoverflow.com/q/22152060
has body: You're allowed to override the ArrayList class and implement your own methods such as .filter_by_single_date(). ArrayList&lt;LineItem&gt;data = new ArrayList&lt;LineItem&gt;(){ public ArrayList&lt;LineItem&gt; filter_by_single_date(){ } }; But I don't really see any reason to do this. You can just make a method in your current class. The ArrayList is an instance var.
score: 0

http://stackoverflow.com/comment/33632393
comment on: http://stackoverflow.com/a/22161131
score: 0
type: AnswerComment
has text: Actually, I forgot to include the lib folder in cassandra. Now it works. Thanks!
type: Comment

http://stackoverflow.com/comment/33431517
type: AnswerComment
has text: @NathanielWaggoner, not 50, at least 49 :) in `location[50][0] = 24`
type: Comment
comment on: http://stackoverflow.com/a/22049247
score: 0

http://stackoverflow.com/a/22011887
has comment: http://stackoverflow.com/comment/68323845
has comment: http://stackoverflow.com/comment/75676887
upvote count: 79
has body: Parse the JSONObject and create HashMap public static void jsonToMap(String t) throws JSONException { HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); JSONObject jObject = new JSONObject(t); Iterator&lt;?&gt; keys = jObject.keys(); while( keys.hasNext() ){ String key = (String)keys.next(); String value = jObject.getString(key); map.put(key, value); } System.out.println("json : "+jObject); System.out.println("map : "+map); } Tested output: json : {"phonetype":"N95","cat":"WP"} map : {cat=WP, phonetype=N95}
has comment: http://stackoverflow.com/comment/93888867
type: Answer
downvote count: 1
has comment: http://stackoverflow.com/comment/45433850
answers question: http://stackoverflow.com/q/22011200
type: AcceptedAnswer
score: 78
accepted answer of: http://stackoverflow.com/q/22011200

http://stackoverflow.com/comment/33521012
has text: java != mysql != nltk != twitter4j
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22093284

http://stackoverflow.com/a/22028495
answers question: http://stackoverflow.com/q/22028442
has comment: http://stackoverflow.com/comment/33396355
has comment: http://stackoverflow.com/comment/33395742
has comment: http://stackoverflow.com/comment/33395551
downvote count: 0
has body: I think there are several problems with your code: You should go until size/2. You're pop-ing twice in each iteration. Then check if the length was odd and just add the last remaining element if so. I think that your code only reverses your stack. This is not tested but i think it should look something like this (also took the liberty to get rid of some useless variables - performance probably isnt an issue in this case). Make your method return a stack and use it like this: st = switchPairs(st); And the method's body: public Stack&lt;Integer&gt; switchPairs(Stack&lt;Integer&gt; st){ Stack&lt;Integer&gt; q = new Stack&lt;Integer&gt;(); for(int i = 0; i &lt; st.size()-1; i++){ q.push(st.elementAt(i+1)); q.push(st.elementAt(i++))); } if(st.size()%2==1){ q.push(st.pop()); } return q; } To keep it void (usage taken from Here) AtomicReference&lt;Stack&lt;Integer&gt;&gt; ref = new AtomicReference&lt;Stack&lt;Integer&gt;&gt;(st); switchPairs(ref); st = ref.get(); And the method's body: public void switchPairs(AtomicReference&lt;Stack&lt;Integer&gt;&gt; ref){ Stack&lt;Integer&gt; q = new Stack&lt;Integer&gt;(); for(int i = 0; i &lt; ref.get().size()-1; i++){ q.push(ref.get().elementAt(i+1)); q.push(ref.get().elementAt(i++))); } if(ref.get().size()%2==1){ q.push(ref.get().pop()); } ref.set(q); }
has comment: http://stackoverflow.com/comment/33396206
score: 1
has comment: http://stackoverflow.com/comment/33396014
has comment: http://stackoverflow.com/comment/33396496
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/33396107
has comment: http://stackoverflow.com/comment/33396384

http://stackoverflow.com/q/22053880
tagged with: android
tagged with: dictionary
tagged with: linked-list
tagged with: java
type: Question
tagged with: hashmap
has body: I have this XMLParser: public class XMLParser { private URL url; public XMLParser(String url){ try { this.url = new URL(url); } catch (MalformedURLException e) { e.printStackTrace(); } } public LinkedList&lt;HashMap&lt;String, String&gt;&gt; parse() { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); LinkedList&lt;HashMap&lt;String, String&gt;&gt; entries = new LinkedList&lt;HashMap&lt;String,String&gt;&gt;(); HashMap&lt;String, String&gt; entry; try { DocumentBuilder builder = factory.newDocumentBuilder(); Document dom = builder.parse(this.url.openConnection().getInputStream()); Element root = dom.getDocumentElement(); NodeList items = root.getElementsByTagName("item"); for (int i=0; i&lt;items.getLength(); i++) { entry = new HashMap&lt;String, String&gt;(); Node item = items.item(i); NodeList properties = item.getChildNodes(); for (int j=0; j&lt;properties.getLength(); j++) { Node property = properties.item(j); String name = property.getNodeName(); if (name.equalsIgnoreCase("title")) { entry.put(CheckNewPost.DATA_TITLE, property.getFirstChild().getNodeValue()); } else if (name.equalsIgnoreCase("link")) { entry.put(CheckNewPost.DATA_LINK, property.getFirstChild().getNodeValue()); } } entries.add(entry); } } catch (Exception e) { throw new RuntimeException(e); } return entries; } } The problem is that I don't know how to obtain last value added on LinkedList and show it on a Toast. I tried this: XMLParser par = new XMLParser(feedUrl); HashMap&lt;String, String&gt; entry = par.parse().getLast(); String[] text = new String[] {entry.get(DATA_TITLE), entry.get(DATA_LINK)}; Toast t = Toast.makeText(getApplicationContext(), text[0], Toast.LENGTH_LONG); t.show(); Evidently I don't have sufficient experience and I know almost nothing about Map, HashMap or so… The XMLParser is not mine.
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/22054056
has title: How do I obtain the values of LinkedList<HashMap<String,String>>?
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22053953

http://stackoverflow.com/comment/33437816
type: QuestionComment
comment on: http://stackoverflow.com/q/22052457
score: 0
has text: Thanks.. I've been working on debugging it and just can't find the error. Will continue working on it though. What really confuses me is that the arrays are the same size.. and it works fine with just the int arrays which made me think this just isn't the right way to go about it.
type: Comment

http://stackoverflow.com/q/22068007
has body: I m learning android please help me. It gives me following errors in logcat. 02-27 14:14:42.455: D/dalvikvm(1655): GC_FOR_ALLOC freed 46K, 5% free 2891K/3020K, paused 152ms, total 156ms 02-27 14:14:42.465: I/dalvikvm-heap(1655): Grow heap (frag case) to 3.668MB for 810016-byte allocation 02-27 14:14:42.545: D/dalvikvm(1655): GC_FOR_ALLOC freed 2K, 4% free 3680K/3812K, paused 76ms, total 77ms 02-27 14:14:43.425: I/Choreographer(1655): Skipped 35 frames! The application may be doing too much work on its main thread. 02-27 14:14:43.645: D/gralloc_goldfish(1655): Emulator without GPU emulation detected. 02-27 14:14:48.395: I/Choreographer(1655): Skipped 58 frames! The application may be doing too much work on its main thread. 02-27 14:14:49.725: I/Choreographer(1655): Skipped 58 frames! The application may be doing too much work on its main thread. 02-27 14:14:52.355: I/Choreographer(1655): Skipped 61 frames! The application may be doing too much work on its main thread. 02-27 14:14:55.195: D/AndroidRuntime(1655): Shutting down VM 02-27 14:14:55.195: W/dalvikvm(1655): threadid=1: thread exiting with uncaught exception (group=0xb3aaaba8) 02-27 14:14:55.275: E/AndroidRuntime(1655): FATAL EXCEPTION: main 02-27 14:14:55.275: E/AndroidRuntime(1655): Process: com.example.dreamhome, PID: 1655 02-27 14:14:55.275: E/AndroidRuntime(1655): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.dreamhome/com.example.dreamhome.LoginFormActivity}: java.lang.NullPointerException 02-27 14:14:55.275: E/AndroidRuntime(1655): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 02-27 14:14:55.275: E/AndroidRuntime(1655): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 02-27 14:14:55.275: E/AndroidRuntime(1655): at android.app.ActivityThread.access$800(ActivityThread.java:135) 02-27 14:14:55.275: E/AndroidRuntime(1655): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 02-27 14:14:55.275: E/…
linked to: http://stackoverflow.com/q/2033914
has comment: http://stackoverflow.com/comment/33463819
type: UnansweredQuestion
tagged with: android
upvote count: 1
has answer: http://stackoverflow.com/a/22068496
tagged with: java
tagged with: eclipse
type: Question
linked to: http://stackoverflow.com/q/16480867
has title: Shutting down VM
downvote count: 0
answer count: 1
score: 1
has comment: http://stackoverflow.com/comment/33464226
favorite count: 0

http://stackoverflow.com/comment/33457446
score: 0
type: AnswerComment
type: Comment
has text: what it means "\\s+" ??? Your function returns me an array of strings, each of which is only one line of the original string. I need one line to the resulting array contained the 4 lines from the original string
comment on: http://stackoverflow.com/a/22064070

http://stackoverflow.com/q/22057604
favorite count: 0
tagged with: arraylist
has comment: http://stackoverflow.com/comment/33446344
has comment: http://stackoverflow.com/comment/33446349
accepted answer: http://stackoverflow.com/a/22058004
downvote count: 3
score: -3
has body: So I want to make an arraylist in a class of its own and add 50 states to it. Can someone help me figure this out because when i add the arraylist and go states(thats my arraylist name).add("Indiana"); it throws an error. What do i do public class Phone { public Phone(){ } ArrayList&lt;String&gt; phoneType = new ArrayList&lt;String&gt;(); phoneType.add("home"); }
type: AnsweredQuestion
has title: Java ArrayList - How do i make one
tagged with: java
has comment: http://stackoverflow.com/comment/33446323
type: Question
has answer: http://stackoverflow.com/a/22058004
upvote count: 0
answer count: 1

http://stackoverflow.com/comment/33441235
has text: What are the values of `start` and `end`?
comment on: http://stackoverflow.com/q/22054758
type: Comment
type: QuestionComment
score: 6

http://stackoverflow.com/comment/33496919
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22085806
has text: when I used FileUtils.deleteDirectory() of apache commons, the folder was deleted successfully. That solved the problem. I will surely check the return boolean value to see what is wrong with the previous code which I have shown in the question
score: 0

http://stackoverflow.com/comment/33536968
score: 0
type: QuestionComment
has text: were using both async http client, and http components. It appears http components doesn't spawn threads the way async http client does (I had confused the two), so using an Executor with a ThreadFactory that names threads does solve it.
comment on: http://stackoverflow.com/q/22106154
type: Comment

http://stackoverflow.com/comment/33560949
type: AnswerComment
comment on: http://stackoverflow.com/a/22121399
type: Comment
has text: `/Controller` is an absolute path. As a relative path, from `home.html`, for instance, it should be just `Controller` (without the slash).
score: 0

http://stackoverflow.com/a/22043542
answers question: http://stackoverflow.com/q/22043393
has comment: http://stackoverflow.com/comment/33421677
upvote count: 4
score: 4
has body: You have several problems. You don't have an ending brace for your statement if(livemode == "on" &amp;&amp; TwitchStatus.isstreamlive == true){ zaehler = 0; It's hard to tell where you want the block closed, partly because your code uses tabs to indent, which doesn't get displayed very well here (also, don't mix tabs and spaces, your code editor should have a way to convert one to the other). Using consistent indentation helps me to keep from getting confused about nesting of braces. Because the indentation is unclear I'm not sure what you want the else clauses to do, it would be better to use braces to explicitly show the blocks that you mean to be executed. Using a consistent formatting scheme like One True Brace style would be a big help here. Basically pick a consistent way to format your code that is very explicit and stick to it, and you will have an easier time. Using == for string comparison is bad (because it compares references, you could have 2 separate references both holding "on", and == would return false). You should use the equals method instead because it will compare the values. Also using == true for boolean comparisons is redundant. It doesn't hurt anything, it's just awkward-looking.
has comment: http://stackoverflow.com/comment/33421362
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22043393
type: Answer

http://stackoverflow.com/comment/33411714
has text: What do you mean by replace/remove/add, are you getting the map from the cache by calling AsMap? Or do you refer to the "invalidate" method?
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22038348

http://stackoverflow.com/comment/33586052
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22120799
has text: `overflow: hidden` doesn't neccesrely mean that it is hidden.
score: 1

http://stackoverflow.com/q/22149403
has comment: http://stackoverflow.com/comment/33610504
has comment: http://stackoverflow.com/comment/33610543
tagged with: enums
linked to: http://stackoverflow.com/q/521171
has comment: http://stackoverflow.com/comment/33610577
has title: Map with combination of enums as keys
has answer: http://stackoverflow.com/a/22149717
answer count: 6
has comment: http://stackoverflow.com/comment/33610683
has answer: http://stackoverflow.com/a/22150019
downvote count: 0
has comment: http://stackoverflow.com/comment/33610661
has comment: http://stackoverflow.com/comment/33610989
favorite count: 0
has comment: http://stackoverflow.com/comment/33610806
has answer: http://stackoverflow.com/a/22150136
type: UnansweredQuestion
tagged with: dictionary
has answer: http://stackoverflow.com/a/22149721
has comment: http://stackoverflow.com/comment/33610737
has answer: http://stackoverflow.com/a/22149577
has answer: http://stackoverflow.com/a/22149786
has body: I was wondering if there exists any Map&lt;K, V&gt; implementation that takes a combination of 2 or more enums for its key. I'll provide a simplified example. Say I have two enums DiceEyes and CardSuit: public enum DiceEyes { ONE, TWO, THREE, FOUR, FIVE, SIX } public enum CardSuit { HEARTS, DIAMONDS, SPADES, CLUBS } Now I have 6 * 4 = 24 images from which I would like to show exactly one, based on what a user selected in a GUI - he selects a DiceEyes and a CardSuit. I have no control over the filenames of the images. So I cannot be smart by naming the images &lt;DiceType&gt;-&lt;CardSuit&gt;-.png or whatsoever. Therefore I need a mapping of the combination of a DiceType and a CardSuit to the filename. I have already thought about a solution that operates on an EnumMap of EnumMaps: EnumMap&lt;DiceType, EnumMap&lt;CardSuit, String&gt;&gt; ... = new ...; But that looks overcomplicated to me. A colleague would then think that DiceType is more or less important than a CardSuit, looking at the order of the types. Introducing a wrapper class for just this purpose also seems like overkill to me. When I have to use it in a Map, I would need to implement equals() and hashCode() which for this purpose seems just too much. With an enum you are already guaranteed of object equality, so I would like to stay with the enums. How can this be achieved without introducing a specific class or too much overhead?
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33610819
has comment: http://stackoverflow.com/comment/33610709
has comment: http://stackoverflow.com/comment/33610502
upvote count: 1
has comment: http://stackoverflow.com/comment/33610607
type: Question

http://stackoverflow.com/a/22114298
answers question: http://stackoverflow.com/q/22114251
has body: The problem is here: 25*60*60*24*1000 All of this is being performed in integer arithmetic - and that value is overflowing. You can see that if you perform the arithmetic using long values instead, and show the result compared to Integer.MAX_VALUE: milliSecFor26 = (25*60*60*24*1000L); System.out.println("Millis: " + milliSecFor26); System.out.println("Integer.MAX_VALUE: " + Integer.MAX_VALUE); Prints: Millis: 2160000000 Integer.MAX_VALUE: 2147483647 So your int arithmetic is actually overflowing to a negative value, which is why you're seeing a Date value before the Unix epoch. As asides: You can use TimeUnit.DAYS.toMillis(26) as a much cleaner way of computing this Within the Java standard libraries (pre-Java 8), you should use Calendar to obtain an appropriate Date from a year/month/day Joda Time is a much nicer library than Date/Calendar Java 8 will have an even cleaner date/time API (in the java.time package).
upvote count: 5
score: 5
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/22114251

http://stackoverflow.com/a/22058859
type: Answer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22058621
score: 1
answers question: http://stackoverflow.com/q/22058621
has body: Suppose this is your directory tree: src/ ro/ nextreports/ integration/ SimpleDemo.class From your package declaration, your compiled class should be in the integration subdiretory. Check that there really is a SimpleDemo.class in that directory. If that is correct, its classpath includes the contents of the src directory. That means that, if you didn't have any JAR dependencies, you could run your application from the src directory like this: java -cp . ro.nextreports.integration.SimpleDemo You need to use the fully qualified class name. Since you do have jars, you have to include them in the classpath as well. Suppose you have one JAR in the directory above src, and another in the current directory, you could use: java -cp ../one.jar;another.jar;. ro.nextreports.integration.SimpleDemo If you run it from another directory, it will still work if you review the classpath's relative directories or use absolute directories to describe your classpath. I am not sure but usually the current directory is always included in the classpath by the java executable.
upvote count: 1
type: AcceptedAnswer

http://stackoverflow.com/comment/133827783
type: AnswerComment
score: 0
type: Comment
has text: @VishalNair can u elaborate on your point which says, `" In that case sonar lint would fail if you have some max parameter length rule is set."`
comment on: http://stackoverflow.com/a/29020641

http://stackoverflow.com/q/22021921
tagged with: c++
tagged with: boost-thread
tagged with: boost
has body: I have a C++ application that triggers an Akka Actor-based MapReduce system. This I do via a C++ JNI wrapper class MapReduceBridge and it works fine taking into account that the Akka Actor and the C++ application threads need to synchronize (shown below). The problem is that with this design I'm forced to have my C++ MapReduceBridge class be a singleton and use static variables because the callback methods registered via RegisterNatives are global. My question is what's the best way to move into an class instance scope so multiple instances of this C++ MapReduceBridge can coexist? The two Java to C++ callbacks accomplish the following: the C++ thread has to wait for the first callback until the Akka-Actor has deployed/installed in all machines the jar containing the MapExecutor and ReduceExecutor. the C++ thread has to wait for the second callback until the Akka-Actor completes running the MapReduce so it can access the results. I use here two callbacks (function callback from Java to C++) using RegisterNatives, this is the C++ side: // allow the C++ MapReduceBridge's application thread to wait for the MapReduce system static boost::mutex mutex_; static boost::mutex::scoped_lock lock_(mutex_); static boost::condition_variable callback_condition_; // callback notification that installation has completed JNIEXPORT jobject JNICALL com_sfoam_hpcmom_mapreduce_bridge_BridgeClient_startupCompletedCallback(JNIEnv* env, jobject obj) { log_info &lt;&lt; "callback 'startup completed' received"; callback_condition_.notify_one(); } // callback notification that MapReduce run has completed JNIEXPORT jobject JNICALL com_sfoam_hpcmom_mapreduce_bridge_BridgeClient_runCompletedCallback(JNIEnv* env, jobject obj) { log_info &lt;&lt; "callback 'run completed' received"; callback_condition_.notify_one(); } static const JNINativeMethod kCallbackMethods[] = { { "startupCompletedCallback", "()V", (void*)&amp;com_sfoam_hpcmom_mapreduce_bridge_BridgeClient_startupCompletedCallback }, { "runCo…
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22022282
tagged with: java-native-interface
tagged with: java
type: Question
score: 0
has title: How can I make JNI RegisterNatives callack Java functions have C++ instance scope?
answer count: 1
accepted answer: http://stackoverflow.com/a/22022282

http://stackoverflow.com/a/36651464
has body: There is typically no difference between a certificate for Authenticode or Java code signing. Both are X.509 certificates with the Extended Key Usage (EKU) "Code Signing". What could be different is the format of the key store. That is how the private key together with the certificate is stored (if stored in software and not on a smartcard or in a hardware security module). Historically Java was using the Java Keystore format (JKS) but can nowdays use PKCS#12/PFX as well. You should be able to convert the keystore to an appropriate format.
upvote count: 1
answers question: http://stackoverflow.com/q/22092585
downvote count: 0
score: 1
type: Answer

http://stackoverflow.com/q/22161412
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33632766
upvote count: 1
has answer: http://stackoverflow.com/a/22161571
has comment: http://stackoverflow.com/comment/33632496
tagged with: java
downvote count: 3
has body: this code is only allowing me to reject a string the second time to try to drop in a textArea where there is all ready a string. public GridLayoutTest() { JFrame frame = new JFrame("GridLayout test"); connection = getConnection(); try { statement = (PreparedStatement) connection result = statement.executeQuery(); while (result.next()) { byte[] image = null; image = result.getBytes("image"); JPanel cellPanel = new JPanel(new BorderLayout()); cellPanel.add(cellLabel, BorderLayout.NORTH); cellPanel.add(droplabel, BorderLayout.CENTER); gridPanel.add(cellPanel); } } catch (SQLException e) { e.printStackTrace();} }
type: Question
has title: java drop and drag label to join correct image
score: -2
has comment: http://stackoverflow.com/comment/33632662
has comment: http://stackoverflow.com/comment/33632735
has comment: http://stackoverflow.com/comment/33632547
has comment: http://stackoverflow.com/comment/33632767
answer count: 1
has comment: http://stackoverflow.com/comment/33632516
favorite count: 0

on-the-fly
type: Tag
tags question: http://stackoverflow.com/q/22071565
tag name: on-the-fly

http://stackoverflow.com/comment/33552459
has text: I have the source code which I downloaded from GitHub. I'm pretty sure there is a method closeQuietly with java.io.Closeable as a parameter. It's in the IOUtils.java class
score: 0
comment on: http://stackoverflow.com/a/22116785
type: AnswerComment
type: Comment

http://stackoverflow.com/a/22044077
score: 0
type: Answer
has body: javac -source 7 YourFile.java will be the solution for this problem
answers question: http://stackoverflow.com/q/22032765

http://stackoverflow.com/comment/33424229
type: QuestionComment
comment on: http://stackoverflow.com/q/22045126
has text: @Smutje: i'mt not sure i fully understand you, but `attributes.getValue(BODY_TAG);` specifies that i want body.
score: 0
type: Comment

http://stackoverflow.com/q/22120421
has answer: http://stackoverflow.com/a/22120938
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/22120629
possible better answer: http://stackoverflow.com/a/22120629
tagged with: android
accepted answer: http://stackoverflow.com/a/22120938
has body: I'm using libgdx to make an application and I need to use the camera so I followed this tutorial and all my camera feed is rotated 90 degrees but they are being drawn as if they weren't. Unfortunately that means the preview is totally distorted and is very hard to use. I won't post my code here unless snippets are asked for because I copy-pasted the code from the tutorial into my game.. The only change I recall making was as follows. I changed the original surfaceCreated() method in CameraSurace.java public void surfaceCreated( SurfaceHolder holder ) { // Once the surface is created, simply open a handle to the camera hardware. camera = Camera.open(); } to open the front facing camera (Im using a Nexus 7 that only has a front camera...) public void surfaceCreated( SurfaceHolder holder ) { // Once the surface is created, simply open a handle to the camera hardware. camera = openFrontFacingCamera(); } @SuppressLint("NewApi") private Camera openFrontFacingCamera() { int cameraCount = 0; Camera cam = null; Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); cameraCount = Camera.getNumberOfCameras(); for ( int camIdx = 0; camIdx &lt; cameraCount; camIdx++ ) { Camera.getCameraInfo( camIdx, cameraInfo ); if ( cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT ) { try { cam = Camera.open( camIdx ); } catch (RuntimeException e) { System.out.println("Falied to open."); } } } return cam; } Other than that change the rest of the code is almost the exact same (excluding minor variable changes and such.)
type: AnsweredQuestion
tagged with: java
type: Question
has title: How to rotate android device camera preview(libgdx)
tagged with: libgdx
tagged with: camera

http://stackoverflow.com/a/22028882
has comment: http://stackoverflow.com/comment/33395781
has comment: http://stackoverflow.com/comment/33396585
score: 3
has comment: http://stackoverflow.com/comment/33395828
upvote count: 3
has comment: http://stackoverflow.com/comment/33396820
answers question: http://stackoverflow.com/q/22028853
downvote count: 0
has comment: http://stackoverflow.com/comment/33395717
has body: The problem is if x is outside the boundaries of 0..M-1. For example, let´s suppose you try to assign array[x-1] when x = 0. Then you´ll get this ArrayIndexOutOfBoundsException
type: Answer

http://stackoverflow.com/tag/json
tags question: http://stackoverflow.com/q/22089791
tags question: http://stackoverflow.com/q/22006226
tags question: http://stackoverflow.com/q/22062056
tags question: http://stackoverflow.com/q/22137333
tags question: http://stackoverflow.com/q/22083382
tags question: http://stackoverflow.com/q/22109842
tags question: http://stackoverflow.com/q/22042638
tags question: http://stackoverflow.com/q/22115665
tags question: http://stackoverflow.com/q/22017380
tags question: http://stackoverflow.com/q/22123203
tags question: http://stackoverflow.com/q/22057694
tags question: http://stackoverflow.com/q/22042448
tags question: http://stackoverflow.com/q/22123692
tags question: http://stackoverflow.com/q/22060560
tags question: http://stackoverflow.com/q/22073431
tags question: http://stackoverflow.com/q/22128935
tags question: http://stackoverflow.com/q/22062180
tags question: http://stackoverflow.com/q/22106509
tags question: http://stackoverflow.com/q/22118984
tags question: http://stackoverflow.com/q/22011200
tags question: http://stackoverflow.com/q/22132761
tags question: http://stackoverflow.com/q/22054311
tags question: http://stackoverflow.com/q/22014374
tags question: http://stackoverflow.com/q/22082685
tags question: http://stackoverflow.com/q/22159427
tags question: http://stackoverflow.com/q/22025916
tags question: http://stackoverflow.com/q/22162916
tags question: http://stackoverflow.com/q/22162785
tags question: http://stackoverflow.com/q/22018531
tags question: http://stackoverflow.com/q/22122647
tags question: http://stackoverflow.com/q/22016605
tags question: http://stackoverflow.com/q/22028298
tags question: http://stackoverflow.com/q/22103056
tags question: http://stackoverflow.com/q/22154498
type: Tag
tags question: http://stackoverflow.com/q/22057553
tags question: http://stackoverflow.com/q/22146188
tags question: http://stackoverflow.com/q/22024445
tags question: http://stackoverflow.com/q/22157390
tags question: http://stackoverflow.com/q/22061135
tags question: http://stackoverflow.com/q/22097504
tags question: http://stackoverflow.com/q/22140267
tags question: http://stackoverflow.com/q/22103300
tags question: http://stackoverflow.com/q/22074192
tags question: http://stackoverflow.com/q/22042794
tags question: http://stackoverflow.com/q/22151464
tags question: http://stackoverflow.com/q/22063089
tags question: http://stackoverflow.com/q/22021483
tags question: http://stackoverflow.com/q/22041707
tags question: http://stackoverflow.com/q/22090850
tags question: http://stackoverflow.com/q/22041300
tags question: http://stackoverflow.com/q/22024876
tags question: http://stackoverflow.com/q/22118972
tags question: http://stackoverflow.com/q/22103451
tags question: http://stackoverflow.com/q/22021600
tags question: http://stackoverflow.com/q/22126326
tag name: json
tags question: http://stackoverflow.com/q/22158660
tags question: http://stackoverflow.com/q/22160744
tags question: http://stackoverflow.com/q/22013771
tags question: http://stackoverflow.com/q/22119045
tags question: http://stackoverflow.com/q/22068521
tags question: http://stackoverflow.com/q/22099845
tags question: http://stackoverflow.com/q/22009203
tags question: http://stackoverflow.com/q/22147242
tags question: http://stackoverflow.com/q/22122401
tags question: http://stackoverflow.com/q/22117641
tags question: http://stackoverflow.com/q/22166774
tags question: http://stackoverflow.com/q/22093145
tags question: http://stackoverflow.com/q/22073535
tags question: http://stackoverflow.com/q/22078564
tags question: http://stackoverflow.com/q/22096274
tags question: http://stackoverflow.com/q/22132179
tags question: http://stackoverflow.com/q/22090815
tags question: http://stackoverflow.com/q/22050636
tags question: http://stackoverflow.com/q/22157116
tags question: http://stackoverflow.com/q/22142952
tags question: http://stackoverflow.com/q/22161243
tags question: http://stackoverflow.com/q/22130979
tags question: http://stackoverflow.com/q/22075637

http://stackoverflow.com/a/22017232
has comment: http://stackoverflow.com/comment/33373733
has body: You have to add the jar which contains your base classes to your android project's classpath. They are generally placed in a libs/ folder at your project folder's root. Also, make sure that the jar is configured to be exported with your source code when packaging your APK. I don't know which IDE you are using, but in order to do that in Eclipse just go to your project's preferences : right click on it > Preferences > Build path > Order and Export and then make sure your jar is checked.
has comment: http://stackoverflow.com/comment/33375250
has comment: http://stackoverflow.com/comment/33374110
score: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22016963
answers question: http://stackoverflow.com/q/22016963
type: Answer
has comment: http://stackoverflow.com/comment/33373675

jframe
tags question: http://stackoverflow.com/q/22124763
tags question: http://stackoverflow.com/q/22080030
tags question: http://stackoverflow.com/q/22153871
tags question: http://stackoverflow.com/q/22080761
tags question: http://stackoverflow.com/q/22104380
tag name: jframe
tags question: http://stackoverflow.com/q/22161855
tags question: http://stackoverflow.com/q/22019393
tags question: http://stackoverflow.com/q/22056821
tags question: http://stackoverflow.com/q/22079260
tags question: http://stackoverflow.com/q/22068920
tags question: http://stackoverflow.com/q/22110855
tags question: http://stackoverflow.com/q/22108540
tags question: http://stackoverflow.com/q/22116859
tags question: http://stackoverflow.com/q/22161179
tags question: http://stackoverflow.com/q/22150143
tags question: http://stackoverflow.com/q/22053385
tags question: http://stackoverflow.com/q/22030127
tags question: http://stackoverflow.com/q/22037658
tags question: http://stackoverflow.com/q/22056226
tags question: http://stackoverflow.com/q/22155853
tags question: http://stackoverflow.com/q/22077801
tags question: http://stackoverflow.com/q/22118917
tags question: http://stackoverflow.com/q/22057731
type: Tag
tags question: http://stackoverflow.com/q/22114928
tags question: http://stackoverflow.com/q/22159746
tags question: http://stackoverflow.com/q/22102497
tags question: http://stackoverflow.com/q/22066620
tags question: http://stackoverflow.com/q/22048734
tags question: http://stackoverflow.com/q/22064953
tags question: http://stackoverflow.com/q/22052095
tags question: http://stackoverflow.com/q/22154691
tags question: http://stackoverflow.com/q/22021425

http://stackoverflow.com/comment/33579863
comment on: http://stackoverflow.com/a/22131556
has text: @tkoomzaaskz No. `DarkRoast` can only see the `description` declared in `DarkRoast` because it shadows the field declared in the superclass. It (`DarkRoast`) *does* have a reference to the superclass, of course, through which it could access the one from there ... but generally that's not something you'd do.
type: Comment
score: 1
type: AnswerComment

http://stackoverflow.com/q/22035125
tagged with: classpath
has body: I have a ProjectB that's on the build path of ProjectA. However with ProjectA there are 5 sub-folders, each with 5 classes within them (some will be Main, some not). My objective is to have ProjectB on the build path of ProjectA except for the build path of the classes within one of these folders. How do I achieve this?
type: Question
tagged with: java
tagged with: compilation
has title: How to remove project from build path for sub-folders only
tagged with: eclipse
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/22036610
tagged with: buildpath
type: UnansweredQuestion

http://stackoverflow.com/a/22125057
downvote count: 0
type: Answer
upvote count: 6
score: 6
has comment: http://stackoverflow.com/comment/33570566
has comment: http://stackoverflow.com/comment/33568420
answers question: http://stackoverflow.com/q/22121918
has body: Is there any reason why you can't use the war packaging type? https://maven.apache.org/plugins/maven-war-plugin/usage.html I would recommend to use the war packaging type and use default maven web-application structure. If you really want to use the jar plugin for your webapp, you need to configure it for your project. Due to your posting, I don't understand your structure and can't give you an example. Check out the usage of jar plugin here:https://maven.apache.org/plugins/maven-war-plugin/usage.html

http://stackoverflow.com/a/22314080
has comment: http://stackoverflow.com/comment/34016558
type: Answer
has body: I'm not sure why (I feel like most of the cloud endpoints answers start this way), but when sending text to the local devserver try URL encoding it beforehand: In JavaScript: var local = (location.host.indexOf("localhost") !== -1); var url = (local) ? encodeURIComponent(article.url) : article.url; Two similar questions that need to be addressed.
answers question: http://stackoverflow.com/q/22069195
score: 0

http://stackoverflow.com/comment/33554170
type: QuestionComment
comment on: http://stackoverflow.com/q/22116731
score: 0
type: Comment
has text: I tried that at all the points where I reset the origin and the dot went where I expected it to go. I just realised that I'm redefining 'by' halfway through the revolve function, I'll tweak that and see if it helps.

http://stackoverflow.com/q/22029734
type: Question
has body: I am implementing android application which uses YouTube API v3 I have received "access not configured" all the time even if changing the project name in Google cloud APIs or changing the android key to browser key I am searching about the subscribes that the user subscribes to that is my all code public class Youtube extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener { private YouTubePlayer YPlayer; private static final int RECOVERY_DIALOG_REQUEST = 1; private static YouTube youtube; GoogleAccountCredential credential; GoogleCredential CREDENTIAL = new GoogleCredential(); com.google.api.services.youtube.YouTube service; final HttpTransport transport = AndroidHttp.newCompatibleTransport(); final JsonFactory jsonFactory = new GsonFactory(); final String CLIENT_ID = "client key"; @SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(this); String test = mPreferences.getString("USER_ACCOUNT_AUTH_PREF", null); AccountManager.get(getApplicationContext()).invalidateAuthToken("com.google", test); final SharedPreferences.Editor editor = mPreferences.edit(); AccountManager.get(getApplicationContext()).getAuthTokenByFeatures( "com.google", "oauth2:https://gdata.youtube.com", null,this, null, null, new AccountManagerCallback&lt;Bundle&gt;() { @Override public void run(AccountManagerFuture&lt;Bundle&gt; future) { try { Bundle bundle = future.getResult(); String acc_name = bundle .getString(AccountManager.KEY_ACCOUNT_NAME); String auth_token = bundle .getString(AccountManager.KEY_AUTHTOKEN); System.out.println("name: " + acc_name + "; token: " + auth_token); editor.putString("USER_ACCOUNT_PREF", acc_name); editor.putString("USER_ACCOUNT_AUTH_PREF", auth_token); } catch (Exception e) { System.out.println( e.getClass().getSimpleName() + ": " + e.getMessage()); } } }, null); editor.commit(); String test2…
tagged with: java
has comment: http://stackoverflow.com/comment/45266147
score: 0
has title: Access not configured youtube api v3 android
tagged with: android-youtube-api
has comment: http://stackoverflow.com/comment/33397538
type: UnansweredQuestion
tagged with: android
answer count: 0
has comment: http://stackoverflow.com/comment/33397254
tagged with: youtube-api
tagged with: youtube

http://stackoverflow.com/a/22139493
type: Answer
has body: INCORRECT. PLEASE DISREGARD You need to convert the string to an array. s.ToCharArray(); Note: this is c# code, I don't know if it is similar to java.
answers question: http://stackoverflow.com/q/22139436
upvote count: 0
has comment: http://stackoverflow.com/comment/33593348
has comment: http://stackoverflow.com/comment/33593264
score: -1
downvote count: 1

http://stackoverflow.com/comment/33647701
type: Comment
comment on: http://stackoverflow.com/q/22167928
type: QuestionComment
score: 0
has text: re changing to valid and using setValidator - It is still trying to apply the validator to the User object passed to createUser

http://stackoverflow.com/a/22100659
answers question: http://stackoverflow.com/q/22100533
has body: Should be (Standard - 20), no? Also, it should be (Rate * 2). pay = (Standard * Rate) + ((Standard - 20) * (Rate * 1.5)) + ((Hours - Double) * (Rate * 2));
score: 0
has comment: http://stackoverflow.com/comment/33523264
type: Answer
has comment: http://stackoverflow.com/comment/33523343
has comment: http://stackoverflow.com/comment/33523198
upvote count: 1
downvote count: 1

http://stackoverflow.com/q/22127259
tagged with: java
type: Question
tagged with: arrays
has body: I am trying to make a custom Comparator-object to use with java.util.Arrays.binarySearch. I want search the array for a String whose reverse value is equal to the reverse value of the target String element (dumb, I know, but it's just for learning). However, when I attempt to run binarySearch on the array, all the elements match properly, except array element 0. Comparator: class SearchComparator&lt;T extends Comparable&lt;T&gt;&gt; implements Comparator&lt;T&gt; { public int compare(T s1, T s2) { String reverse1 = new StringBuilder((String)s1).reverse().toString(); String reverse2 = new StringBuilder((String)s2).reverse().toString(); return reverse1.equals(reverse2) ? 0 : -1; } } Main function: String[] words = new String[]{"One", "Two", "Three", "Four"}; SearchComparator scmp = new SearchComparator(); System.out.println(Arrays.deepToString(words)); System.out.println(Arrays.binarySearch(words, "One", scmp)); System.out.println(Arrays.binarySearch(words, "Two", scmp)); System.out.println(Arrays.binarySearch(words, "Three", scmp)); System.out.println(Arrays.binarySearch(words, "Four", scmp)); Output: [One, Two, Three, Four] -5 1 2 3 What is up with -5? I don't know man.
upvote count: 2
answer count: 1
has title: binarySearch with custom Comparator-object not checking first element
has answer: http://stackoverflow.com/a/22127279
accepted answer: http://stackoverflow.com/a/22127279
favorite count: 0
type: AnsweredQuestion
score: 2
downvote count: 0

listview
tags question: http://stackoverflow.com/q/22091714
tags question: http://stackoverflow.com/q/22111314
tags question: http://stackoverflow.com/q/22021476
tags question: http://stackoverflow.com/q/22055386
tag name: listview
tags question: http://stackoverflow.com/q/22156605
tags question: http://stackoverflow.com/q/22139571
tags question: http://stackoverflow.com/q/22059825
tags question: http://stackoverflow.com/q/22029677
tags question: http://stackoverflow.com/q/22144503
tags question: http://stackoverflow.com/q/22024876
tags question: http://stackoverflow.com/q/22115360
tags question: http://stackoverflow.com/q/22023234
tags question: http://stackoverflow.com/q/22020464
tags question: http://stackoverflow.com/q/22074071
tags question: http://stackoverflow.com/q/22062226
type: Tag
tags question: http://stackoverflow.com/q/22147419
tags question: http://stackoverflow.com/q/22084766
tags question: http://stackoverflow.com/q/22037681

http://stackoverflow.com/q/22118004
upvote count: 10
possible better answer: http://stackoverflow.com/a/28866014
type: Question
accepted answer: http://stackoverflow.com/a/22118090
has answer: http://stackoverflow.com/a/28866014
tagged with: network-programming
score: 10
has answer: http://stackoverflow.com/a/39623475
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/22118090
tagged with: jmx
has title: Why am I getting the error "connection refused" with JMX
has answer: http://stackoverflow.com/a/24453951
answer count: 4
has body: I am unable to connect to JMX object. Here is how I create a JMX object: public static void main(String... args) { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); try { ObjectName name = new ObjectName("org.javasimon.jmx.example:type=Simon"); if (mbs.isRegistered(name)) { mbs.unregisterMBean(name); } SimonManagerMXBean simonManagerMXBean = new SimonManagerMXBeanImpl(SimonManager.manager()); mbs.registerMBean(simonManagerMXBean, name); System.out.println("SimonManagerMXBean registerd under name: "+name); } catch (JMException e) { System.out.println("SimonManagerMXBean registration failed!\n"+e); } while (true) { // waiting for connections } } This is a code for connecting to the remote JMX object: JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://127.0.0.1:9999/jndi/rmi://127.0.0.1:1099/jmxrmi"); JMXConnector jmxc = JMXConnectorFactory.connect(url, null); MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); SimonManagerMXBean simonManagerMXBean = JMX.newMXBeanProxy(mbsc, new ObjectName("org.javasimon.jmx.example:type=Simon"), SimonManagerMXBean.class); return simonManagerMXBean; Unfortunatelly I receive the following error: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: java.net.ConnectException: Connection refused: connect] at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:338) at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248) at my.code.RemoteSimonManagerFactoryImpl.createSimonManager(RemoteSimonManagerFactoryImpl.java:24) at my.code.Demo.main(DemoAggregation.java:21) 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.invo…
type: AnsweredQuestion
tagged with: java
linked to: http://stackoverflow.com/q/856881

http://stackoverflow.com/q/22071463
upvote count: 0
possible better answer: http://stackoverflow.com/a/22071547
has comment: http://stackoverflow.com/comment/33470129
has comment: http://stackoverflow.com/comment/33470916
accepted answer: http://stackoverflow.com/a/22073180
answer count: 3
tagged with: string
has answer: http://stackoverflow.com/a/22073180
tagged with: http://stackoverflow.com/tag/xml
favorite count: 0
score: -4
has answer: http://stackoverflow.com/a/22071547
has comment: http://stackoverflow.com/comment/33470619
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22071928
tagged with: java
type: Question
has body: This is the code I've come through. What I am trying to reach through this is to edit an XML file and code and put special characters like | (pipe) in place of &amp;#x7c and so on. class FileReplace { ArrayList&lt;String&gt; lines = new ArrayList&lt;String&gt;(); String line = null; public void doIt() { try { File f1 = new File("C:/file.xml"); FileReader fr = new FileReader(f1); BufferedReader br = new BufferedReader(fr); while (line = br.readLine() != null) { if (line.contains("&amp;#x7c;")) line = line.replace("&amp;#x7c;", "|"); lines.add(line); } FileWriter fw = new FileWriter(f1); BufferedWriter out = new BufferedWriter(fw); for(String s : lines) out.writeline(s); out.flush(); } catch (Exception ex) { ex.printStackTrace(); } finally { fr.close(); br.close(); out.close() } } public static void main(String args[]) { FileReplace fr = new FileReplace(); fr.doIt(); } } I tried and reached following error, Please help. Thanks
has title: Program in Java to read any file and find a substring, and replace it with another string
downvote count: 4

http://stackoverflow.com/q/22016605
answer count: 3
has answer: http://stackoverflow.com/a/22017167
tagged with: android
has title: Webservice - how to deploy?
accepted answer: http://stackoverflow.com/a/22017167
possible better answer: http://stackoverflow.com/a/22016868
has answer: http://stackoverflow.com/a/22016868
tagged with: mysql
tagged with: web-services
type: AnsweredQuestion
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has answer: http://stackoverflow.com/a/22017090
type: Question
has body: I am trying to write a simple webservice which produces a JSON string. What I really want to do is get some info from my database through this JSON string and use it in my Android application. I want to write it all in Java and try to avoid using php. I am not sure how to deploy this thing to my remote server through Filezilla. This is just not the end result at all. I just tried to write something that could produce a JSON string. I am using the jersey lib btw. package services; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; import org.json.JSONException; import org.json.JSONObject; @Path("/webservice") public class RestFulWebservice { @GET @Produces("application/json") public Response produceJSON() throws JSONException { JSONObject jsonObject = new JSONObject(); double weight = 62; double height = 170; jsonObject.put("Weight", weight); jsonObject.put("Height", height); String result = "Produces JSON: \n" + jsonObject; return Response.status(200).entity(result).build(); } } I would really appreciate any advice. If I can just produce a dynamic JSON string I think I know how to read in my code.
score: 0

http://stackoverflow.com/a/22128542
score: 5
has comment: http://stackoverflow.com/comment/33574150
type: Answer
upvote count: 5
downvote count: 0
has body: As an alternative of Vipul answer you can also add the attribute onClick in the Button tag in the XML layout file. Example: &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: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=".MainActivity" &gt; &lt;Button id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:onClick="myMethod" /&gt; &lt;/RelativeLayout&gt; And, in your MainActivity.java, remove the View.OnClickListener implemented interface (thanks @donfuxx) add the following method: public void myMethod(View v) { //do something }
answers question: http://stackoverflow.com/q/22128505

http://stackoverflow.com/q/22024270
answer count: 1
accepted answer: http://stackoverflow.com/a/22024812
has title: Web Speech API - Android
tagged with: android
has comment: http://stackoverflow.com/comment/33387021
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22024812
tagged with: java
tagged with: speech-to-text
type: Question
has body: I want to implement a functionality like the Web Speech API (only works in Chrome) in an Android app. I mean, a real time speech to text app. Is there any framework or libraries to achieve this?
score: 0
tagged with: real-time

jsf
tags question: http://stackoverflow.com/q/22103734
type: Tag
tags question: http://stackoverflow.com/q/22018409
tags question: http://stackoverflow.com/q/22139262
tags question: http://stackoverflow.com/q/22124998
tags question: http://stackoverflow.com/q/22137643
tags question: http://stackoverflow.com/q/22084411
tags question: http://stackoverflow.com/q/22048980
tags question: http://stackoverflow.com/q/22167939
tags question: http://stackoverflow.com/q/22048499
tags question: http://stackoverflow.com/q/22129467
tags question: http://stackoverflow.com/q/22128865
tags question: http://stackoverflow.com/q/22145942
tags question: http://stackoverflow.com/q/22111231
tags question: http://stackoverflow.com/q/22145792
tags question: http://stackoverflow.com/q/22041158
tags question: http://stackoverflow.com/q/22144195
tag name: jsf
tags question: http://stackoverflow.com/q/22134222
tags question: http://stackoverflow.com/q/22168302
tags question: http://stackoverflow.com/q/22129143
tags question: http://stackoverflow.com/q/22131407
tags question: http://stackoverflow.com/q/22025959
tags question: http://stackoverflow.com/q/22147309
tags question: http://stackoverflow.com/q/22078111
tags question: http://stackoverflow.com/q/22086104
tags question: http://stackoverflow.com/q/22044604
tags question: http://stackoverflow.com/q/22164645
tags question: http://stackoverflow.com/q/22154125
tags question: http://stackoverflow.com/q/22098252

http://stackoverflow.com/comment/33554776
has text: Okay, now that we know what the question means - what have you (the OP) tried so far? Where are you stuck? Recursion may well help you here...
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22117899
score: 0

http://stackoverflow.com/a/22061677
upvote count: 2
type: Answer
accepted answer of: http://stackoverflow.com/q/22060474
score: 2
answers question: http://stackoverflow.com/q/22060474
type: AcceptedAnswer
downvote count: 0
has body: Your &lt;form&gt; tag is missing the attribute name for the action tag. &lt;form id="frmLogin" name="frmLogin" method="post" &lt;c:url value='j_spring_security_check'/&gt;&gt; I would write &lt;form id="frmLogin" name="frmLogin" method="post" action="&lt;c:url value='j_spring_security_check'/&gt;"&gt; BTW: when you have a problem like this (the browser send a request and the server respond some thing complete wrong) next time, then first use a tool like firebug-networkmonitor or live http headers to have a look at the real request that is sended by the browser

http://stackoverflow.com/a/22158093
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33628240
type: Answer
has body: There is not a way to do this inside of output today. But feel free to request it here: https://code.google.com/p/appengine-mapreduce/issues/list What you can do however is to chain a job to run after your map-reduce that will receive it's output and counters. There is an example of this here: https://code.google.com/p/appengine-mapreduce/source/browse/trunk/java/example/src/com/google/appengine/demos/mapreduce/entitycount/ChainedMapReduceJob.java In the above example it is running 3 MapReduce jobs in a row. Note that these don't have to be MapReduce jobs, you can create your own class that extends Job and has a run method which creates your Summary object.
accepted answer of: http://stackoverflow.com/q/22137485
answers question: http://stackoverflow.com/q/22137485
score: 0

http://stackoverflow.com/a/22098591
has body: This is basic inheritance. In the B b = ... case you can access all methods and variables provided from A and B but in the A case you can only use the methods and variables in the A case. B gets typecasted into A when it is created, but that information is not required by the compiler. public class A { int x; } public class B extends A { int y; } A a = new B(); B b = new B(); int c = a.x; //works int c = a.y; //doesn't work int c = b.y; //works int c = b.x; //works Remember, that you can always cast an object "downwards" in the inheritance chain. But you should not cast a object upwards because the variables for the subclass might be used even though they dont exist, for exmaple B b = new A(); So b.y is dangerous since the B object doesn't have an y variable defined.
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/33521468
answers question: http://stackoverflow.com/q/22098461

http://stackoverflow.com/q/22139615
has title: Dragging buttons in Javafx
tagged with: java
tagged with: javafx
has body: I have a button which I would like to drag it and after some time drop it. I searched online the most useful thing I came across was this link. Alike from the link provided I would like the button to be dragged wherever the cursor goes , only when the mouse button goes up the button should drop. How can this problem be solved?Thanks in advance
type: Question
accepted answer: http://stackoverflow.com/a/22140462
answer count: 2
downvote count: 0
favorite count: 0
tagged with: drag-and-drop
upvote count: 2
has answer: http://stackoverflow.com/a/22140462
tagged with: draggable
tagged with: drag
possible better answer: http://stackoverflow.com/a/33873003
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/33873003

http://stackoverflow.com/comment/33408281
type: AnswerComment
has text: I don't have that option right now -- it's not a file, it's an InputStream handed to me by another framework. I could read the whole stream into memory but I have no guarantee that it won't be multiple GB. I really need to work stream-wise if at all possible :(
type: Comment
score: 0
comment on: http://stackoverflow.com/a/22021554

http://stackoverflow.com/a/22151270
has comment: http://stackoverflow.com/comment/33613928
downvote count: 0
has body: Break it up like this: true ? (++i &gt; 2 ? true : false) : false; So here the testing condition is always set to true. So the branch of the ternary that executes is the ++i &gt; 2 ? true : false part. This simply checks to see if after incrementing, i is greater than 2. If so, it will return true. Otherwise it will return false. This whole expression is actually needlessly complex. It can simply be written as such: boolean b = a = (++ i &gt; 2); However, the code is probably logically incorrect since this abstruse expression doesn't make that much sense. Since the previous line sets the value of a, I'm assuming that the next line actually intends to test a. So the actual intent might be: boolean b = a == true ? ++i &gt; 2 ? true : false : false; //notice the == In which case you can break it up as: (a == true) ? (++i &gt; 2 ? true : false) : false; But you don't need to actually do a == true since a is already a boolean, so you can do: a ? (++i &gt; 2 ? true : false) : false; Here, it checks to see if a is true. If it is, it performs the check we already went over (i.e., to see if the incremented value of i is greater than 2), otherwise it returns false. But even this complicated expression can be simplified to just: boolean b = a &amp;&amp; (++i &gt; 2);
type: Answer
upvote count: 6
score: 6
has comment: http://stackoverflow.com/comment/33614622
has comment: http://stackoverflow.com/comment/33614583
has comment: http://stackoverflow.com/comment/33613987
answers question: http://stackoverflow.com/q/22151191
has comment: http://stackoverflow.com/comment/33614502

http://stackoverflow.com/comment/33465088
type: QuestionComment
has text: cannot resolve symbol Scanner line 9
type: Comment
score: 0
comment on: http://stackoverflow.com/q/22068618

http://stackoverflow.com/comment/33520251
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22093109
has text: Run `jarsigner -verify <your-jar>`. Is the jar actually signed?
score: 0

http://stackoverflow.com/a/22032211
score: 1
answers question: http://stackoverflow.com/q/22031789
has body: Regular expression alternative: String str = "32.63578"; String[] parts = str.split("(?&lt;=\\.\\d{2})"); System.out.println(parts[0]); // "32.63" System.out.println(parts[1]); // "578" About the regular expression used: (?&lt;=\.\d{2}) It's positive lookbehind (?&lt;=...). It matches at the position where is preceded by . and 2 digits.
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/comment/33479283
comment on: http://stackoverflow.com/q/22076242
score: 0
type: Comment
has text: The client said they want the orientation to be *unlocked*, but you are asking StackOverflow how to *lock* it to portrait? I am confused.
type: QuestionComment

http://stackoverflow.com/comment/33530129
comment on: http://stackoverflow.com/a/22103336
has text: + 1 for illustrative explanation, but I think @Asanka actually wants to replace words also if they are next to `.,`
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/q/22092180
favorite count: 0
upvote count: 1
type: AnsweredQuestion
tagged with: components
score: 1
has answer: http://stackoverflow.com/a/22130073
tagged with: java
has body: I try add item click listener to ListSelect component, I want to unselect item on click, when click item is selected. In standard way I dont see any possibility to do this ;/ maybe some one know the way ? Thanks for help.
tagged with: vaadin
has title: Vaadin - ListSelect component unselect on click
type: Question
answer count: 1
downvote count: 0
tagged with: selectlist
accepted answer: http://stackoverflow.com/a/22130073

http://stackoverflow.com/a/22161726
accepted answer of: http://stackoverflow.com/q/22157505
type: AcceptedAnswer
downvote count: 0
has body: Yes possible, try like: in your validator add a field error: ValidationUtils.rejectIfEmptyOrWhitespace(errors, "mainForm", "mainform.error.display.alternateText", "mainForm required!"); and in jsp you can show inside form the error like: &lt;c:set var="er"&gt;&lt;form:errors path="mainForm"/&gt;&lt;/c:set&gt; &lt;c:if test="${not empty er}"&gt; &lt;div class="alert alert-error"&gt; &lt;button type="button" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/button&gt; &lt;h4&gt;Validation Error :&lt;/h4&gt; Please correct the following:&lt;br/&gt; ${er} &lt;/div&gt; &lt;/c:if&gt;
answers question: http://stackoverflow.com/q/22157505
type: Answer
score: 2
upvote count: 2

http://stackoverflow.com/comment/98965133
score: 0
type: AnswerComment
has text: do you have any offical documentation about the deprecation?
type: Comment
comment on: http://stackoverflow.com/a/25404917

keyevent
tags question: http://stackoverflow.com/q/22012325
type: Tag
tags question: http://stackoverflow.com/q/22120698
tags question: http://stackoverflow.com/q/22105859
tag name: keyevent

http://stackoverflow.com/a/22163432
score: 1
accepted answer of: http://stackoverflow.com/q/22162832
upvote count: 1
type: AcceptedAnswer
type: Answer
downvote count: 0
has body: Thx for all the troubleshooting proposals in the comments. The cause for this behaviour was that I copied the ValueContainer interface twice into two differnt packages as I assumed it would be missing given that Eclipse didn't seem to find it first (thx @sasankad for the proposal to clean the project). I hope this is still helpful for others as the error message and solution-proposals by the compiler and Eclipse respectively are not and are rather misleading.
answers question: http://stackoverflow.com/q/22162832

http://stackoverflow.com/a/22159045
has comment: http://stackoverflow.com/comment/33628463
score: 0
type: AcceptedAnswer
has body: It just a feeling but .. I think you should have: print spread.entry_named(sys.argv[1],sys.argv[2]) instead print spread.entry_named(sys.argv[0],sys.argv[1]) argv[0] is the python script. On the other hand I'm not sure p.getInputStream() does what you mean here. One good advice? Get a good Java and Python reference and at least read the content related with the API you are trying to use here. After that, If you still without know what to do, comeback here.
type: Answer
accepted answer of: http://stackoverflow.com/q/22157108
has comment: http://stackoverflow.com/comment/33628520
answers question: http://stackoverflow.com/q/22157108

http://stackoverflow.com/comment/33519623
type: QuestionComment
has text: possible duplicate of [Android INJECT\_EVENTS permission](http://stackoverflow.com/questions/5383401/android-inject-events-permission)
type: Comment
comment on: http://stackoverflow.com/q/22098463
score: 0

http://stackoverflow.com/q/22091151
has comment: http://stackoverflow.com/comment/33519758
score: 0
answer count: 1
has title: Mule ESB, "IN" operator within a JDBC transformer
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33524743
has comment: http://stackoverflow.com/comment/33523733
tagged with: esb
has comment: http://stackoverflow.com/comment/33525088
has body: Let's imaging that I would like to pass a list into a JDBC transformer. For instance, I create the list in a flow : &lt;scripting:transformer&gt;&lt;scripting:script engine="groovy"&gt;&lt;scripting:text&gt; // Some calculations and stuff def single_quote_alias = "'" def listString = seasonMbIds.join("',' ") return single_quote_alias + listString + single_quote_alias // now it's like: '11','22','33' &lt;/scripting:text&gt;&lt;/scripting:script&gt;&lt;/scripting:transformer&gt; And then pass the list into another transformer: &lt;jdbc:outbound-endpoint connector-ref="XYZ" queryKey="someName" exchange-pattern="request-response" /&gt; and here is the actual query: &lt;jdbc:query key="someName" value="SELECT anID FROM aTable WHERE aField IN (#[payload:])" /&gt; it gives me "out of bound index exception" : Message : java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 (javax.script.ScriptException) Code : MULE_ERROR--2 -------------------------------------------------------------------------------- Exception stack is: 1. Index: 0, Size: 0 (java.lang.IndexOutOfBoundsException) java.util.ArrayList:635 (null) 2. java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 (javax.script.ScriptException) There are some escaping problem maybe. I used different delimiters and problem still exists ... Any suggestion ?
has comment: http://stackoverflow.com/comment/33523827
type: Question
tagged with: mule-el
has answer: http://stackoverflow.com/a/22094267
tagged with: java
tagged with: mule

http://stackoverflow.com/comment/33611459
score: 2
has text: POSt data is not sent via the URL. That'd be a GET query... which CAN be sent along with a POST request, but they're otherwise two completely separate mechanisms which can happen to share the same request.
comment on: http://stackoverflow.com/q/22149936
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33427864
type: Comment
comment on: http://stackoverflow.com/a/22046544
has text: thanks for your answer mok but it doesn't work, i got an error in PanelCotizacion, another way to pass the value?
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33598303
has text: Note that the _browser_ does not send its IP Address along, but the _server_ records the remote client IP on each request. This is not very reliable: think (reverse) proxies, NAT, etc.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22130678
score: 1

http://stackoverflow.com/q/22148141
answer count: 1
has title: my alarmmanager sometimes not firing
type: UnansweredQuestion
tagged with: android
has body: my alarmmanager sometimes not firing Main_activity: Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(System.currentTimeMillis()); cal.set(Calendar.HOUR_OF_DAY, tp1.getCurrentHour()); cal.set(Calendar.MINUTE, tp1.getCurrentMinute()); cal.set(Calendar.SECOND, 0); long timeDif = cal.getTimeInMillis() - System.currentTimeMillis(); long horaFinal = System.currentTimeMillis() + AlarmManager.INTERVAL_DAY + timeDif; long result = (cal.getTimeInMillis() - System.currentTimeMillis()) / 1000; long results = (horaFinal- System.currentTimeMillis())/1000; long alarma; if(result >= 0 && result < 60){ alarma = cal.getTimeInMillis(); }else{ alarma = horaFinal; } Intent intent = new Intent(this, Temporizador.class); PendingIntent pendingIntent = PendingIntent.getBroadcast( this.getApplicationContext(), 234324243, intent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, alarma, pendingIntent); if (result >= 0 && result < 60) { Toast.makeText(this, "La alarma sonará en menos de un minuto.", Toast.LENGTH_LONG).show(); } else if (result < 3600 & result >= 60) { result = result / 60; Toast.makeText(this, "La alarma sonará en " + result + " minutos.", Toast.LENGTH_LONG).show(); } else if (result >= 3600) { int resultado = (int) (result / 3600); long minutos = (result % 3600) / 60; Toast.makeText( this, "La alarma sonará en " + resultado + " horas y " + minutos + " minutos.", Toast.LENGTH_LONG) .show(); }else{ if(results >= 0 && results < 60){ Toast.makeText(this, "La alarma sonará en menos de un minuto.", Toast.LENGTH_LONG).show(); } else if (results < 3600 & results >= 60) { results /= 60; Toast.makeText(this, "La alarma sonará en " + results + " minutos.", Toast.LENGTH_LONG).show(); }else if (results >= 3600) { int resultado = (int) (results / 3600); long minutos = (results % 3600) / 60; Toast.makeText( this, "La alarma sonará en " + resultado + " horas y " + minutos + " minutos.", Toast.LENGTH_LONG) .show…
tagged with: java
type: Question
tagged with: alarmmanager
score: 0
has answer: http://stackoverflow.com/a/22148344
has comment: http://stackoverflow.com/comment/63948819

android-securityexception
tags question: http://stackoverflow.com/q/22139305
tag name: android-securityexception
type: Tag

http://stackoverflow.com/comment/33529709
type: Comment
comment on: http://stackoverflow.com/a/22103239
has text: This does not prevent words next to punctuation from being detected, as is specified by the OP.
score: 0
type: AnswerComment

http://stackoverflow.com/a/22081025
has comment: http://stackoverflow.com/comment/38517782
has comment: http://stackoverflow.com/comment/37947461
score: 12
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/22068854
has body: Well I got it finally up by adapting latest demo app pom.xml directly from git. Missing widgetset is in com.vaadin vaadin-client-compiled ${vaadin.version}
upvote count: 12

http://stackoverflow.com/a/22152708
answers question: http://stackoverflow.com/q/22020317
has body: You can't use setenv.sh on Windows. Instead modify the catalina.bat file, or use the Configure Tomcat utility in the Start Menu to set the javaagent option. These steps can be found in more detail in the New Relic documentation
score: 0
type: Answer

http://stackoverflow.com/comment/33495952
type: Comment
score: 1
type: QuestionComment
has text: You should use int instead of Integer.
comment on: http://stackoverflow.com/q/22085224

http://stackoverflow.com/comment/33534319
comment on: http://stackoverflow.com/q/22106270
score: 0
type: Comment
has text: Yes, if you dont know the method header at compile time, you can call in only by `method.invoke()`
type: QuestionComment

http://stackoverflow.com/a/41764942
has body: I use Ctrl+F to find some text &amp; when done hit esc. This will close find/replace window &amp; clear view for your editor. Also you can use combination of word select commands and (Ctrl+K) (Ctrl+Shift +K). This should save you installing plugin.
score: 0
answers question: http://stackoverflow.com/q/22052510
type: Answer

http://stackoverflow.com/q/22070763
type: AnsweredQuestion
has title: Apache POI seeing columns in empty spreadsheet?
accepted answer: http://stackoverflow.com/a/22076367
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/22070978
has comment: http://stackoverflow.com/comment/33469059
answer count: 3
has comment: http://stackoverflow.com/comment/33469076
has answer: http://stackoverflow.com/a/22076367
downvote count: 0
has comment: http://stackoverflow.com/comment/33471888
favorite count: 0
has body: I have an empty spreadsheet, but when I'm accessing it with Apache POI (version 3.10), it says it has 1024 columns and 20 physical columns. I really deleted all the cells, only some formatting remains, but no content. And if I delete some columns with LibreOffice Calc (version 4.1.3.2), the number of columns only increases! What's going on? Is there a reliable way to get the real number of columns (or cells in a row)? import java.net.URL; import org.apache.poi.ss.usermodel.*; public class Test { public static void main(final String... args) throws Exception { final URL url = new URL("http://aditsu.net/empty.xlsx"); final Workbook w = WorkbookFactory.create(url.openStream()); final Row r = w.getSheetAt(0).getRow(0); System.out.println(r.getLastCellNum()); System.out.println(r.getPhysicalNumberOfCells()); } }
has answer: http://stackoverflow.com/a/22070978
has answer: http://stackoverflow.com/a/58215306
has comment: http://stackoverflow.com/comment/33473840
has comment: http://stackoverflow.com/comment/33471244
tagged with: apache-poi
tagged with: libreoffice-calc
upvote count: 1
has comment: http://stackoverflow.com/comment/33469206
tagged with: excel
type: Question

variables
tags question: http://stackoverflow.com/q/22158288
tag name: variables
tags question: http://stackoverflow.com/q/22141786
tags question: http://stackoverflow.com/q/22121241
tags question: http://stackoverflow.com/q/22101439
tags question: http://stackoverflow.com/q/22163702
tags question: http://stackoverflow.com/q/22113857
type: Tag
tags question: http://stackoverflow.com/q/22039952
tags question: http://stackoverflow.com/q/22039291
tags question: http://stackoverflow.com/q/22152219
tags question: http://stackoverflow.com/q/22051235
tags question: http://stackoverflow.com/q/22027276
tags question: http://stackoverflow.com/q/22160704
tags question: http://stackoverflow.com/q/22099608

http://stackoverflow.com/comment/33778361
has text: Hi @mvreijn, need a help i have a UPN alias testserver.ad registered for domain demo.com, now do i fetch domain of testserver.ad from code base.
type: AnswerComment
type: Comment
score: 0
comment on: http://stackoverflow.com/a/22091904

semaphore
type: Tag
tags question: http://stackoverflow.com/q/22020915
tag name: semaphore

http://stackoverflow.com/q/22099634
has title: How to exclude spring context initialization time from your first running unit test?
has comment: http://stackoverflow.com/comment/33521624
downvote count: 0
tagged with: junit
has comment: http://stackoverflow.com/comment/33522899
favorite count: 0
has comment: http://stackoverflow.com/comment/33524823
answer count: 0
type: UnansweredQuestion
has body: Hi I am using SpringJUnit4ClassRunner for my unit tests. It does a bunch of initialization like scanning jpa packages, creating a dataSource and binding it to my jndi environment. All of this takes time. I realize my first unit test function always takes a longer time than the others. I guess Jvm puts the initialization step when running the first step. I am doing some basic load tests and this situation affects me. Is there a way to exclude this init step time from my first running test.
tagged with: spring
has comment: http://stackoverflow.com/comment/33523356
score: 3
linked to: http://stackoverflow.com/q/7338153
upvote count: 3
tagged with: java
type: Question

http://stackoverflow.com/a/60670811
type: Answer
has body: I've faced with similar issue. Tried published recommendations but unsuccessfully. Possible the reason I'm using sdkman to manage java versions, may be something with permissions because of Mac OS. For Mac user it is important try manage configuration: try SetJavaHome {{path to your java}} in ~/.sqldeveloper/{{sql-dev-version}}/product.conf this step could help if you are using jdk installed by brew following default path. If you've installed openjdk with sdkman path to java will be like ~/.sdkman/candidates/java/{{java-version}} and this path needs to be mapped on default expectations with aliases. I did not have information about the default path, so it needs to find executable file: start sqldeveloper (to make shown error message); in terminal try ps ux | grep sql - it will help you to detect executable file location sqldeveloper.sh; open the file with text editor: remove or comment block that tries to get java from default location /usr/libexec/java_home; find line with export JAVA_HOME=$TMP_PATH and replace path with your path to java home or simply remove line if JAVA_HOME was specified in OS settings.
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/22158923
downvote count: 0

http://stackoverflow.com/comment/33580952
type: Comment
has text: What does the second question mean?
type: QuestionComment
comment on: http://stackoverflow.com/q/22132207
score: 0

http://stackoverflow.com/a/37475568
downvote count: 0
score: 1
upvote count: 1
has body: I have acheived in root tablet, Below is my full procedure adb push sqlite3 /sdcard/sqlite3 adb shell su mount -o remount,rw /system cp /sdcard/sqlite3 /system/xbin/sqlite3 chmod 755 /system/xbin/sqlite3 mount -o remount,ro /system adb shell sqlite3 /data/system/locksettings.db UPDATE locksettings SET value = '1' WHERE name = 'lockscreen.disabled' You can download the file from http://www.digitechhub.com/sqlite3
answers question: http://stackoverflow.com/q/22142940
type: Answer

http://stackoverflow.com/q/22018043
has comment: http://stackoverflow.com/comment/33375028
has comment: http://stackoverflow.com/comment/33375021
tagged with: java
has comment: http://stackoverflow.com/comment/33376044
type: Question
has comment: http://stackoverflow.com/comment/33375849
upvote count: 0
score: -2
has comment: http://stackoverflow.com/comment/33375073
has comment: http://stackoverflow.com/comment/33375647
has answer: http://stackoverflow.com/a/22018146
has comment: http://stackoverflow.com/comment/33376041
has comment: http://stackoverflow.com/comment/33375503
has answer: http://stackoverflow.com/a/22018797
has comment: http://stackoverflow.com/comment/33375806
has answer: http://stackoverflow.com/a/22018119
has comment: http://stackoverflow.com/comment/33376255
has title: Re-initializing final fields in a static class
has answer: http://stackoverflow.com/a/22018422
has comment: http://stackoverflow.com/comment/33375261
has comment: http://stackoverflow.com/comment/33375612
has body: I have a static class, like this: public class StaticClass { public static final String stringValue; static { stringValue = OtherClass.someMethod(); } } We use StaticClass.stringValue all over the place. But in a given situation, I want to force it to reload, so the static initializer runs again. Is this possible? I know I could use reflection to set this field manually. But in practice, there are 1000's of fields in this class. I'm fully aware of how odd this all sounds, and why I shouldn't do it. I want to know if this is possible. I want the field to be final, so my developers can't accidentally change the values. But I want the fields to all reload after a given user input.
has comment: http://stackoverflow.com/comment/33376076
has comment: http://stackoverflow.com/comment/33376437
has answer: http://stackoverflow.com/a/22018121
favorite count: 0
answer count: 5
type: UnansweredQuestion
downvote count: 2
has comment: http://stackoverflow.com/comment/33376681
has comment: http://stackoverflow.com/comment/33375681
has comment: http://stackoverflow.com/comment/33375218

http://stackoverflow.com/q/22100820
tagged with: jena
downvote count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33582950
favorite count: 0
type: Question
has title: Using custom rule in Jena to assign individual to type
score: 1
has answer: http://stackoverflow.com/a/22133758
tagged with: http://stackoverflow.com/tag/rdf
has body: Is it possible to add a rule in Jena which defines the type of an individual? For example String r; r = "[rule1: (?a example:drives ?b), (?b rdf:type example:Truck) -&gt; (?a rdf:type example:TruckDriver)]"; //then parse and send to reasoner...etc All of the examples and documentation I found online uses custom rules to assign relationships between individuals (object properties) as opposed to this rule which is used to assign an individual to a class.
upvote count: 1
answer count: 1
has comment: http://stackoverflow.com/comment/33583146
has comment: http://stackoverflow.com/comment/33606663
tagged with: jena-rules
tagged with: java
has comment: http://stackoverflow.com/comment/33581761

http://stackoverflow.com/a/30030770
answers question: http://stackoverflow.com/q/22123932
has body: Today i had an issue with a Clob field because i was using "setString" to set the parameter, but then i had this error while testing with a very long string: "setString can handle only Strings with less than 32766 characters" I used connection.createClob but it gave me this exception: java.lang.AbstractMethodError: org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.createClob()Ljava/sql/Clob; So looking for this exception i found this using CLOB in java throwing exception and the accepted answer (using setCharacterStream instead of setClob) worked for me Copy/Pasted from the accepted answer (so all credits are for a_horse_with_no_name ) StringReader reader = new StringReader(userAbout); PreparedStatement insertClob = dbCon.prepareStatement("UPDATE user_data SET user_about=? WHERE user_id=?"); insertClob.setCharacterStream(1, reader, userAbout.length()); insertClob.setInt(2,userId);
upvote count: 1
score: 1
downvote count: 0
type: Answer

http://stackoverflow.com/a/23543987
downvote count: 0
type: Answer
score: 1
upvote count: 1
has body: Hence direct use of Element is deprecated, don't use Element itself, but its subclass SpanElement: import com.google.gwt.dom.client.SpanElement; SpanElement span = Document.get().createSpanElement(); DOM.insertChild(getElement(), span, 0);
answers question: http://stackoverflow.com/q/22106514

http://stackoverflow.com/a/22109228
answers question: http://stackoverflow.com/q/22109043
upvote count: 1
has body: You might be able to get some benefit from for (int i= 0; i &lt; L ; ++i) { int j=0; for (; j &lt; i; ++j) { } for (++j; j &lt; L; ++j) { } } which avoids testing L while you're still testing i. I've also switched to pre-increment -- since you aren't using the result it probably doesn't make any difference after the optimizer is done with it, but postincrement is, conceptually, a more complicated operation unless there happens to be instruction-set support for it. If you can change the order in which results are reported, this would be faster: int L1=L-1; for (int i=L1; i &gt;=0 ; --i) { int j=L1; for (; j &gt; i; --j) { } for (--j; j &gt;=0; --j) { } } Testing against most values requires a subtraction. Testing against zero doesn't; it occurs "for free" when the value is loaded. In fact, you could improve it further: int L1=L-1, i=L1; do { int j=L1; do { } while(--j&gt;i); while(--j&gt;=0) { } } while(--i &gt;= 0); That avoids the redundant initial test. (Note that you still need to test at the top of the second loop, in case i was 0.) However, in fact the loop overhead is the least of your problems here; the System.out.println() calls are going to consume far more cycles than the loop control will.
downvote count: 0
score: 1
type: Answer

http://stackoverflow.com/comment/33584686
comment on: http://stackoverflow.com/q/22134211
type: Comment
type: QuestionComment
score: 0
has text: @BoristheSpider If he increments by 2, then the number 9 will be prime.

http://stackoverflow.com/a/22166590
score: 2
has body: The first call: IntegerPrinter.class.getClassLoader() Will actually do: IntegerPrinterTest.class.getClassLoader().loadClass("IntegerPrinter") So it totally ignores your custom classloader. In other words: your own classloader is not actually used for any objects you create using native calls like "new" etc. To do that it should be responsible for loading the IntegerPrinter class as well. It is rather circumspect (and in general useless) to do it in the same class but you could do: Class&lt;?&gt; clazz = loader.loadClass("IntegerPrinterTest"); clazz.getMethod("main").invoke(null); (note this code is not tested but should approximate something that works)
downvote count: 0
type: Answer
upvote count: 2
answers question: http://stackoverflow.com/q/22165920

http://stackoverflow.com/comment/33489443
type: Comment
comment on: http://stackoverflow.com/a/22081003
type: AnswerComment
has text: I have updated the answer for option 2 (returning an integer value), In this case you are using the return for 2 different purposes which is not ideal (and could lead to confusion when other people maintain your code).
score: 0

http://stackoverflow.com/q/22153678
has body: Hi I'm having a problem with Openshift. The error is: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'loginController' resolved to null On my Tomcat7 and Glassfish it works fine. I'm using JSF 2.0 with Primefaces 4 and CDI Weld. Here is my code: My pojo public class Login { private int codigo; private String username; private String password; // getters and setters } My controller import javax.enterprise.context.SessionScoped; import javax.inject.Inject; import javax.inject.Named; //others imports @Named @SessionScoped public class LoginController implements Serializable { private static final long serialVersionUID = 4560576357452534579L; @Inject private LoginDAO loginDao; private Login login; // others fields // getters and setters of Login } My JSF page &lt;p:inputText class="form-control" id="username" value="#{loginController.login.username}" /&gt; &lt;p:password class="form-control" id="password" value="#{loginController.login.password}" /&gt;
tagged with: cdi
type: UnansweredQuestion
tagged with: openshift
tagged with: primefaces
score: 0
tagged with: java
has title: Openshif - JSF2.0, Primefaces4 e CDI Weld - Controller resolved to null
has answer: http://stackoverflow.com/a/22161638
type: Question
tagged with: jsf-2
answer count: 1

http://stackoverflow.com/a/22143941
has comment: http://stackoverflow.com/comment/33604403
type: Answer
answers question: http://stackoverflow.com/q/22143648
has comment: http://stackoverflow.com/comment/33603038
has body: Try this class, it's an easy way using netbeans. /* * NewJFrame.java * * Created on 3 mars 2014, 10:08 */ package GUI; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; /** * * @author boussarhane */ public class NewJFrame extends javax.swing.JFrame { protected UIManager.LookAndFeelInfo[] m_infos; String[] LAFNames; /** Creates new form NewJFrame */ public NewJFrame() { initComponents(); m_infos = UIManager.getInstalledLookAndFeels(); LAFNames = new String[m_infos.length]; for (int i = 0; i &lt; m_infos.length; i++) { //LAFNames[i] = m_infos[i].getName(); if (m_infos[i].getName().equals("Nimbus")) { try { UIManager.setLookAndFeel(m_infos[i].getClassName()); SwingUtilities.updateComponentTreeUI(this); } catch (ClassNotFoundException ex) { Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, ex); } catch (UnsupportedLookAndFeelException ex) { Logger.getLogger(Acceuil.class.getName()).log(Level.SEVERE, null, ex); } } } } /** 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. */ // &lt;editor-fold defaultstate="collapsed" desc="Generated Code"&gt; private void initComponents() { jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jButton1.setText("jButton1"); jButton2.setText("jButton2"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD…
has comment: http://stackoverflow.com/comment/33641751
has comment: http://stackoverflow.com/comment/33617392
score: 1
has comment: http://stackoverflow.com/comment/33614253
upvote count: 1
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33634469
accepted answer of: http://stackoverflow.com/q/22143648

http://stackoverflow.com/q/22019785
type: Question
score: 0
has body: I am running Jetty with 2 handlers, webapp and servlet, and 2 contexts, "/" and "/d/*". Webapp loads fine, while I get "404 Not found" when trying to go to servlet. Here is the code I use: public static void main(String[] args){ // The simple Jetty config here will serve static content from the webapp directory String webappDirLocation = "src/main/webapp/"; // The port that we should run on can be set into an environment variable // Look for that variable and default to 8080 if it isn't there. String webPort = System.getenv("PORT"); if (webPort == null || webPort.isEmpty()) { webPort = "7777"; } Server server = new Server(Integer.valueOf(webPort)); HandlerCollection handlerCollection = new HandlerCollection(); // Add the GUI part WebAppContext webapp = new WebAppContext(); webapp.setContextPath("/"); webapp.setDescriptor(webappDirLocation + "/WEB-INF/web.xml"); webapp.setResourceBase(webappDirLocation); handlerCollection.addHandler(webapp); // Add the API part ServletContextHandler apiContext = new ServletContextHandler(ServletContextHandler.SESSIONS); apiContext.setContextPath("/d"); apiContext.addServlet(new ServletHolder(new DownloaderServlet()), "/*"); handlerCollection.addHandler(apiContext); // Add both handlers to the server server.setHandler(handlerCollection); try { server.start(); server.join(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } Servlet code: @SuppressWarnings("serial") @WebServlet public class DownloaderServlet extends HttpServlet { public DownloaderServlet(){} @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println(" My Servlet "); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } } Web.xml: <?xml version="1.0" encoding="UTF-8"?> index.html
has answer: http://stackoverflow.com/a/22021232
answer count: 1
has title: Jetty Servlet context not found
type: UnansweredQuestion
tagged with: jetty
tagged with: java
tagged with: servlets

http://stackoverflow.com/q/22096398
score: 7
tagged with: java
tagged with: database
has body: Suppose you have the following code: Connection connection = null; PreparedStatement ps = null; try { Connection = connectionFactory.getConnection(); ps = statement.prepareStamement(someQuery); // execute and read and stuff // now you want to use the ps again, since you don't want ps1, ps2, ps3, etc. ps = statement.prepareStatement(someOtherQuery); // DOES THIS FORM A POTENTIAL LEAK? } catch (a lot of exceptions) { // process exceptions } finally { // close the resources (using util class with null-checks and everything) SomeUtilClass.close(ps); SomeUtilClass.close(connection); } Is reusing the ps variable a potential leak? And if so, I would hate to declare multiple of such prepared statements (ps1, ps2, ps3, etc). How should I refactor this? Thoughts anyone? EDIT Receiving several answers stating that this doesn't matter. I would like to point out that I'm experiencing open cursors that stay open a little bit too long, and was wondering if this pattern might have something to do with it. My thoughts were: The first statement gets dereferenced and GC'ed, so how does the first PreparedStatement get closed (Database-wise) in this example?
has answer: http://stackoverflow.com/a/22096505
has answer: http://stackoverflow.com/a/22096500
tagged with: resources
type: Question
downvote count: 0
tagged with: jdbc
accepted answer: http://stackoverflow.com/a/22096500
favorite count: 0
has answer: http://stackoverflow.com/a/22098071
answer count: 5
possible better answer: http://stackoverflow.com/a/22096536
upvote count: 7
has title: Possible resource leak when reusing PreparedStatement?
has answer: http://stackoverflow.com/a/22096536
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22096478

http://stackoverflow.com/a/60988271
type: Answer
has body: In Hbase 2.0.2 version there is no repair option to recover inconsistencies. Run hbase hbck command. If the error mesaage look like mentioned below: ERROR: Region { meta =&gt; EMP_NMAE,\x02\x00\x00\x00\x00,1571419090798.054b393c37a80563ae1aa60f29e3e4df., hdfs =&gt; hdfs://node1:8020/apps/hbase/data/data/LEVEL_RESULT/054b393c37a80563ae1aa60f29e3e4df, deployed =&gt; , replicaId =&gt; 0 } not deployed on any region server. ERROR: Region { meta =&gt; TABLE_3,\x02174\x0011100383\x00496\x001,1571324271429.6959c7157693956825be65676ced605c., hdfs =&gt; hdfs://node1:8020/apps/hbase/data/data/TABLE_NAME/6959c7157693956825be65676ced605c, deployed =&gt; , replicaId =&gt; 0 } not deployed on any region server. copy this error inconsistancy to an file and pull the alphanumeric value by using the below command. If our inconsistancy count is less we can take value manually if the number is more it would be hectic to retrive the entire value. so use the below command to narrow down to alphanemeric alone which can be copied and put in hbase shell at a stretch. cat inconsistant.out|awk -F'.' '{print $2}' Open hbase hbase shell and assign these consistancy manually. LIKE BELOW: assign '054b393c37a80563ae1aa60f29e3e4df' assign '6959c7157693956825be65676ced605c' assign '7058dfe0da0699865a5b63be9d3799ab' assign 'd25529539bae49eb078c7d0ca6ce84e4' assign 'e4ad94f58e310a771a0f5a1eade884cc' once the assigning is completed run the hbase hbck command again
score: 0
answers question: http://stackoverflow.com/q/22098754

http://stackoverflow.com/a/22884706
has body: The problem appears that the base class is not aware of the layout. Not sure how or why it worked for others without having to do something like this.. but I am new to Android. I was getting the same error and solved by passing my layout to the base via onCreate. So in the base, I modified onCreate to be like this: protected void onCreate(Bundle savedInstanceState, int resLayoutID) { super.onCreate(savedInstanceState); setContentView(resLayoutID); Then, from my new activity, I have this: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState, R.layout.my_activity); This code in my base now works instead of staying null: drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerList = (ListView) findViewById(R.id.left_drawer); btw, this result was suggested to me by a friend and it worked for me.
score: 5
answers question: http://stackoverflow.com/q/22137283
upvote count: 5
type: Answer
downvote count: 0

rest
tags question: http://stackoverflow.com/q/22017474
tags question: http://stackoverflow.com/q/22034910
tags question: http://stackoverflow.com/q/22067928
tags question: http://stackoverflow.com/q/22166813
tags question: http://stackoverflow.com/q/22113707
tags question: http://stackoverflow.com/q/22159454
tags question: http://stackoverflow.com/q/22053414
tags question: http://stackoverflow.com/q/22142979
tags question: http://stackoverflow.com/q/22122626
tags question: http://stackoverflow.com/q/22048511
tags question: http://stackoverflow.com/q/22115118
tags question: http://stackoverflow.com/q/22076654
tags question: http://stackoverflow.com/q/22043648
tags question: http://stackoverflow.com/q/22119730
tags question: http://stackoverflow.com/q/22091551
tags question: http://stackoverflow.com/q/22161777
tags question: http://stackoverflow.com/q/22101117
tags question: http://stackoverflow.com/q/22144644
tags question: http://stackoverflow.com/q/22042744
tags question: http://stackoverflow.com/q/22089501
tags question: http://stackoverflow.com/q/22069821
tags question: http://stackoverflow.com/q/22009203
tags question: http://stackoverflow.com/q/22043499
tags question: http://stackoverflow.com/q/22078564
tags question: http://stackoverflow.com/q/22078568
tags question: http://stackoverflow.com/q/22113598
tags question: http://stackoverflow.com/q/22114085
tags question: http://stackoverflow.com/q/22070816
tags question: http://stackoverflow.com/q/22153511
tags question: http://stackoverflow.com/q/22159694
tags question: http://stackoverflow.com/q/22118487
type: Tag
tags question: http://stackoverflow.com/q/22163397
tags question: http://stackoverflow.com/q/22145107
tags question: http://stackoverflow.com/q/22006226
tags question: http://stackoverflow.com/q/22040572
tags question: http://stackoverflow.com/q/22075578
tag name: rest
tags question: http://stackoverflow.com/q/22039369
tags question: http://stackoverflow.com/q/22057694
tags question: http://stackoverflow.com/q/22140095
tags question: http://stackoverflow.com/q/22007151
tags question: http://stackoverflow.com/q/22084867
tags question: http://stackoverflow.com/q/22016191
tags question: http://stackoverflow.com/q/22061135
tags question: http://stackoverflow.com/q/22041138
tags question: http://stackoverflow.com/q/22106509
tags question: http://stackoverflow.com/q/22122365
tags question: http://stackoverflow.com/q/22164147

http://stackoverflow.com/q/22161552
type: Question
has body: long time searcher but first time I'm posting a question. I am an IT student going into [haven't started yet] my second programming class. The first was just an intro to Java (we're talking basics really). I have been having a hard time with calling methods within the same class. I have attempted search-foo with poor results. A few articles pop up but they don't cover exactly what I'm looking for. Included is an example (quickly and probably poorly written) to get across what I'm asking. The basic gist [remember to stay with me since I'm new to programming in general] is that I want to add two numbers, creating a third, and have the system display the result... public class MethodCallExample{ public static void main(String[] args){ int valueTwo = 3; MethodToCall(); int valueOne; int TrueValue = valueOne + valueTwo; System.out.println("The total value is " + TrueValue + "!"); } public static int MethodToCall(){ int valueOne = 2; return valueOne; } } When I go to compile I get one of two errors depending on which derp I try to underp. If I compile as its' written, I receive a "valueOne might not have been initialized" error, and if I either move or remove -int valueOne - I receive "cannot find symbol" referring to valueOne. Any help is greatly appreciated since I am still learning. Sincerely, Hubert Farnsworth
possible better answer: http://stackoverflow.com/a/22161574
upvote count: 0
has answer: http://stackoverflow.com/a/22161643
has title: Method calling within the same class
score: -1
answer count: 3
has comment: http://stackoverflow.com/comment/33632989
favorite count: 0
has answer: http://stackoverflow.com/a/22161569
has comment: http://stackoverflow.com/comment/33632822
downvote count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22161574
tagged with: java
accepted answer: http://stackoverflow.com/a/22161569

http://stackoverflow.com/comment/33544752
has text: I own a Galaxy S3 and it has both real and emulated SD storage. So I have 3 usable storage partitions: SD real, SD emulated and the Internal storage. I'm not sure which one of us is not understanding the other but I'm a little confused now... Can you tell me the exact location of the files you are trying to delete? The absolute path would be very helpful.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22112344
type: Comment

http://stackoverflow.com/comment/33363543
type: Comment
type: QuestionComment
has text: using regex you could filter the whole file's content, getting a multidimensional array with captions included: /((\S*)#){6}(\w)/
comment on: http://stackoverflow.com/q/22010955
score: 0

http://stackoverflow.com/a/22034140
upvote count: 1
has comment: http://stackoverflow.com/comment/33405310
type: Answer
has body: The answer is: you can't. Because of type erasure that information no longer exists at run time. Pass in a Class argument when you create your FrontUtil instance. private Class&lt;T&gt; clazz; public FrontUtil(Class&lt;T&gt; clazz) { this.clazz = clazz; } Then use that Class object wherever you need it.
downvote count: 0
has comment: http://stackoverflow.com/comment/33405710
score: 1
has comment: http://stackoverflow.com/comment/33425395
answers question: http://stackoverflow.com/q/22034062

http://stackoverflow.com/q/22027417
has comment: http://stackoverflow.com/comment/33392899
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33393012
score: 2
has comment: http://stackoverflow.com/comment/33392890
has title: Switching between data bases in Java
tagged with: java
has comment: http://stackoverflow.com/comment/33392811
accepted answer: http://stackoverflow.com/a/22028975
has body: I want to obtain some data in my java code from a netezza DB, hold that in memory and then switch to an oracle db and run some analysis. However, when I try and switch to the second db below, I get the following error: org.netezza.util.PSQLEexception: Invalid URL format What am I doing wrong? I thought switching the Class.forName would be enough. Note that - I can set up the oracle connection separately (when I don't do netezza). But the problem arises when I try to switch from netezza to Oracle Class.forName("org.netezza.Driver"); System.out.println(" Connecting ... "); conn = DriverManager.getConnection(url, user, pwd); System.out.println("Connected "+ conn); PreparedStatement pstat = conn.prepareStatement("some query"); ResultSet rstru = pstat.executeQuery(); while(rstru.next()){ //Do some thing } rstru.close(); if(conn != null) conn.close(); Class.forName("oracle.jdbc.driver.OracleDriver"); System.out.println("Connecting to Oracle"); conn = DriverManager.getConnection("some other url", "user2", "passwrd2"); System.out.println("Connected "+ conn); pstat = conn.prepareStatement("second query"); rstru=pstat.executeQuery();
type: Question
has comment: http://stackoverflow.com/comment/33392935
has comment: http://stackoverflow.com/comment/33393038
tagged with: database
answer count: 1
tagged with: jdbc
downvote count: 0
has comment: http://stackoverflow.com/comment/33392881
has answer: http://stackoverflow.com/a/22028975
has comment: http://stackoverflow.com/comment/33392837
has comment: http://stackoverflow.com/comment/33392954
favorite count: 0
tagged with: database-connection
upvote count: 2
has comment: http://stackoverflow.com/comment/33392920

http://stackoverflow.com/q/22130692
tagged with: database-design
has comment: http://stackoverflow.com/comment/33578267
tagged with: password-protection
accepted answer: http://stackoverflow.com/a/22131031
tagged with: operating-system
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22131031
tagged with: java
tagged with: authentication
has comment: http://stackoverflow.com/comment/33578560
has title: Java: call OS for administrator level authentication?
type: Question
score: 0
answer count: 1
has body: I'm making a mock inventory program for an inventory database, and I want to implement a feature where if in a use case scenario, a warehouse receiver (who wouldn't have administrator login status in the company network I would hope) would attempt to delete a record of the database, he would have to enter OS level administrator authentication since deletion of records could wreak tax audit havoc. I want to make the deletion still accessible if the real person in the office next door could access the software if the receiver informs his supervisor that he's made a critical mistake in data entry such as UPC. The supervisor could then inform her network admin... So with that said, I'm wondering how I call the operating system. Since I've never done this before the first thing that came to mind was something like String adminPassword = JOptionPane.showInputDialog( "Enter Network Administrator Password"); if(callSomeOSFeatureForAdminPasswordReturnsTrue(adminPassword)){ record.delete(); } Sorry if this is a dumb question but I've never done anything like this and it doesn't make sense from a security standpoint because then what's to prevent a rather dark-minded programmer from transmitting that String? That's kind of a tangent but basically I just would like to know what I should look up to make sure end user local network administrator level authentication is done on a database record deletion attempt. Every year warehouses have to audit everything in the inventory so if some receiver thought "delete" was supposed to be used every time you ran out of a product temporarily the audit would be a nightmare (Trust me, I've been through these in real life and they're like a tornado through the warehouse, and if more than only a tiny amount of things are unaccounted for, the supervisors are BEYOND mad.)

http://stackoverflow.com/a/22108248
type: Answer
has comment: http://stackoverflow.com/comment/33632840
upvote count: 1
answers question: http://stackoverflow.com/q/22108121
score: 1
has body: Change this JTextField assessTF = new JTextField(10); JTextField schoolRateTF = new JTextField(10); JTextField countyRateTF = new JTextField(10); JTextField schoolTaxTF = new JTextField(10); JTextField countyTaxTF = new JTextField(10); JTextField totalTaxTF = new JTextField(10); to this assessTF = new JTextField(10); schoolRateTF = new JTextField(10); countyRateTF = new JTextField(10); schoolTaxTF = new JTextField(10); countyTaxTF = new JTextField(10); totalTaxTF = new JTextField(10); That way, you aren't using the variables you defined as a class field, but creating new ones. And that's why you couldn't access them later with getText and setText.
has comment: http://stackoverflow.com/comment/33587996
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22108121

http://stackoverflow.com/q/22022656
accepted answer: http://stackoverflow.com/a/22022924
has body: I'm doing a Book shop GUI for college, I have 4 classes: Book, bookfile, BookGUI, TestClass. I create a bookFile() object (bkf) in my test, and I add a Book to it (b), I then create my BookGUI(bkf) object (g) passing bkf into it. I can only edit the BookGUI class! I cant figure out how to access the bkf object I passed in when I created my BookGUI object, from within the actionPerformed() I need to update the Arraylist in bookFile() when the add button is pressed, How do I call the .addBook() on the bkf object from within action preformed? Please Only answer the question I have asked, as I will figure the rest out myself, unless it is good coding ethics. Thanks for any help. TestClass public class TestClass { public static void main(String[] args) { bookFile bkf = new bookFile(); Book b = new Book("Dan Brown","The daVinci Code",3,10.99); bkf.addBook(b); BookGUI g = new BookGUI(bkf); g.setVisible(true); } } BookGUI import javax.swing.*; import javax.swing.border.TitledBorder; import java.awt.*; import java.awt.event.*; class BookGUI extends JFrame implements ActionListener{ private final int width = 290; private final int height = 260; private JLabel title, author, quantity, price; private JTextField titleTBox, authorTBox, quantityTBox, priceTBox; private JTextArea outputBox; private JButton addButton, totalQ, totalV, exit; private TitledBorder border; private Container c; private JPanel input = new JPanel(new GridLayout(0,2)); private JPanel buttons = new JPanel(new GridLayout(2,2)); private JPanel output = new JPanel(new FlowLayout()); public BookGUI(bookFile bkf) { c = getContentPane(); this.setLayout(new BorderLayout(2,2)); this.setSize(width, height); this.add(input,BorderLayout.NORTH); input.setBackground(Color.LIGHT_GRAY); title = new JLabel("Title"); input.add(title); titleTBox = new JTextField(); input.add(titleTBox); author = new JLabel("Author"); input.add(author); authorTBox = new JTextField(); input.add(authorTBox); quantity = new JLabel("Quantity"); inp…
tagged with: java
upvote count: 1
downvote count: 1
type: Question
score: 0
answer count: 2
has title: Access an object from within actionPerformed
has answer: http://stackoverflow.com/a/22022924
has answer: http://stackoverflow.com/a/22022918
favorite count: 0
possible better answer: http://stackoverflow.com/a/22022918
type: AnsweredQuestion

http://stackoverflow.com/comment/33750268
comment on: http://stackoverflow.com/a/22091240
has text: I am not able to download the sample files. Getting a server error: Could not locate the files.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33602224
type: Comment
score: 1
type: QuestionComment
has text: Not `String[i] elementsToAdd2 = ...` but `elementsToAdd2[i] = ...`. And the loop should not run while `i <= elementsToAdd2.length`, but while `i < elementsToAdd2.length`.
comment on: http://stackoverflow.com/q/22144913

http://stackoverflow.com/a/22049207
score: 2
upvote count: 2
accepted answer of: http://stackoverflow.com/q/22048950
answers question: http://stackoverflow.com/q/22048950
type: AcceptedAnswer
downvote count: 0
has body: You may want to try out jsoup.http://jsoup.org/cookbook/introduction/parsing-a-document
has comment: http://stackoverflow.com/comment/33443443
type: Answer

http://stackoverflow.com/q/22086840
tagged with: java
type: Question
has title: My session not became Null after invalidating the session
tagged with: httpsession
has answer: http://stackoverflow.com/a/22086887
tagged with: servlets
answer count: 2
downvote count: 0
possible better answer: http://stackoverflow.com/a/22086882
has answer: http://stackoverflow.com/a/22086882
favorite count: 0
has body: Hi Can anyone plz let me know what would be the problem in the following code.In this below code I have invalidated my session after creating the new session by using the http session.getsession(true) and setting the attribute also.Once I click the logout i am invalidating the session but that is not became null. Here I am not getting null System.out.println("sess"+sess) HttpSession sess = request.getSession(false); sess.removeAttribute("name"); sess.invalidate(); System.out.println("sess"+sess);
upvote count: 2
accepted answer: http://stackoverflow.com/a/22086887
type: AnsweredQuestion
score: 2

http://stackoverflow.com/q/22005235
tagged with: android
has title: How to hide an intent in android
tagged with: android-activity
type: UnansweredQuestion
tagged with: java
type: Question
score: 0
has body: I am using an activity to show Pdf in android but whenever I use it another application will install to the phone. The new app will allow user to use that module to open pdf too, that I dont want. how can i prevent this. i use this code to run the activity but i forgot where i got the resource which was long time ago: final File file = new File("/sdcard/anyfile.pdf"); Uri uri = Uri.fromFile(file); Intent intent = new Intent(); intent.setClassName("com.artifex.mupdf", "com.artifex.mupdf.MuPDFActivity"); intent.setAction(Intent.ACTION_VIEW); intent.setData(uri); startActivity(intent);
answer count: 1
has answer: http://stackoverflow.com/a/22005338

http://stackoverflow.com/comment/33403619
type: Comment
comment on: http://stackoverflow.com/a/22033460
type: AnswerComment
score: 0
has text: Here ""+s1 means single space will added to the String s1 so it's not equal to the another String s

http://stackoverflow.com/q/22028550
tagged with: sonarqube
tagged with: gradle
type: Question
downvote count: 0
tagged with: jacoco
has answer: http://stackoverflow.com/a/22106350
has answer: http://stackoverflow.com/a/22238617
has comment: http://stackoverflow.com/comment/33555292
answer count: 3
has answer: http://stackoverflow.com/a/22106694
has title: Integrating Sonar, Jacoco, Gradle, ScalaTest with Junit, Java
favorite count: 0
has comment: http://stackoverflow.com/comment/33554814
tagged with: scala
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/19395182
score: 6
upvote count: 6
has body: I have very successfully integrated Gradle (1.11), Sonar ( 4.1.1 ), Java, Scala and Jacoco in my build process. I even managed to get info regarding the number of successful tests ( thanks to Stackoverflow! ). I have one problem though. I can't seem to get info about coverage per test. It would be very nice to have this info. &gt; 15:11:16.514 INFO - Sensor JaCoCoSensor... 15:11:16.535 INFO - &gt; Analysing C:\example\gradle-sonar-jacoco-scala\build\jacoco\test.exec &gt; 15:11:17.887 INFO - No information about coverage per test. A simplified version of the project is at : https://github.com/sebastianharko/gradle-sonar-java-jacoco-scalatest-junit Cheers !
tagged with: java
has comment: http://stackoverflow.com/comment/33777730

http://stackoverflow.com/comment/33458424
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22060372
type: Comment
has text: I have problem, if i have two or more group here, all time executed first group. How to execute second time this method call next group. or third time third group. it means how to start this if second time call this function, starting index from first groupindex+1 and third call this method second groupindex+1 and so on. I have lots of confusing here. please give hint.

http://stackoverflow.com/comment/33625644
has text: Thanks for your answer. I think this would be the solution but there's one problem. I can't initialize grid in the Grid class because I need the values given be the Constructor. But when I'm trying to initialize the grid array in the Constructor, eclipse returns 'Illegal modifier for paramter grid; only final is permitted'. I've forgotten to mention that there's a super("Title"); in the Constructor at the beginning, sorry about that!
comment on: http://stackoverflow.com/a/22157286
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33644012
type: Comment
comment on: http://stackoverflow.com/a/22167753
has text: Thanks for the Reple , however what is RequestTask in this ? my code is :
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33515923
has text: try to copy the full stacktrace
comment on: http://stackoverflow.com/a/22094784
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/22131556
has comment: http://stackoverflow.com/comment/33580101
downvote count: 0
has comment: http://stackoverflow.com/comment/33579823
has comment: http://stackoverflow.com/comment/33580042
accepted answer of: http://stackoverflow.com/q/22131527
answers question: http://stackoverflow.com/q/22131527
has comment: http://stackoverflow.com/comment/33579863
score: 4
has comment: http://stackoverflow.com/comment/33579873
type: AcceptedAnswer
has body: Shouldn't the subclass field overwrite superclass field? No - the subclass field is actually an entirely new field. Since you mean to assign to the superclass field, you need to create a constructor like this: public DarkRoast() { description = "Dark roast"; } (This is unlike the method cost() - technically when you override a non-abstract method you still 'sort of' have the old method as well)
has comment: http://stackoverflow.com/comment/33580116
type: Answer
upvote count: 4

http://stackoverflow.com/comment/33565359
has text: I don't understand why the client has to know anything about the server's internals...You should have a known address to connect to, and then the server would accept the connection and launch another thread. Am I missing something?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22123608

http://stackoverflow.com/a/22129390
type: AcceptedAnswer
downvote count: 0
type: Answer
upvote count: 6
has comment: http://stackoverflow.com/comment/33575749
accepted answer of: http://stackoverflow.com/q/22129252
score: 6
has body: Generating random number for every chance is good approach : double[] chances = {1, 35, 0.85, 50, 0.1, 0.05, 0.01, 0.001, 65, 11}; Random r = new Random(); boolean dropped = false; for (int i = 0; i &lt; chances.length; i++) { if (chances[i] &gt; r.nextDouble() * 100) { System.out.println("Item with " + chances[i] + " chance is dropped"); dropped = true; break; } } if (dropped == false) { System.out.println("Dropping default item"); } Note that as long as you only drop one item, the order of elements is important. For example, you have 5 items that drop in 99%. Logically for the fifth item there will be only (0.01^4)*0.99 chance that it drops.
answers question: http://stackoverflow.com/q/22129252
has comment: http://stackoverflow.com/comment/33575935

http://stackoverflow.com/q/22102643
favorite count: 0
accepted answer: http://stackoverflow.com/a/22102782
tagged with: android
tagged with: android-imageview
score: 2
type: AnsweredQuestion
has body: I was wondering whats the best way to rotate a GridView with the scrollbar also changing orientation when a user rotates their screen. The rotation example of what I want to accomplish: Portrait | Part 1 | Part 2 | ------------------- | 5 | 6 | | | 4 | 3 | | | 2 | 4 | V | 5 | 1 | Landscape ------------------------------- Part 1 | 5 | 4 | 2 | 5 | -------------------------------- Part 2 | 6 | 3 | 4 | 1 | ---&gt; I couldn't find any android/java libraries that could accomplish this. Maybe I need to use the Matrix object to do some rotation manipulation? Hope someone can point me in the right direction.
upvote count: 2
tagged with: java
type: Question
tagged with: android-gridview
has title: Rotating Android GridView with Items
has answer: http://stackoverflow.com/a/22102782
downvote count: 0
answer count: 1

http://stackoverflow.com/comment/33493319
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/22083563
type: Comment
has text: So this completely changed the way I thought about it. Instead of having an observer on the list itself, I am going to add a repaint method at the end of each method that mutates the frame i am working on, however so far it isn't changing as I had hoped, here is my framePaint method{

http://stackoverflow.com/comment/33592662
type: AnswerComment
comment on: http://stackoverflow.com/a/22138994
type: Comment
score: 1
has text: @Pedantic: **Every** control statement is just syntactic sugar for a `goto`; saying this is like a `goto` is like saying an if statement is like a `goto`: it's true, but that doesn't mean it suffers from the problems that come with *unrestricted* use of `goto`.

http://stackoverflow.com/comment/33448808
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22058895
type: QuestionComment
has text: @SotiriosDelimanolis I'm using `while(p!=0 || k!=0);` because I realized **after** writing the program that it needed to do something else. @ZongZhengLi Sorry, I have no idea what is causing the problem, so I figured having all the code would help.

http://stackoverflow.com/a/22128435
type: Answer
has comment: http://stackoverflow.com/comment/33574060
has comment: http://stackoverflow.com/comment/33574115
answers question: http://stackoverflow.com/q/22128363
has comment: http://stackoverflow.com/comment/33596220
score: 0
has body: The most likely cause is that you create a lot of Sockets but do not .close() them properly. You don't show code so no one can fix that for you; anyway, there are classical idioms when dealing with Sockets, or indeed any class which implements Closeable (which Socket does). With Java 6: final Closeable closeable = whatever(); // or Socket, or InputStream, or... try { doSomethingWith(closeable); } finally { closeable.close(); } With Java 7: try ( final Closeable closeable = whatever(); ) { doSomethingWith(closeable); } // Automatically closed for you NOTE: with Java 7, it is in fact anything which implements AutoCloseable; and Closeable extends AutoCloseable. NOTE 2: if Java 6 and you can afford Guava 14+, consider using Closer.

android-dialog
type: Tag
tags question: http://stackoverflow.com/q/22107687
tag name: android-dialog

http://stackoverflow.com/comment/33583978
type: Comment
score: 1
has text: My disagreements aside, if you believe that is the case, consider editing the OP's question to give it a title that is more descriptive, so others can find it in the future instead of reasking the same question. If you are going on this quest to improve the community, either go all the way or don't bother.
type: AnswerComment
comment on: http://stackoverflow.com/a/22133720

http://stackoverflow.com/q/22008337
tagged with: c#-4.0
tagged with: bouncycastle
downvote count: 1
type: AnsweredQuestion
tagged with: java
has body: I have Java code for generating keypair using BC as follows: KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); keyGen.initialize(1024); KeyPair key = keyGen.generateKeyPair(); PrivateKey priv = key.getPrivate(); PublicKey pub = key.getPublic(); String privateKey = new String(Base64.encode(priv.getEncoded(), 0,priv.getEncoded().length, Base64.NO_WRAP)); String publicKey1 = new String(Base64.encode(pub.getEncoded(), 0,pub.getEncoded().length, Base64.NO_WRAP)); String publicKey = new String(Base64.encode(publicKey1.getBytes(),0, publicKey1.getBytes().length, Base64.NO_WRAP)); Now I want to do same in C# using BC. I have downloaded WP8BouncyCastle library via nuget package manager. I have written as: var kpgen = new RsaKeyPairGenerator(); kpgen.Init(new KeyGenerationParameters(new SecureRandom(new CryptoApiRandomGenerator()), 1024)); var keyPair = kpgen.GenerateKeyPair(); AsymmetricKeyParameter privateKey = keyPair.Private; AsymmetricKeyParameter publicKey = keyPair.Public; string prvKey = Convert.ToBase64String(UTF8Encoding.UTF8.GetBytes(privateKey.ToString())); string pubKey = Convert.ToBase64String(UTF8Encoding.UTF8.GetBytes(publicKey.ToString())); string pubKey1 = Convert.ToBase64String(UTF8Encoding.UTF8.GetBytes(pubKey.ToString())); But I need getEncoded() method available in Java which is not available in BC library in C#. This getEncoded() method is used to convert given key into X.509 encoded key.In case of Java, public key getting twice converted (getencoded() and getBytes()) ,I am not able to do same in C#. Is there any solution to it?
tagged with: windows-phone-8
upvote count: 10
has answer: http://stackoverflow.com/a/22044223
has title: Generating keyPair using Bouncy Castle
score: 9
type: Question
favorite count: 0
answer count: 1
accepted answer: http://stackoverflow.com/a/22044223

http://stackoverflow.com/q/22104338
type: Question
has comment: http://stackoverflow.com/comment/33530849
has answer: http://stackoverflow.com/a/22104455
has answer: http://stackoverflow.com/a/22104669
tagged with: hashmap
has answer: http://stackoverflow.com/a/22105293
upvote count: 3
tagged with: trie
downvote count: 0
has comment: http://stackoverflow.com/comment/33530318
has body: I have a txt file containing 1 million English word with their frequencies in this format: good 345667 bad 456777 ... I need to store it using either a HashMap or a Trie data structure in Java. Later on I need to look up words from the list without other operations. My understanding is that, the look up is slower for HashMap than Trie, but Trie will take up more memory usage, and the implementation of a Trie also takes effort, while HashMap already is ready for use. For production code, do you have any advice or suggestions on what data structures best suit for this situation? Thanks in advance. Also, HashMap allows for "constant time" for lookup. Is it really slower than a Trie for English words?
favorite count: 0
has comment: http://stackoverflow.com/comment/33530448
has answer: http://stackoverflow.com/a/22109836
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33530141
answer count: 4
has comment: http://stackoverflow.com/comment/33530370
score: 3
has comment: http://stackoverflow.com/comment/33539410
tagged with: java
has title: Choose Trie or HashMap for storing a word frequency list?

http://stackoverflow.com/comment/33500521
type: Comment
has text: Node was just a generic name I chose. If all the classes you want to use in the tree implements a shared interface then you can add them as children.
comment on: http://stackoverflow.com/a/22087743
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33606823
has text: by jdbc can i call this
comment on: http://stackoverflow.com/a/22146150
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33541118
type: Comment
comment on: http://stackoverflow.com/a/22110152
score: 0
type: AnswerComment
has text: Thanks - I made changes. I am getting there. I don't have any errors anymore but the loop stops prematurely.

http://stackoverflow.com/q/22027788
tagged with: maven
tagged with: java
type: Question
answer count: 1
has comment: http://stackoverflow.com/comment/33408454
score: 0
has answer: http://stackoverflow.com/a/22036898
has title: Referencing a pom jar in child projects
has body: I am trying to centralize all dependencies in a pom in order to remove redundancy. However, when I try to put the javaee-web-api dependency in a centralized location it just wont get parsed by my servlet class EventManager.java. My question is: Can you put a dependency with "provided" scope in a parent pom and reference it in the child project? parent-proj com.google.code.gson gson 2.2.4 javax javaee-web-api 6.0 provided child-proj com.study poc1 1.0-SNAPSHOT pom EventManager.java (Located in child project) package com.study.webstore.event.processor; import com.study.webstore.event.AnalyticsModel; import com.study.webstore.util.GenericUtils; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; public class EventManager implements Filter { private static final Logger log = Logger.getLogger(EventManager.class); //some more code
linked to: http://stackoverflow.com/q/3597684
type: UnansweredQuestion

http://stackoverflow.com/a/22301967
score: 0
answers question: http://stackoverflow.com/q/22027000
type: AcceptedAnswer
type: Answer
has body: I was able to resolve this by adding a Filter for the URL pattern I was interested in. More info here.
accepted answer of: http://stackoverflow.com/q/22027000

http://stackoverflow.com/a/22057293
has comment: http://stackoverflow.com/comment/33445881
answers question: http://stackoverflow.com/q/22057252
score: 4
accepted answer of: http://stackoverflow.com/q/22057252
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33445933
has comment: http://stackoverflow.com/comment/33445985
has comment: http://stackoverflow.com/comment/33445903
has body: Here you say, the return value is array of int : public static int[] sumTotal... Just change it to : public static int sumTotal...
type: Answer
upvote count: 4
downvote count: 0

http://stackoverflow.com/comment/33496108
score: 1
has text: Without an error log will be a litlle dificult to help, can you add your logcat?
comment on: http://stackoverflow.com/q/22085350
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/33377604
type: QuestionComment
comment on: http://stackoverflow.com/q/22017760
has text: I'm not entirely sure where my answer fails in comparison to your question.
score: 0
type: Comment

http://stackoverflow.com/comment/33413251
comment on: http://stackoverflow.com/q/22037125
type: Comment
score: 0
has text: @user3355121 no you do not creating new session or you are doing it wrong.
type: QuestionComment

http://stackoverflow.com/comment/33616947
score: 0
comment on: http://stackoverflow.com/q/22152858
type: QuestionComment
type: Comment
has text: Do you have the value as a number (int, long, double, char) or as a String?

http://stackoverflow.com/a/22161621
upvote count: 3
has body: Have you declared your SimpleTest class to be a member of the junitfaq package? If you have, you should be able to run it from the src directory like java junitfaq.SimpleTest but you should get an error like this if you try to run it from within the junitfaq directory: Exception in thread "main" java.lang.NoClassDefFoundError: SimpleTest (wrong name: junitfaq/SimpleTest) Make sure your SimpleTest class starts with package junitfaq; Edit: Here's a working example incorporating the comments below. login@domain:~/temp> mkdir src login@domain:~/temp> cd src login@domain:~/temp/src> mkdir junitfaq login@domain:~/temp/src> nano junitfaq/SimpleTest.java The contents of SimpleTest.java are as follows when I exit nano: package junitfaq; public class SimpleTest { public static void main(String[] args) { System.out.println("Test"); } } login@domain:~/temp/src> javac junitfaq/SimpleTest.java login@domain:~/temp/src> java junitfaq.SimpleTest Test
has comment: http://stackoverflow.com/comment/33701821
has comment: http://stackoverflow.com/comment/33633864
accepted answer of: http://stackoverflow.com/q/22161530
has comment: http://stackoverflow.com/comment/33633569
has comment: http://stackoverflow.com/comment/33649850
has comment: http://stackoverflow.com/comment/33633546
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33634066
downvote count: 0
answers question: http://stackoverflow.com/q/22161530
has comment: http://stackoverflow.com/comment/33685828
has comment: http://stackoverflow.com/comment/33633222
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/33685645

http://stackoverflow.com/comment/33399375
has text: @user2870532: you might have to create and post a [minimal, compilable and runnable example program](http://stackoverflow.com/help/mcve) for us to fully understand your problem.
type: AnswerComment
comment on: http://stackoverflow.com/a/22030879
score: 0
type: Comment

http://stackoverflow.com/q/22141777
favorite count: 0
has answer: http://stackoverflow.com/a/22141832
has body: File file = new File("result.csv"); FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); What happens if we do not close the buffered writer object after the write completion? I mean what if we miss bw.close()?
has title: Java Buffered Writer
score: 2
upvote count: 2
linked to: http://stackoverflow.com/q/1388602
type: Question
type: AnsweredQuestion
tagged with: bufferedwriter
accepted answer: http://stackoverflow.com/a/22141832
tagged with: java
answer count: 1
downvote count: 0

http://stackoverflow.com/comment/33575558
comment on: http://stackoverflow.com/a/22129353
score: 0
type: Comment
has text: Yes, just took it as an example.
type: AnswerComment

http://stackoverflow.com/comment/33632099
type: Comment
type: QuestionComment
has text: Post the code of all those things you have tried.
score: 1
comment on: http://stackoverflow.com/q/22161179

http://stackoverflow.com/comment/33370942
type: Comment
has text: is there a specifi function in java to parse a text and replace the line breaks with or tags? could you please help me with the code
type: AnswerComment
comment on: http://stackoverflow.com/a/22015698
score: 0

http://stackoverflow.com/a/22085780
type: Answer
score: 0
has body: You could just surround it in a try/catch like so from my understanding. void downloadPage() { try { URL url=new URL("http://www.google.com"); do(url); } catch(MalformedException me) { System.out.println("caught this: " + me); } }
has comment: http://stackoverflow.com/comment/33527632
has comment: http://stackoverflow.com/comment/33523515
answers question: http://stackoverflow.com/q/22085734
has comment: http://stackoverflow.com/comment/33523874

http://stackoverflow.com/a/32454219
has body: In ActiveMQ you do not have to create destinations before they can be used. The ActiveMQ broker creates the physical resources associated with a destination on demand, so if you call createQueue() on a JMS session, it will create the queue for you if it does not already exist. See: http://activemq.apache.org/how-do-i-create-new-destinations.html
score: 9
downvote count: 0
upvote count: 9
type: Answer
answers question: http://stackoverflow.com/q/22048537

http://stackoverflow.com/a/22084010
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33493795
has body: You want the parameter to be of type Book: public void addBook(Book newBook) { catalog[(catalog.length + 1)] = newBook; } This will throw an ArrayIndexOutOfBoundsException though, because you're trying to put an element in the array after the last index. You'll need to keep track of how many books have been added and rebuild your array when it gets full. Like this: private int numberOfBooks = 0; public void addBook(Book newBook) { numberOfBooks++; if(numberOfBooks &gt;= catalog.length) { // Rebuild array Book[] copy = new Book[catalog.length * 2] for(int i=0; i&lt;catalog.length; i++){ copy[i] = catalog[i]; } catalog = copy; } catalog[numberOfBooks] = newBook; } Or use a collection like java.util.ArrayList. So instead of having this line: Book[] catalog; You might have ArrayList&lt;Book&gt; catalog = new ArrayList&lt;Book&gt;(); This creates an ArrayList which is a Java implementation of a dynamically sized array. Then your addBook method might look like this: public void addBook(Book newBook) { catalog.add(newBook); } In order to use ArrayList you'll need to include this line at the beginning of the file, after the package mitPractice; line: import java.util.ArrayList;
score: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/22083915
answers question: http://stackoverflow.com/q/22083915
has comment: http://stackoverflow.com/comment/33493723

http://stackoverflow.com/comment/33498033
type: Comment
has text: My friend, please give some times to your code before posting to so one by one (mentioning about last post).... sorry if I am harsh
score: 1
comment on: http://stackoverflow.com/q/22086482
type: QuestionComment

http://stackoverflow.com/comment/33530388
type: AnswerComment
comment on: http://stackoverflow.com/a/22103460
type: Comment
score: 1
has text: There is an implementation (from OpenJDK) that is annotated [here](http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/net/Socket.java).

http://stackoverflow.com/comment/33458239
type: QuestionComment
score: 0
has text: It's not really in the application itself. This method is located in a .java class that only holds common constants, so most of the class just looks like public static final XXX = YYY. In the end that lognames->level map is created. Are you saying there is no possibility to "translate" the LogManager class to slf4j / logback?
comment on: http://stackoverflow.com/q/22064173
type: Comment

http://stackoverflow.com/q/22052185
tagged with: readline
type: AnsweredQuestion
upvote count: 3
score: -4
has answer: http://stackoverflow.com/a/22052217
has body: I have a .txt file: 80,90,100,110,120,130,140,150,160 100,20,22,24,26,28,26,28,29,27 110,30,32,34,36,37,39,37,39,40 120,40,41,42,44,45,46,48,47,49 which represents a table with prices for blinds, the first row is the width of the blind and the first column without 80 is the height. The rest of the numbers are the prices. I already did this using c# but in java I have no idea what to do, in c# my code looks like this and everything is fine. Can somebody show me the same thing in java? theWidth and theHeight are text fields where I have to type the dimensions. string[] lines = File.ReadAllLines(@"tabel.txt"); string[] aux = lines[0].Split(','); for (int i = 0; i &lt; aux.Length-1; i++) { if (aux[i] == theWidth.ToString()) { Console.WriteLine(aux[i]); indiceLatime = i; } } for (int i = 1; i &lt; lines.Length; i++) { aux = lines[i].Split(','); if (aux[0] == theHeight.ToString()) { showPrice.Text = aux[indiceLatime + 1]; } } In java I tried something like this: try { BufferedReader inputStream = new BufferedReader(new FileReader("tabel.txt")); int theWidth = 90; int theHeight = 100; int indiceLatime = 0; String line; try { while ((line = inputStream.readLine()) != null) { String[] aux = line.split(","); for (int i = 0; i &lt; aux.length; i++) { if (aux[i].equals(Integer.toString(theWidth))) { indiceLatime = i; } } for (int i = 1; i &lt; aux.length; i++) { if (aux[0].equals(Integer.toString(theHeight))) { System.out.println("price: " + aux[indiceLatime]); } } } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } So the price is in theHeight's row of theWidth's index which I am trying to get somehow. Is there somebody who can show me how can I get the correct number(price) out from the row?
downvote count: 7
type: Question
tagged with: java
answer count: 2
accepted answer: http://stackoverflow.com/a/22052217
has title: How to get a specific value from a text file
tagged with: bufferedreader
tagged with: readfile
favorite count: 0
possible better answer: http://stackoverflow.com/a/22052284
has answer: http://stackoverflow.com/a/22052284
tagged with: filereader

http://stackoverflow.com/q/22091974
answer count: 0
has body: Since javafx MediaView does not accept rtp streaming (am I wrong?) I'm trying to use LibJitsi. My idea is to capture incoming stream and render it in a SwingNode. The problem is that VideoMediaStream#getVisualComponent() from LibJitsi returns an AWT component and it seems that JavaFX SwingNode does not render AWT components, even if I wrap them in a JComponent.
upvote count: 3
has comment: http://stackoverflow.com/comment/33543351
tagged with: java
tagged with: swing
type: Question
tagged with: awt
tagged with: javafx-8
score: 3
downvote count: 0
favorite count: 0
has title: How to render AWT components in SwingNode
has comment: http://stackoverflow.com/comment/33507470
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33508586

http://stackoverflow.com/comment/33638129
has text: Use ajax to call ur servlet and fill server return content in div. if u want everything in same page (without changing page).
comment on: http://stackoverflow.com/q/22164575
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22121603
has body: There is nothing in the JDBC specification (that I know of) that will allow you to do this. If at all, this is a database-specific functionality. Oracle supports such functionality starting Oracle 11g: http://docs.oracle.com/cd/E18283_01/java.112/e16548/dbchgnf.htm
score: 0
answers question: http://stackoverflow.com/q/22121454
type: Answer

http://stackoverflow.com/comment/33390971
has text: If you mean, that there is a second element in the set, so that vmv.toString() leads to the output "[a, a]"... this isn't the case. With your code there is only one "a" in the set after adding it twice.
score: 0
comment on: http://stackoverflow.com/q/22026352
type: QuestionComment
type: Comment

http://stackoverflow.com/q/22132804
downvote count: 1
has comment: http://stackoverflow.com/comment/33582194
type: Question
has answer: http://stackoverflow.com/a/34618700
has comment: http://stackoverflow.com/comment/33582224
has title: Understanding Java reflection drawbacks
linked to: http://stackoverflow.com/q/14639753
has comment: http://stackoverflow.com/comment/33582406
answer count: 3
score: 1
favorite count: 0
upvote count: 2
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33582490
has answer: http://stackoverflow.com/a/22132919
has answer: http://stackoverflow.com/a/55487733
tagged with: reflection
linked to: http://stackoverflow.com/q/3002904
tagged with: java
has comment: http://stackoverflow.com/comment/33582344
has body: I am trying to understand the drawbacks as mentioned in Java docs Security Restrictions Reflection requires a runtime permission which may not be present when running under a security manager. What are the runtime permissions that reflection needs? What is security manager in this context? Is this drawback specific to Applets only? Exposure of Internals Since reflection allows code to perform operations that would be illegal in non-reflective code, such as accessing private fields and methods, the use of reflection can result in unexpected side-effects, which may render code dysfunctional and may destroy portability. Reflective code breaks abstractions and therefore may change behavior with upgrades of the platform. How reflection can break abstraction? and how does it affect with upgrades of the platform. Please help me in clarifying these. Thanks a lot.

http://stackoverflow.com/comment/33373493
type: Comment
comment on: http://stackoverflow.com/a/22017105
score: 0
type: AnswerComment
has text: what i want to do is to display an error message to the user depending of the exception thrown

http://stackoverflow.com/comment/33415956
has text: de.baimos.blueid.lockserver api TRUNK-SNAPSHOT ${project.basedir}/lib/lockserver-sdk.jar system
type: Comment
comment on: http://stackoverflow.com/a/22038567
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33610151
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22144781
type: Comment
has text: After some additional searching for similar problems: I can report that I have tried the following as well: 1.Removed all layout and panels - this had no effect. I also downgraded the primefaces library to version 3.5 (I am using 4.0) - this had the effect that the displaySelectedSingle() function was not even called !

http://stackoverflow.com/comment/51527064
type: Comment
comment on: http://stackoverflow.com/a/24051823
score: 2
type: AnswerComment
has text: For `/data/data/com.android.providers.settings/databases/settings.db` it is said that it's best to use `adb shell settings put secure lockscreen.disabled 1` to modify the database. Is there a similar utility to modify `locksettings.db` instead of direct sqlite call?

http://stackoverflow.com/a/22125425
score: 2
type: AcceptedAnswer
downvote count: 0
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/33568984
answers question: http://stackoverflow.com/q/22124538
accepted answer of: http://stackoverflow.com/q/22124538
has body: the constructor of MrRunnable should get a reference to the queue

http://stackoverflow.com/comment/124797388
type: Comment
has text: I know the post was 7 years ago, but how i did this was have a static bool (reInit), and during the transform() method, if that bool is false, i use reflection with the LaunchClassLoader to re-organise them, making my transformer the last. And if it's true, i just continue dumping bytecode to a file. Here's the pastbin if you wanna check it out: https://pastebin.com/Rn5xqyfp
comment on: http://stackoverflow.com/a/22086124
type: AnswerComment
score: 0

http://stackoverflow.com/a/22037083
upvote count: 6
answers question: http://stackoverflow.com/q/22036885
has comment: http://stackoverflow.com/comment/33409248
downvote count: 0
has comment: http://stackoverflow.com/comment/33409343
type: Answer
has comment: http://stackoverflow.com/comment/33409251
has body: Decimal numbers can't be represented exactly in double. So 2.655 ends up being this: 2.65499999999999980460074766597 whereas 1.655 ends up being this: 1.655000000000000026645352591
score: 6

http://stackoverflow.com/q/22012661
type: Question
upvote count: 2
has comment: http://stackoverflow.com/comment/33365414
has answer: http://stackoverflow.com/a/22013245
possible better answer: http://stackoverflow.com/a/22012745
favorite count: 0
has answer: http://stackoverflow.com/a/22013239
answer count: 5
has comment: http://stackoverflow.com/comment/33365426
tagged with: android
has answer: http://stackoverflow.com/a/22013094
has comment: http://stackoverflow.com/comment/33365486
has comment: http://stackoverflow.com/comment/33365518
has comment: http://stackoverflow.com/comment/33365483
has answer: http://stackoverflow.com/a/22012834
accepted answer: http://stackoverflow.com/a/22012834
downvote count: 0
has title: Android external Jar
score: 2
type: AnsweredQuestion
tagged with: java
tagged with: noclassdeffounderror
has answer: http://stackoverflow.com/a/22012745
has body: I have some api with java and I need it in my android app. When I am using it with including all packages and classes it works fine. Now I create JAR file from my java project using export. Now when I add the jar to my android app as a external jar my all errors are disappeared but when I run my app I got an error java.lang.NoClassDefFoundError. I have seen that kind of errors early in my apps and it was the problem of Jar. How can I generate JAR file to avoid this situation?

http://stackoverflow.com/q/22026524
has answer: http://stackoverflow.com/a/22027168
accepted answer: http://stackoverflow.com/a/22027168
type: Question
score: -1
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33391707
has title: deleteRow from database android
answer count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/33391180
favorite count: 0
has body: hi I want to delete a row from the listview from an another activity. I tried a lot but didn't succeed. here is my code. I want to delete item from the listview through case.id.id_favorite2 case R.id.id_favorit: // Add it to the DB and re-draw the ListView myDb.insertRow("Atherosclerosis", 0, ""); Toast.makeText(getApplicationContext(), "Item Added to favorite list!", Toast.LENGTH_SHORT).show(); case R.id.id_favorit2: myDb.deleteRow(??); Toast.makeText(getApplicationContext(), "Item deleted from favorite list!", Toast.LENGTH_SHORT).show(); here is my DBAdapter. database code for delete. public class DBAdapter { ///////////////////////////////////////////////////////////////////// // Constants &amp; Data ///////////////////////////////////////////////////////////////////// // For logging: private static final String TAG = "DBAdapter"; // DB Fields public static final String KEY_ROWID = "_id"; public static final int COL_ROWID = 0; /* * CHANGE 1: */ // TODO: Setup your fields here: public static final String KEY_NAME = "name"; public static final String KEY_STUDENTNUM = "studentnum"; public static final String KEY_FAVCOLOUR = "favcolour"; // TODO: Setup your field numbers here (0 = KEY_ROWID, 1=...) public static final int COL_NAME = 1; public static final int COL_STUDENTNUM = 2; public static final int COL_FAVCOLOUR = 3; public static final String[] ALL_KEYS = new String[] {KEY_ROWID, KEY_NAME, KEY_STUDENTNUM, KEY_FAVCOLOUR}; // DB info: it's name, and the table we are using (just one). public static final String DATABASE_NAME = "MyDb"; public static final String DATABASE_TABLE = "mainTable"; // Track DB version if a new version of your app changes the format. public static final int DATABASE_VERSION = 2; private static final String DATABASE_CREATE_SQL = "create table " + DATABASE_TABLE + " (" + KEY_ROWID + " integer primary key autoincrement, " /* * CHANGE 2: */ // TODO: Place your fields here! // + KEY_{...} + " {type} not null" // - Key is the column name you crea…
tagged with: android
type: AnsweredQuestion
upvote count: 0
has comment: http://stackoverflow.com/comment/33391502
tagged with: java

http://stackoverflow.com/q/22051438
has answer: http://stackoverflow.com/a/22051716
favorite count: 0
has comment: http://stackoverflow.com/comment/33435594
has comment: http://stackoverflow.com/comment/33435488
has comment: http://stackoverflow.com/comment/33435826
upvote count: 6
tagged with: synchronization
has comment: http://stackoverflow.com/comment/33435708
has title: Synchronization of methods, objects, class in Java
tagged with: multithreading
tagged with: thread-synchronization
accepted answer: http://stackoverflow.com/a/22051716
score: 6
has comment: http://stackoverflow.com/comment/33435629
has comment: http://stackoverflow.com/comment/33435962
linked to: http://stackoverflow.com/q/3047564
has comment: http://stackoverflow.com/comment/33435873
type: Question
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/14447095
tagged with: java
has comment: http://stackoverflow.com/comment/33436033
has body: I need some clarification with regards to use of synchronization in multi-threaded environment. I have a small example Class below. but I am actually finding it hard to make a test case of how the following will work; The reason I want test case is to the understand how synchronization handles these different scenarios If a thread calls SharedResource.staticMethod, it will acquire the lock for the class. does it mean an instance of SharedResource, say x, will have to wait till it gets lock to exectute x.staticMethod. Will synchronization of this in a block, acquires the lock for that section of the code or for entire object. i.e can another thread call the same method on same object; but execute the remainder of the code that is not part of synchronization block If the above point is true, having a dummy object to lock on does not provide any additional benefit. Correct? So there are different levels of synchronziations. Class level, Object level, method level and block level. so that would mean locks for these individual levels should exist? If I acquired a lock on the Object, another Thread cannot call any methods on the same object, but if I acquired a lock on the method, another thread can acquire lock on a different method. Is this correct? Some tips on on how to create two threads that act on same object and same method will be helpful (I understand I need to extend Thread class or implement Runnable interface). But not sure how to make a two threads call the same method on same object. class SharedResource { public Integer x =0; public static Integer y=0; Object dummy = new Object(); public Integer z=0; public synchronized static void staticMethod(){ System.out.println("static Method is called"); y++; } public synchronized void incrementX(){ System.out.println("instance method; incrementX"); x++; } public void incrementXBlock(){ synchronized(this){ x++; } System.out.println("instance method; incrementXBlock"); } public void incrementZ(){ synchronized (dummy) …
has comment: http://stackoverflow.com/comment/33435742
answer count: 1
has comment: http://stackoverflow.com/comment/33436020
downvote count: 0

http://stackoverflow.com/a/22061879
has comment: http://stackoverflow.com/comment/84435877
has comment: http://stackoverflow.com/comment/61626951
has comment: http://stackoverflow.com/comment/68308614
has body: This will match yyyy-mm-dd and also yyyy-m-d: ^\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])$ If you're looking for an exact match for yyyy-mm-dd then try this ^\d{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])$ or use this one if you need to find a date inside a string like The date is 2017-11-30 \d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])* https://regex101.com/r/acvpss/1
has comment: http://stackoverflow.com/comment/94143617
downvote count: 0
has comment: http://stackoverflow.com/comment/105513327
has comment: http://stackoverflow.com/comment/63310070
answers question: http://stackoverflow.com/q/22061723
score: 221
type: Answer
has comment: http://stackoverflow.com/comment/123969626
has comment: http://stackoverflow.com/comment/84435963
has comment: http://stackoverflow.com/comment/62788412
has comment: http://stackoverflow.com/comment/61845995
upvote count: 221
has comment: http://stackoverflow.com/comment/90206647
has comment: http://stackoverflow.com/comment/136522379
has comment: http://stackoverflow.com/comment/79999157

http://stackoverflow.com/comment/33544950
type: Comment
has text: What architecture is your current machine? And did you export your new `LD_LIBRARY_PATH` before you run `java`?
score: 0
comment on: http://stackoverflow.com/q/22112371
type: QuestionComment

http://stackoverflow.com/a/22106459
answers question: http://stackoverflow.com/q/22106171
type: Answer
upvote count: 1
score: 1
has body: As you have written "Manager will be responsible for creating and storing Dog objects in an array", so you need to create better list of Dog objects (so you can add and remove Dogs), add CRUD methods for this list. If you'll need an array from the list you can easily convert it later. So put something like this public class Manager { private List&lt;Dog&gt; = new ArrayList&lt;&gt;(); ... CRUD operations here } Then you need to add UI controls to actually input information about dogs, and display a table of dogs. So it will be panes, text inputs, buttons, etc.
downvote count: 0

http://stackoverflow.com/comment/33599298
type: QuestionComment
has text: plz check the above links in the question. It not allowing me to post code so uploaded my screen shots.
comment on: http://stackoverflow.com/q/22142952
score: 0
type: Comment

http://stackoverflow.com/a/22129615
answers question: http://stackoverflow.com/q/22129536
score: 1
upvote count: 1
has body: List&lt;String&gt; list = new ArrayList&lt;&gt;(); is equivalent to List&lt;String&gt; list = new ArrayList&lt;String&gt;(); Operator &lt;&gt; is called diamond and was introduced in JDK7 The first statement in your question is invalid.
downvote count: 0
has comment: http://stackoverflow.com/comment/33576011
type: Answer

http://stackoverflow.com/q/22027676
has comment: http://stackoverflow.com/comment/33393594
tagged with: android-volley
tagged with: android
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/22027796
accepted answer: http://stackoverflow.com/a/22027796
linked to: http://stackoverflow.com/q/12850143
has title: show indeterminate progress indicator
type: AnsweredQuestion
score: 2
has body: I am trying to show a progress indicator when doing network requests with volley. I am getting the error "Only the original thread that create a view hierarchy can touch its views". I cannot figure out how to get my hideProgressDialog() onto the same thread as showProgressDialog(). Here's my code... showProgressDialog("Logging you in"); String url = ApplicationController.getInstance().getBaseURL() + "Customer/LoginCustomer"; JsonRequest&lt;String&gt; jr = new JsonRequest&lt;String&gt;(Method.POST, url, jo.toString(), this.createSuccessListener(), this.createErrorListener()) { @Override protected Response&lt;String&gt; parseNetworkResponse(NetworkResponse nr) { hideProgressDialog(); try { String str = new String(nr.data, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; } }; ApplicationController.getInstance().addToRequestQueue(jr); } /** Create Volley Listeners **/ private Response.ErrorListener createErrorListener() { return new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { hideProgressDialog(); } }; } private Response.Listener&lt;String&gt; createSuccessListener() { return new Response.Listener&lt;String&gt;() { @Override public void onResponse(String response) { hideProgressDialog();} }; } Solution Thanks to tautvydas. I ended up putting these methods in my base class. protected void showProgressDialog(String message) { if(mHandler == null){ mHandler = new Handler(); } if (mDialog == null || !mDialog.isShowing()) { mDialog = new ProgressDialog(getActivity()); mDialog.setMessage(message); mDialog.setCancelable(false); mDialog.setIndeterminate(true); mDialog.show(); } } protected void hideProgressDialog() { if (mDialog != null) { mHandler.post(new Runnable() { @Override // this will run on the main thread. public void run() { mDialog.hide(); } }); } }
downvote count: 0
tagged with: java
type: Question
upvote count: 2
tagged with: network-programming

http://stackoverflow.com/comment/33519314
score: 2
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22098667
has text: Probably [Two's complement](http://en.wikipedia.org/wiki/Two%27s_complement) whereas the first bit is the sign bit.

http://stackoverflow.com/q/22158121
favorite count: 0
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/22158247
tagged with: java
has body: I want to calculate the beat per minute in a Audio File in android , I have just a small clue , There is a Visualizer Library which creates a DIGITAL BAR effect with the Audio files wave , I can check for the beat with this , Is this the correct solution or is there any proper way to do this ? I want to categorize Audio files in a proper way. According to the Beat/minute in a File. Any help would be greatfull
downvote count: 4
has title: Calculating the Beat/Minute in a Audio File in Android
upvote count: 0
type: UnansweredQuestion
score: -4
has answer: http://stackoverflow.com/a/22161290
tagged with: android

http://stackoverflow.com/comment/33568974
score: 1
comment on: http://stackoverflow.com/q/22125709
type: Comment
type: QuestionComment
has text: debug and figure out? If you call a method with a non empty list as argument, the method gets a non empty list..

http://stackoverflow.com/comment/33361303
comment on: http://stackoverflow.com/a/22009374
has text: Well, for starters you're absolutely right about the relationship with VideoGameDatabaseRecord and VideoGame - there should only be one VideoGame per record, that's a foolish mistake on my part. As for the free tools I tried ArgoUML and the NetBeans UML plugin but found both to be quite clunky.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33417761
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22041706
has text: Ok, then he will probably follow one of the other 2 solution, with formatter or bigdecimal
type: AnswerComment

http://stackoverflow.com/a/22089444
has body: You have to take a look at the underlying ObservableList. The code that works for me was: tableView.getItems().get(tableView.getSelectionModel().getSelectedIndex()) In my test that returns a Person object (POJO i wrote) which has to contain a get() method.
score: 3
has comment: http://stackoverflow.com/comment/33508213
has comment: http://stackoverflow.com/comment/33516165
has comment: http://stackoverflow.com/comment/33505987
has comment: http://stackoverflow.com/comment/33507371
has comment: http://stackoverflow.com/comment/33513770
upvote count: 3
has comment: http://stackoverflow.com/comment/33510663
has comment: http://stackoverflow.com/comment/33511043
has comment: http://stackoverflow.com/comment/33504484
has comment: http://stackoverflow.com/comment/33508324
has comment: http://stackoverflow.com/comment/33512742
has comment: http://stackoverflow.com/comment/33505070
has comment: http://stackoverflow.com/comment/33504774
type: Answer
answers question: http://stackoverflow.com/q/22088217
has comment: http://stackoverflow.com/comment/33506564
has comment: http://stackoverflow.com/comment/33512322
downvote count: 0
has comment: http://stackoverflow.com/comment/33504902
has comment: http://stackoverflow.com/comment/33513610

http://stackoverflow.com/a/22013561
has body: If you want to load some resource not using absolute/relate path of your file system, you should use the classloader. Your resource (for example icon.ico) can be packaged in foo.jar but some other icon with the same name can be also in bar.jar. The getClass().getResource() statement helps to specify where the classloader will look for.
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/22012998
downvote count: 0
type: Answer

http://stackoverflow.com/comment/33602360
has text: It is ALWAYS decided at compilation time. Generics is only compile time.
comment on: http://stackoverflow.com/a/22096355
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33638568
type: QuestionComment
comment on: http://stackoverflow.com/q/22145517
has text: my content-type is application/json
score: 0
type: Comment

http://stackoverflow.com/a/22016872
has comment: http://stackoverflow.com/comment/33500949
has comment: http://stackoverflow.com/comment/33501182
has body: First step for this app should be to get angle to which point mobile(camera) is inclined. If it is possible to get inclined angle a, then as per your given link by formula of tangent you will get distance of the object from the camera , here you have to consider cameras height(h).Once you get height then again incline your mobile to the top of the object,and calculate height. In short most important step is to get angle of inclination of the mobile to the object, after that all remaining part is trigonometric calculations. After all it will give approximate results not accurate. If you are able to calculate angle to which mobile is inclined Step First: calculate distance 1) Incline your mobile to the bottom of the object it will give you angle A(as shown in diagram) 2) consider height h at what you have held your mobile (consider standard as 5ft ) or You may use SONAR system to get height where you have held the phone or this may help you 3) Now by formula of tangent you will get distance d as shown in figure Step 2: Calculate height 1) Incline your mobile to the top of the object and get angle B as shown in figure. 2) As you have calculated d in previous step, put the angle b and d in tangent formula you will get h1 3) Add h and h1, you will get height of the object
answers question: http://stackoverflow.com/q/22016101
upvote count: 1
has comment: http://stackoverflow.com/comment/33501500
type: Answer
has comment: http://stackoverflow.com/comment/33379110
downvote count: 0
has comment: http://stackoverflow.com/comment/33457447
has comment: http://stackoverflow.com/comment/33459640
has comment: http://stackoverflow.com/comment/33501340
score: 1
has comment: http://stackoverflow.com/comment/33501131
has comment: http://stackoverflow.com/comment/33501042
has comment: http://stackoverflow.com/comment/33542353
has comment: http://stackoverflow.com/comment/33401905

message-queue
tags question: http://stackoverflow.com/q/22143742
type: Tag
tags question: http://stackoverflow.com/q/22117709
tag name: message-queue

http://stackoverflow.com/q/22142830
has title: XML/HTML builder class using SAX and W3C Java libraries can't handle HTML input
tagged with: java
type: Question
score: 0
tagged with: saxparser
has body: All, I am developing a Java Web service that fetches archived data from an external DB. The requirement is that as well as returning the results as an XML message the client can also request to have the results presented on a HTML page. This diagram describes the high level design: I have realised though while doing my implementation that XML and HTML are not exactly the same e.g.: HTML parsing can tolerate specific elements not being closed. This causes my current class implementation to throw up these errors (caused by the HTML input) Error Messages [03/Mar/2014:09:12:05] warning (19052): CORE3283: stderr: [Fatal Error] web.html:1:3: The markup in the document preceding the root element must be well-formed. [03/Mar/2014:09:12:05] warning (19052): CORE3283: stderr: org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed. My Code import org.w3c.dom.*; import javax.xml.parsers.*; import org.w3c.dom.Element; import org.xml.sax.SAXException; public class OutputBuilder { private DocumentBuilderFactory docBF; private DocumentBuilder docBuilder; private Document doc; private static float UUID; private String docType; public OutputBuilder(String template, String output) throws ParserConfigurationException, SAXException, IOException { docBF = DocumentBuilderFactory.newInstance(); docBuilder = docBF.newDocumentBuilder(); //set the base document to the specified template file doc = docBuilder.parse(new File(template)); // docType = output; } /* * Build the final document by adding values passed in from query results */ public void fillTemplate(ResultSet qR) throws SQLException { if(docType.equals("html")) { //find the designated point of data insertion to the html document Element appendPoint = doc.getElementById("archive_table"); //get meta data column names for table header row ResultSetMetaData rsmd = qR.getMetaData(); //generate this first row which is the header Element headerRow = doc.createElement("tr"); //create a colum…
has answer: http://stackoverflow.com/a/22142995
answer count: 1
tagged with: http://stackoverflow.com/tag/html
tagged with: http://stackoverflow.com/tag/xml
accepted answer: http://stackoverflow.com/a/22142995
type: AnsweredQuestion

http://stackoverflow.com/comment/33461994
has text: Are there any more selective way to list primary keys of a specific schema/table? `for (Schema sch : create.meta().getSchemas()) { if ("chembl_17".equals(sch.getName())) { Table<?> tab = sch.getTable("protein_classification"); if (tab != null) { UniqueKey<?> key = tab.getPrimaryKey(); for (TableField<?, ?> f : key.getFields()) { System.out.printf("%s: %s%n", f.getName(), f.getDataType().getTypeName()); } } else { // no PK defined } } }` Sorry for the formating...
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22037070

http://stackoverflow.com/q/22112064
has answer: http://stackoverflow.com/a/22112155
tagged with: java
type: Question
tagged with: jsoup
answer count: 1
downvote count: 0
has title: How to get part of an Element in Android using Jsoup
accepted answer: http://stackoverflow.com/a/22112155
favorite count: 0
tagged with: android
tagged with: http://stackoverflow.com/tag/html
score: 1
upvote count: 1
has body: I'm trying to find a way to get the last part of a Element and set it to a textView Here is my code for getting the element and setting it to a textView. Element burnabyStatus = doc.getElementsByClass("main-campus-status").first(); String b_status = burnabyStatus.text(); TextView tv_b_status = (TextView) findViewById(R.id.b_status); tv_b_status.setTypeface(tf, Typeface.BOLD); tv_b_status.setText(b_status); As of now burnabyStatus.text() is equal to "Burnaby Campus Open" but I want my textView to just show "Open" or "Closed" for when it changes on the website. Here is the website from where I am getting the information from here
type: AnsweredQuestion

http://stackoverflow.com/comment/33542481
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22087460
has text: @user1613403 sure there is, see [this example of weblogic configuration](http://docs.oracle.com/cd/E13222_01/wls/docs81/ConsoleHelp/domain_jmsqueue_config_thresholds.html) and [this for OpenMQ](http://www.coderanch.com/t/471077/java/Maximum-number-messages-Queue-OpenMQ). also, for all implementations, you can check the amount of messages in the queue at any given time and act accordingly
type: AnswerComment

http://stackoverflow.com/comment/63844871
type: Comment
has text: That may have fixed it for you, but I think this really came about because you were trying to persist a list rather than its individual entities.
type: AnswerComment
comment on: http://stackoverflow.com/a/22035121
score: 0

http://stackoverflow.com/q/22062655
has answer: http://stackoverflow.com/a/22062732
score: 0
answer count: 3
has body: So I have a ListAdapter which has various options and what I want is that when a user clicks on the ListAdapter an activity starts which has an EditText and the EditText should be automatically filled with option which was, clicked on for the ListAdapter. Currently I have Main.java: public class Main extends ListActivity{ String options[] = {"option1","option2"}; protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter&lt;String&gt; (Main.this,android.R.layout.simple_list_item_1,options); } protected void onListItemClick(ListView l,View v, int position, long id){ super.onListItemClick(l,v,position,id); try{ Class theClass = Class.forname("com.example.SecondActivity"); Intent oI = new Intent(Main.this,theClass); startActivity(oI); }catch(ClassNotFoundException e){e.printStackTrace();} } SecondActivity.java (This contains the activity with the edit text): public class SecondActivity extends Activity{ protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContextView(R.layout.secondactivity) EditText edt = (EditText) findViewById(R.id.edt1); } What all extra do I need to do so that this works. All the help is deeply appreciated.
has answer: http://stackoverflow.com/a/22080556
tagged with: listadapter
type: UnansweredQuestion
tagged with: android
tagged with: android-edittext
has answer: http://stackoverflow.com/a/22062757
tagged with: java
type: Question
has title: Android - Export Option on ListAdapter to another Activity which has EditText
linked to: http://stackoverflow.com/q/5265913

m2e
type: Tag
tag name: m2e
tags question: http://stackoverflow.com/q/22106164
tags question: http://stackoverflow.com/q/22024489

http://stackoverflow.com/comment/33431155
score: 0
has text: This is not how you post a question. Re- post it correctly with a little bit more "CODE"
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22049108

http://stackoverflow.com/a/23157844
upvote count: 8
type: Answer
score: 8
downvote count: 0
has comment: http://stackoverflow.com/comment/35976793
answers question: http://stackoverflow.com/q/22066481
has body: instead of using MyRequestObservable.retry I use a wrapper function retryObservable(MyRequestObservable, retrycount, seconds) which return a new Observable that handle the indirection for the delay so I can do retryObservable(restApi.getObservableStuff(), 3, 30) .subscribe(new Action1&lt;BonusIndividualList&gt;(){ @Override public void call(BonusIndividualList arg0) { //success! } }, new Action1&lt;Throwable&gt;(){ @Override public void call(Throwable arg0) { // failed after the 3 retries ! }}); // wrapper code private static &lt;T&gt; Observable&lt;T&gt; retryObservable( final Observable&lt;T&gt; requestObservable, final int nbRetry, final long seconds) { return Observable.create(new Observable.OnSubscribe&lt;T&gt;() { @Override public void call(final Subscriber&lt;? super T&gt; subscriber) { requestObservable.subscribe(new Action1&lt;T&gt;() { @Override public void call(T arg0) { subscriber.onNext(arg0); subscriber.onCompleted(); } }, new Action1&lt;Throwable&gt;() { @Override public void call(Throwable error) { if (nbRetry &gt; 0) { Observable.just(requestObservable) .delay(seconds, TimeUnit.SECONDS) .observeOn(mainThread()) .subscribe(new Action1&lt;Observable&lt;T&gt;&gt;(){ @Override public void call(Observable&lt;T&gt; observable){ retryObservable(observable, nbRetry - 1, seconds) .subscribe(subscriber); } }); } else { // still fail after retries subscriber.onError(error); } } }); } }); }

http://stackoverflow.com/comment/33592946
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22139305
has text: add permission after `<application>` tag close and try
score: 0

http://stackoverflow.com/q/22022000
tagged with: java
has body: I'm facing problem with post http link for web-service so i have used to encode pic to 64 byte coding to send it to web-service the problem in img parameter but there is no spaces can any one help me to reslove this problem? java.lang.IllegalArgumentException: Illegal character in query at index 204: http://ictfox.com/Hafil_Updates/SchoolLocation_Insert.aspx?schoolId=212&amp;Location_Longitude=0&amp;Location_Latitude=0&amp;Location_Image=/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB this is my class code : File file = new File(picturePath); // Get image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(file), null, o); // The new size we want to scale to final int MIN_SIZE = 70; // Find the correct scale value. int scale = 1; while (((o.outWidth / scale) &gt;&gt; 1) &gt;= MIN_SIZE &amp;&amp; ((o.outHeight / scale) &gt;&gt; 1) &gt;= MIN_SIZE) { scale &lt;&lt;= 1; } BitmapFactory.Options opts2 = new BitmapFactory.Options(); opts2.inSampleSize = scale; try { // Bitmap bm = BitmapFactory.decodeFile(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); BitmapFactory.decodeStream(new FileInputStream(file), null, opts2).compress(Bitmap.CompressFormat.JPEG, 100, baos); // bm // is // the // bitmap // object BitmapFactory.decodeStream(new FileInputStream(file), null, opts2).recycle(); byte[] b = baos.toByteArray(); imageString = Base64.encodeToString(b, Base64.DEFAULT); Log.d("Http Response:",imageString); } catch (Exception e) { e.printStackTrace(); Log.d("Http Response:", e.toString()); } } catch (FileNotFoundException e) { Log.d("Http Response:", e.toString()); } String date2 = new SimpleDateFormat("yyyy-MM-ddhh:mm:ss",Locale.getDefault()).format(new Date()); HttpClient httpClient = new DefaultHttpClient(); httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY); // Creating HTTP Post HttpPost httpPost = ne…
upvote count: 1
tagged with: http
type: Question
answer count: 2
has title: Illegal character in query for post http
downvote count: 0
has answer: http://stackoverflow.com/a/22022263
favorite count: 0
has answer: http://stackoverflow.com/a/22022245
has comment: http://stackoverflow.com/comment/33382665
type: UnansweredQuestion
tagged with: android
tagged with: web-services
score: 1

http://stackoverflow.com/tag/c
tags question: http://stackoverflow.com/q/22133900
tags question: http://stackoverflow.com/q/22030908
tags question: http://stackoverflow.com/q/22107359
tag name: c
type: Tag
tags question: http://stackoverflow.com/q/22046461
tags question: http://stackoverflow.com/q/22007644
tags question: http://stackoverflow.com/q/22068928
tags question: http://stackoverflow.com/q/22048950
tags question: http://stackoverflow.com/q/22142475
tags question: http://stackoverflow.com/q/22161146
tags question: http://stackoverflow.com/q/22054617
tags question: http://stackoverflow.com/q/22114834
tags question: http://stackoverflow.com/q/22110095

http://stackoverflow.com/comment/33627133
type: AnswerComment
type: Comment
has text: The equations are parsed by the software first & then converted to expressions/compiled so no security in this case. But it's potential with this approach sure.
comment on: http://stackoverflow.com/a/22157662
score: 0

pca
tag name: pca
tags question: http://stackoverflow.com/q/22089039
type: Tag

performance
tags question: http://stackoverflow.com/q/22145933
tags question: http://stackoverflow.com/q/22168275
tags question: http://stackoverflow.com/q/22015807
tags question: http://stackoverflow.com/q/22160778
tags question: http://stackoverflow.com/q/22032281
tags question: http://stackoverflow.com/q/22007197
tags question: http://stackoverflow.com/q/22087849
tags question: http://stackoverflow.com/q/22031466
tags question: http://stackoverflow.com/q/22014605
tags question: http://stackoverflow.com/q/22056287
tags question: http://stackoverflow.com/q/22055452
tags question: http://stackoverflow.com/q/22027763
tags question: http://stackoverflow.com/q/22087566
tags question: http://stackoverflow.com/q/22020652
tags question: http://stackoverflow.com/q/22032483
tags question: http://stackoverflow.com/q/22161720
tags question: http://stackoverflow.com/q/22095205
tags question: http://stackoverflow.com/q/22016026
tags question: http://stackoverflow.com/q/22110151
tags question: http://stackoverflow.com/q/22058594
tags question: http://stackoverflow.com/q/22081604
tags question: http://stackoverflow.com/q/22122446
tags question: http://stackoverflow.com/q/22146764
tags question: http://stackoverflow.com/q/22060955
tags question: http://stackoverflow.com/q/22160451
tags question: http://stackoverflow.com/q/22013601
tags question: http://stackoverflow.com/q/22010604
tags question: http://stackoverflow.com/q/22098904
tags question: http://stackoverflow.com/q/22058760
tags question: http://stackoverflow.com/q/22077187
tags question: http://stackoverflow.com/q/22005940
tags question: http://stackoverflow.com/q/22095484
tags question: http://stackoverflow.com/q/22165264
tags question: http://stackoverflow.com/q/22073949
tag name: performance
tags question: http://stackoverflow.com/q/22090056
tags question: http://stackoverflow.com/q/22087212
tags question: http://stackoverflow.com/q/22119557
type: Tag
tags question: http://stackoverflow.com/q/22096861
tags question: http://stackoverflow.com/q/22092294
tags question: http://stackoverflow.com/q/22123810
tags question: http://stackoverflow.com/q/22061461

http://stackoverflow.com/a/22038123
type: AcceptedAnswer
downvote count: 0
has body: If the port has a value and is not null then try: int portInt = Integer.valueOf(port.trim());
type: Answer
answers question: http://stackoverflow.com/q/22037736
accepted answer of: http://stackoverflow.com/q/22037736
upvote count: 1
score: 1

http://stackoverflow.com/q/22090510
type: Question
has comment: http://stackoverflow.com/comment/33522922
upvote count: 1
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/35559434
has comment: http://stackoverflow.com/comment/35550244
tagged with: xsd
has title: errors in classes generated by JAXB from XSD
has answer: http://stackoverflow.com/a/40464783
has comment: http://stackoverflow.com/comment/35590964
downvote count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/35549159
has body: I use JAXB in eclipse Luna to generate Java classes from a third party XSD file. This file often defines a simple type which is just a primitive type. For instance: &lt;xsd:simpleType name="ChannelIdType"&gt; &lt;xsd:restriction base="xsd:unsignedInt" /&gt; &lt;/xsd:simpleType&gt; The simple type is then used for elements of a complex type, for instance: &lt;xsd:complexType name="DataRequestEntryType"&gt; &lt;xsd:sequence&gt; &lt;xsd:element name="ChannelId" type="ChannelIdType" /&gt; &lt;xsd:element name="IsChannelOpen" type="xsd:boolean" /&gt; ... &lt;/xsd:sequence&gt; &lt;/xsd:complexType&gt; JAXB generates a Java class for the complex type that seems perfectly correct: public class DataChannelEntryType { @XmlElement(name = "ChannelId") &lt;-- ERROR here, see below protected long channelId; @XmlElement(name = "IsChannelOpen") protected boolean isChannelOpen; ... } But, it also generates the following JAXB ERROR for the line @XmlElement(name = "ChannelId") The expected XML type associated with 'long' is not valid for XML element 'ChannelId'. Does anybody know what that error message means? I cannot change the XSD file, but what should one do to remove the error (short of removing the simple class, which anyway seems quite legal)? Or at least suppress the generation of the error? Any help will be greatly appreciated!
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33506039
has comment: http://stackoverflow.com/comment/35557861
tagged with: jaxb
tagged with: eclipse
has comment: http://stackoverflow.com/comment/35549257

http://stackoverflow.com/q/22126774
answer count: 1
downvote count: 0
has body: I've got following problem. I have to write small application that connects to pacs and gets images. I decided to use dcm4che toolkit. I've written following code: public class Dcm4 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here DcmQR dcmqr = new MyDcmQR("server"); dcmqr.setCalledAET("server", true); dcmqr.setRemoteHost("213.165.94.158"); dcmqr.setRemotePort(104); dcmqr.getKeys(); dcmqr.setDateTimeMatching(true); dcmqr.setCFind(true); dcmqr.setCGet(true); dcmqr.setQueryLevel(MyDcmQR.QueryRetrieveLevel.IMAGE); dcmqr.addMatchingKey(Tag.toTagPath("PatientID"),"2011"); dcmqr.addMatchingKey(Tag.toTagPath("StudyInstanceUID"),"1.2.276.0.7230010.3.1.2.669896852.2528.1325171276.917"); dcmqr.addMatchingKey(Tag.toTagPath("SeriesInstanceUID"),"1.2.276.0.7230010.3.1.3.669896852.2528.1325171276.916"); dcmqr.configureTransferCapability(true); List&lt;DicomObject&gt; result=null; byte[] imgTab=null; BufferedImage bImage=null; try { dcmqr.start(); System.out.println("started"); dcmqr.open(); System.out.println("opened"); result = dcmqr.query(); System.out.println("queried"); dcmqr.get(result); System.out.println("List Size = " + result.size()); for(DicomObject dco:result){ System.out.println(dco); dcmTools.toByteArray(dco); System.out.println("end parsing"); } } catch (Exception e) { System.out.println("error "+e); } try{ dcmqr.stop(); dcmqr.close(); }catch (Exception e) { } System.out.println("done"); } } Everything seems to be fine until I call dcmTools.toByteArray(dco). Output till calliing toByteArray() looks like this: List Size = 1 (0008,0052) CS #6 [IMAGE] Query/Retrieve Level (0008,0054) AE #6 [server] Retrieve AE Title (0020,000E) UI #54 [1.2.276.0.7230010.3.1.3.669896852.2528.1325171276.916] Series Instance UID Source of ToByteArray: public static byte[] toByteArray(DicomObject obj) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); BufferedOutputStream bos = new Buf…
favorite count: 0
has comment: http://stackoverflow.com/comment/34083200
has answer: http://stackoverflow.com/a/22178150
upvote count: 2
type: AnsweredQuestion
tagged with: java
has title: Dcm4Che - getting images from pacs
accepted answer: http://stackoverflow.com/a/22178150
type: Question
score: 2
tagged with: dicom

http://stackoverflow.com/comment/33376167
has text: @birdy yes it is initialized correctly since app works fine and thats one of the textviews and the app work constantly with. I only get this run time error when I change orientation. I am going to post the whole onCreate method but i am pretty sure that it has nothing to do with my initialization
score: 0
comment on: http://stackoverflow.com/q/22005918
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/33605146
type: AnswerComment
score: 0
type: Comment
has text: @GyroGearless It's `if (r >= 10) { sum = (char)('A' + r - 10) + sum; } else { sum = r + sum; }`, but I was just correcting the initial code, I'm still convinced that the best way is to use `Integer.toHexString(n)` or `Integer.toString(n, 16)`
comment on: http://stackoverflow.com/a/22145487

http://stackoverflow.com/q/22019922
has comment: http://stackoverflow.com/comment/33381392
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/22020081
type: Question
score: 0
tagged with: jsoup
has title: Getting text from between Tags in XML using jSoup
has comment: http://stackoverflow.com/comment/33380871
answer count: 1
has body: Im trying to get the value of &lt;report_id&gt; from the following statement &lt;start_task_response status_text="OK, request submitted" status="202"&gt;&lt;report_id&gt;524291e2-bde8-4cd8-b48b-59a38f347ff2&lt;/report_id&gt;&lt;/start_task_response&gt; I have tried using the following code but it doesn't seem to want to work? Any help would be gratefully received. String taskid = Jsoup.parse(input).getAllElements().tagName(report_id); or String taskid = Jsoup.parse(input).getAllElements().attr("report_id"); Thanks EDIT: Ok, as asked below; I will update with the response included from the below solution. Here is my (working) code now... Elements elms = Jsoup.parse(input).select("start_task_response report_id"); for (Element e : elms){ String taskid = e.text(); jTextField6.setText(taskid); System.out.println(taskid); This still does not return anything into String taskid. I have also tried modifying the ("start_task_response report_id") to ("report_id") Any further help would be appreciated
has comment: http://stackoverflow.com/comment/33381276
has comment: http://stackoverflow.com/comment/33380740
has comment: http://stackoverflow.com/comment/33391565
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/22020081
tagged with: netbeans

wiimote
tags question: http://stackoverflow.com/q/22091318
tag name: wiimote
type: Tag

http://stackoverflow.com/comment/33678196
comment on: http://stackoverflow.com/q/22150650
has text: @Pshemo thanks, I wasn't aware of the change.
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/a/22073504
has comment: http://stackoverflow.com/comment/33475664
has comment: http://stackoverflow.com/comment/33475292
downvote count: 0
has comment: http://stackoverflow.com/comment/33474868
has body: Assume I am teller 1. You are teller 0. lock[tellerID] = true; I grab a lock for myself. turn = 1 - tellerID; I say "It is your turn now." Turn is set to the ID of the other teller (for now). while lock[1-tellerID] I loop while you have a lock. while turn == (1 - tellerID) I also loop while it is your turn. Imagine we both reached the while loop one after another. I have my lock, and you have your lock. We are both waiting for the other to release the lock, or for it to be our turn. It has to either be your turn or my turn, so only one of us falls through the loop. This is obviously mutual exclusion. When you go to make another deposit, you will notify me that it is my turn. Waiting, grabbing locks, and taking turns are all part of an entry protocol. Releasing locks is part of an exit protocol. Everything in between is, by default, a critical section. Everything outside is, by default, a non-critical section.
answers question: http://stackoverflow.com/q/22072654
has comment: http://stackoverflow.com/comment/33475765
type: Answer
has comment: http://stackoverflow.com/comment/33474946
has comment: http://stackoverflow.com/comment/33475060
score: 1
upvote count: 1

http://stackoverflow.com/comment/33529837
comment on: http://stackoverflow.com/q/22103812
has text: What is `getState()`?
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/33506640
has text: To give to the underlying data store the opportunity to apply those optimizations as it sees fit. But maybe together to readOnly I should use also the propagation attribute?
type: AnswerComment
comment on: http://stackoverflow.com/a/22091190
score: 0
type: Comment

http://stackoverflow.com/comment/33614557
comment on: http://stackoverflow.com/q/22151550
has text: Wouldn't the text area just return whatever it contains immediately? And wouldn't that normally be either a null or empty string? I'm wondering if the overall approach is flawed?
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33641823
score: 0
type: Comment
type: QuestionComment
has text: Could you provide the package/folder structure of your project ?
comment on: http://stackoverflow.com/q/22166762

http://stackoverflow.com/comment/33524344
type: QuestionComment
comment on: http://stackoverflow.com/q/22101116
has text: have a look at these [Similar1](http://stackoverflow.com/questions/12433499/org-hibernate-queryparameterexception-could-not-locate-named-parameter) [Similar2](http://stackoverflow.com/questions/18680813/org-hibernate-queryparameterexception-could-not-locate-named-parameter-userid)
score: 0
type: Comment

http://stackoverflow.com/q/22036446
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/22036572
type: Question
tagged with: c#
has title: Can't figure out where these C# and Java code differ
answer count: 1
downvote count: 0
accepted answer: http://stackoverflow.com/a/22036572
favorite count: 0
has body: I have some C# code that converts an image to base64 string. The code is : MemoryStream ms = new MemoryStream(); Image img = Image.FromFile(filename); img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); string s = Convert.ToBase64String(ms.GetBuffer()); I am trying to implement it with JAVA. my java code is : BufferedImage img = null; img = ImageIO.read(new File(filename)); byte[] bytes = ((DataBufferByte)img.getData().getDataBuffer()).getData(); String js = Base64.encodeBase64String(bytes); this two piece of code should return the same string for the same image file. But they are returning different strings. I am unable to figure out why. Can anyone shed some light on it?
type: AnsweredQuestion
score: 3
tagged with: apache-commons

http://stackoverflow.com/comment/33408057
comment on: http://stackoverflow.com/a/22007415
type: AnswerComment
has text: Actually, the issue I have with doing it the way you posted is that it requires me to initialize the variable--it isn't initialized until the first while loop, and I'm still having the same issue with scope. The suggesting Eclipse makes is to say "Student[] students = Null;" but obviously, that is wrong...
score: 0
type: Comment

http://stackoverflow.com/a/22051568
type: Answer
has comment: http://stackoverflow.com/comment/33436274
has comment: http://stackoverflow.com/comment/33436510
has comment: http://stackoverflow.com/comment/33436593
has comment: http://stackoverflow.com/comment/33435980
has comment: http://stackoverflow.com/comment/33436403
has comment: http://stackoverflow.com/comment/33435543
answers question: http://stackoverflow.com/q/22050639
has comment: http://stackoverflow.com/comment/33436715
has body: Please take a @njzk2's comment above - SelectableTextView is not a ViewGroup so it can't contain child Views. You'll need to remove the TextView from your SelectableTextView and call setText() on the SelectableTextView instead. Another issue: I'm guessing ObservableScrollView extends Android's native ScrollView, right? If that's true, ObservableScrollView can only contain 1 direct child. In this case you need a ViewGroup like RelativeLayout or LinearLayout to hold everything else. Try this (making ObservableScrollView the parent): &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;com.zyz.mobile.example.ObservableScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scroller" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true"&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="#ffffff"&gt; &lt;com.zyz.mobile.example.SelectableTextView android:id="@+id/main_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="#000000" android:textSize="20sp" android:bufferType="spannable" android:text="@string/text"/&gt; &lt;/LinearLayout&gt; &lt;/com.zyz.mobile.example.ObservableScrollView&gt; Then add your ObservableScrollViews to the LinearLayout
has comment: http://stackoverflow.com/comment/33436626
has comment: http://stackoverflow.com/comment/33436121
score: 0
has comment: http://stackoverflow.com/comment/33435666

http://stackoverflow.com/comment/33597518
comment on: http://stackoverflow.com/q/22142089
score: 0
type: QuestionComment
type: Comment
has text: 1st method will replace old values, if you want so..

http://stackoverflow.com/comment/81131906
has text: The first approach works, but the minimum position in the clob is 1.
type: Comment
comment on: http://stackoverflow.com/a/22124307
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33522687
has text: private String tagName; the same problem :*_*:
comment on: http://stackoverflow.com/a/22100412
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/29842479
score: 3
upvote count: 3
downvote count: 0
answers question: http://stackoverflow.com/q/22148782
has body: 1. GO TO Window-> Preferences -> General -> Network Connection. 2. Change the Settings Active Provider-> Manual-> and check---> HTTP, HTTPS and SOCS Restart Eclipse and ENJOY!
type: Answer

http://stackoverflow.com/q/22035182
has title: What do I need to use Oracle Database with my application?
type: AnsweredQuestion
has body: What are things that I need to develop an application that uses an Oracle Database? Actually my confusion is that I have made a schema for my database and if I want to install my application on another PC, would I have to install entire Oracle Database? This is driving me crazy as probably the size of my application is smaller then the Oracle Database. I'm new in the programming (practical) field, I am writing the application in JavaSE.
tagged with: java
tagged with: database
type: Question
accepted answer: http://stackoverflow.com/a/22035245
score: 0
tagged with: oracle-database
answer count: 1
has answer: http://stackoverflow.com/a/22035245

http://stackoverflow.com/q/22006981
has comment: http://stackoverflow.com/comment/33358295
type: UnansweredQuestion
tagged with: file
tagged with: if-statement
tagged with: java
type: Question
answer count: 1
has title: What does it mean in Java when it says "reached end of file while parsing"?
score: 0
has body: So I'm getting close to finishing my big project due within 6 hours from now, and has I was adding the code for filing, I got an error which says: E:\3 IB Computer Science SL\Dossier Computer Science IA The Solution\Product\Kingdom_Hearts.java:664: reached end of file while parsing } Process completed. Mind you my project is a bunch of if statements within each other, with files which are outputted when the user inputs 3 numbers (integers). What exactly does this mean, and how can I fix it? To show what I have throughout my entire program so far: EDIT: Here's what I have now after getting rid of 2 unnecessary braces. I'm still getting the same error: import java.io.*; //Allows for Files, and the IOException. import java.util.*; //Allows for the scanner, which allows the user to make her or his choices. public class Kingdom_Hearts { public static void main (String[] args) throws IOException { System.out.println("Select a Kingdom Hearts title to view enemies."); System.out.println("1. Kingdom Hearts"); System.out.println("2. Kingdom Hearts: Final Mix"); System.out.println("3. Kingdom Hearts: Chain of Memories"); System.out.println("4. Kingdom Hearts II"); System.out.println("5. Kingdom Hearts II: Final Mix"); System.out.println("6. Kingdom Hearts: 358/2 Days"); System.out.println("7. Kingdom Hearts: Birth by Sleep"); System.out.println("8. Kingdom Hearts: Re:coded"); System.out.println("9. Kingdom Hearts 3D: Dream Drop Distance"); //All the Kingdom Hearts games in the series to choose to view their enemies from. Scanner kH = new Scanner (System.in); //Allows the user to make any kind of selection throughout the enitire program. int choose = kH.nextInt(); //Gives the user the choice to select the number that corresponds to the Kingdom Hearts game. boolean looper = true; if (choose == 1) //enemies from the original Kingdom Hearts { System.out.println("In the orginal Kingdom Hearts, there is only one enemy race, which is the Heartless."); System.out.println("Please type …
has answer: http://stackoverflow.com/a/22007072
has comment: http://stackoverflow.com/comment/33355763

http://stackoverflow.com/comment/33520825
type: Comment
type: QuestionComment
has text: The code you have posted is printing nothing but spaces. Please post the code that's actually giving the output you mention.
score: 1
comment on: http://stackoverflow.com/q/22099123

http://stackoverflow.com/comment/33467190
has text: I found the cause. Every time i call `page = outPdf.getImportedPage(pdfInsertReader, indexpage.source_page);` i get the page that I've already used previously and added a barcode to, so it adds another barcode on top of the old one each time i try to get a "fresh" page from the PDF im inserting (in the end there were thousands of barcodes on top of eachother). Now i just need to find out how to get an original page back instead of the ones i have already modified, since the barcodes differ just a little on each page.
comment on: http://stackoverflow.com/q/22068566
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/33492538
type: Comment
comment on: http://stackoverflow.com/q/22083207
type: QuestionComment
has text: Why dont just redownlaod eclipse ? its small. Use ( Eclipse IDE for Java Developers) it include window builder already.Then you can download all other parts by going into donwload install new software of whathever is that tab called. Place *eclipse name(kepler,juno etc.) and you will be able to see all the plugins you can install.That is with no hassle if you dont mind to download again.Im kinda confused why it doesnt let you install it again :/ .Never had trouble with that.
score: 0

http://stackoverflow.com/q/22055163
accepted answer: http://stackoverflow.com/a/22055281
answer count: 1
has answer: http://stackoverflow.com/a/22055281
tagged with: http://stackoverflow.com/tag/csv
has title: MySQLSyntaxErrorException: SQL Insert syntax error
type: AnsweredQuestion
tagged with: mysql
type: Question
tagged with: java
has body: I am receiving a syntax error when trying to insert values from a csv to a database using java. Here is my code try{ BufferedReader br=new BufferedReader(new FileReader(filename1)); String line; while((line=br.readLine())!=null){ String[]value=line.split(",");//Seperator System.out.println(value[0]); System.out.println(value[1]); System.out.println(value[2]); if (programused == "Example"){ String sql="insert into websitehistory (Date, URL, VisitCount) " + "values (?,?,?)"; pst=conn.prepareStatement(sql); pst.setString(1, value[0]); pst.setString(2, value[1]); pst.setString(3, value[2]); pst.executeUpdate(sql); Update_exampleTable(); } Here is mysql query of inserting the separated values into the database. Value is an array that contains the in putted csv file, "filename1" This is my table structure: Field Type Null Key Default Extra Date text No NULL URL text No NULL VisitCount text No NULL And the type of data that is inside the csv file that I would like to insert: 31/01/2014 15:26:00, https://www.youtube.com/, 13 31/01/2014 15:25:00, https://www.youtube.com/, 17 30/01/2014 12:15:00, https://www.facebook.com/, 20 This then throws a MySQL syntax error: Check the manual that corresponds to your MySQL server version for the right syntax to use near '?,?,?)' at line 1. If I replace the ? with value[0] value[1] and so on, some of the data is inserted but retrieves gives a different SQL syntax error within the data but when using place holders none of the data is inserted into the table. Any help would be fantastic.
score: 0

http://stackoverflow.com/comment/33487590
has text: @Tim, sorry I misunderstood. It's okay to use the same number multiple times. The correct answer is 528, so our cubic is fine. I did a manual check of your input [1, -2, 3] and I expected 6, got 6 (with cubic), got 5 (with quadratic).
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22078922
score: 0

http://stackoverflow.com/a/59085981
upvote count: 4
downvote count: 0
has body: You can create a method to positively enable all the calling parameters as the code below, it also works fine in case your StoredProcedureQuery contains out parameters. This helps you don't break the null parameter checking somewhere. public void setStoreProcedureEnableNullParameters(StoredProcedureQuery storedProcedureQuery) { if (storedProcedureQuery == null || storedProcedureQuery.getParameters() == null) return; for (Parameter parameter : storedProcedureQuery.getParameters()) { ((ProcedureParameterImpl) parameter).enablePassingNulls(true); } } Then call StoredProcedureQuery storedProcedure = entityManager.createStoredProcedureQuery("your_store_procedure") .registerStoredProcedureParameter("Param_1", String.class, ParameterMode.OUT) .registerStoredProcedureParameter("Param_2", String.class, ParameterMode.IN) .registerStoredProcedureParameter("Param_3", String.class, ParameterMode.IN); // Remember you must call before setting the value for the parameters setStoreProcedureEnableNullParameters(storedProcedure); storedProcedure .setParameter("Param_2", null) .setParameter("Param_3", "Some value"); storedProcedure.execute(); String outValue = (String) storedProcedure.getOutputParameterValue("Param_1");
type: Answer
score: 4
answers question: http://stackoverflow.com/q/22045641

http://stackoverflow.com/q/22008844
tagged with: java
has body: currently I need to find some special lexical characteristics of a string in Java such as Total number of characters Total number of alphabetic characters Total number of uppercase characters .... I wonder that is there a library can do that? It would be great to save coding time. Thank you very much.
type: Question
tagged with: lexical
possible better answer: http://stackoverflow.com/a/22008974
has answer: http://stackoverflow.com/a/22008989
upvote count: 2
answer count: 3
has title: Library for identifying lexical features of a string in Java
favorite count: 0
accepted answer: http://stackoverflow.com/a/22008944
has answer: http://stackoverflow.com/a/22008974
type: AnsweredQuestion
score: 2
has answer: http://stackoverflow.com/a/22008944
downvote count: 0

http://stackoverflow.com/q/22021149
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33382203
has comment: http://stackoverflow.com/comment/33381009
has comment: http://stackoverflow.com/comment/33381884
has comment: http://stackoverflow.com/comment/33382925
has comment: http://stackoverflow.com/comment/33382059
has comment: http://stackoverflow.com/comment/33381715
answer count: 0
has body: I am getting a NumberFormatException when I try to access an element of list from a modelattribute in the request scope using the below statement "${requestscope. modelattribute. list["+i+"].name}" where i can be any number. But when I directly put a number instead of i like "${requestscope. modelattribute. list[0].name}" I get the proper value. Please tell me how to make it work or if there is any other way to do it
has comment: http://stackoverflow.com/comment/33381443
has comment: http://stackoverflow.com/comment/33382999
has comment: http://stackoverflow.com/comment/33382543
has comment: http://stackoverflow.com/comment/33381996
type: Question
has comment: http://stackoverflow.com/comment/33382124
has comment: http://stackoverflow.com/comment/33381783
has title: Trouble in accessing list element in request scope
tagged with: java
score: 0
has comment: http://stackoverflow.com/comment/33383046
has comment: http://stackoverflow.com/comment/33382712

http://stackoverflow.com/comment/33428048
has text: @AliNaddaf I am using the CCL , it handles the disconnect logic. Unless I am incorrect. Also note that this happens intermittently.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22046752
score: 0

http://stackoverflow.com/q/22020635
tagged with: tree
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22021151
accepted answer: http://stackoverflow.com/a/22021151
tagged with: java
has body: One of my midterm review questions asks to parse this tree in different ways - pre/postfix etc. It asks these two ways as well though: In "Infix, Java precedence rules" and in "Infix, left-to-right precedence" What is the difference between Java precedence rule and plain left-to-right infix rule? I thought if it was as Java precedence, something like "newline" may be needed like the actual java code but I really don't see what's really asked here. Thanks for your help in advance Another question. How would you regard d and e nodes? If it was postfix, (d e) f h * - would be appropriate for that portion of tree?
type: Question
score: 0
answer count: 1
tagged with: operator-precedence
tagged with: parsing
has title: Java precedence on abstract syntax tree?

http://stackoverflow.com/comment/33521595
type: QuestionComment
comment on: http://stackoverflow.com/q/22099647
score: 0
has text: probably exception is correct and you don't have action with this name, but paste your struts.xml
type: Comment

http://stackoverflow.com/comment/33595718
type: AnswerComment
comment on: http://stackoverflow.com/a/22140850
score: 0
type: Comment
has text: Well the static method "dataExtract" creates the objects that it is referencing, so I'm not really sure when there would be an instance where the variable would not be initialized. I may just be misunderstanding what you are trying to say, other than that I think I understand what you are saying. I appreciate your help!

http://stackoverflow.com/q/22048071
accepted answer: http://stackoverflow.com/a/22118129
score: 0
answer count: 1
has title: Charts with transparent image in jasper reports
has answer: http://stackoverflow.com/a/22118129
type: AnsweredQuestion
has body: Using JFreeChart, Jasper Reports and Jaspersoft Studio, I try to generate the following chart: But when I generate a PDF in Jaspersoft Studio, I get the following: I'm using an image mask with transparency, which corresponds to this: Is there a config in jasper studio/reports that helps to fix this?
tagged with: java
tagged with: jfreechart
type: Question
tagged with: jasper-reports

http://stackoverflow.com/comment/33524697
comment on: http://stackoverflow.com/a/22047191
type: AnswerComment
score: 0
has text: Oreilly books tend to be good, most others tend to suck (there are exceptions in both cases). I have lots of books, but generally use the internet for info instead. Stack Overflow is a great resource for detailed information when you're already 99% of the way there and can't find a bug. Avoid it for "high level" problems and general questions since that's not really what it's for. Google searches have Stack Overflow as at least one of the top 10 hits. If you're interested in game programming (which is what I do), check out Unity. It's free and has tons of sample code on their website.
type: Comment

http://stackoverflow.com/comment/33580339
type: AnswerComment
type: Comment
has text: @Vash I carried out a quick experiment (I was sure that you are wrong but I wanted to check) and you are wrong. The `findFirst` will only traverse the `Stream` until it finds the first matching element - `filter` will not traverse the entire `Stream`. Running `(build 1.8.0-ea-b120`.
comment on: http://stackoverflow.com/a/22131497
score: 0

http://stackoverflow.com/a/22119205
answers question: http://stackoverflow.com/q/22119045
type: Answer
has comment: http://stackoverflow.com/comment/33557503
has body: You should avoid possible threading issues by defining the AsyncTask as &lt;Intent, Void, Void&gt; and call its execute method like trainSchedule.execute(getIntent()); Change doInBackground(Void... params) to doInBackground(Intent... params) and get the extras from that intent before you setup the URL by using String start = params[0].getExtras().getString("fromStation"); String end = params[0].getExtras().getString("toStation");
score: 0

http://stackoverflow.com/comment/33574614
score: 1
has text: do you have all needed jars for it? It seems there is no EM in your classpath;
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22128631

http://stackoverflow.com/q/22159687
has title: error starting tomcat 7 from eclipse
tagged with: tomcat
linked to: http://stackoverflow.com/q/26143894
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/32951274
linked to: http://stackoverflow.com/q/10744928
score: 2
has body: im getting this error when starting my tomcat 7 can someone help me? Mar 03, 2014 5:07:31 PM org.apache.catalina.startup.Bootstrap initClassLoaders SEVERE: Class loader creation threw exception java.io.IOException: Invalid argument at java.io.WinNTFileSystem.canonicalize0(Native Method) at java.io.Win32FileSystem.canonicalize(Unknown Source) at java.io.File.getCanonicalPath(Unknown Source) at java.io.File.getCanonicalFile(Unknown Source) at org.apache.catalina.startup.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:171) at org.apache.catalina.startup.Bootstrap.createClassLoader(Bootstrap.java:176) at org.apache.catalina.startup.Bootstrap.initClassLoaders(Bootstrap.java:103) at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:208) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:406)
upvote count: 2
has comment: http://stackoverflow.com/comment/33642684
type: Question
has answer: http://stackoverflow.com/a/22771890
tagged with: java
tagged with: eclipse
answer count: 2
downvote count: 0

http://stackoverflow.com/a/22147139
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/33634708
has body: Actually when a mapreduce job is triggered, it first check the input file(s), for simplicity consider we have only one big inputfile!. If it is larger in size than the block size, job tracker split this file by the block size, then initiate No. of map tasks = No. of Splits generated and pass each split to each mapper task for processing. So no more than one split will be processed by each mapper. Also if the input file size is less than the block size, then jobtracker will take it as a separate split. Suppose block size is 64MB, and you have 2 files each having 10MB in size, then jobtracker will generate 2 splits!,because according to FileInputFormat a split can be exactly a single file(incase filesize &lt;= block size) or a part of a file (in case its size > blocksize). Thus, a mapper will only process a single split, also a split cannot contain more than one file (true for FileInputFormat the default format, but in case of combine file input format it can span over multiple files). I guess you are using FilInputFormat. HTH! You can refer the Hadoop: The Definitive Guide to understand its basics.
answers question: http://stackoverflow.com/q/22117605

http://stackoverflow.com/a/22168078
has comment: http://stackoverflow.com/comment/33646673
has comment: http://stackoverflow.com/comment/33646444
has comment: http://stackoverflow.com/comment/33644809
has comment: http://stackoverflow.com/comment/33646728
score: 2
has comment: http://stackoverflow.com/comment/33646104
has comment: http://stackoverflow.com/comment/33644662
upvote count: 2
has body: TRy like this AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(S_2nd_LoginActivity.this); alertDialogBuilder.setTitle("Are you sure you want to cancel?") .setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { finish(); } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); And in your onDestroy() method call android.os.Process.killProcess(android.os.Process.myPid());
has comment: http://stackoverflow.com/comment/33644710
downvote count: 0
answers question: http://stackoverflow.com/q/22167955
has comment: http://stackoverflow.com/comment/33645282
type: Answer
has comment: http://stackoverflow.com/comment/33645384

http://stackoverflow.com/a/22165013
type: Answer
has comment: http://stackoverflow.com/comment/33638644
accepted answer of: http://stackoverflow.com/q/22164693
has comment: http://stackoverflow.com/comment/33643056
has body: Project pro = new Project(); pro.setPrj_Id(existingId); emp.setProject(pro);
score: 0
has comment: http://stackoverflow.com/comment/33642754
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33638862
answers question: http://stackoverflow.com/q/22164693

http://stackoverflow.com/q/22063623
has body: I have a question regarding field validation with values present in the database. I've been following http://jumpstart.doublenegative.com.au/jumpstart/examples/input/contributingvalidators as a guide, and it's been pretty straightforward for the most parts. However, I've hit a wall of some sort. I'm trying to make my own validator: public class UniqueValueProperty extends AbstractValidator&lt;String, String&gt; { // my validation stuff here } This is how I'm trying to contribute it: public void contributeFieldValidatorSource(MappedConfiguration&lt;String, Validator&gt; configuration) { configuration.add(UniqueValueProperty.VALIDATION_NAME, new UniqueValueProperty()); } So, to sum up: I understand I need to provide a javascript code for client side validation, but I'm not sure how to actually access the DAO and do the check? Edit: Validator has a method you override, which does this: Hook used by components to allow the validator to contribute additional attributes or (more often) client-side JavaScript @Override public void render(Field field, String constraintValue, MessageFormatter formatter, MarkupWriter writer, FormSupport formSupport) { formSupport.addValidation(field, VALIDATION_NAME, buildMessage(formatter, field, constraintValue), null); If I understood it correctly, I can add some javascript code for client-side validation, right? Well, what I'd like to do in that part (dunno if it's possible) is to actually check for some things in my DB using the DAO, or even to pass more (dynamic) paremeters to validator, such as a list of values it should not trigger validation fail on. Thanks :D Edit: Lance, are you suggesting I could do this: Tapestry.Validator.uniqueValueProperty = function(field, message, constraint) { field.addValidator(function(value) { if ((value != null) &amp;&amp; (value.trim().length &gt; 0)) { if (dao.valueExistsInColumn(value, constraint)) { throw message; } } }); }; where dao variable is injected in my validator object, contributed via addI…
score: 0
tagged with: validation
answer count: 1
tagged with: tapestry
has answer: http://stackoverflow.com/a/22073487
tagged with: field
type: AnsweredQuestion
has title: How to validate Tapestry's form fields with values that come from database?
tagged with: java
accepted answer: http://stackoverflow.com/a/22073487
type: Question
tagged with: javascript

http://stackoverflow.com/q/22118215
favorite count: 0
has body: I have a maze generating algorithm working with depth-first search. It first generates a raw maze which looks like this: Then it creates the maze using this algorithm: http://www.mazeworks.com/mazegen/mazetut/index.html The result looks like this: The red pixel marks the goal, the green one the start. It gets stuck at the goal and jumps back and forth until it thinks it finished. Maze Generator source: public Maze generate(int width, int height) { Maze maze = getRawMaze(width, height); List&lt;Point&gt; cellStack = new LinkedList&lt;Point&gt;(); int totalAirCells = maze.getTotalAirCells(); Point currentCell = maze.getRandomAirCell(ran); maze.setCellTypeAt(currentCell, Maze.CellType.START); int visitedCells = 1; while(visitedCells&lt;totalAirCells) { Point[] unvisitedNeighbors = getUnvisitedNeighbors(maze, currentCell); if(unvisitedNeighbors.length!=0) { System.out.println("Go Foward"); Point newCell = unvisitedNeighbors[ran.nextInt(unvisitedNeighbors.length)]; maze.connect(newCell, currentCell); cellStack.add(currentCell); currentCell = newCell; visitedCells++; }else { System.out.println("Go Back"); Point recentCell = cellStack.get(cellStack.size()-1); cellStack.remove(cellStack.size()-1); currentCell = recentCell; } } maze.setCellTypeAt(currentCell, Maze.CellType.GOAL); return maze; } public Point[] getUnvisitedNeighbors(Maze maze, Point p) { List&lt;Point&gt; unvisitedNeighbors = new ArrayList&lt;Point&gt;(); Point[] neighbors = maze.getNeighbors(p); for(Point n : neighbors) { if(maze.getSurroundingWalls(n)==4)unvisitedNeighbors.add(n); } return unvisitedNeighbors.toArray(new Point[unvisitedNeighbors.size()]); } additional source: public int getSurroundingWalls(Point p) { if(getCellTypeAt(p)==CellType.AIR) { int walls = 0; if(getCellTypeAt(new Point(p.x+1, p.y))==CellType.WALL)walls++; if(getCellTypeAt(new Point(p.x-1, p.y))==CellType.WALL)walls++; if(getCellTypeAt(new Point(p.x, p.y+1))==CellType.WALL)walls++; if(getCellTypeAt(new Point(p.x+1, p.y-1))==CellType.W…
tagged with: maze
has comment: http://stackoverflow.com/comment/33554950
has comment: http://stackoverflow.com/comment/33555017
tagged with: depth-first-search
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22182364
tagged with: java
downvote count: 2
upvote count: 1
type: Question
has title: Java depth-first search maze generating alogrithm gets stuck
score: -1
accepted answer: http://stackoverflow.com/a/22182364
has comment: http://stackoverflow.com/comment/33763026
answer count: 1

http://stackoverflow.com/comment/33514626
has text: You can have a look [here](https://github.com/haraldk/TwelveMonkeys/tree/master/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/image) for examples of creating custom `DataBuffer`s backed by a `ByteBuffer` (`MappedFileBuffer` and `MappedImageFactory`). Not sure it will help much though. I believe multithreading will be your best shot.
comment on: http://stackoverflow.com/q/22095733
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/q/22022273
type: Question
has answer: http://stackoverflow.com/a/22022472
linked to: http://stackoverflow.com/q/13102045
answer count: 1
downvote count: 0
has title: While loop causing nextLine() to skip
favorite count: 0
has comment: http://stackoverflow.com/comment/33383087
has comment: http://stackoverflow.com/comment/33383326
score: 2
upvote count: 2
type: UnansweredQuestion
tagged with: java
duplicate of: http://stackoverflow.com/q/13102045
has body: I'm work on a homework question and am having an issue with a part of my loop /** * Created by wilson on 2/25/2014. */ import java.util.Scanner; public class GradesDemo { public static void main(String[] args) { Grades grade = new Grades(); String name; double score = 0; boolean invalid = true; Scanner keyboard = new Scanner(System.in); //One loop iteration for each student for (int i = 0; i &lt; 5; i++) { invalid = true; //Asks for student name, and stores to array System.out.println("Student's Name:"); name = keyboard.nextLine(); grade.setName(name, i); //while loop to check if score entered by user is valid while (invalid == true) { System.out.println("Student's Score:"); score = keyboard.nextDouble(); //Check if score entered was valid. If not, user will be asked again if (score &gt;= 0 &amp;&amp; score &lt;= 100) invalid = false; else System.out.println("Score is invalid. Must be between 0-100. Try again."); } grade.setScore(score, i); //Calculate grade grade.findGrade(i); } for (int i = 0; i &lt;5; i++) { System.out.println(grade.toString(i)); } } } Output Sample: Student's Name: John Doe Student's Score: 88 Student's Name: Student's Score: As you can see, in the second iteration of the loop, it skips waiting for user input under Student name directly to student score, causing an error.
has comment: http://stackoverflow.com/comment/33383160

http://stackoverflow.com/comment/33499256
type: QuestionComment
has text: System.out.println() prints on server console not the client.
comment on: http://stackoverflow.com/q/22087101
score: 0
type: Comment

http://stackoverflow.com/q/22042570
has answer: http://stackoverflow.com/a/22042925
has comment: http://stackoverflow.com/comment/33420651
answer count: 6
has comment: http://stackoverflow.com/comment/33426859
has title: Remove zero values from array
score: 0
has comment: http://stackoverflow.com/comment/33426287
has answer: http://stackoverflow.com/a/22042637
tagged with: arrays
has answer: http://stackoverflow.com/a/22042711
has comment: http://stackoverflow.com/comment/33451826
has answer: http://stackoverflow.com/a/22042621
has comment: http://stackoverflow.com/comment/33425951
accepted answer: http://stackoverflow.com/a/22042711
possible better answer: http://stackoverflow.com/a/22042646
tagged with: android
has comment: http://stackoverflow.com/comment/33427351
has comment: http://stackoverflow.com/comment/33425840
has answer: http://stackoverflow.com/a/22042646
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33454228
has answer: http://stackoverflow.com/a/22042727
tagged with: java
has body: I have an array with zero values, and I wish to copy this array to other array but without the zero values. How can I do this if determining the array size is not possible because I do not know how many zeros are there. Please note that I can not use List or ArrayList because of reasons. // frame is the original array final int[] sorted = new int[??]; for (int i = 0; i &lt; frame.length; i++) { if (frame[i] != 0) { sorted[i] = frame[i]; } }
type: Question

http://stackoverflow.com/a/22123130
has body: If this was my code I would extract the Calendar variable into another method, overloading the method so that there is one version that takes the Calendar as a parameter and one version with no arguments, like this: public static String getDate() { return getDate(Calendar.getInstance()); } public static String getDate(Calendar cal} { // your example code } This way you can write tests exercising your logic in getDate without having to use any mocks. If you really want to cover the no-args version of the method then you can use PowerMock to mock Calendar's getInstance method (here's a question with examples of that).
type: AcceptedAnswer
type: Answer
score: 2
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22122687
has comment: http://stackoverflow.com/comment/33583973
answers question: http://stackoverflow.com/q/22122687
upvote count: 2

http://stackoverflow.com/comment/33388953
comment on: http://stackoverflow.com/q/22024971
has text: Surpisingly nothing showing up in your project and packages. Please create a project first and then add the java class within the project.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33413567
comment on: http://stackoverflow.com/a/22039446
score: 0
type: AnswerComment
has text: @Alvaro if he is browsing in https it makes the problem. right?
type: Comment

http://stackoverflow.com/a/22083796
type: Answer
has comment: http://stackoverflow.com/comment/33493680
has comment: http://stackoverflow.com/comment/33493367
has comment: http://stackoverflow.com/comment/33494136
has body: The case is the same as you can not create default toString() in interface. The enum already contains signature for static valueOf(String) method therefore you can not override it. The enum are compile time constant and because of that it really doubtful that they will be extensible someday. If you want to get the constant via name you can use this: public static &lt;E extends Enum&lt;E&gt;&gt; Optional&lt;E&gt; valueFor(Class&lt;E&gt; type, String name) { return Arrays.stream(type.getEnumConstants()).filter( x -&gt; x.name().equals(name)).findFirst(); }
answers question: http://stackoverflow.com/q/22083689
has comment: http://stackoverflow.com/comment/33493550
score: 0

http://stackoverflow.com/comment/34035283
type: Comment
type: QuestionComment
has text: It was my noob coding I forgot to have a <= in my for loop.
comment on: http://stackoverflow.com/q/22031086
score: 0

http://stackoverflow.com/q/22092930
type: Question
tagged with: java
has comment: http://stackoverflow.com/comment/33521606
has comment: http://stackoverflow.com/comment/33596904
accepted answer: http://stackoverflow.com/a/22141896
answer count: 1
downvote count: 0
favorite count: 0
tagged with: android
tagged with: android-studio
score: 2
type: AnsweredQuestion
upvote count: 2
has title: service entry keeps disappearing from manifest
has body: I recently implemented an intent service in my app and wondered why i wasnt able to start it. Unable to start service Intent { cmp=com.myapp/.service.DownloadSerive } U=0: not found After checking git status i found that the previously added service entry in manifest was removed. - &lt;service android:name=".service.DownloadSerive"/&gt; After readding and building it surpise, surprise: It was gone again! I`m not sure what to do now and also kind off blocked on finishing my service. How can manifest changes just vanish? Does AndroidStudio do stuff in it?
tagged with: maven
has answer: http://stackoverflow.com/a/22141896
tagged with: git

http://stackoverflow.com/a/22121521
answers question: http://stackoverflow.com/q/22121474
type: Answer
has body: The code block with the static modifier signifies a class initializer; without the static modifier the code block is an instance initializer. Static initializers are executed in the order they are defined (top down, just like simple variable initializers) when the class is loaded (actually, when it's resolved, but that's a technicality). Instance initializers are executed in the order defined when the class is instantiated, immediately before the constructor code is executed, immediately after the invocation of the super constructor. static block
score: 0

http://stackoverflow.com/comment/33497278
has text: That is a good idea, and so far I like yours the best for sure. I did do a little bit of searching, and I found this similar (I think, not sure if his purpose is even close to mine) question: bit.ly/1hu6T59 Do you think the code in that answer might give me my desired effect?
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22060087

inheritance
tags question: http://stackoverflow.com/q/22164716
tags question: http://stackoverflow.com/q/22126403
tags question: http://stackoverflow.com/q/22137700
tags question: http://stackoverflow.com/q/22047201
tags question: http://stackoverflow.com/q/22131527
tags question: http://stackoverflow.com/q/22139513
tags question: http://stackoverflow.com/q/22116010
tags question: http://stackoverflow.com/q/22064530
tags question: http://stackoverflow.com/q/22052330
tags question: http://stackoverflow.com/q/22029064
tag name: inheritance
tags question: http://stackoverflow.com/q/22082079
tags question: http://stackoverflow.com/q/22128565
tags question: http://stackoverflow.com/q/22117072
tags question: http://stackoverflow.com/q/22048684
tags question: http://stackoverflow.com/q/22107482
tags question: http://stackoverflow.com/q/22158339
tags question: http://stackoverflow.com/q/22097873
type: Tag
tags question: http://stackoverflow.com/q/22008060
tags question: http://stackoverflow.com/q/22025668
tags question: http://stackoverflow.com/q/22053750
tags question: http://stackoverflow.com/q/22031047
tags question: http://stackoverflow.com/q/22083518
tags question: http://stackoverflow.com/q/22096052
tags question: http://stackoverflow.com/q/22016863
tags question: http://stackoverflow.com/q/22166067
tags question: http://stackoverflow.com/q/22086506
tags question: http://stackoverflow.com/q/22050249
tags question: http://stackoverflow.com/q/22131364
tags question: http://stackoverflow.com/q/22051019
tags question: http://stackoverflow.com/q/22126077
tags question: http://stackoverflow.com/q/22022751

http://stackoverflow.com/q/22151491
has comment: http://stackoverflow.com/comment/33615754
type: UnansweredQuestion
has body: i am new to Spring technology. I created a Spring MVC project when i try to run project using Tomcat i am getting following error in eclipse console. Please help me out, i tried several options by searching in Google but clueless. I don't know where went wrong... Error: org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/controller/] in DispatcherServlet with name 'SpringMVC' HomeController.java @Controller public class HomeController { @RequestMapping(value = "/student", method = RequestMethod.GET) public ModelAndView student() { return new ModelAndView("student", "command", new Student()); } @RequestMapping(value = "/addStudent", method = RequestMethod.POST) public String addStudent(@ModelAttribute("SpringWeb")Student student, ModelMap model) { model.addAttribute("name", student.getName()); model.addAttribute("age", student.getAge()); model.addAttribute("id", student.getId()); return "result"; } } web.xml contextConfigLocation /WEB-INF/root-context.xml org.springframework.web.context.ContextLoaderListener SpringMVC org.springframework.web.servlet.DispatcherServlet contextConfigLocation /WEB-INF/SpringMVC-servlet.xml 1 SpringMVC / SpringMVC-servlet.xml <mvc:annotation-driven /> <context:component-scan base-package="com.spring.controller" /> <resources mapping="/resources/**" location="/resources/" /> <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <beans:property name="prefix" value="/WEB-INF/views/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean>
tagged with: spring
has comment: http://stackoverflow.com/comment/33614562
tagged with: spring-mvc
has comment: http://stackoverflow.com/comment/33614462
tagged with: java
duplicate of: http://stackoverflow.com/q/41577234
type: Question
linked to: http://stackoverflow.com/q/41577234
has title: org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/controller/] in DispatcherServlet with name 'SpringMVC'
score: 0
has comment: http://stackoverflow.com/comment/33615591
has answer: http://stackoverflow.com/a/22156869
answer count: 1
has comment: http://stackoverflow.com/comment/33615522

http://stackoverflow.com/q/22118734
answer count: 4
has answer: http://stackoverflow.com/a/22118780
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22118801
type: Question
has title: How to Check filename
has answer: http://stackoverflow.com/a/22118776
tagged with: filenames
tagged with: java
has answer: http://stackoverflow.com/a/22118768
has body: I have a method that reads filename for a file from a certain source. My method should handle two types of files. My next method depends on the name of the file. _InPayed.txt" "_OutPayed.txt My problem is how to check if the filename is ..._inpayed Or ..._OutPayed How to check the string after the strick " _" Code: public class FilenameDemo { public static void main(String[] args) { final String FPATH = "/home/mem/"filename.txt"; System.out.println("Extension = " + myHomePage.extension()); System.out.println("Filename = " + myHomePage.filename()); } }
has comment: http://stackoverflow.com/comment/33555933
score: 0
tagged with: filereader

http://stackoverflow.com/comment/33555044
score: 1
has text: Did you override the `toString` method in your class?
comment on: http://stackoverflow.com/q/22118237
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33644163
comment on: http://stackoverflow.com/a/22168289
type: AnswerComment
score: 0
type: Comment
has text: a decimal value to parse as an integer? Please rethink your example

http://stackoverflow.com/q/22080451
type: Question
has answer: http://stackoverflow.com/a/22080726
has comment: http://stackoverflow.com/comment/33487518
score: 0
tagged with: arrays
tagged with: string
has answer: http://stackoverflow.com/a/22080651
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22080752
has title: Comparing multiple string lengths in array Java
answer count: 4
tagged with: java
has answer: http://stackoverflow.com/a/22080623
has body: This is what's asked of us: Ask the English version of the first names of three of your family members using showInputDialog() method of the JOptionPane class. Display the name of the family member who has the longest first name as following. (If there is a tie, just display one of the two.) Daniel has the longest first name. This is what I have so far and am stuck: import javax.swing.JOptionPane; public class Foothill { public static void main(String[] args) { String[] names = new String[2]; for(int x=0; x &lt; 4; x++){ names[x] = (JOptionPane.showInputDialog("Enter your name")); for(int j=0; ) } if();{ JOptionPane.showMessageDialog(null,"The number with the greatest value is " + Max); } } } I'm having a hard time understanding how to test the length of each string in the array and then compare the length of the strings within the array. I understand there are built-in methods to do this, but can someone please explain how to do this through iteration? Thanks!

http://stackoverflow.com/comment/33568134
type: Comment
comment on: http://stackoverflow.com/q/22124831
score: 0
type: QuestionComment
has text: Thanks. Yes, I am not talking about languages. That was a question about data structures.

http://stackoverflow.com/a/22163074
has comment: http://stackoverflow.com/comment/33641841
accepted answer of: http://stackoverflow.com/q/22162785
has body: try this it may help public boolean reset() { DataInputStream is; DataOutputStream os; boolean result = true; String noReset = "Could not reset."; String reset = "The server has been reset."; try { Socket socket = new Socket(InetAddress.getByName("x.x.x.x"), 3994); String string = "{\"id\":1,\"method\":\"object.deleteAll\",\"params\":[\"subscriber\"]}"; is = new DataInputStream(socket.getInputStream()); os = new DataOutputStream(socket.getOutputStream()); PrintWriter pw = new PrintWriter(os); pw.println(string); pw.flush(); BufferedReader in = new BufferedReader(new InputStreamReader(is)); JSONObject json = new JSONObject(in.readLine()); if(!json.has("result")) { System.out.println(noReset); result = false; } is.close(); os.close(); } catch (IOException e) { result = false; System.out.println(noReset); e.printStackTrace(); } catch (JSONException e) { result = false; System.out.println(noReset); e.printStackTrace(); } System.out.println(reset); return result; }
type: Answer
answers question: http://stackoverflow.com/q/22162785
has comment: http://stackoverflow.com/comment/33639962
has comment: http://stackoverflow.com/comment/33641826
has comment: http://stackoverflow.com/comment/33640963
has comment: http://stackoverflow.com/comment/33640889
upvote count: 1
has comment: http://stackoverflow.com/comment/33641663
has comment: http://stackoverflow.com/comment/37611909
score: 1
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33640754

http://stackoverflow.com/comment/33723834
has text: Thanks, but it doesn't seem to work. I got: expected 'struct AppMessageCallbacksNode *' but argument is of type 'AppMessageCallbacksNode, so I tried to change it to app_message_register_callbacks(&messageCallBacks); which compiled but does not get the String from the phone. Thanks once again.
comment on: http://stackoverflow.com/a/22162266
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/22145811
answers question: http://stackoverflow.com/q/22145515
type: Answer
upvote count: 1
score: 1
downvote count: 0
has body: That simply adds a task to the tasks queue of the Java thread which is in charge of the rendering &amp; events for your whole application. Note : This thread is called EDT (Event Dispatching Thread).

xamarin.android
type: Tag
tag name: xamarin.android
tags question: http://stackoverflow.com/q/22167582

http://stackoverflow.com/q/22058430
has title: Point Of Sales - Stuck on arrays
favorite count: 0
has comment: http://stackoverflow.com/comment/33447880
has comment: http://stackoverflow.com/comment/33447914
possible better answer: http://stackoverflow.com/a/22058674
has answer: http://stackoverflow.com/a/22058521
accepted answer: http://stackoverflow.com/a/22058521
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33447941
type: Question
tagged with: object
tagged with: arrays
has body: Basically I have multiple classes and I'm trying to get an array of LineItem for each Item that a customer purchases. LineItem includes the UPC, Description, Price, Quantity, SubTotal and Discount which is all stored in a seperate class. I'm trying to get it that when you use the method addItemToSaleList it will add to the array. I need to use an array and not an array list, so I have to copy over the array to a temp array, and then recreate a new array adding to the number the array can store and then recopying it over. I'm stuck getting the array to generate. Below is the code I have public class Product { private double price; private String description; private String ProductCode; private DiscountStrategy discoutStrategy; public Product(double price, String description, String ProductCode, DiscountStrategy discoutStrategy) { this.price = price; this.description = description; this.ProductCode = ProductCode; this.discoutStrategy = discoutStrategy; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getProductCode() { return ProductCode; } public void setProductCode(String ProductCode) { this.ProductCode = ProductCode; } public DiscountStrategy getDiscountStrategy() { return discoutStrategy; } public void setDiscoutStrategy(DiscountStrategy discoutStrategy) { this.discoutStrategy = discoutStrategy; } } public class LineItem { private Product product; private double quantity; public LineItem(Product product, double quantity) { this.product = product; this.quantity = quantity; } //Calculates the Discount Amount whether or not it's a percentage or dollar //off public double getDiscountAmount () { return product.getDiscountStrategy().getDiscount(product.getPrice(), quantity); } //Calculates the Subtotal, gets the quantity from the DiscountStrategy and then //the price…
score: 0
answer count: 2
upvote count: 1
downvote count: 1
has answer: http://stackoverflow.com/a/22058674

http://stackoverflow.com/comment/33530566
type: Comment
has text: @user1988876 It's not exactly ignored. The `interrupt()` method raises the flag. The fact that the interrupted thread is in `sleep()` will cause the JVM to drop the flag and throw an `InterruptedException` in that thread's execution. You have to understand that thread interruption is something the developer has to implement. It's not done automatically. [Here's the tutorial](http://docs.oracle.com/javase/tutorial/essential/concurrency/interrupt.html) if you are interested.
comment on: http://stackoverflow.com/a/22104149
score: 0
type: AnswerComment

http://stackoverflow.com/q/22057646
tagged with: jpa
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33465863
has body: There's a way to map a relationship many-to-many, using the @jointable, and avoid the automatic cascade of jointable rows? The cascade property of the @ManyToMany annotation is for create/merge/delete the related entity (not the rows of jointable) and the insertable/updatable of joincolumns/ inversejoincolumns properties in @JoinTable is ignored when I persist/merge the owned entity of relationship. Example: In User (Owner) x Role (mappedby) relationship, when I merge an User with the collection of Role empty, all rows of table USER_ROLE is deleted for that user. Tks in advance. That's my point: For make the problem question simple, let's suppose that I have an User entity with three attributes: id, email and a set of Roles (owner, @manytomany, @jointable). I will merge an User entity that have at least one or more Roles, without find it through entityManager: User user = new User(); //detached user.setId(1L); // for merge user.setEmail("newemailaddress@example.com"); entityManager.merge(user); The result in database is: UPDATE user... /*ok!*/ delete from user_role where ... /* I'd like to avoid it! */
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33467018
tagged with: java
tagged with: hibernate
has comment: http://stackoverflow.com/comment/33467543
has comment: http://stackoverflow.com/comment/33464941
upvote count: 1
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33466444
has title: JPA (with Hibernate) @ManyToMany @JoinTable relationship cascade
has answer: http://stackoverflow.com/a/22062763
has comment: http://stackoverflow.com/comment/33465709
score: 0

http://stackoverflow.com/comment/33661326
has text: @gcotis; Take a look at SWIG (Simplified Wrapper and Interface Generator), JNI (Java Native Interface) and JNA (Java Native Access). But I'd say that Micro Focus page has all the details you need. In particular the blurb on com.microfocus.cobol.CobolBean and probably great hints in the array sample.
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22150498

http://stackoverflow.com/a/22140330
score: 1
upvote count: 1
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22139941
answers question: http://stackoverflow.com/q/22139941
type: Answer
has body: You need to use Collections#sort. It will take your Array List and a Comparator. You can create anonymous Comparator and in its compareTo method you will obtain that first value by splitting both the string and than compare them and return -1,0,1 accordingly. Hope this helps.

http://stackoverflow.com/a/22036242
accepted answer of: http://stackoverflow.com/q/22036060
has body: You can get values from oracle and set values from Resulset. Like this Connection con = YOUR_CONNECTION; PreparedStatment ps = con.prepareStatment(YOU SELECT); ResultSet result = ps.executeQuery(); while (result.next()) { pieModel.set(result.getSting("branch_code"), result.gtInt("accounts_opened ")); }
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/22036060
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/33731439
type: AnswerComment
comment on: http://stackoverflow.com/a/22163526
has text: Thanks but , post changing the elements , still i couln't pick up a specific date using webdriver.
type: Comment
score: 0

http://stackoverflow.com/q/22069141
has title: Using Java/Webdriver I want to select the second element with the same name
score: 0
has answer: http://stackoverflow.com/a/22069191
has body: I have the following piece of java for clicking an icon. driver.findElement(By.cssSelector("a[class='icon']")).click(); I cannot select a unique ID, as they change everytime I login. There are three classNames with 'icon' as the className on the page, and I want webdriver/java/selenium to click the second one. How do I do this? Thanks in advance,
answer count: 1
accepted answer: http://stackoverflow.com/a/22069191
type: AnsweredQuestion
tagged with: java
tagged with: selenium
type: Question

http://stackoverflow.com/a/22059114
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22059018
has comment: http://stackoverflow.com/comment/33449060
has comment: http://stackoverflow.com/comment/33449134
has comment: http://stackoverflow.com/comment/33449236
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/33449097
has comment: http://stackoverflow.com/comment/33449043
has comment: http://stackoverflow.com/comment/33449221
has body: What you are getting is the output of the default toString() in Object class. If you want to print something meaningful then you need to Override the toString() method in your ArrayStack class. public String toString() { // iterate through your array and generate a String consisting of all elements // alternatively you can take advantage of the fact that Arraylist has already // overriden toString() method to print all elements return st.toString(); }
score: 1
accepted answer of: http://stackoverflow.com/q/22059018
upvote count: 1

http://stackoverflow.com/comment/33517770
comment on: http://stackoverflow.com/a/22097250
has text: Inorder to work as the html select tag, do my custom Simple Tag have to include all the attributes of the select html tag? (not just only optionList, name and size)
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33609782
has text: Is the line number in the stack trace this: `for(int i = 0; i<digitalIOModeSwitchArray.length;i++){` or this: `digitalIOModeSwitchArray[i].setOnCheckedChangeListener(`? Please post how (and when) you instantiate the array.
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22149006

http://stackoverflow.com/comment/33481788
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22077187
has text: And note that your examples above is comparing apples to oranges since the first case does not scan to find the location to replace.
score: 0

http://stackoverflow.com/a/22150019
downvote count: 0
answers question: http://stackoverflow.com/q/22149403
type: Answer
has body: Unfortunately this kind of flexibility is not possible. Map is defined as &lt;K, V&gt; and basically that's that. The only ways are what you've presented: create a key object or use a map of maps. (Alternatively I suppose you could also write your own Map implementation.) Since you are using enum it's actually convenient to make a wrapper object, but I'd recommend a slight twist on it. You can make it immutable and only have a single instance for each pair. This will avoid object creation. You can override equals if you want but since there will only be one of each pair, identity would be sufficient. You can use == to compare them which also means you could use IdentityHashMap. public final class DiceCardPair { private final DiceEyes eyes; private final CardSuit suit; private DiceCardPair( final DiceEyes eyes, final CardSuit suit ) { this.eyes = eyes; this.suit = suit; } @Override public int hashCode() { // very compact hash code // make shift bigger if more constants return eyes.ordinal() | suit.ordinal() &lt;&lt; 3; } @Override public boolean equals(Object obj) { if(!(obj instanceof DiceCardPair)) { return false; } DiceCardPair pair = (DiceCardPair)obj; return eyes == pair.eyes &amp;&amp; suit == pair.suit; } private static final DiceCardPair[][] values; static { DiceEyes[] eyes = DiceEyes.values(); CardSuit[] suits = CardSuit.values(); values = new DiceCardPair[eyes.length][suits.length]; for(int i = 0; i &lt; values.length; i++) { for(int k = 0; k &lt; values[i].length; k++) { values[i][k] = new DiceCardPair( eyes[i], suits[k] ); } } } public static DiceCardPair valueOf(DiceEyes e, CardSuit s) { return values[e.ordinal()][s.ordinal()]; } } You don't even really have to use the instances of a class like this directly either, for example: Value v = map.get(DiceCardPair.valueOf(DiceEyes.ONE, CardSuit.SPADES)); if(v == null) { map.put(DiceCardPair.valueOf(DiceEyes.ONE, CardSuit.SPADES), new Value()); }
score: 1
upvote count: 1

http://stackoverflow.com/a/22021663
has comment: http://stackoverflow.com/comment/33382090
has comment: http://stackoverflow.com/comment/33382091
answers question: http://stackoverflow.com/q/22021571
type: Answer
has comment: http://stackoverflow.com/comment/33382143
score: 1
has body: Try the following code: import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; public class Question1 { public static void main(String[] args) { MyFrame f = new MyFrame("Simple Submit Cancel Form"); f.init(); } } class MyFrame extends JFrame { MyFrame(String title) { super(title); } private JPanel mainPanel; private GridBagConstraints cText = new GridBagConstraints(); private GridBagConstraints cButton = new GridBagConstraints(); private GridBagLayout gbLayout = new GridBagLayout(); void init() { mainPanel = new JPanel(); mainPanel.setLayout(gbLayout); mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20)); this.setContentPane(mainPanel); cText.anchor = GridBagConstraints.WEST; cText.weightx = 0.0; cText.gridx = 0; cText.gridy = 0; JTextField tf = new JTextField(20); gbLayout.setConstraints(tf, cText); mainPanel.add(tf); cButton.gridwidth = 4; cButton.weightx = 0.0; cButton.gridx = 0; cButton.gridy = 1; JPanel demoPanel = new JPanel(); JButton b = new JButton("Submit"); gbLayout.setConstraints(demoPanel, cButton); demoPanel.add(b); b = new JButton("Cancel"); // gbLayout.setConstraints(b,cButton); demoPanel.add(b); mainPanel.add(demoPanel); this.pack(); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); } } I have just put the two buttons inside a JPanel and put the JPanel inside the GridBagLayout Panel !
has comment: http://stackoverflow.com/comment/33388747
upvote count: 1
has comment: http://stackoverflow.com/comment/33382191
has comment: http://stackoverflow.com/comment/33382320
downvote count: 0

http://stackoverflow.com/q/22019624
upvote count: 1
possible better answer: http://stackoverflow.com/a/22019769
has answer: http://stackoverflow.com/a/22019798
accepted answer: http://stackoverflow.com/a/22019798
favorite count: 0
has comment: http://stackoverflow.com/comment/33378074
has comment: http://stackoverflow.com/comment/33378156
tagged with: abstract-class
has answer: http://stackoverflow.com/a/22019937
tagged with: nullpointerexception
has comment: http://stackoverflow.com/comment/33378161
has answer: http://stackoverflow.com/a/22019729
has title: NullPointerException When trying to call Abstract class - Java
answer count: 4
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33378143
has comment: http://stackoverflow.com/comment/33378582
downvote count: 0
has comment: http://stackoverflow.com/comment/33378247
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22019769
type: Question
has comment: http://stackoverflow.com/comment/33378041
has body: When my submit button is clicked it validates input fields depending on which fields were used, then calls the writeItemToFile() method. private void btnSubmit_actionPerformed(ActionEvent e) { if (validateInput()){ if (enabledFields == "music") createMusicItem(); else if (enabledFields == "product") createProductItem();} writeItemToFile(); }//btnSubmit_actionPerformed The writeItemToFile() method is small and frankly could be skipped, but is needed for my assignment. It calls the write(Item item) method in my Inventory class. It sends along the item declaration at the top of my code. Item item; The problem is that the Item class is abstract so when it's passed it gives me a NullPointerException. Below is my write(Item item) method just for good measure. My question is this, is there a way I have to instantiate the abstract class? How do I avoid this method. public void write(Item item) { invFilename = item.getFileName(); File inventoryFile = new File(invFilename); try { invWriter = new FileWriter(inventoryFile, true); } // try catch (IOException e) { System.out.println("ERROR: File " + invFilename + "could not opened: " + e.getMessage()); }//catch try { invWriter.write(item.getFileRecord()); }//try catch (IOException e) { System.out.println("ERROR: Product " + item.getFileRecord() + "could not be written to file " + invFilename + ": " + e.getMessage()); }//catch }//write(Item item) Please be gentle. Error message: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at Inventory.write(Inventory.java:13) at AddItemFrame.writeItemToFile(AddItemFrame.java:575) at AddItemFrame.btnSubmit_actionPerformed(AddItemFrame.java:500) at AddItemFrame.access$1(AddItemFrame.java:492) at AddItemFrame$3.actionPerformed(AddItemFrame.java:217) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultB…
has comment: http://stackoverflow.com/comment/33378186
has comment: http://stackoverflow.com/comment/33378268
has comment: http://stackoverflow.com/comment/33378502
has comment: http://stackoverflow.com/comment/33378575

http://stackoverflow.com/comment/33593096
comment on: http://stackoverflow.com/a/22139109
score: 0
type: Comment
has text: same result, it still skips
type: AnswerComment

http://stackoverflow.com/comment/33376131
score: 0
type: AnswerComment
type: Comment
has text: pwas: "The other problem is random access to char (via charAt)." I think that's a different way of saying the same thing: It needs to backtrack at any time. @fge: Not familiar with those classes. I'll take a look.
comment on: http://stackoverflow.com/a/22018249

http://stackoverflow.com/comment/33414699
type: Comment
has text: As another troubleshooting approach, on the working development server, what happens if you change "folderId" (the String) to "folderOMG"? Does it all still work?
type: QuestionComment
comment on: http://stackoverflow.com/q/22039341
score: 0

http://stackoverflow.com/a/22018508
answers question: http://stackoverflow.com/q/22018128
has body: ctrl-F12 swaps between landscape and portrait. Default setting is related to your screen resolution setup I think.
score: 0
type: Answer

http://stackoverflow.com/q/22068375
tagged with: null
tagged with: arrays
tagged with: nullpointerexception
upvote count: 1
answer count: 1
has answer: http://stackoverflow.com/a/22068634
favorite count: 0
type: UnansweredQuestion
has title: Java - Trying to put null values on array
downvote count: 0
score: 1
tagged with: java
has body: I'm trying to put null values on some values of this array: public ElectricInstallation(){ this.dim1 = (int) Math.random()*85 + 1; this.dim2 = (int) Math.random()*85 + 1; this.dim3 = (int) Math.random()*85 + 1; for(int i = 0; i &lt; this.dim1; i++){ for(int j = 0; j &lt; this.dim2; j++){ for(int k = 0; k &lt; this.dim3; k++){ this.machine[i][j][k] = null; } } } } Ergo, I'm trying to create empty values on this array to do this after that: public void makeScenario(){ for(int i = 0; i &lt; this.dim1; i++){ for(int j = 0; j &lt; this.dim2; j++){ for(int k = 0; k &lt; this.dim3; k++){ if(Math.random() &lt; 0.7){ this.machines[i][j][k] = new ElectricMachine((int) Math.random()*15000 + 1); if(Math.random() &lt; 0.5){ this.machine[i][j][k].clic(); } } } } } } In other words, I want to make some values to be ElectricMachine and others to be null, but java throws me this: "java.lang.NullPointerException". What can I do?
type: Question

http://stackoverflow.com/q/22021425
score: 0
tagged with: java
tagged with: jpanel
has answer: http://stackoverflow.com/a/22021658
has comment: http://stackoverflow.com/comment/33381486
has comment: http://stackoverflow.com/comment/33389736
type: UnansweredQuestion
has body: I've created a simple program that draws a rectangle which falls down the screen at a constant rate. I first run Main.java: package highst; public class Main { public static void main(String args[]){ new GameFrame(); } } which creates a new instance of GameFrame.java: package highst; import javax.swing.JFrame; public class GameFrame extends JFrame { public GameFrame() { super("Falling rectangle"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(800, 600); GameLogic game = new GameLogic(); this.getContentPane().add(game); this.setVisible(true); game.run(); } } Which in turn creates a new instance of GameLogic.java: package highst; import java.awt.Color; import java.awt.Graphics; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.swing.JPanel; public class GameLogic extends JPanel implements Runnable, KeyListener { Marvin marvin; private enum GameState{ Running, Dead } GameState state = GameState.Running; public GameLogic(){ marvin = new Marvin(50, 50); Thread thread = new Thread(this); thread.start(); addKeyListener(this); setFocusable(true); this.setBackground(Color.black); } public void paintComponent(Graphics g){ super.paintComponent(g); g.setColor(Color.white); g.fillRect(marvin.getX(), marvin.getY(), 50, 50); } @Override public void keyPressed(KeyEvent e) { if(e.getKeyCode() == KeyEvent.VK_SPACE){ marvin.jump(); } } @Override public void keyReleased(KeyEvent e) { // TODO Auto-generated method stub } @Override public void keyTyped(KeyEvent e) { // TODO Auto-generated method stub } @Override public void run() { if(state == GameState.Running){ while(true){ marvin.update(); repaint(); try { Thread.sleep(17); } catch (InterruptedException e) { e.printStackTrace(); } } } } } Which finally makes use of what will be my playable character, Marvin.java who is now a white rectangle: package highst; public class Marvin { private int x, y; public Marvin(int x, int y){ this.x = y; this.y = y; } public void update(){ y -= -1; } pu…
has answer: http://stackoverflow.com/a/22028390
has title: Moving a rectangle incredibly choppy
type: Question
tagged with: jframe
answer count: 3
has answer: http://stackoverflow.com/a/22021686
has comment: http://stackoverflow.com/comment/33381509

http://stackoverflow.com/a/22156855
answers question: http://stackoverflow.com/q/22156690
type: Answer
downvote count: 0
score: 1
has body: Here you are declaring ml as a generic List. Since you are using a wildcard, you can only know that the actual type of the contained objects might be a Number or one of it's subtype. But the JVM doesn't really know what exactly this type is. Thus, this declaration makes ml to be a read-only List. That's why you cannot add any element in it, just get and read them. Change it to: List
upvote count: 1

http://stackoverflow.com/comment/33533245
type: AnswerComment
comment on: http://stackoverflow.com/a/22032946
score: 0
type: Comment
has text: I was indeed editing the one passed in instead of the one in the state that I was passing in. My professor had specified in docs that the one passed in and the one in state were the same name (probably a typo?) and once I changed the name and initialized the arraylist, it worked fine. Thank you so much for the help.

http://stackoverflow.com/comment/33537604
type: AnswerComment
comment on: http://stackoverflow.com/a/22108120
score: 0
type: Comment
has text: `Random()` empty constructor used seed based on the time, therefore leading to a different sequences in each run. If you use the same custom seed then you'll get same results.

http://stackoverflow.com/comment/33467192
has text: Thanks. Got most of it done, only one problem remains: http://stackoverflow.com/questions/22064173 Do you have an idea on that too?
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22068316

http://stackoverflow.com/q/22024701
type: Question
score: 3
has answer: http://stackoverflow.com/a/29663716
has comment: http://stackoverflow.com/comment/33387781
answer count: 1
tagged with: junit
downvote count: 0
favorite count: 0
tagged with: maven
has title: Surefire JUnit test does not log failed Assume in test xml files
has body: I am using org.apache.maven.plugins maven-surefire-plugin 2.16 and junit junit 4.11 to test my project. I have a very simple test method @Test public void test() throws IOException { Assume.assumeTrue("I am broken, so I am ignored", false); // some tests } When I build the project with maven, I get the following code snippet in the surefire xml file <skipped/> I do not think this is the correct behavior of surefire, since assumption failures are treated the same as ignored, it should follow the same logging standard as ignored. This JIRA clearly says the reason should be logged. What do you think? Is there a workaround to get that message into the xml file? Thanks Update 1 The reason I cannot use @Ignore is because I do not want to hard code a test as ignored. I want it to be skipped based on some precondition that cannot be determined at coding time.
upvote count: 3
type: UnansweredQuestion
tagged with: java
tagged with: surefire

titanium
type: Tag
tags question: http://stackoverflow.com/q/22070753
tag name: titanium

http://stackoverflow.com/a/22157475
answers question: http://stackoverflow.com/q/22156928
upvote count: 1
type: Answer
downvote count: 0
score: 1
has body: Condition in while statement checks if X == Y and X &lt; Y. It breaks of out of while loop if those conditions are not valid anymore. Consider below palindrome. Iteration 1: X Y + + | | +-v--+----+---+---+---+---+---+---+-v-+ | | | | | | | | | | | A | B | C | D | E | D | C | B | A | +----+----+---+---+---+---+---+---+---+ Iteration 2: +----+----+---+---+---+---+---+---+---+ | | | | | | | | | | | A | B | C | D | E | D | C | B | A | | | | | | | | | | | +----+----+---+---+---+---+---+---+---+ ^ ^ | | + + X Y Iteration 3: X Y + + | | v v +----+----+---+---+---+---+---+---+---+ | | | | | | | | | | | A | B | C | D | E | D | C | B | A | | | | | | | | | | | +----+----+---+---+---+---+---+---+---+ Iteration 4: X Y + + | | +- --+----+---+-v-+---+-v-+---+---+- -+ | | | | | | | | | | | A | B | C | D | E | D | C | B | A | +----+----+---+---+---+---+---+---+---+ Iteration 5: Loop would break at this point. Since X &lt; Y is not valid anymore XY ++ || +----+----+---+---+vv-+---+---+---+---+ | | | | | | | | | | | A | B | C | D | E | D | C | B | A | | | | | | | | | | | +----+----+---+---+---+---+---+---+---+ If above example was not a palindrome and looks something like this +- --+----+---+-v-+---+-v-+---+---+- -+ | | | | | | | | | | | A | B | K | D | E | D | C | B | A | +----+----+---+---+---+---+---+---+---+ Then your while loop breaks at 3rd Iteration since you first condition X==Y won't be valid. At this point X will still be Less than Y. So if a string is not a palindrome while loop will surely break before both X &amp; Y meet i.e. always X &lt; Y

http://stackoverflow.com/comment/33435224
has text: it do not create target folder with [ mvn clean install ]. Should I add any other thing ?
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22051142

http://stackoverflow.com/comment/33360232
has text: Please give some more information. What exactly do you want to achieve? You write, that you want to reuse the same FrameBuffer as Texture. But then you write "will return the same texture everytime.". Isn't that what you want?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22009475
score: 1

http://stackoverflow.com/comment/33580197
has text: Yes i understand. Have tried a very basic class public class Test{ int x=12; public Test(){} public int add(int y){ return this.x+y; } but its not compiling in beanshell! :(
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22131172

instantiation
type: Tag
tags question: http://stackoverflow.com/q/22106441
tags question: http://stackoverflow.com/q/22168275
tag name: instantiation
tags question: http://stackoverflow.com/q/22117072

dependency-injection
tags question: http://stackoverflow.com/q/22136211
tags question: http://stackoverflow.com/q/22090473
tags question: http://stackoverflow.com/q/22010530
type: Tag
tags question: http://stackoverflow.com/q/22061324
tags question: http://stackoverflow.com/q/22158940
tags question: http://stackoverflow.com/q/22124769
tags question: http://stackoverflow.com/q/22092292
tags question: http://stackoverflow.com/q/22130547
tags question: http://stackoverflow.com/q/22059907
tags question: http://stackoverflow.com/q/22034554
tags question: http://stackoverflow.com/q/22149683
tags question: http://stackoverflow.com/q/22101191
tags question: http://stackoverflow.com/q/22022019
tags question: http://stackoverflow.com/q/22047781
tag name: dependency-injection

java.util.scanner
tags question: http://stackoverflow.com/q/22055271
tags question: http://stackoverflow.com/q/22068618
tags question: http://stackoverflow.com/q/22122983
tag name: java.util.scanner
tags question: http://stackoverflow.com/q/22134643
tags question: http://stackoverflow.com/q/22020224
tags question: http://stackoverflow.com/q/22070535
tags question: http://stackoverflow.com/q/22085493
tags question: http://stackoverflow.com/q/22054655
type: Tag
tags question: http://stackoverflow.com/q/22111206
tags question: http://stackoverflow.com/q/22026415
tags question: http://stackoverflow.com/q/22050391
tags question: http://stackoverflow.com/q/22005370
tags question: http://stackoverflow.com/q/22139036
tags question: http://stackoverflow.com/q/22022678
tags question: http://stackoverflow.com/q/22104364
tags question: http://stackoverflow.com/q/22103530
tags question: http://stackoverflow.com/q/22141468
tags question: http://stackoverflow.com/q/22050545

http://stackoverflow.com/q/22081117
tagged with: java
has answer: http://stackoverflow.com/a/22082524
has title: WebView getUrl() from another thread
has comment: http://stackoverflow.com/comment/33488712
answer count: 1
has comment: http://stackoverflow.com/comment/33489119
downvote count: 0
has body: This is my first app that uses the WebView for my web page. I want to know how to get the current url from a webview, I'm using this: SessionDetector session = new SessionDetector(this); webView = (WebView) findViewById(R.id.content); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setDomStorageEnabled(true); webView.loadUrl(AppWebViewUrls.getBaseUrl()); session.start(); And this class for get the current url: class SessionDetector extends Thread { private boolean isLogged = false; private MainActivity context; SessionDetector(MainActivity context) { this.context = context; } @Override public void run() { while (!isLogged) { if (context.webView.getUrl().contains("cpanel")) { isLogged = true; } } context.createMenu(); } } But, Android throws an exception with the message "All webview methods must be called on the same thread". I would be glad to know how and why is the cause for this error.
favorite count: 0
has comment: http://stackoverflow.com/comment/33491038
has comment: http://stackoverflow.com/comment/33488678
tagged with: android
has comment: http://stackoverflow.com/comment/125661588
type: UnansweredQuestion
tagged with: multithreading
tagged with: webview
upvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33490421
score: 1

http://stackoverflow.com/comment/33568169
comment on: http://stackoverflow.com/q/22124892
score: 0
type: QuestionComment
has text: @NiksTyagi I eddited fraction but my main class is Assignment1
type: Comment

http://stackoverflow.com/comment/33595737
type: Comment
comment on: http://stackoverflow.com/q/22140906
score: 0
has text: The problem is somwhere else, please post the exception. Also consider not to use HibernateTemplate: http://stackoverflow.com/questions/5104765/hibernatedaosupport-is-not-recommended-why
type: QuestionComment

http://stackoverflow.com/q/22077370
has comment: http://stackoverflow.com/comment/33485060
has comment: http://stackoverflow.com/comment/33481490
has comment: http://stackoverflow.com/comment/33481798
upvote count: 1
has comment: http://stackoverflow.com/comment/33482020
answer count: 1
linked to: http://stackoverflow.com/q/22079633
has comment: http://stackoverflow.com/comment/33482004
favorite count: 0
has comment: http://stackoverflow.com/comment/33481582
has comment: http://stackoverflow.com/comment/33481423
has comment: http://stackoverflow.com/comment/33481462
has body: I'm trying to copy a file from /path/to the/file.ext (yes, it has spaces, I suspect this is at least part of the trouble) to /data/data/com.my_pkg.app/file.ext. In my (root) app, I do: String cmd = "su -c \"cp /path/to\\ the/file.ext /data/data/com.my_pkg.app/file.ext\""; try { Process process; process = new ProcessBuilder(cmd).start(); try { process.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } } catch (IOException e1) { e1.printStackTrace(); } But this raises an IOException: no such file or directory. Checking my sanity, I opened a root file explorer app, navigated to the path above, copied it, and pasted it in my app's directory, and everything was fine. Why is cp not finding it? - the file explorer app must be doing the same (well, with modification that makes it work!) thing underneath all that GUI. Edit: the full error: W/System.err( 2441): java.io.IOException: Error running exec(). Command: [su -c "cp /path/to\ the/file.ext /data/data/com.my_pkg.app/file.ext"] Working Directory: null Environment: [ANDROID_ROOT=/system, EMULATED_STORAGE_SOURCE=/mnt/shell/emulated, LOOP_MOUNTPOINT=/mnt/obb, EMULATED_STORAGE_TARGET=/storage/emulated, ANDROID_BOOTLOGO=1, LD_LIBRARY_PATH=/vendor/lib:/system/lib, EXTERNAL_STORAGE=/storage/emulated/legacy, ANDROID_SOCKET_zygote=10, ANDROID_DATA=/data, PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin, ANDROID_ASSETS=/system/app, ASEC_MOUNTPOINT=/mnt/asec, BOOTCLASSPATH=/system/framework/core.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/framework2.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/webviewchromium.jar, ANDROID_PROPERTY_WORKSPACE=9,0, ANDROID_STORAGE…
tagged with: android
has comment: http://stackoverflow.com/comment/33485134
has comment: http://stackoverflow.com/comment/33482524
has answer: http://stackoverflow.com/a/22079497
accepted answer: http://stackoverflow.com/a/22079497
type: AnsweredQuestion
tagged with: ioexception
downvote count: 0
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33482640
has title: Android app shell "no such file or directory", fine in a file explorer and adb
type: Question
tagged with: nosuchfileexception
has comment: http://stackoverflow.com/comment/33483018
has comment: http://stackoverflow.com/comment/33484836
has comment: http://stackoverflow.com/comment/33483685

http://stackoverflow.com/comment/33481877
score: 1
type: QuestionComment
type: Comment
has text: @trutheality: I would suggest that complaining before running isn't the same as "running just fine". If you have to go through what is effectively a warning dialog before doing something where normally you wouldn't, it's not "just fine". Anyway, my main point is that the question doesn't mention *any* of that, nor even which IDE is involved. It's a poor question, and I'm perfectly content with my downvote.
comment on: http://stackoverflow.com/q/22076688

http://stackoverflow.com/comment/33383989
comment on: http://stackoverflow.com/q/22022722
has text: Yes, an "ars" is something else entirely.
type: Comment
type: QuestionComment
score: 4

http://stackoverflow.com/a/22017105
has comment: http://stackoverflow.com/comment/33373859
has comment: http://stackoverflow.com/comment/33375187
has comment: http://stackoverflow.com/comment/33373899
has comment: http://stackoverflow.com/comment/33378444
score: 0
answers question: http://stackoverflow.com/q/22016978
has comment: http://stackoverflow.com/comment/33375605
has comment: http://stackoverflow.com/comment/33376487
has comment: http://stackoverflow.com/comment/33373493
has comment: http://stackoverflow.com/comment/33376755
has body: And what happens now? If it's that you only show one error, it's because you are throwing an exception and have only a single catch block. If you want to catch all of them and accumulate errors then you need to put a try/catch around each individual chunk of code that can throw the exceptions.
type: Answer
has comment: http://stackoverflow.com/comment/33374022
has comment: http://stackoverflow.com/comment/33377923
has comment: http://stackoverflow.com/comment/33375150
has comment: http://stackoverflow.com/comment/33377679
has comment: http://stackoverflow.com/comment/33375095
has comment: http://stackoverflow.com/comment/33378168
has comment: http://stackoverflow.com/comment/33374658
has comment: http://stackoverflow.com/comment/33373769
has comment: http://stackoverflow.com/comment/33373644
has comment: http://stackoverflow.com/comment/33376803

http://stackoverflow.com/a/22071788
answers question: http://stackoverflow.com/q/22070274
type: Answer
score: 2
downvote count: 0
has body: Doesn't the inclusion of ORM make the application heavy? This cannot be answered objectively. Firstly, what do "light" and "heavy" mean? Lets assume we are talking about some measure of the application: we could be talking about the size of the application source code; i.e. the stuff that the programmer wrote we could be talking about the size of the application binary ... including the libraries the application uses we could be talking about the amount of memory used by the application, or the CPU time, or a measure of database traffic or disc traffic it generates. But that just tells us what lighter and heavier mean. What about "light" and "heavy"? Is there an objective value for any of these measures where we can say "light" or "heavy"? No ... there isn't. But getting back to lighter / heavier. Can we say that using an ORM makes an application heavier? On most measures, yes (probably), but in one important measure, the answer is clearly no. That is, when we use an ORM, we would expect that the programmer has less code (of various forms) to write than if the same functionality was implemented using JDBC, SQL &amp; an RDBMs. The other question that you didn't ask is whether it matters that an application is lighter or heavier. And I would say, that it really depends on the application, the platform and the development project's resources and timelines. For instance, if I have a challenging set of requirements and a tight deadline, then I might use ORM irrespective of whether ORM uses more memory, CPU, database bandwidth, etc ... because it is lighter on the development side, and that means my project can be completed on time. In summary: Does ORM make an application heavy? This is not an meaningful question. Does ORM make it heavier? It depends on what you are measuring. Does it matter? Not if ORM heaviness is the trade-off for on-time and under-budget. Is ORMLite really light-weight? Again not objectively answerable, and probably not relevant ... unless you are wo…
upvote count: 2

http://stackoverflow.com/a/22139691
upvote count: 1
answers question: http://stackoverflow.com/q/22139645
type: Answer
has comment: http://stackoverflow.com/comment/33593707
downvote count: 0
score: 1
has body: you are using the same instance of tempStudent. So each element of the ArrayList is pointing to the same Students object. Create before everytime you are inserting into the list.

http://stackoverflow.com/q/22065542
answer count: 2
has title: Why storm replays tuple from spout instead of retry on crashing component?
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/22068286
linked to: http://stackoverflow.com/q/16457830
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/22068286
tagged with: apache-storm
type: Question
has body: I am using storm to process online problems, but I cant't understand why storm replays tuple from spout . Retrying on what crashed may be more effective than replaying from root, right? Anyone can help me? Thx
possible better answer: http://stackoverflow.com/a/22066610
score: 4
has answer: http://stackoverflow.com/a/22066610
upvote count: 4

http://stackoverflow.com/comment/33409862
score: 0
type: Comment
type: QuestionComment
has text: the object which i created and saved in session ,when will this object will be removed from session?
comment on: http://stackoverflow.com/q/22037125

http://stackoverflow.com/comment/33497324
type: QuestionComment
comment on: http://stackoverflow.com/q/22085267
has text: @Gene I thought the question stated that there could be a preprocessing step of O(kn) and after that step the searches need to be below O(k + log n), which as dashblinkenlight pointed out would be O(log kn).
score: 0
type: Comment

http://stackoverflow.com/q/22038504
type: Question
has body: I am not that good at java program, i am trying to do something like this please help. I want to make a simple translator for one particular language, say korean. Can i download a korean - english dictionary from internet and use it as a hash map or a dictionary datastructure to search for korean word based on the english input i give?
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/22040684
favorite count: 0
has answer: http://stackoverflow.com/a/22038670
has title: Java code to translate using a particular language dictionary
type: UnansweredQuestion
tagged with: python
tagged with: dictionary
score: 2
upvote count: 2
tagged with: java

http://stackoverflow.com/comment/33535093
type: Comment
type: QuestionComment
has text: @DeadChex The platforms for which JDKs and JREs exist are listed here: https://jdk8.java.net/download.html
comment on: http://stackoverflow.com/q/22106130
score: 0

http://stackoverflow.com/comment/33536206
comment on: http://stackoverflow.com/q/22107359
score: 0
has text: Sorry for wrong code I edited it, I equated it to head->next
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22153726
tagged with: java
has comment: http://stackoverflow.com/comment/38048211
has comment: http://stackoverflow.com/comment/33657942
answer count: 2
has comment: http://stackoverflow.com/comment/33621433
has comment: http://stackoverflow.com/comment/33668986
favorite count: 0
tagged with: spring-batch
has title: Repeat steps of a Spring Batch flow for each item of a list
has comment: http://stackoverflow.com/comment/33668801
score: 8
linked to: http://stackoverflow.com/q/10530652
downvote count: 0
has comment: http://stackoverflow.com/comment/33656695
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/33025879
tagged with: spring
upvote count: 8
type: Question
has body: How can I implement a Spring Batch job which has to read a list and then repeat one or more steps for each item in the list? I am currently reading the list in the one step and then I put it in the job context. But the job context is persisted in the DB and if it gets too big, a CLOB has to be used and I do not have access to one. So I am looking for a solution that doesn't involve storing the whole list on the job context. Of course, I could simply put the list in a local variable. But I am curious whether there is a more Spring Batch-like option.
has answer: http://stackoverflow.com/a/22183688

http://stackoverflow.com/comment/33372172
has text: `instance` of an `abstract` class ?? ^_^ OOP break.
comment on: http://stackoverflow.com/q/22016405
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/33932119
type: QuestionComment
has text: @MikeMB: The data result as a Cartesian product of several dimensions, e.g., a date dimension, a scenario dimension, etc. And of course a TB of RAM sounds much, but may be affordable in a couple of years. But managing memory consumption by an adaptive forget/recalc mechanism is actually part of my vision, even if my computer has only 36GB of RAM - I do not think it is strictly _necessary_ to use a database.
comment on: http://stackoverflow.com/q/22106121
score: 0
type: Comment

http://stackoverflow.com/comment/33388576
has text: A class is a class, and it defines a type. Whether it's abstract or not doesn't matter. The whole point of polymorphism is that, if an object has a given type, then it implements the methods defined in that type. You don't need to know the concrete type of the object to use it. That's why you can use Lists, Sets, Iterators, etc. although they're interfaces (i.e. purely abstract types).
comment on: http://stackoverflow.com/a/22022711
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33482589
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22047781
has text: let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/48608/discussion-between-jwells131313-and-dejel)
score: 0

http://stackoverflow.com/comment/33425562
type: QuestionComment
comment on: http://stackoverflow.com/q/22046082
has text: and a split with no split character... what does it lead to?
score: 0
type: Comment

http://stackoverflow.com/a/22019769
score: 0
answers question: http://stackoverflow.com/q/22019624
type: Answer
has comment: http://stackoverflow.com/comment/33378526
has comment: http://stackoverflow.com/comment/33378468
has comment: http://stackoverflow.com/comment/33378430
has body: the Item class is abstract That means you cannot have an object of this class. You need to extend the abstract class and pass an object of your new class. Check here : Abstract classes cannot be instantiated, but they can be subclassed
has comment: http://stackoverflow.com/comment/33378808

http://stackoverflow.com/comment/33416828
type: Comment
comment on: http://stackoverflow.com/q/22033660
has text: thanks bimalesh for the links but could get answers to my question
score: 0
type: QuestionComment

http://stackoverflow.com/comment/33485103
type: Comment
type: QuestionComment
score: 2
has text: What is `SelectItem`?
comment on: http://stackoverflow.com/q/22079272

http://stackoverflow.com/comment/33364452
type: Comment
type: QuestionComment
has text: with or without quotes don't make any diffrence.
comment on: http://stackoverflow.com/q/22010686
score: 0

http://stackoverflow.com/comment/33528271
has text: I have this save problem, what you need to do is copy and past the code yourself; that way you can make it whatever you want.
comment on: http://stackoverflow.com/q/22103064
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/33555875
has text: Thanks for the edit. I just wrote this down without checking that it would actually run.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/22118220
score: 0

http://stackoverflow.com/a/22096069
type: Answer
has comment: http://stackoverflow.com/comment/33515455
has body: I'd invert your process. Instead of polling the source for changes, I'd make your source to write the changes into a queue (JMS came to my mind, but it could be any queue). This will make your job easier and probably with better performance. To do that in your external system is just as simple as adding some triggers in the DB or any listener in the persistence layer (if there is any), just like any audit procedure would do. Of course, this option does only make sense if you have control over your source data. Why do you need many threads to do the synchronization?
has comment: http://stackoverflow.com/comment/33515284
answers question: http://stackoverflow.com/q/22095719
has comment: http://stackoverflow.com/comment/33517304
score: 0

http://stackoverflow.com/comment/33510941
comment on: http://stackoverflow.com/q/22093426
has text: @Isaac you are right, I did not get it that those are configurables
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/a/22130549
answers question: http://stackoverflow.com/q/22130407
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/22130407
score: 0
has body: Since the problem is not specified explicitly, I am pointing out the obvious errors with the presumption that 'Testing' encrypted should print 'Testing' once decrypted. AES is a symmetric key algorithm, hence you have to use the same key for encrypting and decrypting (k2 should not be there at all) c.doFinal of the encrypted data doesn't make much sense, this should be reference to your Cipher DECRYPT_MODE -> c2 Hence, change: c2.init(Cipher.DECRYPT_MODE, k2); To: c2.init(Cipher.DECRYPT_MODE, k); And change: byte[] data = c.doFinal(encryptedData); To: byte[] data = c2.doFinal(encryptedData); To print the final outcome: Change: System.out.println(data); To: System.out.println(new String(data));

http://stackoverflow.com/comment/33594420
type: Comment
has text: @SotiriosDelimanolis the last version in http://www.mvnrepository.com/ is 1.9.13
score: 0
comment on: http://stackoverflow.com/q/22140080
type: QuestionComment

http://stackoverflow.com/comment/33518288
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22059041
type: AnswerComment
has text: Ah ok. Are you using either Jackson, Moxy, or Jettison as a JSON library with Jersey? If so you can make the first method parameter a `JsonObject` (which will differ based on the json lib you are using) and pull the strings from that

http://stackoverflow.com/q/22066739
has body: After running app-engine java project multiple times in eclipse, app-engine local server doesn't work. I am getting error "This webpage is not available" in Google chrome. But eclipse console says that "dev App Server is now running". But using dev_appserver.cmd works fine, it is too difficult when developing the project. Any ideas to solve this? PS: rerunning is done after stopping the current execution of the server.
type: UnansweredQuestion
tagged with: java
tagged with: eclipse
type: Question
answer count: 2
score: 0
tagged with: google-app-engine
has answer: http://stackoverflow.com/a/23689560
has answer: http://stackoverflow.com/a/22067686
has title: google app engine local server doesn't work run after multiple times in eclipse

http://stackoverflow.com/comment/33569713
type: Comment
has text: Your `if (next == null)` condition has the same issue your base case originally did. Imagine your list contains only [0, -20]. Now insert -10 and walk through the code in your head.
comment on: http://stackoverflow.com/a/22126035
type: AnswerComment
score: 0

http://stackoverflow.com/q/22056226
tagged with: void
has title: Java no response from other classes
tagged with: jframe
has comment: http://stackoverflow.com/comment/33445439
type: AnsweredQuestion
tagged with: java
has body: I have this GUI program where I'm trying to basically copy windows CMD. Since I have lots of features in this program, I decided to put parts of the code in different classes. But it doesn't respond. if(command.size()&lt;2 &amp;&amp; command.size()&gt;0) { switch(command.get(0)) { case "dt": getDateTime a = new getDateTime(); a.Start(); break; // other case(s) down below } } Here is the geDateTime class public class getDateTime { public static void Start() { Terminal t = new Terminal(); try { DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); Date date = new Date(); String s = dateFormat.format(date).toString(); t.print(s); }catch(Exception e){ e.printStackTrace(); } } } Here is the print(); void in the main class... public static void print(String s) { Color c = Color.WHITE; // prints white text to JFrame Style style = output.addStyle("Style", null); StyleConstants.setForeground(style, c); try{ document.insertString(document.getLength(), s, style); }catch(Exception e){e.printStackTrace();} } Now when I enter the command for accessing the getDateTime class, the program freezes and I can't input anything. HOWEVER, if I just put the getDateTime class into a void inside the main class it works fine; but this would be a problem to just put everything into the main class since some function(s) could have hundreds of line of code. No errors are produced when the program freezes.
has answer: http://stackoverflow.com/a/22057230
type: Question
has comment: http://stackoverflow.com/comment/33445376
answer count: 1
tagged with: user-interface
linked to: http://stackoverflow.com/q/7026507
tagged with: class
score: 0
accepted answer: http://stackoverflow.com/a/22057230

http://stackoverflow.com/q/22159798
has comment: http://stackoverflow.com/comment/33630065
has comment: http://stackoverflow.com/comment/33629959
type: UnansweredQuestion
has title: My public static void main(String[] args){ (Windows 8) gets an error
score: -3
has comment: http://stackoverflow.com/comment/33629677
has comment: http://stackoverflow.com/comment/33629892
has answer: http://stackoverflow.com/a/22160161
tagged with: java
has comment: http://stackoverflow.com/comment/33630767
downvote count: 3
has comment: http://stackoverflow.com/comment/33629729
has comment: http://stackoverflow.com/comment/33629799
type: Question
has comment: http://stackoverflow.com/comment/33630627
tagged with: eclipse
answer count: 2
upvote count: 0
has comment: http://stackoverflow.com/comment/33629777
has answer: http://stackoverflow.com/a/22159962
has comment: http://stackoverflow.com/comment/33629803
has body: Yes, I admit, I AM watching a tutorial for my game. Yet he can run it perfectly. I just have one issue. This is my main, and then I'll show you my problem. Or maybe by the title you can find it in my main. Oh, those pasted code lines are also part of my main. package game.Mixit.Game.main; public class main { import java.awt.Canvas; import javax.swing.JFrame; public class Game extends Canvas implements Runnable { private static final long serialVersionUID = 1L; public static final int WIDTH = 160; public static final int HEIGHT = WIDTH/ 12*9; public static final int SCALE = 3; public static final String name = "Game"; private static Object start; private JFrame frame; public boolean running = false; public Game() { setMinimumSize(new Dimension(WIDTH*SCALE, HEIGHT*SCALE)); setMaximumSize(new Dimension(WIDTH*SCALE, HEIGHT*SCALE)); setPreferredSize(new Dimension(WIDTH*SCALE, HEIGHT*SCALE)); frame = new JFrame(NAME); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(this.BorderLayoud.CENTER); frame.pack(); frame.setResizable(false); frame.setLocationRelativeTo(null); frame.setVisible(true); public synchronized void start() { running = true new Thread(this).start(); } public synchronized void stop() { running = false } } public void run() { while (running) { System.out.println("Hello World");} } public static void main(String[] args){ new Game().start(); } public void start() { } } }
favorite count: 0
has comment: http://stackoverflow.com/comment/33630080

http://stackoverflow.com/comment/33367377
comment on: http://stackoverflow.com/q/22013145
has text: It looks like a TCP socket timeout to the remote host to me.
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/22171398
accepted answer of: http://stackoverflow.com/q/22167743
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 1
has body: Here is a pure SWT solution: private static Shell popup; public static void main(String[] args) { Display d = new Display(); final Shell shell = new Shell(d); shell.setLayout(new FillLayout()); final Button button = new Button(shell, SWT.PUSH); button.setText("test"); button.addListener(SWT.MouseEnter, new Listener() { public void handleEvent(Event e) { callPopUp(e, shell); } }); button.addListener(SWT.MouseExit, new Listener() { public void handleEvent(Event e) { hidePopUp(); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!d.readAndDispatch()) { d.sleep(); } } d.dispose(); } private static void hidePopUp() { if (popup != null &amp;&amp; !popup.isDisposed()) { popup.close(); popup = null; } } private static void callPopUp(Event e, Shell shell) { System.out.println("CREATE"); if (popup == null) { popup = new Shell(shell.getDisplay(), SWT.NO_TRIM | SWT.ON_TOP | SWT.MODELESS); popup.setLayout(new FillLayout()); new Label(popup, SWT.NONE).setText("Howdy"); popup.pack(); popup.open(); shell.forceFocus(); } popup.setLocation(shell.getLocation().x + e.x, shell.getLocation().y + e.y); } Looks like this:
upvote count: 1
answers question: http://stackoverflow.com/q/22167743

http://stackoverflow.com/q/22078108
possible better answer: http://stackoverflow.com/a/22108600
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/33522149
has body: Using GWT, I've got a webapp, and on a certain page it pulls a parameter from the URL that has the pipe character (|) encoded. So, for example, the full URL would be (in dev mode): http://127.0.0.1:8888/Home.html?gwt.codesvr=127.0.0.1:9997#DynamicPromo:pk=3%257C1000 and when I pull the parameter "pk" I should get "3|1000". (%257C is the encoded pip char) Well, this works just fine in Firefox and Chrome. In IE (I'm using 11), I get "3%7C1000" when I pull the parameter. For whatever reason, IE drops the 25 in the encoded character, meaning it's no longer a pipe char and my app breaks. I've read around and found that encoding issues are common on IE. In particular, I found this page: http://support.microsoft.com/kb/928847 It's suggested solutions include: Disable the Auto-Select setting in Internet Explorer. Provide the character set in the HTTP headers. Move the META tag to within the first kilobyte of data that is parsed by MSHTML. I've tried those 3 and it didn't help. Here is the beginning of my Home.html: &lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&gt; &lt;meta http-equiv="content-type" content="text/html;charset=utf-8" /&gt; The other two suggestions: Increase the size of the server's initial HTTP response. The initial size should be at least 1 KB. Make sure that the System Locale setting matches the character set of the META tag that is specified in the HTML page. I don't feel will do anything. My system locale settings are correct. And since my meta tags are at the beginning of the document, they are within the first kilobyte of data, so they would be read first. So I don't see why I'd need to increase the HTTP response size. So, I need IE to properly read this encoded character for the web application to work properly. Does anyone have any other suggestions I could try? UPDATE: How the URL is encoded: URL.encodePathSegment(place.getValue()) Where URL is from the package …
tagged with: utf-8
tagged with: meta
has answer: http://stackoverflow.com/a/22108600
has comment: http://stackoverflow.com/comment/33489623
tagged with: gwt
type: AnsweredQuestion
has title: Internet Explorer doesn't handle html encoding in URL (GWT)
tagged with: java
accepted answer: http://stackoverflow.com/a/22150537
has comment: http://stackoverflow.com/comment/33493751
type: Question
has comment: http://stackoverflow.com/comment/33501758
tagged with: encoding
has comment: http://stackoverflow.com/comment/33493293
has answer: http://stackoverflow.com/a/22150537

http://stackoverflow.com/q/22101923
has body: What are the the best methods to get values that occur more than once in a large list of words without slowing my run time?. My file contains 1xx,xxx words and I put them into a linked list. Now, I want to get only the words that occur more than once out of that list. For example, if a list contains: ....This is is is just a test test.... I want to get is and test and put them into another list using an iterator. I don't know if my code is right, and I think that this is not the best solution to approach for this problem. for(int i = 0; i &lt; word.size(); i++) { Word s = word.get(i); Word s1 = word.get(i+1); if(s.equals(s1)) { newWord.add(s); } }
has comment: http://stackoverflow.com/comment/33525606
has comment: http://stackoverflow.com/comment/33525534
has answer: http://stackoverflow.com/a/22102138
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22101992
tagged with: list
type: Question
has answer: http://stackoverflow.com/a/22102084
has comment: http://stackoverflow.com/comment/33525712
tagged with: java
score: 0
answer count: 3
has title: get value that occurs more than one in a list?

http://stackoverflow.com/comment/33644205
comment on: http://stackoverflow.com/a/22168179
type: AnswerComment
score: 0
has text: @Santhosh.S ``Double.parseDouble(string);
type: Comment

http://stackoverflow.com/q/22065579
has title: Unmarshalling error after obfuscation
answer count: 1
has comment: http://stackoverflow.com/comment/33460585
score: 0
tagged with: unmarshalling
has comment: http://stackoverflow.com/comment/33460089
tagged with: obfuscation
has answer: http://stackoverflow.com/a/30859243
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33459806
tagged with: java
tagged with: jaxb
has body: I am getting following exception whenever I try to unmarshal xml file with my obfuscated jar file. javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"XCaliberMessage"). Expected elements are (none) If jar file is not obfuscated then it works fine. Here is My code: fileName = "/xcalSmartChk/test-job.xml"; File f = new File(fileName); JAXBContext jc = JAXBContext.newInstance(UploadTestResultXml.class); Unmarshaller u = jc.createUnmarshaller(); UploadTestResultXml xMssg = (UploadTestResultXml) u.unmarshal(f); Marshaller m = jc.createMarshaller(); m.marshal(xMssg, bodyElement); Note: I have also keep classes related to this function while obfuscating. Can somebody tell me where I am going wrong?
tagged with: marshalling
type: Question
has comment: http://stackoverflow.com/comment/33460394

http://stackoverflow.com/comment/33608325
comment on: http://stackoverflow.com/a/22148270
has text: the contacts are on the emulator and i added only 1 number each
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/22047084
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22014671
type: Answer
has comment: http://stackoverflow.com/comment/69507452
answers question: http://stackoverflow.com/q/22014671
has comment: http://stackoverflow.com/comment/56576933
score: 12
has body: Not sure why, but using id instead of groupId and artifactId in the overlay worked: my-legacy-war-project legacy
upvote count: 12
type: AcceptedAnswer

http://stackoverflow.com/comment/33531722
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22104759
has text: It's not clear from your question what the problem is. What is happening that you don't like? The compiler errors? Please provide more information.
score: 0

http://stackoverflow.com/comment/33426253
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22026708
has text: It works now. I was overriding both paint() and paintComponent() and it must have been doing paintComponent() first (for the notes) and then paint() (covering them up with blank staffs). Thanks for your help!

jspinner
tags question: http://stackoverflow.com/q/22131286
type: Tag
tag name: jspinner
tags question: http://stackoverflow.com/q/22134138
tags question: http://stackoverflow.com/q/22127833

wifi
tag name: wifi
type: Tag
tags question: http://stackoverflow.com/q/22031992

http://stackoverflow.com/comment/33436550
score: 0
has text: I'm really new to Hibernate and Oracle. By creating this class URITYPE that implements UserType it will map my string to the URITYPE Column in my database?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22047198

http://stackoverflow.com/comment/33548573
score: 0
type: Comment
type: AnswerComment
has text: 510 columns are not going to be visible, _ever_ on a normal monitor. So you have to make a decision on you want the data to be viewed.
comment on: http://stackoverflow.com/a/22104331

http://stackoverflow.com/a/22145013
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33602680
upvote count: 2
has body: You don't need to use the | sign in the regex, because you're using an array of characters to match to. Basically if you want to match something to a,b,c or d, which means that the string can contain any of those letters you can simply do String pattern = "[abcd]*"; // * means they can be repeated, for example "aabdcb" str.matches(pattern); No need to use the pipe. On the other hand if you want to strictly say that a string is either a or b you can use a pattern like pattern = "(a)|(b)"; // matches either "a" or "b" Hope this clears up things a bit for you. You might want to check out this page to learn more about using pipe in regexes.
accepted answer of: http://stackoverflow.com/q/22144878
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22144878
type: Answer

http://stackoverflow.com/a/22145991
downvote count: 0
has comment: http://stackoverflow.com/comment/33605523
upvote count: 2
type: Answer
has body: In over 15 years of writing Java on a professional level I've never once encountered a need to flush a stream before writing to it. The flush operation would do nothing at all, as there's nothing to flush. You want to flush the stream before closing it, though the close operation should do that for you it is often considered best practice to do it explicitly (and I have encountered situations where that did make a difference, where apparently the close operation did not actually do a flush first. Maybe you are confused with that?
answers question: http://stackoverflow.com/q/22145523
score: 2

http://stackoverflow.com/comment/33390221
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22025686
type: AnswerComment
has text: thank you for the helping but they ansower my question

http://stackoverflow.com/q/22056566
has answer: http://stackoverflow.com/a/55662302
accepted answer: http://stackoverflow.com/a/22084116
downvote count: 0
favorite count: 0
has body: I am building an application using Gradle, JDK 8, Java FX, and Test FX. I need to be on JDK 8 for our application to work on all platforms with our tech stack. My problem is that I am unable to get code coverage into our build. I found this link... https://github.com/jacoco/jacoco/issues/74 ...and using the Jacoco preview build at the top, I was able to replace my intellij JARs and successfully run my tests and get the coverage. However, I am having trouble putting this into my build.gradle. From what I can tell, I need to add a local repository in my build script... ... apply plugin: "jacoco" ... buildscript { repositories { // Local Repo // MVN Repo(s) } dependencies { // Classpaths } } jacoco { toolVersion = "0.6.4.201311160552" // I need this specific version, which isn't on a MVN repo } ...I tried to add my local repo several ways including... flatDir(dirs: "lib") flatDir dirs: "${projectDir}/lib" maven { url uri("lib") } one or two other ways I forget ...my lib folder contains the exact contents, unchanged, from the preview build zip's lib folder in the link above. It doesn't seem like gradle is having a problem locating the local repo, but it is having trouble finding the JAR. I assume there is something wrong with the way I am naming it or the way that it is "packaged". I have tried modifying the JAR names but I keep getting the error... What went wrong: A problem occurred configuring root project 'myProject'. Could not resolve all dependencies for configuration ':classpath'. Could not find :org.jacoco.agent:. Required by: :myProject:unspecified ...any ideas why my JAR is not being found? Thanks!
has title: How can you override an existing Gradle plugin from a local repository?
tagged with: java-8
type: AnsweredQuestion
tagged with: java
tagged with: javafx
has answer: http://stackoverflow.com/a/22084116
tagged with: gradle
type: Question
tagged with: jacoco
score: 4
possible better answer: http://stackoverflow.com/a/55662302
upvote count: 4
answer count: 2

http://stackoverflow.com/q/22144644
has title: Call a specific method using Restlet framework
type: AnsweredQuestion
has body: I'm using Restlet library and I would like to know if it is possible to call a specific method of a class when accessing through a URL. Right now I have something like this: public Restlet createInboundRoot() { Router router = new Router(getContext()); router.attach("/monitor", Monitor.class); } Which calls the Monitor class when accessing to /monitor/ by URL. I would like to be able to do things like this: public Restlet createInboundRoot() { Router router = new Router(getContext()); router.attach("/monitor/name", Monitor.getName()); router.attach("/monitor/description", Monitor.getDescription()); } Is this possible with Restlet framework? Right now the workaround I found was by using GET parameters and using conditions on the represent method: public StringRepresentation represent() { String type= getQuery().getValues("type"); if(type.equals("getName")){ this.getName(); } if(type.equals("getDescription")){ this.getDescription(); } } But it doesn't sound like the way to do it.
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33613958
upvote count: 1
accepted answer: http://stackoverflow.com/a/22172741
type: Question
has comment: http://stackoverflow.com/comment/33619003
downvote count: 0
tagged with: restlet
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33602884
has comment: http://stackoverflow.com/comment/33610555
has answer: http://stackoverflow.com/a/22172741
tagged with: rest

http://stackoverflow.com/a/22027691
has body: ArrayDeque does what you want. It doesn't move the elements around. It moves the index of where the start and the end is. When you add an element, the end counter moves and when you remove an element, the start counter moves. One advantage of ArrayDeque is that it can use less memory and does create garbage. On the down side it has a fixed maximum size. LinkedList grows and shrinks. BTW If you want a light weight sliding window or the average of some values, an exponentially weighted moving average is much cheaper as you only need to record two values, the previous and last time. e.g double last = 0; long lastTime = 0; double halfLife = 60 * 1000; // 60 seconds for example. public static double ewma(double sample, long time) { double alpha = Math.exp((lastTime - time) / halfLife); lastTime = time; return last = sample * alpha + last * (1 - alpha); } or you can approximate this to avoid calling Math.exp with public static double ewma(double sample, long time) { long delay = time - lastTime double alpha = delay &gt;= halfLife ? 1.0 : delta / halfLife; lastTime = time; return last = sample * alpha + last * (1 - alpha); } This is many times faster and for short intervals gives much the same result.
has comment: http://stackoverflow.com/comment/33393491
type: Answer
has comment: http://stackoverflow.com/comment/33393648
upvote count: 5
downvote count: 0
has comment: http://stackoverflow.com/comment/33393711
answers question: http://stackoverflow.com/q/22027474
score: 5

http://stackoverflow.com/a/22499653
has comment: http://stackoverflow.com/comment/34244932
has comment: http://stackoverflow.com/comment/34482549
answers question: http://stackoverflow.com/q/22135449
has body: 1) The first is to use a hash to store your data object, objHash. 2) You need a extra lock to assure the atomic exeuction of type1 and type2 operation on objHash.Type2 is write operations, and Type1 is read operations. You can use a readwrite lock and store the locks in a hash table, lockHash. 3) For assure the atomic operation of type1, type2 on the data object, you have to enclosed your type1/2 operation in a synchronzied statement that get a lock to this data object. public class ConDeleteHash { ConcurrentHashMap &lt;String, Object&gt; objHash = new ConcurrentHashMap &lt;String, Object&gt; (); ConcurrentHashMap &lt;String, ReentrantReadWriteLock&gt; lockHash = new ConcurrentHashMap &lt;String, ReentrantReadWriteLock&gt; (); void Type1Op(String name) { ReadWriteLock rwl = lockHash.get(name); if(rwl==null) return; Lock lock = rwl.readLock(); lock.lock(); Object obj = objHash.get(name); if(obj==null) return; synchronized(obj) { System.out.println("TYPE1 to :"+ obj.toString()); } lock.unlock(); } void Type2Op(String name) { ReadWriteLock rwl = lockHash.get(name); if(rwl==null) return; Lock lock = rwl.writeLock(); Object obj = objHash.get(name); synchronized(obj) { System.out.println("TYPE2 to :"+ obj.toString()); } lockHash.remove(name); objHash.remove(name); lock.unlock(); } void add(String name, Object obj) { if(lockHash.get(name)!=null) return; objHash.put(name, obj); lockHash.put(name, new ReentrantReadWriteLock()); } }
score: 0
has comment: http://stackoverflow.com/comment/34431336
type: Answer
has comment: http://stackoverflow.com/comment/34365690

http://stackoverflow.com/q/22150037
upvote count: 14
tagged with: java
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/31121117
has answer: http://stackoverflow.com/a/22269402
tagged with: javascript
tagged with: gruntjs
has title: local tomcat server with grunt watch auto-reload
has answer: http://stackoverflow.com/a/22271735
has body: The project I have a maven based project which I need to deploy into a local tomcat server (for development). Now, on the front-end, I want to have a grunt dev-build ( jslint, concat, karma, sass, etc). What I need A solution which is not tied to only one IDE ( and should also work in the command line ) I don't want to deploy a war file only a dist folder. I don't want to recompile java each time I change a client-side resource: js,css,html,images etc. grunt should watch the files and do pre processing / concatenation / lint / tests after the watch grunt should deploy the files to a local tomcat and autoreload the page It MUST be fast! and I mean less than a second. I looked at some questions, but I cannot figure out how to make it all work
tagged with: tomcat
favorite count: 0
has answer: http://stackoverflow.com/a/22207956
type: UnansweredQuestion
tagged with: maven
score: 13
answer count: 4

http://stackoverflow.com/a/22031273
has body: From copying your code into Eclipse: Firstly you are missing a ; when you are getting the input for limit. Secondly your System.out.println(sum); is outside of your main method, it should be at the end of the method i.e. after your for loop. Thirdly, you have named your class SumMultiples.java. This is not a valid name, rename it to SumMultiples. You should be getting compile errors and your IDE should help you work this out. If you aren't using an IDE, please do so as it will help you debug these issues and help you get familiar with Java.
downvote count: 0
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/22031114

http://stackoverflow.com/a/22055356
accepted answer of: http://stackoverflow.com/q/22055053
type: AcceptedAnswer
downvote count: 0
has body: With a general sorted array of numbers, binary search is the way to go, which is O(log n). But because there is a mathematical relationship between the numbers (each number is 1.1 times the previous one), take advantage of that fact. You're looking for the maximum exponent level such that levels[0] * Math.pow(1.1, level) &lt;= exp Solving for level, level = log{base 1.1}(exp / levels[0]) Taking advantage of the fact that loga(b) = ln(b) / ln(a)... int level = (int) Math.log(exp/levels[0]) / Math.log(1.1); Because of the mathematical relationship, you just need this calculation, and no searching, so it's O(1). double base = 1; double factor = 1.1; for (double score : Arrays.asList(1.0, 1.1, 1.3, 8.6, 9.46)) { int level = (int) (Math.log(score / base) / Math.log(factor)); System.out.println(level); } Prints 0 1 2 22 23
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/22055053

http://stackoverflow.com/a/22110570
upvote count: 1
type: Answer
downvote count: 0
score: 1
has body: The index starts from 0 and not 1. Hence in the string "ttsttxctlltnt", the character at position 5(0,1,2,3,4,5) i.e 'x' will be printed.
answers question: http://stackoverflow.com/q/22110500

loadui
tags question: http://stackoverflow.com/q/22010430
type: Tag
tag name: loadui

http://stackoverflow.com/comment/33382187
score: 0
type: Comment
has text: Thanks for your answer. Am I able to read it in using `ObjectInputStream ois = new ObjectInputStream(inputStream); set =ois.readObject();` It seems like I'm not able to convert the object?
type: AnswerComment
comment on: http://stackoverflow.com/a/22017348

http://stackoverflow.com/comment/33491266
type: Comment
score: 0
has text: @hoaz But then I'd lose all possible updates to the list between ListProvider#getList and ListProvider#setList. Consistency/correctness of the original list is most important, I do not care much about performance. Access should simply happen on a FCFS basis.
type: QuestionComment
comment on: http://stackoverflow.com/q/22082106

http://stackoverflow.com/a/22122598
has body: Apart from the fact that ImageIO might be easier to use when you want to write an image to a file, there's not really something wrong with the code that you currently tried to use for writing the image file. But with all the rest! Obviously you are doing quite a lot of trial and error. And one can quickly see from the code that you do not really know what you are doing there. You are not really computing anything, because the values that you enter in your main method are not really used in the Julia method, and the iteration that is done in the Julia method is flawed. So some general hints: Follow the naming conventions Make clear to yourself where you will use which variable Keep the scope of variables as small as possible. That means: Declare the variable directly before you want to use it As long as you are still experimenting, don't use the Scanner. Just define some "default" values for the variables, so that you don't have to enter them again and again each time that you start the program! Use a smaller image size. You don't have to wait until a large, 515x512 image is computed to see whether it works or not. A 50x50 image is sufficient for that. Slightly cleaned up: import java.awt.Color; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; public class Julia { public static BufferedImage julia() { int width = 200; int height = 100; BufferedImage outImage = new BufferedImage( width, height, BufferedImage.TYPE_3BYTE_BGR ); Complex c = new Complex (cReal, cImag); for (int i = 0; i&lt;width; i++) { for(int j = 0; j&lt;height; j++) { double zreal = (xMin +i*(xMax- xMin) / width); double zimag = (yMin+ j*(yMax-yMin)/ height); Complex z = new Complex( zreal, zimag); int k=0; for (k= 0; k&lt; 256; k++) { z = z.multi(z); z = z.add(c); // if (Math.sqrt(Math.pow(z.real, 2.0)+ // Math.pow(z.i…
score: 0
type: Answer
answers question: http://stackoverflow.com/q/22120890

http://stackoverflow.com/a/22058706
type: Answer
has comment: http://stackoverflow.com/comment/33448424
has comment: http://stackoverflow.com/comment/33448416
has comment: http://stackoverflow.com/comment/33448535
has comment: http://stackoverflow.com/comment/33491067
has comment: http://stackoverflow.com/comment/33448439
upvote count: 5
accepted answer of: http://stackoverflow.com/q/22058695
has body: How about String[] test = testString.split("\\.[ ]*"); or String[] test = testString.split("\\.\\s*"); or for more than one period (and ellipsis) String[] test = testString.split("\\.+\\s*");
score: 5
answers question: http://stackoverflow.com/q/22058695
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/22152277
answer count: 0
linked to: http://stackoverflow.com/q/29076145
type: Question
has comment: http://stackoverflow.com/comment/33618546
score: 3
has comment: http://stackoverflow.com/comment/34080682
has comment: http://stackoverflow.com/comment/38762515
tagged with: java
has title: how to fix netbeans Arabic encoding appearing as symbols
has comment: http://stackoverflow.com/comment/33616704
upvote count: 3
tagged with: encoding
downvote count: 0
linked to: http://stackoverflow.com/q/4133195
favorite count: 0
tagged with: linux
type: UnansweredQuestion
tagged with: netbeans
has comment: http://stackoverflow.com/comment/33656942
has body: in netbeans the Arabic characters looks as strange symbols how can i set the encoding to solve this problem OS : Linux Ubuntu netbeans version : 7.4 image link : https://i.sstatic.net/UsFk2.png

http://stackoverflow.com/comment/33529687
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22096371
has text: @ntoskrnl I have actually filed a bug report earlier today haven't seen it anywhere around http://bugs.java.com yet though.
type: Comment

http://stackoverflow.com/q/22015282
tagged with: cron
answer count: 1
has body: I have the following code: EntityManager mgr = null; try { mgr = getEntityManager(); ZooperTheme2 theme = null; theme = mgr.find(Theme2.class, "1"); theme.setPopularity(7); mgr.persist(theme); for (int c = 1; c &lt; 204; c++) { theme = mgr.find(Theme2.class, "" + c); theme.calculatePopularity(); mgr.persist(theme); } } catch (Exception e) { } finally { mgr.close(); } The part before the 'For' loop: theme = mgr.find(Theme2.class, "1"); theme.setPopularity(7); mgr.persist(theme); Works just fine by itself. But when I add the 'For' loop to iterate across all of the themes, none of the themes are updating (including theme "1" using .setPopularity(7). The log files show the following error: Uncaught exception from servlet javax.persistence.PersistenceException: Illegal argument at org.datanucleus.api.jpa.NucleusJPAHelper.getJPAExceptionForNucleusException(NucleusJPAHelper.java:298) at org.datanucleus.api.jpa.JPAEntityManager.close(JPAEntityManager.java:197) at com.companionfree.zooperthemeviewer.CronController.doGet(CronController.java:43) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) 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.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.apphosting.utils.servlet.TransactionCleanupFilter.d…
has answer: http://stackoverflow.com/a/22030233
tagged with: google-app-engine
type: AnsweredQuestion
score: 0
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/22030233
has comment: http://stackoverflow.com/comment/33396947
has comment: http://stackoverflow.com/comment/33376808
has title: Cron job can't use 'For' loop?

http://stackoverflow.com/comment/58542679
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22137684
has text: I saw I never picked an answer here. Thanks for taking the time back in 2014 to explain the concept of libraries to me.
type: Comment

http://stackoverflow.com/comment/33633927
has text: @Code-Guru Yes, it could be refactored, I assume you mean so each player makes its own move, but I didn't really want to recommend too much. It's not broken the way it is so it's fine in my book.
comment on: http://stackoverflow.com/a/22162229
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/22041692
has comment: http://stackoverflow.com/comment/33455123
has comment: http://stackoverflow.com/comment/33453189
answers question: http://stackoverflow.com/q/22040759
has comment: http://stackoverflow.com/comment/33452551
has comment: http://stackoverflow.com/comment/33454549
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33455256
has comment: http://stackoverflow.com/comment/33454423
upvote count: 2
accepted answer of: http://stackoverflow.com/q/22040759
type: Answer
has body: You can do that with the android-maven plugin (at least in version 3.80). The following is a blueprint for the profile in the pom: yourProfile com.jayway.maven.plugins.android.generation2 android-maven-plugin manifestUpdate process-resources manifest-update <manifestApplicationLabel>yourLabel</manifestApplicationLabel> <manifestApplicationIcon>yourIcon</manifestApplicationIcon> For other parameters see the maven plugin.
score: 2
has comment: http://stackoverflow.com/comment/33455906

http://stackoverflow.com/comment/33930610
has text: If you cancel login without granting access, and click login again, it will open permission page again. In order to login use, the user should accept permission dialog
comment on: http://stackoverflow.com/q/22127409
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33627510
type: QuestionComment
has text: MP3 attributes are stored in ID3 tags inside the MP3 file. Files.copy() and Java's NIO2 API only works with file system attributes.
type: Comment
comment on: http://stackoverflow.com/q/22156713
score: 0

http://stackoverflow.com/comment/33614674
score: 0
type: AnswerComment
has text: Thanks for your explanation, Peter. However, I already knew about these issues and, as I said, I know I need to rewrite this code (thanks for the pointers). I'm interested in finding out why there is the difference in behaviour when the web app is run on GAE and locally. In the first case both `sendRedirect` and the exception are exectued whereas in the latter case only the exception is thrown but the `sendRedirect` is ignored.
type: Comment
comment on: http://stackoverflow.com/a/22151170

http://stackoverflow.com/comment/33691851
type: Comment
has text: I try to explain: The Sprite has a `position.x`, `position.y`, defining his central point. Now if you are moving to the right, you can only collide with tiles on your right. So check only for those tiles. For this you only need to add `xMovement` to your `position.x` to get the new position. Tiles are defined by x and y coordinates. So you need to find the y coordinate of your character. It is possible, that your character is in between 2 tiles right? So you need to check, if the tile at the `newX` and `upperY` is empty and the tile at `newX`, `lowerY` is empty. This is what i am doing.
comment on: http://stackoverflow.com/a/22193157
score: 0
type: AnswerComment

http://stackoverflow.com/q/22092365
tagged with: jdatechooser
has body: I want to disable or hide or make the past dates in JDateChooser not selectable. How can I make this? I've tried to use .setSelectableDateRange but it doesn't work. I also tried .setMinSelectableDate() but still no luck. I don't know but netbeans doesn't seem to know those because those doesn't show up in code suggestions. I'm using it like this: public void dateset() { jDateChooser1.getCalendar(). //What to put here? It doesn't have .setSelectableRange } I only tried the one that I've found on this one: How to show only date after the date of today in JCalendar I think that post was already outdated. Please help.
has comment: http://stackoverflow.com/comment/33512407
has answer: http://stackoverflow.com/a/22115527
has answer: http://stackoverflow.com/a/22093246
has comment: http://stackoverflow.com/comment/33508398
upvote count: 3
has title: Hide or disable past dates on JDateChooser
has comment: http://stackoverflow.com/comment/33508501
possible better answer: http://stackoverflow.com/a/22093246
favorite count: 0
tagged with: netbeans
downvote count: 0
linked to: http://stackoverflow.com/q/18820257
tagged with: swing
linked to: http://stackoverflow.com/q/10021565
type: AnsweredQuestion
score: 3
tagged with: java
accepted answer: http://stackoverflow.com/a/22115527
has comment: http://stackoverflow.com/comment/33509088
type: Question
answer count: 2

http://stackoverflow.com/q/22095341
accepted answer: http://stackoverflow.com/a/22103879
type: AnsweredQuestion
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/22103879
type: Question
score: 15
has body: I am trying to build an http POST using the examples of Apache Components (4.3) - http://hc.apache.org/httpcomponents-client-4.3.x/tutorial/html/fluent.html. Unfortunately, I receive an error that I have not been able to find out how to solve. I have used the former HttpClient before - so this is my first go with components. Here is a snippet of the code: String address = "http://1.1.1.1/services/postPositions.php"; String response = Request.Post(address) .bodyString("Important stuff", ContentType.DEFAULT_TEXT) .execute().returnContent().asString(); System.out.println(response); and when I run that code I get an exception: Exception in thread "main" java.lang.IllegalStateException: POST request cannot enclose an entity at org.apache.http.client.fluent.Request.body(Request.java:299) at org.apache.http.client.fluent.Request.bodyString(Request.java:331) at PostJson.main(PostJson.java:143) I have tried to build a form element as well and use the bodyForm() method - but I get the same error.
answer count: 3
has title: How to use fluent of Apache Components
has answer: http://stackoverflow.com/a/28561142
upvote count: 15
favorite count: 0
has answer: http://stackoverflow.com/a/22102462
tagged with: apache-httpclient-4.x
possible better answer: http://stackoverflow.com/a/28561142

http://stackoverflow.com/comment/33528383
comment on: http://stackoverflow.com/q/22103223
score: 0
has text: @ajb - no, I would never paste my code on pastebin.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33602669
has text: System.out.println("{{Infobox musical artist {{|honorific-prefix}} = The Honourable | name = Bob Marley | image = Bob-Marley.jpg}}".replaceAll("\\{\\{(.*)\\}\\}", "")); gives you what?
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22144880

http://stackoverflow.com/q/22072149
possible better answer: http://stackoverflow.com/a/22072268
has comment: http://stackoverflow.com/comment/33471433
type: Question
score: 1
tagged with: java
has body: I was trying to read records from MySQL database and put it in a class variable in JDBC but it throws exception The Error is: java.lang. NullPointerException. What is it that I am doing wrong here? Code: try { conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/databasename", "root", "password"); st = conn.createStatement(); rs = st.executeQuery("SELECT * FROM tablename"); kids records = new kids(); int i = 0; while (rs.next()) { records.id[i] = rs.getInt("id"); records.name[i] = rs.getString("name"); records.user_id[i] = rs.getInt("user_id"); System.out.println("id: " + records.id[i] + "name: " + records.name[i] + "user_id" + records.user_id[i]); i++; } } catch (Exception e) { System.err.println("The Error: " + e); } The kid class, which is supposed to store the records is as follows. public class kids{ public int id[]; public String name[]; public int user_id[]; public kids(){ for (int x=0;x&lt;100;x++){ this.id[x]=0; this.name[x]=""; this.user_id[x]=0; } } }
has answer: http://stackoverflow.com/a/22072227
answer count: 2
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/33471402
accepted answer: http://stackoverflow.com/a/22072227
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22072268
has title: JDBC: java.lang.NullPointerException
upvote count: 1
has comment: http://stackoverflow.com/comment/33471416

http://stackoverflow.com/comment/33457876
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22064160
score: 0
has text: I already have Hibernate ORM which deals with the other process. So if i am going to use plain JDBC to run script then i need to get the JDBC connection for executing script.

http://stackoverflow.com/a/22096045
answers question: http://stackoverflow.com/q/22095941
score: 0
has body: i is not always begin incremented, if you use a for loop the problem is easier to avoid. public static void get_factors(int num){ factorList = new ArrayList&lt;Integer&gt;(); for(int i = 2; i &lt; num; i++) { if (num%i == 0) { factorList.add(i); } } }
type: Answer

http://stackoverflow.com/comment/33489302
has text: This may be of help http://stackoverflow.com/questions/4886091/insert-space-after-capital-letter?rq=1
comment on: http://stackoverflow.com/q/22081418
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22090850
answer count: 2
has comment: http://stackoverflow.com/comment/33505576
has comment: http://stackoverflow.com/comment/33506292
has title: Extracting links of a facebook page
tagged with: facebook-graph-api
has comment: http://stackoverflow.com/comment/33505781
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22091711
has comment: http://stackoverflow.com/comment/33505508
type: Question
has answer: http://stackoverflow.com/a/22091157
has body: How can I extract all the links of a facebook page. Can I extract it using jsoup and pass "like" link as parameter to extract all the user's info who liked that particular page private static String readAll(Reader rd) throws IOException { StringBuilder sb = new StringBuilder(); int cp; while ((cp = rd.read()) != -1) { sb.append((char) cp); } return sb.toString(); } public static JSONObject readurl(String url) throws IOException, JSONException { InputStream is = new URL(url).openStream(); try { BufferedReader rd = new BufferedReader (new InputStreamReader(is, Charset.forName("UTF-8"))); String jsonText = readAll(rd); JSONObject json = new JSONObject(jsonText); return json; } finally { is.close(); } } public static void main(String[] args) throws IOException, JSONException, FacebookException { try { System.out.println("\nEnter the search string:"); @SuppressWarnings("resource") Scanner sc=new Scanner(System.in); String s=sc.nextLine(); JSONObject json = readurl("https://graph.facebook.com/"+s); System.out.println(json); }} CAN i MODIFY THIS AND INTEGRATE THIS CODE. BELOW CODE EXTRACTS ALL LINKS OF A PARTICULAR PAGE. i TRIED TO THE ABOVE CODE BUT IT'S NOT WORKING String url = "http://www.firstpost.com/tag/crime-in-india"; Document doc = Jsoup.connect(url).get(); Elements links = doc.getElementsByTag("a"); System.out.println(links.size()); for (Element link : links) { System.out.println(link.absUrl("href") +trim(link.text(), 35)); } } public static String trim(String s, int width) { if (s.length() &gt; width) return s.substring(0, width-1) + "."; else return s; } }
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has comment: http://stackoverflow.com/comment/33505613
score: 0

http://stackoverflow.com/q/22030307
linked to: http://stackoverflow.com/q/9329568
tagged with: java
linked to: http://stackoverflow.com/q/19712745
type: Question
has comment: http://stackoverflow.com/comment/33398112
has answer: http://stackoverflow.com/a/22030385
has body: In my program I have to constantly access the hard drive thousands of times to view images (no way around it), occasionally my program gets tripped up on a "file not found IO Exception" most likely because of the many modifications I'm making to the images and re saving quickly. How do I continue my program even if this error occurs, because currently it causes my program to stop? Code: filepattern=imageLocation+temp+"image.jpg"; File outputfile = new File(filepattern); BufferedImage img = null; try { img = ImageIO.read(outputfile); } catch (IOException e) { } Note: I have fixed the problem by making sure the file exists first. Thanks for all your help!
has comment: http://stackoverflow.com/comment/33397921
score: 0
tagged with: exception
has comment: http://stackoverflow.com/comment/33398034
has comment: http://stackoverflow.com/comment/33398026
has comment: http://stackoverflow.com/comment/33397992
has comment: http://stackoverflow.com/comment/33398068
has answer: http://stackoverflow.com/a/22030406
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22030327
has title: How do you continue your program even if an exception occurs?
has answer: http://stackoverflow.com/a/22030328
answer count: 4

http://stackoverflow.com/comment/100931981
has text: in fact, the calculation on this number will overflow even for `unsigned long`
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22023118

http://stackoverflow.com/comment/33450358
type: Comment
has text: package name is not case sensitive I think. The package is named as helloWorld only. With the caps. But in the code it is getting printed as helloworld.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/22059281

http://stackoverflow.com/a/22039435
type: Answer
answers question: http://stackoverflow.com/q/22039199
has body: Your code looks like you want to simply reuse an abstract method implementation and apply some conversion afterwards - if using third party code, I would approve this approach, but in this case you are in control of the class hierarchy and so I would extract common behavior in an abstract base class your ConcretePagerRepository and PagerRepositoryConvertionDecorator each will be extending. Besides, overwriting an already overwritten abstract method is not particularly good coding style, because you are secretly inheriting code. Methods designed for inheritance should be abstract or empty, or, if not intended to be inherited, final.
score: 0

http://stackoverflow.com/comment/33616043
has text: i moved it from being declared in the class to calling it in a function, works now
comment on: http://stackoverflow.com/q/22151971
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/22063746
has comment: http://stackoverflow.com/comment/33504032
has comment: http://stackoverflow.com/comment/33457234
has comment: http://stackoverflow.com/comment/33457504
answers question: http://stackoverflow.com/q/22063286
score: 0
has body: You have to export classes to project. In eclipse you have to "tick" library, I assume NetBeans have the same option somewhere. If you don't export library, your program is trying to find it and can't do it because it is not a "global" library known to all programs.
type: Answer

http://stackoverflow.com/comment/33445531
has text: It's also what I get when I test the url you provided : http://api.zappos.com/Search&term=boots&key=<my_key_inserted_here> Are you sure that your key is correct?
comment on: http://stackoverflow.com/a/22056377
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/22084301
answer count: 1
has comment: http://stackoverflow.com/comment/33494278
has comment: http://stackoverflow.com/comment/33494237
has comment: http://stackoverflow.com/comment/33494317
has answer: http://stackoverflow.com/a/22084346
tagged with: client
type: AnsweredQuestion
has body: I'm relatively new to Java programming. I was wondering what could I code to test this method? Could you please post any suggestions? I would like to test my method in a client class. public void insertThird(Player p) { PlayerNode pn = new PlayerNode(p); PlayerNode current = head; if (current == null) head = pn; else { current = current.getNext(); if(current!=null) { pn.setNext(current.getNext()); current.setNext(pn); } else { head.setNext(pn); } } numberOfItems++; }
tagged with: methods
type: Question
accepted answer: http://stackoverflow.com/a/22084346
tagged with: testing
linked to: http://stackoverflow.com/q/652292
tagged with: java
has title: Code for testing my method
score: 0

controls
tags question: http://stackoverflow.com/q/22114306
type: Tag
tags question: http://stackoverflow.com/q/22050899
tag name: controls

http://stackoverflow.com/a/22095329
upvote count: 2
has comment: http://stackoverflow.com/comment/33518893
has body: If you want to execute AA.start() before to execute each target method like AA.addListener(new DetectionListener());, you should use @Before annotation. Then you can execute AA.start() method before execute each @Test target method. If you execute the method after the test, you should use @After annotation. public class ThreeMinuteRun { ... @Before public void setUp() throws Exception { AA.start(); } @After public void tearDown() throws Exception { AA.stop(); } ... @Test public void testAddListener() { AA.addListener(new DetectionListener()); } } When testAddListener test called, it will be call in the order as follows: AA.start(); AA.addListener(new DetectionListener()); AA.stop()
has comment: http://stackoverflow.com/comment/33534241
has comment: http://stackoverflow.com/comment/33536979
has comment: http://stackoverflow.com/comment/33519550
has comment: http://stackoverflow.com/comment/33743452
has comment: http://stackoverflow.com/comment/33515738
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33519157
has comment: http://stackoverflow.com/comment/33519658
accepted answer of: http://stackoverflow.com/q/22094644
has comment: http://stackoverflow.com/comment/33513933
type: Answer
answers question: http://stackoverflow.com/q/22094644
has comment: http://stackoverflow.com/comment/33517044
has comment: http://stackoverflow.com/comment/33514954
score: 2

http://stackoverflow.com/q/22041915
has comment: http://stackoverflow.com/comment/33421326
has comment: http://stackoverflow.com/comment/33418844
tagged with: swing
downvote count: 1
type: AnsweredQuestion
upvote count: 3
tagged with: java
accepted answer: http://stackoverflow.com/a/22045469
type: Question
linked to: http://stackoverflow.com/q/5621338
answer count: 1
has title: Why does my components go out of boundaries, please help me to align it with the necessary code
tagged with: alignment
has comment: http://stackoverflow.com/comment/33418819
has comment: http://stackoverflow.com/comment/33418824
has answer: http://stackoverflow.com/a/22045469
favorite count: 0
has comment: http://stackoverflow.com/comment/33424367
score: 2
tagged with: vertical-alignment
has body: import net.java.dev.designgridlayout.Tag; import net.java.dev.designgridlayout.DesignGridLayout; import javax.swing.table.DefaultTableModel; import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; class alignmentprob { JFrame JF; Container C,C5; JDesktopPane JDP; JInternalFrame JIF5; JLabel i5l1,i5l2,i5l3,i5l4,i5l5,i5l6,i5l7; JTextField i5t1,i5t2,i5t3; JComboBox&lt;String&gt; i5cb1; JButton i5b1,i5b2,i5b3; JSeparator i5sep1,i5sep2,i5sep3,i5sep4,i5sep5,i5sep6; JTable i5Table1; DefaultTableModel i5Model; String[] i5Credit = {"A","B"}; String[] i5ColumnNames = {"Name","Qty","Rate/kg","rate/dzn","total amt."}; JScrollPane i5t1sp1; public alignmentprob() { JF = new JFrame(); JDP = new JDesktopPane(); JF.setVisible(true); JF.setSize(800,600); JIF5 = new JInternalFrame("Daily Analysis",true,true, true, true); C=JF.getContentPane(); C.add(JDP,BorderLayout.CENTER); JIF5.setVisible(true); JIF5.setBounds(10, 10, 600, 500); C5 = JIF5.getContentPane(); DesignGridLayout layout5 = new DesignGridLayout(C5); i5l1 = new JLabel("FREIGHT DETAILS"); i5l2 = new JLabel("Date : "); i5l3 = new JLabel("SALE DETAILS"); i5l4 = new JLabel("Cash Sales : Rs. "); i5l5 = new JLabel("Credit : "); i5l6 = new JLabel("EXPENSES"); i5l7 = new JLabel("Food &amp; Tea : Rs. "); i5t1 = new JTextField(20); i5t2 = new JTextField(20); i5t3 = new JTextField(20); i5cb1 = new JComboBox&lt;String&gt;(i5Credit); i5b1 = new JButton("Save"); i5b2 = new JButton("Reset"); i5b3 = new JButton("Close"); i5sep1 = new JSeparator(); i5sep2 = new JSeparator(); i5sep3 = new JSeparator(); i5sep4 = new JSeparator(); i5sep5 = new JSeparator(); i5sep6 = new JSeparator(); i5Model = new DefaultTableModel(i5ColumnNames,5); i5Table1 =new JTable(i5Model){@Override public boolean isCellEditable(int arg0, int arg1) { return false; } }; i5t1sp1 = new JScrollPane(i5Table1); layout5.row().left().add(i5sep1).fill().withOwnRowWidth(); layout5.row().center().add(i5l1); layout5.row().left().add(i5sep2).fill(…
has comment: http://stackoverflow.com/comment/33418424
has comment: http://stackoverflow.com/comment/33418237

http://stackoverflow.com/q/22067446
type: Question
tagged with: exception
has title: Couldn't Convert jTextfield string into float value..... Giving number format exception
score: 0
has answer: http://stackoverflow.com/a/22067890
tagged with: java
answer count: 3
has comment: http://stackoverflow.com/comment/33462822
tagged with: swing
tagged with: jtextfield
has answer: http://stackoverflow.com/a/22067603
accepted answer: http://stackoverflow.com/a/22067603
tagged with: numberformatexception
possible better answer: http://stackoverflow.com/a/22067505
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22067505
has body: Im experiencing a problem in parsing jTextfield into float value so i can perform operation but its giving number format exception Here is the Error Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: empty String at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1011) at java.lang.Float.parseFloat(Float.java:452) and this is what im doing float T1 = Float.parseFloat(txt_T1_f.getText());

http://stackoverflow.com/comment/33421965
type: QuestionComment
comment on: http://stackoverflow.com/q/22043480
has text: What is the comparator of Set<Item> and Set<Component>?
score: 0
type: Comment

http://stackoverflow.com/comment/34897894
type: Comment
comment on: http://stackoverflow.com/a/22032450
score: 0
type: AnswerComment
has text: You can also do this in the E3 manner by using a "preferencesCustomization" extension. Within your plugin_customization.ini file, add the following line (this assumes you have a custom view called com.example.product.application.view.problems): `org.eclipse.ui.ide/org.eclipse.ui.internal.views.markers.CachedMarkerBuildercom.example.product.application.view.problems=<?xml version="1.0" encoding="UTF-8"?> ` The key/value declaration must all be on one line, and yes, the key ID is supposed to look smooshed together.

http://stackoverflow.com/a/22034781
score: 0
type: Answer
has body: For long tasks (e.g. connecting to a server) you should consider using a Service rather than an Activity. Because an Activity could be destroyed at any time by the user pressing home/back button, or by the system for memory saving issues. Every thing you need to know is here.
answers question: http://stackoverflow.com/q/22034483

http://stackoverflow.com/q/22080579
possible better answer: http://stackoverflow.com/a/22080661
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22080661
has title: how find a number of specific sub-string in a string
has answer: http://stackoverflow.com/a/22080717
tagged with: java
has answer: http://stackoverflow.com/a/22080734
has answer: http://stackoverflow.com/a/22080744
has comment: http://stackoverflow.com/comment/33487707
type: Question
has answer: http://stackoverflow.com/a/22080702
score: 0
answer count: 6
has body: hi i'm starting to learn java but i have a problem with regex i have a string like this str = "int f ( int a , int b )" i want to find how many "int" occured i read in oracle's doc and i found that we have a regex called X{n} that told us for example if the "int" matches exactly n time or not i write this code but it gives me false String temp = "int f ( int a , int b )"; Pattern pattern = Pattern.compile("\\bint{3}\\b"); Matcher matcher = pattern.matcher(temp); if(matcher.find() system.out.print("found"); any idea
has answer: http://stackoverflow.com/a/22080805
accepted answer: http://stackoverflow.com/a/22080744
has comment: http://stackoverflow.com/comment/33494048
tagged with: regex
has comment: http://stackoverflow.com/comment/33487635

http://stackoverflow.com/comment/33412966
score: 0
has text: You should check the line number on the exception stack trace. That way you can see exactly what line of code is causing the error.
comment on: http://stackoverflow.com/a/22029244
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33450068
has text: Sometimes when I am stuck I just dont see things.Anyway thanks a lot for helping me out mate.
type: AnswerComment
comment on: http://stackoverflow.com/a/22059421
score: 0
type: Comment

http://stackoverflow.com/q/22091577
possible better answer: http://stackoverflow.com/a/22092570
has comment: http://stackoverflow.com/comment/33507935
has answer: http://stackoverflow.com/a/22092570
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22091804
has body: I am trying to make a servlet, and trying to override my doGet method. There is an error in the @Override doGet protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } It is under processRequest the error comes. The concrete error message is: The method processRequest(HttpServletRequest, HttpServletResponse) is undefined for the type CookieUsageServlet Does anybody know why I get this error? package ExamplePackage; import java.io.IOException; import java.util.Date; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/CookieUsageServlet") public class CookieUsageServlet extends HttpServlet { private static final long serialVersionUID = 1L; @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Cookie cookie = getCookie(request, response); printResponse(response, cookie); } private Cookie getCookie(HttpServletRequest request, HttpServletResponse response) { Cookie cookie = null; Cookie[] cookiesArray = request.getCookies(); if(cookiesArray != null) { for(int x = 0; x < cookiesArray.length; x++) { if(cookiesArray[x].getName().equals("test_cookie")) cookie = cookiesArray[x]; } } if(cookie != null) { System.out.println("cookie retrieved"); } else { int timeToExpireCookie = new Integer(getServletContext().getInitParameter("time-to-expire-cookie")).intValue(); cookie = new Cookie("test_cookie", Long.toString(new Date().getTime())); cookie.setMaxAge(timeToExpireCookie); cookie.setPath(request.getContextPath()); // Sti til logi…
tagged with: java
has comment: http://stackoverflow.com/comment/33507306
has comment: http://stackoverflow.com/comment/33507446
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33506756
has comment: http://stackoverflow.com/comment/33507360
has title: override doGet in servlet
tagged with: servlets
accepted answer: http://stackoverflow.com/a/22091804
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/33506889
has comment: http://stackoverflow.com/comment/33508951
favorite count: 0
has comment: http://stackoverflow.com/comment/33508249
has comment: http://stackoverflow.com/comment/33507025
has comment: http://stackoverflow.com/comment/33506918
upvote count: 1

http://stackoverflow.com/a/22120535
has body: If you want to round, you can use the round() method. double d = 6 +/- some small error long l = Math.round(d); Or you can add 0.5 for positive numbers long l = (long) (d + 0.5); or long l = (long) (d + (d &lt; 0 ? -0.5 : 0.5));
type: Answer
upvote count: 1
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/22120508

http://stackoverflow.com/comment/33382343
type: Comment
score: 1
has text: [Classes and objects.](http://docs.oracle.com/javase/tutorial/java/javaOO/)
comment on: http://stackoverflow.com/q/22021872
type: QuestionComment

http://stackoverflow.com/comment/33709932
comment on: http://stackoverflow.com/a/22092067
type: Comment
has text: i cant belive i failed to see that obvious mistake.. this error pulled my focus away from such issues.. thanks
type: AnswerComment
score: 0

http://stackoverflow.com/a/22160948
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/22160865
downvote count: 0
has body: Your first println statement (Response Value(main class)) will always be executed right away, which is why it prints null. Your register class will then do the processing on a separate thread and print the fetched value. In other words, your first println statement will never be called after you have finished fetching the content. What you may want to consider doing is adding a callback interface to your register class. This way, your Activity can implement it, pass it to your AsyncTask implementation, which will then trigger the callback when it is done. For example: The interface: public interface Callback { void onComplete(String response); } And in your register class: private Callback mCallback; public void setCallback(Callback callback) { mCallback = callback; } @Override public void onExecute(String result) { mCallback.execute(result); }
score: 1

http://stackoverflow.com/q/22021476
linked to: http://stackoverflow.com/q/79041428
has comment: http://stackoverflow.com/comment/33381809
tagged with: listview
has answer: http://stackoverflow.com/a/22021743
score: 0
has answer: http://stackoverflow.com/a/22022059
tagged with: android
has comment: http://stackoverflow.com/comment/33384324
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33383876
has comment: http://stackoverflow.com/comment/33381946
tagged with: java
has title: List view not sending exact list item clicked
type: Question
has body: Im not sure but my List is not working, supposed to be, when the onItemClick is hit, I should transfer that to a different class and open that activity, it is opening when i try to startactivity but not getting the exact item clicked to play. This is a media player btw. I really need help. NowPlayingActivity private ImageButton btnPlay; private ImageButton btnForward; private ImageButton btnBackward; private ImageButton btnNext; private ImageButton btnPrevious; private ImageButton btnRepeat; private ImageButton btnShuffle; private SeekBar songProgressBar; private TextView songTitleLabel; private TextView songCurrentDurationLabel; private TextView songTotalDurationLabel; // Media Player private MediaPlayer mp; // Handler to update UI timer, progress bar etc,. private Handler mHandler = new Handler();; private SongsManager songManager; private Utilities utils; private int seekForwardTime = 5000; // 5000 milliseconds private int seekBackwardTime = 5000; // 5000 milliseconds private int currentSongIndex = 0; private boolean isShuffle = false; private boolean isRepeat = false; private ArrayList&lt;HashMap&lt;String, String&gt;&gt; songsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.player); // All player buttons btnPlay = (ImageButton) findViewById(R.id.btnPlay); btnForward = (ImageButton) findViewById(R.id.btnForward); btnBackward = (ImageButton) findViewById(R.id.btnBackward); btnNext = (ImageButton) findViewById(R.id.btnNext); btnPrevious = (ImageButton) findViewById(R.id.btnPrevious); btnRepeat = (ImageButton) findViewById(R.id.btnRepeat); btnShuffle = (ImageButton) findViewById(R.id.btnShuffle); songProgressBar = (SeekBar) findViewById(R.id.songProgressBar); songTitleLabel = (TextView) findViewById(R.id.songTitle); songCurrentDurationLabel = (TextView) findViewById(R.id.songCurrentDurationLabel); songTotalDurationLabel = (TextView) fi…
answer count: 2

http://stackoverflow.com/a/22113442
answers question: http://stackoverflow.com/q/22113394
has body: You could try Maven for organising and installing your dependencies: http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
has comment: http://stackoverflow.com/comment/33547299
has comment: http://stackoverflow.com/comment/33546829
downvote count: 0
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/33546973
has comment: http://stackoverflow.com/comment/33546767
score: 1
has comment: http://stackoverflow.com/comment/33546951

parameterized
tags question: http://stackoverflow.com/q/22163898
tags question: http://stackoverflow.com/q/22026635
type: Tag
tag name: parameterized

http://stackoverflow.com/comment/33437882
has text: Oh, I forgot. I dont want relationships to be entities and i would like not to have them all mapped as many to many.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22052606
type: Comment

akka
type: Tag
tags question: http://stackoverflow.com/q/22106019
tag name: akka

http://stackoverflow.com/comment/33632516
comment on: http://stackoverflow.com/q/22161412
has text: @leigero I can't agree with you more. Scaring off new users is awful and unnecessary.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22005632
has comment: http://stackoverflow.com/comment/33353794
has comment: http://stackoverflow.com/comment/33353820
possible better answer: http://stackoverflow.com/a/22006478
tagged with: treemodel
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/22006478
has answer: http://stackoverflow.com/a/22006358
has comment: http://stackoverflow.com/comment/33353908
tagged with: swing
has comment: http://stackoverflow.com/comment/33412665
has body: I am working on JTree and i need to Create XML file of Jtree so is there any good way to convert it? I am using JTree in java. I just need to convert it and i have Checkbox as node into the Tree and i have used render for it. and when submit call i need to convert that Jtree into XML. is there any good way for that?? My Tree is Dynamically Created. so i need to convert it. i tried this try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document doc = factory.newDocumentBuilder().newDocument(); Element rootElement = doc.createElement("Vervesystems"); TreeNode root = (TreeNode) jTree1.getModel().getRoot(); parseTreeNode(root, rootElement); System.out.println("Node name"+root.toString()); System.err.println("Root node"+root.getChildCount()); Transformer tf = TransformerFactory.newInstance().newTransformer(); tf.setOutputProperty(OutputKeys.INDENT, "yes"); tf.setOutputProperty(OutputKeys.METHOD, "xml"); tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); DOMSource domSource = new DOMSource(doc); StreamResult sr = new StreamResult(new File("/home/kishan/NetBeansProjects/03-02-2014-VISDashboard/src/com/verve/visdashboard/TreeModel.xml")); tf.transform(domSource, sr); } catch (Exception e) { System.err.println("This is exception "+e); } private void parseTreeNode(TreeNode treeNode, Node doc) { try { Element parentElement = doc.getOwnerDocument().createElement("folder"); doc.appendChild(parentElement); System.err.println("Element name"+parentElement.getTagName()); // Apply properties to root element... org.w3c.dom.Attr attrName = doc.getOwnerDocument().createAttribute("DisplayName"); attrName.setNodeValue("Treenode"); System.err.println("Count"+treeNode.getChildCount()); parentElement.getAttributes().setNamedItem(attrName); Enumeration kiddies = treeNode.children(); while (kiddies.hasMoreElements()) { TreeNode child = (TreeNode) kiddies.nextElement(); //doc.appendChild(child); System.out.println("Child"+child.toString()); parseT…
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33353693
tagged with: jtree
linked to: http://stackoverflow.com/q/23707562
tagged with: java
has comment: http://stackoverflow.com/comment/33353604
accepted answer: http://stackoverflow.com/a/22006358
type: Question
has title: Converting JTree to Xml in java
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/33354074

http://stackoverflow.com/comment/33580902
comment on: http://stackoverflow.com/q/22132134
score: 1
has text: So are you asking for order or for limiting relations? o.O
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/71201808
type: QuestionComment
has text: Can you see the compiled .class file in target/classes? I am not sure that .java files in src/main/resources get compiled.
score: 1
comment on: http://stackoverflow.com/q/22100991
type: Comment

http://stackoverflow.com/comment/33621211
score: 0
has text: Rohit, thanks... I'm not wild about instantiating each of the classes just to get their description, that's why I thought static methods would be better, but as you say it's not possible. As currently implemented, I don't have uniform visible zero arg constructors because the classes take args and I do some non-trivial setup in the constructors. Any advice on that?
type: AnswerComment
comment on: http://stackoverflow.com/a/22152125
type: Comment

http://stackoverflow.com/comment/33634902
type: Comment
comment on: http://stackoverflow.com/a/22162865
type: AnswerComment
has text: Good catch user<randomobfuscatednumber>
score: 0

http://stackoverflow.com/q/22032045
possible better answer: http://stackoverflow.com/a/22090163
type: AnsweredQuestion
score: 3
has answer: http://stackoverflow.com/a/22090163
has answer: http://stackoverflow.com/a/22160152
downvote count: 0
linked to: http://stackoverflow.com/q/6981564
tagged with: java
tagged with: hibernate
type: Question
has comment: http://stackoverflow.com/comment/33502659
has comment: http://stackoverflow.com/comment/33525010
tagged with: spring-security
tagged with: struts2
upvote count: 3
answer count: 3
has title: Why am I receiving JDBC driver warning and ThreadLocal errors?
favorite count: 0
has body: I am running my application on GlassFish, I use Spring Security and Hibernate. When I run the application the following warning and errors will be shown on GlassFish console. How can I avoid them? WARNING: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. SEVERE: The web application [] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1087985b]) and a value of type [org.hibernate.internal.SessionImpl] (value [SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=[] updates=[] deletions=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[] unresolvedInsertDependencies=UnresolvedEntityInsertActions[]])]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. SEVERE: The web application [] created a ThreadLocal with key of type [net.sf.json.AbstractJSON$1] (value [net.sf.json.AbstractJSON$1@362386d7]) and a value of type [java.util.HashSet] (value [[]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. SEVERE: The web application [] created a ThreadLocal with key of type [net.sf.json.AbstractJSON$1] (value [net.sf.json.AbstractJSON$1@362386d7]) and a value of type [java.util.HashSet] (value [[]]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. hibernate.cfg.xml <hibernate-configuration> <session-factory> com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/myproject root 12 org.hibernate.dialect.MySQLDialect thread true HibernateUtil.java public class HibernateUtil { private static ServiceRegistry serviceRegistry; private static final ThreadLoca…
accepted answer: http://stackoverflow.com/a/22160152
tagged with: glassfish-4
has comment: http://stackoverflow.com/comment/33511992
has answer: http://stackoverflow.com/a/22173088
linked to: http://stackoverflow.com/q/3320400

http://stackoverflow.com/comment/33536071
comment on: http://stackoverflow.com/q/22107380
score: 0
type: Comment
has text: Just a thought: you might want to add a `java` tag to your question, for example by replacing "file". That would more likely get the attention of the people who can help you.
type: QuestionComment

http://stackoverflow.com/a/22105427
answers question: http://stackoverflow.com/q/22102103
has body: In order to check to see if a country is in the array, use an if statement. As you read in each country this checks to see if if exists in the array. If it doesn't, it adds the country to the array. if(!Arrays.asList(yourArr).contains(country)){ yourArr[i] = country; }
type: Answer
score: 0

http://stackoverflow.com/a/22069154
type: Answer
score: 2
accepted answer of: http://stackoverflow.com/q/22069026
has body: You should probably have only one CachedThreadPool in your whole application. Doing so, it allows you to factorize resources associated to the pool and also to take advantage of a better thread re-use. Creating a thread pool every time is a costly operation. Therefore create it once and use it as much as you want.
upvote count: 2
answers question: http://stackoverflow.com/q/22069026
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/22098572
upvote count: 19
has body: You have to do your database stuff into an other thread, cause if the operation take time it will freez the JavaFX thread (The GUI) In JavaFx you can use Service and Task to do background stuff. You should read Concurency in javafx Service By executing your database stuff into a service, you will be able to monitor it easely cause Service provide the necessary to do that, and have method like onSuccedeed, onFailed... Really have a look to that, is an essential part if you want to do JavaFx correctly. Main.java import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage primaryStage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); primaryStage.setTitle("Hello World"); primaryStage.setScene(new Scene(root, 300, 275)); primaryStage.show(); } public static void main(String[] args) { launch(args); } } ServiceExample.java import javafx.concurrent.Service; import javafx.concurrent.Task; public class ServiceExample extends Service&lt;String&gt; { @Override protected Task&lt;String&gt; createTask() { return new Task&lt;String&gt;() { @Override protected String call() throws Exception { //DO YOU HARD STUFF HERE String res = "toto"; Thread.sleep(5000); return res; } }; } } Controller.java import javafx.concurrent.WorkerStateEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.scene.control.ProgressIndicator; public class Controller { @FXML private ProgressIndicator progressIndicator; public void initialize() { final ServiceExample serviceExample = new ServiceExample(); //Here you tell your progress indicator is visible only when the service is runing progressIndicator.visibleProperty().bind(serviceExample.runningProperty()); serviceExample.setOnSucceeded(new EventHandler&lt;WorkerStateEvent&gt;() { @Override public void handle(WorkerStateEvent wor…
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22098288
answers question: http://stackoverflow.com/q/22098288
type: Answer
has comment: http://stackoverflow.com/comment/33524437
downvote count: 0
has comment: http://stackoverflow.com/comment/33521966
score: 19

bukkit
tag name: bukkit
tags question: http://stackoverflow.com/q/22119642
type: Tag
tags question: http://stackoverflow.com/q/22160617

http://stackoverflow.com/q/22138164
linked to: http://stackoverflow.com/q/22108540
has answer: http://stackoverflow.com/a/22138285
type: Question
has title: JButtons won't update on button click
has answer: http://stackoverflow.com/a/22138279
has body: Currently displays a GUI with an 8x8 grid of randomized colored buttons. The newButton is to reset the score display to 0 and reset the grid with a fresh like it does on startup after being clicked. I haven't been able to find many solutions other than that it's to do with the way Java displays it's buttons and the way layering works. Here are the 2 classes I'm using. import javax.swing.JFrame; import javax.swing.*; import java.awt.event.*; import javax.swing.JPanel; import java.awt.Color; public class ShinyButtonsApp extends JFrame implements ActionListener { private static byte ROWS = 8; public int useThis; ShinyButtons shiny = new ShinyButtons(); public static ImageIcon[] icons = {new ImageIcon("RedButton.png"), new ImageIcon("OrangeButton.png"), new ImageIcon("YellowButton.png"), new ImageIcon("GreenButton.png"), new ImageIcon("BlueButton.png"), new ImageIcon("LightGrayButton.png"), new ImageIcon("DarkGrayButton.png")}; public ShinyButtonsApp(String title) { super(title); // Set title of window setDefaultCloseOperation(EXIT_ON_CLOSE); // allow window to close setSize(578, 634); // Set size of window setResizable(false); getContentPane().setLayout(null); JLabel aLabel = new JLabel("Score: "); aLabel.setLocation(10, 570); aLabel.setSize(80,30); getContentPane().add(aLabel); JTextField scoreField = new JTextField(); scoreField.setText(Integer.toString(shiny.score)); scoreField.setEditable(false); scoreField.setHorizontalAlignment(JTextField.RIGHT); scoreField.setLocation(60, 570); scoreField.setSize(120,30); scoreField.setBackground(Color.WHITE); getContentPane().add(scoreField); JButton newButton = new JButton("New Game"); newButton.addActionListener(this); newButton.setLocation(348,570); newButton.setSize(110,30); getContentPane().add(newButton); JButton quitButton = new JButton("Quit"); quitButton.setLocation(468,570); quitButton.setSize(80,30); getContentPane().add(quitButton); resetButtons2(); } public void actionPerformed(ActionEvent e) { shiny.score = 0; shi…
score: 0
answer count: 3
has comment: http://stackoverflow.com/comment/33591029
has comment: http://stackoverflow.com/comment/33590935
has answer: http://stackoverflow.com/a/22138743
accepted answer: http://stackoverflow.com/a/22138743
has comment: http://stackoverflow.com/comment/33591092
possible better answer: http://stackoverflow.com/a/22138279
tagged with: jbutton
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/a/22018121
type: Answer
has body: If what you want is to maintain a relationship that stringValue cannot be something other than OtherClass.someMethod() why not just use a getter method that fetches it, in place of even maintaining a variable? Something of the likes: public class StaticClass { public static getStringValue() { return OtherClass.someMethod(); } } I think we need more information into the problem. There is likely a much better way to do what you want.
answers question: http://stackoverflow.com/q/22018043
score: 0

http://stackoverflow.com/comment/33458460
has text: @Alex How should I proceed then? I didn't get what you told. Can you provide any link for reference?
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22062841

http://stackoverflow.com/comment/33522154
type: Comment
has text: Right. This processor does not have a hardware float co processor. And @Voo, thanks for your input, but why bash on me (with the 'as usually', etc) rather than teach. I do not claim to know everything, otherwise I wouldn't ask questions here. Any suggestion on how I could improve the actual results? I'm thinking about multiplying the floats by a few orders of magnitude, then cast to int before converting to string.
comment on: http://stackoverflow.com/a/22099770
type: AnswerComment
score: 0

http://stackoverflow.com/q/22104782
answer count: 3
has title: Just add twitter4j-core-3.0.5.jar to your application classpath in net beans and maven
tagged with: netbeans-7
has answer: http://stackoverflow.com/a/22105237
favorite count: 0
tagged with: maven
has body: I am trying to add a jar in accordance with this link: http://twitter4j.org/en/index.html#howToUse It states "Just add twitter4j-core-3.0.5.jar to your application classpath." How do I do that in: Netbeans maven eclipse Thanks!
downvote count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22118166
accepted answer: http://stackoverflow.com/a/22118166
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/22105237
tagged with: eclipse
type: Question
has comment: http://stackoverflow.com/comment/33531998
upvote count: 2
has answer: http://stackoverflow.com/a/22105329

http://stackoverflow.com/comment/33526031
score: 0
type: Comment
has text: i'm sure that the sql server is running. I checked it in the configuration manager, and i can use it with Microsoft Sql Server Management Studio
comment on: http://stackoverflow.com/a/22097820
type: AnswerComment

http://stackoverflow.com/q/22020231
tagged with: maven
has body: I'm trying to create maven project using maven template from command propmt. But it looks like downloading the jar and gatting failed. Maven version is 3.2.1. Please advise why this happening ? C:\workspace>mvn archetype:generate -DgroupId=com.mkyong -DartifactId=CounterWebApp -DarchetypeArtifactId=maven-archetype-webapp -Dinte ractiveMode=false [INFO] Scanning for projects... Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-clean-plugin :2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5 Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-install-plugin:2.4: Plugin org.apache.maven.plugins:maven-install-pl ugin:2.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-install-plugin:jar:2. 4 Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-deploy-plugin:2.7: Plugin org.apache.maven.plugins:maven-deploy-plug in:2.7 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-deploy-plugin:jar:2.7 Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-site-plugin/3.3/maven-site-plugin-3.3.pom
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
has title: Maven - Not able to create project using maven template
accepted answer: http://stackoverflow.com/a/22020494
type: Question
tagged with: apache
downvote count: 0
answer count: 1
tagged with: maven-3
favorite count: 0
has answer: http://stackoverflow.com/a/22020494

http://stackoverflow.com/comment/33566978
has text: In other words, why can't you just do [something like this: http://pastie.org/8816329](http://pastie.org/8816329)
comment on: http://stackoverflow.com/q/22120747
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22016586
has comment: http://stackoverflow.com/comment/33373266
possible better answer: http://stackoverflow.com/a/22018312
has answer: http://stackoverflow.com/a/22018312
accepted answer: http://stackoverflow.com/a/22017153
has comment: http://stackoverflow.com/comment/33372439
has comment: http://stackoverflow.com/comment/33373288
answer count: 2
has comment: http://stackoverflow.com/comment/33372796
has title: Syntax error insert "}" to complete classBody, new at coding
has comment: http://stackoverflow.com/comment/33372651
has comment: http://stackoverflow.com/comment/33373022
has comment: http://stackoverflow.com/comment/33372516
has comment: http://stackoverflow.com/comment/33372601
has comment: http://stackoverflow.com/comment/33372607
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22017153
tagged with: syntax
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/33373467
has comment: http://stackoverflow.com/comment/33373265
has body: I have looked around and could not seem to find a solution to this. I'm not sure what is wrong with my code here. Link to my code http://pastebin.com/8z7rjVVK Error received while compiling: ===== COMPILING - PLEASE WAIT... ===== src\server\model\players\packets\ClickingButtons.java:1313: error: reached end o f file while parsing } ^ 1 error =============== DONE =================== Press any key to continue . . . Sorry, I know there are other questions regarding the same error, but I can't seem to fix this. Thanks. This is Java.
has comment: http://stackoverflow.com/comment/33373205
type: Question

binary-tree
tag name: binary-tree
type: Tag
tags question: http://stackoverflow.com/q/22077875
tags question: http://stackoverflow.com/q/22024776
tags question: http://stackoverflow.com/q/22160973

http://stackoverflow.com/q/22115510
has body: I'm triyng to make a game like bejeweled or candy crush. I have created 64 buttons units 8x8. I want to change the image of buttons clicked. But i couldn't. I would be glad if you can help. Or how else can I do? Edit: I'm so sorry. I couldn't explain my problem clearly. My problem, i want to change pictures of clicked two buttons. For example, i clicked buttons[5] and i clicked buttons[11]. Then icon of buttons[5] should be buttons[11] icon and icon of [11] should be buttons[5] icon. public class butondeneme extends JFrame{ private JPanel grid; private JFrame jr; public butondeneme(){ jr=new JFrame(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 640, 640); grid=new JPanel(); grid.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); grid.setLayout(new GridLayout(8,8,5,5)); JButton[] buttons = new JButton[64]; //Creating random image for buttons for (int i = 0; i&lt;buttons.length; i++) { Random r = new Random(); int a = r.nextInt(9)+1; switch(a){ case 1 : buttons[i]=new JButton(new ImageIcon("img//Cakal.png")); break; case 2 : buttons[i]=new JButton(new ImageIcon("img//BugsBunny.png")); break; case 3 : buttons[i]=new JButton(new ImageIcon("img//Pig.png")); break; case 4 : buttons[i]=new JButton(new ImageIcon("img//Taz.png")); break; case 5 : buttons[i]=new JButton(new ImageIcon("img//Sam.png")); break; case 6 : buttons[i]=new JButton(new ImageIcon("img//DuffyDuck.png")); break; case 7 : buttons[i]=new JButton(new ImageIcon("img//Tweety.png")); break; case 8 : buttons[i]=new JButton(new ImageIcon("img//Slyvester.png")); break; case 9 : buttons[i]=new JButton(new ImageIcon("img//RoadRunner.png")); break; } //Adding number to find easily String comand=Integer.toString(i); //Get ImageIcon name final String imgName=((ImageIcon)buttons[i].getIcon()).toString(); buttons[i].addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ } } }); buttons[i].setActionCommand(comand); grid.add(buttons[i]); } add(grid); } public stati…
downvote count: 0
score: 1
tagged with: java
tagged with: swing
type: Question
has answer: http://stackoverflow.com/a/22115700
has answer: http://stackoverflow.com/a/22115660
accepted answer: http://stackoverflow.com/a/22115700
upvote count: 1
tagged with: button
favorite count: 0
has answer: http://stackoverflow.com/a/22115687
has comment: http://stackoverflow.com/comment/33550341
possible better answer: http://stackoverflow.com/a/22115885
has title: Clicking the button to change the picture
has answer: http://stackoverflow.com/a/22115885
answer count: 4
type: AnsweredQuestion

http://stackoverflow.com/comment/33511782
comment on: http://stackoverflow.com/a/22094586
has text: Quotes do dissapear? Isn't it `char A='<CR>'`; (with CR being zero-with whitespace that breaks the line?)
type: Comment
type: AnswerComment
score: 0

jakarta-ee
tags question: http://stackoverflow.com/q/22145942
tags question: http://stackoverflow.com/q/22110151
tags question: http://stackoverflow.com/q/22168348
tags question: http://stackoverflow.com/q/22120435
tags question: http://stackoverflow.com/q/22143884
tags question: http://stackoverflow.com/q/22147407
tags question: http://stackoverflow.com/q/22119280
tags question: http://stackoverflow.com/q/22101510
type: Tag
tags question: http://stackoverflow.com/q/22013145
tags question: http://stackoverflow.com/q/22168156
tags question: http://stackoverflow.com/q/22121061
tags question: http://stackoverflow.com/q/22167518
tags question: http://stackoverflow.com/q/22061597
tags question: http://stackoverflow.com/q/22148257
tags question: http://stackoverflow.com/q/22117709
tags question: http://stackoverflow.com/q/22048164
tags question: http://stackoverflow.com/q/22014604
tag name: jakarta-ee
tags question: http://stackoverflow.com/q/22165436
tags question: http://stackoverflow.com/q/22129057
tags question: http://stackoverflow.com/q/22167592
tags question: http://stackoverflow.com/q/22160711
tags question: http://stackoverflow.com/q/22166832
tags question: http://stackoverflow.com/q/22106886
tags question: http://stackoverflow.com/q/22044604
tags question: http://stackoverflow.com/q/22007387
tags question: http://stackoverflow.com/q/22012975
tags question: http://stackoverflow.com/q/22066090
tags question: http://stackoverflow.com/q/22166415
tags question: http://stackoverflow.com/q/22147287
tags question: http://stackoverflow.com/q/22010530
tags question: http://stackoverflow.com/q/22032446
tags question: http://stackoverflow.com/q/22159454
tags question: http://stackoverflow.com/q/22005734
tags question: http://stackoverflow.com/q/22117933
tags question: http://stackoverflow.com/q/22117863
tags question: http://stackoverflow.com/q/22126292
tags question: http://stackoverflow.com/q/22124046
tags question: http://stackoverflow.com/q/22026715
tags question: http://stackoverflow.com/q/22096529
tags question: http://stackoverflow.com/q/22088141
tags question: http://stackoverflow.com/q/22164645
tags question: http://stackoverflow.com/q/22117377
tags question: http://stackoverflow.com/q/22081314
tags question: http://stackoverflow.com/q/22039569
tags question: http://stackoverflow.com/q/22133497
tags question: http://stackoverflow.com/q/22039398
tags question: http://stackoverflow.com/q/22142374
tags question: http://stackoverflow.com/q/22074361
tags question: http://stackoverflow.com/q/22010704
tags question: http://stackoverflow.com/q/22138969
tags question: http://stackoverflow.com/q/22119545

http://stackoverflow.com/q/22155832
has title: Spring Java Config: how do you create a prototype-scoped @Bean with runtime arguments?
downvote count: 0
has answer: http://stackoverflow.com/a/65370727
linked to: http://stackoverflow.com/q/57311147
accepted answer: http://stackoverflow.com/a/22184027
tagged with: scope
has comment: http://stackoverflow.com/comment/33623373
has answer: http://stackoverflow.com/a/22185037
has comment: http://stackoverflow.com/comment/33672378
favorite count: 0
answer count: 9
has answer: http://stackoverflow.com/a/73047081
upvote count: 186
has comment: http://stackoverflow.com/comment/33623335
has answer: http://stackoverflow.com/a/58259808
has comment: http://stackoverflow.com/comment/41735058
tagged with: spring
has answer: http://stackoverflow.com/a/53125791
type: AnsweredQuestion
has body: Using Spring's Java Config, I need to acquire/instantiate a prototype-scoped bean with constructor arguments that are only obtainable at runtime. Consider the following code example (simplified for brevity): @Autowired private ApplicationContext appCtx; public void onRequest(Request request) { //request is already validated String name = request.getParameter("name"); Thing thing = appCtx.getBean(Thing.class, name); //System.out.println(thing.getName()); //prints name } where the Thing class is defined as follows: public class Thing { private final String name; @Autowired private SomeComponent someComponent; @Autowired private AnotherComponent anotherComponent; public Thing(String name) { this.name = name; } public String getName() { return this.name; } } Notice name is final: it can only be supplied via a constructor, and guarantees immutability. The other dependencies are implementation-specific dependencies of the Thing class, and shouldn't be known to (tightly coupled to) the request handler implementation. This code works perfectly well with Spring XML config, for example: &lt;bean id="thing", class="com.whatever.Thing" scope="prototype"&gt; &lt;!-- other post-instantiation properties omitted --&gt; &lt;/bean&gt; How do I achieve the same thing with Java config? The following does not work using Spring 3.x: @Bean @Scope("prototype") public Thing thing(String name) { return new Thing(name); } Now, I could create a Factory, e.g.: public interface ThingFactory { public Thing createThing(String name); } But that defeats the entire point of using Spring to replace the ServiceLocator and Factory design pattern, which would be ideal for this use case. If Spring Java Config could do this, I would be able to avoid: defining a Factory interface defining a Factory implementation writing tests for the Factory implementation That's a ton of work (relatively speaking) for something so trivial that Spring already supports via XML config.
has answer: http://stackoverflow.com/a/22184027
score: 186
has comment: http://stackoverflow.com/comment/33622997
tagged with: java
possible better answer: http://stackoverflow.com/a/43594962
has comment: http://stackoverflow.com/comment/33622828
tagged with: spring-java-config
tagged with: prototype
has answer: http://stackoverflow.com/a/43594962
type: Question
has answer: http://stackoverflow.com/a/52021965
has answer: http://stackoverflow.com/a/57449425

http://stackoverflow.com/a/22021249
score: 0
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/33413663
has comment: http://stackoverflow.com/comment/33408900
has body: You're not using the FileOutputStream class correctly. The first parameter is the array you want to write on the file. The second one is the offset from that array that you want to start writing from. The third one is the length of what you want to write. So, in your case, if you use an offset which is different from 0, you'll get an out of bounds exception. If you want to write that number inside a file using FileOutputStream, you can read that file (using, for example, a FileInputStream), read the amount of bytes you want to read and write them into the output stream, then write that number using something akin to: output.write(t.getBytes(),0,t.length); And finally reading the rest of the inputstream and writing it into the outputstream. Best of luck.
type: Answer
has comment: http://stackoverflow.com/comment/33381371
has comment: http://stackoverflow.com/comment/33381177
answers question: http://stackoverflow.com/q/22020447
has comment: http://stackoverflow.com/comment/33381281

casting
tags question: http://stackoverflow.com/q/22022751
tags question: http://stackoverflow.com/q/22122171
tags question: http://stackoverflow.com/q/22110401
tags question: http://stackoverflow.com/q/22144671
tags question: http://stackoverflow.com/q/22031588
tags question: http://stackoverflow.com/q/22030021
tag name: casting
type: Tag
tags question: http://stackoverflow.com/q/22156877
tags question: http://stackoverflow.com/q/22092589
tags question: http://stackoverflow.com/q/22067409
tags question: http://stackoverflow.com/q/22077773
tags question: http://stackoverflow.com/q/22077950

http://stackoverflow.com/q/22153377
score: 7
favorite count: 0
has answer: http://stackoverflow.com/a/30141019
has comment: http://stackoverflow.com/comment/33627336
has comment: http://stackoverflow.com/comment/36754715
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22174202
has body: I recently came across this article which provided a nice intro to memory mapped files and how it can be shared between two processes. Here is the code for a process that reads in the file: import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; public class MemoryMapReader { /** * @param args * @throws IOException * @throws FileNotFoundException * @throws InterruptedException */ public static void main(String[] args) throws FileNotFoundException, IOException, InterruptedException { FileChannel fc = new RandomAccessFile(new File("c:/tmp/mapped.txt"), "rw").getChannel(); long bufferSize=8*1000; MappedByteBuffer mem = fc.map(FileChannel.MapMode.READ_ONLY, 0, bufferSize); long oldSize=fc.size(); long currentPos = 0; long xx=currentPos; long startTime = System.currentTimeMillis(); long lastValue=-1; for(;;) { while(mem.hasRemaining()) { lastValue=mem.getLong(); currentPos +=8; } if(currentPos &lt; oldSize) { xx = xx + mem.position(); mem = fc.map(FileChannel.MapMode.READ_ONLY,xx, bufferSize); continue; } else { long end = System.currentTimeMillis(); long tot = end-startTime; System.out.println(String.format("Last Value Read %s , Time(ms) %s ",lastValue, tot)); System.out.println("Waiting for message"); while(true) { long newSize=fc.size(); if(newSize&gt;oldSize) { oldSize = newSize; xx = xx + mem.position(); mem = fc.map(FileChannel.MapMode.READ_ONLY,xx , oldSize-xx); System.out.println("Got some data"); break; } } } } } } I have, however, a few comments/questions regarding that approach: If we execute the reader only on an empty file, i.e run long bufferSize=8*1000; MappedByteBuffer mem = fc.map(FileChannel.MapMode.READ_ONLY, 0, bufferSize); long oldSize=fc.size(); This will allocate 8000 bytes which will now extend the file. The buffer that this returns has a limit of 8000 and a position of 0, therefore, the reader can proceed and rea…
has comment: http://stackoverflow.com/comment/33618005
tagged with: java
has title: Java NIO - Memory mapped files
upvote count: 7
tagged with: nio
type: Question
possible better answer: http://stackoverflow.com/a/23024728
has answer: http://stackoverflow.com/a/23024728
downvote count: 0
has comment: http://stackoverflow.com/comment/33645712
accepted answer: http://stackoverflow.com/a/22174202
tagged with: buffer
answer count: 3
tagged with: memory-mapped-files
tagged with: channel

regex
tags question: http://stackoverflow.com/q/22163764
tags question: http://stackoverflow.com/q/22049929
tags question: http://stackoverflow.com/q/22068860
tags question: http://stackoverflow.com/q/22015228
tags question: http://stackoverflow.com/q/22081418
tags question: http://stackoverflow.com/q/22079519
tags question: http://stackoverflow.com/q/22063215
tags question: http://stackoverflow.com/q/22143320
tags question: http://stackoverflow.com/q/22048471
tags question: http://stackoverflow.com/q/22164368
tags question: http://stackoverflow.com/q/22092586
tag name: regex
tags question: http://stackoverflow.com/q/22146173
tags question: http://stackoverflow.com/q/22116300
tags question: http://stackoverflow.com/q/22025343
tags question: http://stackoverflow.com/q/22146334
tags question: http://stackoverflow.com/q/22091332
tags question: http://stackoverflow.com/q/22139372
tags question: http://stackoverflow.com/q/22119665
tags question: http://stackoverflow.com/q/22048692
tags question: http://stackoverflow.com/q/22163499
tags question: http://stackoverflow.com/q/22089659
tags question: http://stackoverflow.com/q/22026404
tags question: http://stackoverflow.com/q/22057701
tags question: http://stackoverflow.com/q/22031634
tags question: http://stackoverflow.com/q/22065494
tags question: http://stackoverflow.com/q/22051862
tags question: http://stackoverflow.com/q/22052810
tags question: http://stackoverflow.com/q/22107954
tags question: http://stackoverflow.com/q/22156876
tags question: http://stackoverflow.com/q/22011164
tags question: http://stackoverflow.com/q/22121519
tags question: http://stackoverflow.com/q/22111046
tags question: http://stackoverflow.com/q/22050907
tags question: http://stackoverflow.com/q/22016401
tags question: http://stackoverflow.com/q/22138158
tags question: http://stackoverflow.com/q/22009571
tags question: http://stackoverflow.com/q/22076659
tags question: http://stackoverflow.com/q/22158664
tags question: http://stackoverflow.com/q/22031789
tags question: http://stackoverflow.com/q/22129439
tags question: http://stackoverflow.com/q/22155183
tags question: http://stackoverflow.com/q/22103159
tags question: http://stackoverflow.com/q/22080579
tags question: http://stackoverflow.com/q/22028800
tags question: http://stackoverflow.com/q/22126134
tags question: http://stackoverflow.com/q/22090303
tags question: http://stackoverflow.com/q/22085742
tags question: http://stackoverflow.com/q/22040852
tags question: http://stackoverflow.com/q/22088071
tags question: http://stackoverflow.com/q/22043592
tags question: http://stackoverflow.com/q/22135648
tags question: http://stackoverflow.com/q/22168592
tags question: http://stackoverflow.com/q/22026415
tags question: http://stackoverflow.com/q/22019803
tags question: http://stackoverflow.com/q/22015273
tags question: http://stackoverflow.com/q/22144701
tags question: http://stackoverflow.com/q/22144878
tags question: http://stackoverflow.com/q/22034294
tags question: http://stackoverflow.com/q/22017480
tags question: http://stackoverflow.com/q/22042009
tags question: http://stackoverflow.com/q/22133506
tags question: http://stackoverflow.com/q/22021129
tags question: http://stackoverflow.com/q/22046130
tags question: http://stackoverflow.com/q/22061139
tags question: http://stackoverflow.com/q/22061723
tags question: http://stackoverflow.com/q/22112150
type: Tag
tags question: http://stackoverflow.com/q/22064409
tags question: http://stackoverflow.com/q/22076358
tags question: http://stackoverflow.com/q/22061614
tags question: http://stackoverflow.com/q/22047484
tags question: http://stackoverflow.com/q/22128481
tags question: http://stackoverflow.com/q/22036015

http://stackoverflow.com/q/22157913
accepted answer: http://stackoverflow.com/a/22158390
answer count: 2
downvote count: 0
score: 1
favorite count: 0
has body: I'm trying to implement a ExpandableListView in java that when click deployment space elements inside, not the typical wish list allows choosing an option. What I try to do is basically something like this One can see that the spinner "wraps" to have items and does not have a list, Would I could help a little?
has comment: http://stackoverflow.com/comment/33626785
tagged with: android
has comment: http://stackoverflow.com/comment/33626419
upvote count: 1
has title: How I can implement a ExpandableListView in java (for Android) that make click display items?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22158390
tagged with: java
possible better answer: http://stackoverflow.com/a/22158648
type: Question
tagged with: android-layout
has answer: http://stackoverflow.com/a/22158648
tagged with: android-spinner

http://stackoverflow.com/a/22165118
upvote count: 3
has body: The problem is that you have put 0 in the minute field.So it fires only at 2:00. Try trigger2 = TriggerBuilder .newTrigger() .withIdentity("abc", "group1") .withSchedule( CronScheduleBuilder.cronSchedule("0/30 * 14-23 * * ?")) .build();
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33638932
type: Answer
accepted answer of: http://stackoverflow.com/q/22164912
downvote count: 0
answers question: http://stackoverflow.com/q/22164912
has comment: http://stackoverflow.com/comment/33638849
score: 3
has comment: http://stackoverflow.com/comment/33639220
has comment: http://stackoverflow.com/comment/33638786

http://stackoverflow.com/comment/33466697
type: Comment
comment on: http://stackoverflow.com/a/22069191
has text: Added an extended description (see updated answer). It is essentially the same, but in general, method `findElements` returns a `List` object. In order to get an element from that object, you can use `get` (as for any other `List` object, regardless of Selenium)... you're welcome!
type: AnswerComment
score: 0

http://stackoverflow.com/q/22096958
has title: Updates imageView of my adapter in android
type: Question
has answer: http://stackoverflow.com/a/22097491
answer count: 2
possible better answer: http://stackoverflow.com/a/22097491
score: 0
accepted answer: http://stackoverflow.com/a/22143896
tagged with: android
has comment: http://stackoverflow.com/comment/33516221
has body: I want to use AsyncTask to have images of articles which is in the cache or in the net. After that put these images in the corresponding imageView of my adapter. Here are my code: Article.java public class Article { private String titre = ""; private String auteur = ""; private String date = ""; private String contenu = ""; private String url = ""; private Bitmap photo = null; public Article() { } public Article(Context context, String titre, String auteur, String date, String url, String contenu) { this.titre = titre; this.auteur = auteur; this.date = date; this.contenu = contenu; this.url = url; Bitmap image = BitmapFactory.decodeResource(context.getResources(), R.drawable.no_image); this.photo = image; } public String getTitre() { return titre; } public String getAuteur() { return auteur; } public String getDate() { return date; } public String getUrl() { return url; } public String getContenu() { return contenu; } public Bitmap getPhoto() { return photo; } public void setTitre(String titre) { this.titre = titre; } public void setAuteur(String auteur) { this.auteur = auteur; } public void setDate(String date) { this.date = date; } public void setUrl(String url) { this.url = url; } public void setContenu(String contenu) { this.contenu = contenu; } public void setPhoto(Bitmap photo) { this.photo = photo; } } ArticleAdapter public class ArticleAdapter extends BaseAdapter { private ArrayList&lt;Article&gt; articles; private LayoutInflater mInflater; private Resources mResource = null; public ArticleAdapter(Context context, ArrayList&lt;Article&gt; articles) { mInflater = LayoutInflater.from(context); this.articles = articles; this.mResource = context.getResources(); } @Override public int getCount() { // TODO Auto-generated method stub return articles.size(); } @Override public Object getItem(int pos) { // TODO Auto-generated method stub return articles.get(pos); } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } @…
favorite count: 0
upvote count: 1
tagged with: android-imageview
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33516978
tagged with: java
has answer: http://stackoverflow.com/a/22143896
downvote count: 1

http://stackoverflow.com/q/22009301
tagged with: java
has answer: http://stackoverflow.com/a/22009333
has title: How to empty a jlist without jlist.removeall()
has comment: http://stackoverflow.com/comment/33360219
score: 0
answer count: 3
tagged with: jlist
linked to: http://stackoverflow.com/q/13597903
has answer: http://stackoverflow.com/a/22009439
has answer: http://stackoverflow.com/a/22009569
has body: Am using jlist.removeall to remove all the items in jlist but its not working for me private void d_location2ActionPerformed(java.awt.event.ActionEvent evt) { l_storieslist.removeAll(); } It is not removing anything from my jlist an dam using netbeans
duplicate of: http://stackoverflow.com/q/13597903
type: UnansweredQuestion
tagged with: swing
type: Question
tagged with: actionlistener

http://stackoverflow.com/comment/33584257
type: Comment
comment on: http://stackoverflow.com/a/22133943
has text: Sorry, I did not get your point. Are you suggesting SwingWorkers should be avoided in general or SwingWorkers with custom ExecutorService? Last line of the SwingWorker documentation is "Because SwingWorker implements Runnable, a SwingWorker can be submitted to an Executor for execution."
score: 1
type: AnswerComment

http://stackoverflow.com/comment/33517549
type: QuestionComment
has text: Using *Java HotSpot(TM) 64-Bit Server VM (build 25.0-b69, mixed mode)*. Same as mentioned in your question.
score: 0
comment on: http://stackoverflow.com/q/22096052
type: Comment

http://stackoverflow.com/comment/33585829
type: Comment
type: QuestionComment
has text: Your bug is in the constructor. It does nothing. (And Sotirios beat me to it ... again)
score: 3
comment on: http://stackoverflow.com/q/22134928

http://stackoverflow.com/comment/33587052
type: QuestionComment
comment on: http://stackoverflow.com/q/22135464
has text: It is in the for+each loop so it implements Iterable<T> so its provide an Iterator that is JDK
score: 0
type: Comment

http://stackoverflow.com/comment/33503642
score: 0
has text: `getCommand` is actually `sendCommand`?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22089666

http://stackoverflow.com/comment/33508562
comment on: http://stackoverflow.com/a/22091906
type: AnswerComment
score: 0
type: Comment
has text: Thanks, but this does not work, follow the error. Add

http://stackoverflow.com/q/22079046
has answer: http://stackoverflow.com/a/22079528
possible better answer: http://stackoverflow.com/a/22079105
downvote count: 1
has body: I am being beginner trying to learn java basics and here in the this program I am confused why we can't reassign the value of class instance variable. this is error in this program. Please guys help me out to figure it out. thanks class AddInsideClassVar{ int a = 3; int c; c = a + a; public static void main(String args[]){ System.out.println(); } }
has answer: http://stackoverflow.com/a/22079511
has answer: http://stackoverflow.com/a/22079105
has comment: http://stackoverflow.com/comment/33484547
accepted answer: http://stackoverflow.com/a/22079528
answer count: 5
has answer: http://stackoverflow.com/a/22079130
has answer: http://stackoverflow.com/a/22079073
tagged with: class
type: AnsweredQuestion
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33484590
type: Question
has comment: http://stackoverflow.com/comment/33484657
has title: trying to reassign value to class instance variables
upvote count: 2
tagged with: java

http://stackoverflow.com/comment/55696775
score: 0
type: Comment
type: QuestionComment
has text: Possible duplicate of [Java simple code: java.net.SocketException: Unexpected end of file from server](http://stackoverflow.com/questions/19824339/java-simple-code-java-net-socketexception-unexpected-end-of-file-from-server)
comment on: http://stackoverflow.com/q/22147457

http://stackoverflow.com/comment/33479274
type: Comment
has text: @djechlin one more map is needed, the one with the number as key. Which is a map inside a map again...
comment on: http://stackoverflow.com/a/22076135
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33644710
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22168078
type: Comment
has text: try my second solution

http://stackoverflow.com/q/22113390
has answer: http://stackoverflow.com/a/22113522
type: AnsweredQuestion
tagged with: java
tagged with: apache-cocoon
tagged with: freebsd
downvote count: 0
answer count: 1
tagged with: neo4j
accepted answer: http://stackoverflow.com/a/22113522
favorite count: 0
score: 2
has body: I'm currently running cocoon on my FreeBSD server (9.2) I'm using this version of java : java -version openjdk version "1.6.0_32" OpenJDK Runtime Environment (build 1.6.0_32-b28) OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode) But I would like also to use Neo4j which needs Java 7. I did a pkg opendjk7 but I don't know how to tell Neo4j to use this version of Java (in my PATH I have Java 6). What should I do ? Thanks a lot Sincerely A.H
upvote count: 2
has title: Choose a specific java version for neo4j or cocoon
type: Question

sql
tags question: http://stackoverflow.com/q/22141776
tags question: http://stackoverflow.com/q/22150562
tags question: http://stackoverflow.com/q/22097665
tags question: http://stackoverflow.com/q/22069246
tags question: http://stackoverflow.com/q/22123698
tags question: http://stackoverflow.com/q/22047520
tags question: http://stackoverflow.com/q/22123139
tags question: http://stackoverflow.com/q/22157227
tags question: http://stackoverflow.com/q/22056402
tags question: http://stackoverflow.com/q/22126570
tags question: http://stackoverflow.com/q/22077892
tags question: http://stackoverflow.com/q/22100892
tags question: http://stackoverflow.com/q/22105896
tags question: http://stackoverflow.com/q/22033556
tags question: http://stackoverflow.com/q/22160068
tags question: http://stackoverflow.com/q/22114576
tags question: http://stackoverflow.com/q/22077589
tags question: http://stackoverflow.com/q/22138665
tags question: http://stackoverflow.com/q/22154150
tags question: http://stackoverflow.com/q/22049924
tags question: http://stackoverflow.com/q/22124327
tags question: http://stackoverflow.com/q/22052606
tag name: sql
tags question: http://stackoverflow.com/q/22146599
tags question: http://stackoverflow.com/q/22113992
type: Tag
tags question: http://stackoverflow.com/q/22010544
tags question: http://stackoverflow.com/q/22096093
tags question: http://stackoverflow.com/q/22135600
tags question: http://stackoverflow.com/q/22112647
tags question: http://stackoverflow.com/q/22032124
tags question: http://stackoverflow.com/q/22017361
tags question: http://stackoverflow.com/q/22054647
tags question: http://stackoverflow.com/q/22059347
tags question: http://stackoverflow.com/q/22016414
tags question: http://stackoverflow.com/q/22164046
tags question: http://stackoverflow.com/q/22117096
tags question: http://stackoverflow.com/q/22140059
tags question: http://stackoverflow.com/q/22078386
tags question: http://stackoverflow.com/q/22133571
tags question: http://stackoverflow.com/q/22163988
tags question: http://stackoverflow.com/q/22167872
tags question: http://stackoverflow.com/q/22027865
tags question: http://stackoverflow.com/q/22021823
tags question: http://stackoverflow.com/q/22055707
tags question: http://stackoverflow.com/q/22141202
tags question: http://stackoverflow.com/q/22145513
tags question: http://stackoverflow.com/q/22049503
tags question: http://stackoverflow.com/q/22087751
tags question: http://stackoverflow.com/q/22005734
tags question: http://stackoverflow.com/q/22144254
tags question: http://stackoverflow.com/q/22168486
tags question: http://stackoverflow.com/q/22112477
tags question: http://stackoverflow.com/q/22088042
tags question: http://stackoverflow.com/q/22139645
tags question: http://stackoverflow.com/q/22026715
tags question: http://stackoverflow.com/q/22005458
tags question: http://stackoverflow.com/q/22092704
tags question: http://stackoverflow.com/q/22074729
tags question: http://stackoverflow.com/q/22082706
tags question: http://stackoverflow.com/q/22068406
tags question: http://stackoverflow.com/q/22135500
tags question: http://stackoverflow.com/q/22094547
tags question: http://stackoverflow.com/q/22161526
tags question: http://stackoverflow.com/q/22124858
tags question: http://stackoverflow.com/q/22160647
tags question: http://stackoverflow.com/q/22035559
tags question: http://stackoverflow.com/q/22120782
tags question: http://stackoverflow.com/q/22028487
tags question: http://stackoverflow.com/q/22104688
tags question: http://stackoverflow.com/q/22096259
tags question: http://stackoverflow.com/q/22164693
tags question: http://stackoverflow.com/q/22146441
tags question: http://stackoverflow.com/q/22012756
tags question: http://stackoverflow.com/q/22051756

http://stackoverflow.com/q/22108330
type: Question
has answer: http://stackoverflow.com/a/22108872
tagged with: swing
answer count: 1
tagged with: defaulttablemodel
has body: Question: I would like to get the information in the JTable back into an Array of String[][] 2-dimensional array when the save button is pressed. Actually I would like to update a new String[][] array every time a key is pressed but that will have to wait until the Save button is working. When I made my ActionListener I had to create another instance of TestTable so I could pass in the table since I like to make all of my ActionListeners outside of the main class. Action Listener: class buttonListener implements ActionListener { private String[][] tempTable = null; **TestTable tt = new TestTable();** public Object[][] getTableData (JTable table) { int nRow = table.getRowCount(); int nCol = table.getColumnCount(); String[][] tData = new String[nRow][nCol]; for (int i = 0 ; i &lt; nRow ; i++) { for (int j = 0 ; j &lt; nCol ; j++) { tData[i][j] = (String) table.getValueAt(i,j); } } return tData; } **@Override public void actionPerformed(ActionEvent arg0) { tempTable = (String[][]) getTableData(tt.t); }** } This is the code for the simple JTable. Question: I want to be able to save the data when the button is clicked? Code: import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; public class TestTable extends JPanel { private static final long serialVersionUID = 1L; String[] columnNames = {"Col1", "Col2", "Col3", "Col4", "Col5", "Col6", "Col7"}; Object[][] data = { {"A", "B", "C", new Integer(1), new Boolean(true), "AA", "BB"}, {"D", "E", "F", new Integer(2), new Boolean(false), "CC", "DD"}, {"G", "H", "I", new Integer(3), new Boolean(true), "EE", "FF"}, {"J", "K", "L", new Integer(4), new Boolean(false), "GG", "HH"}, {"M", "N", "O", new I…
score: 0
tagged with: java
has title: How to get the data back of a JTable?
type: UnansweredQuestion
tagged with: jtable

http://stackoverflow.com/q/22118237
has comment: http://stackoverflow.com/comment/33555257
has comment: http://stackoverflow.com/comment/33555044
type: UnansweredQuestion
tagged with: swing
tagged with: java
has answer: http://stackoverflow.com/a/22118417
type: Question
has body: I have an Arraylist&lt;ActivityPerformed&gt; activityPerformed that I want to print into a textArea as a part of a String printReport(). This is what I have right now (located in Tracker.class) public String getActivityPerformed() { String done = ""; String error = "No tracked activities.\n"; for(int i = 0; i &lt; activityPerformed.size(); i++) { done += activityPerformed.get(i); done += "\n"; return done; } return error; } public String printReport() { lifestyleReport = "\n \nLifestyle Report \n"; lifestyleReport += "Activities Performed \n" + getActivityPerformed(); return lifestyleReport; } } And this is what I have for the GUI (TrackerGUI.class): public class Report implements ActionListener { public void actionPerformed (ActionEvent ae) { if(tracker.foodEaten.isEmpty() == true &amp;&amp; tracker.activityPerformed.isEmpty() == true) textArea.append("Error: No food/activity tracked. \n"); else textArea.append(tracker.printReport()); } } What do I add to the code to make the array print into the textArea properly? I always get something like this: @365bc793
answer count: 2
has answer: http://stackoverflow.com/a/22118325
has comment: http://stackoverflow.com/comment/33555176
has title: Array to String to append to a textArea in a JFrame GUI?
tagged with: arraylist
score: 0
tagged with: user-interface

http://stackoverflow.com/a/22100787
score: 0
type: Answer
answers question: http://stackoverflow.com/q/22100730
has body: Because, default constructor is only called, when there is no constructor in Java.

http://stackoverflow.com/q/22030902
answer count: 1
has comment: http://stackoverflow.com/comment/33399091
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22031082
tagged with: java
has comment: http://stackoverflow.com/comment/33399294
has body: Basically, all I want to do is get the text response of a PHP page with some POST variables I define. So, what is the easiest way of sending some POST data (like "arg1=this&amp;arg2=that") to a URL and handling the response (content, not headers) as a string?
has comment: http://stackoverflow.com/comment/33399116
accepted answer: http://stackoverflow.com/a/22031082
type: Question
score: 0
has comment: http://stackoverflow.com/comment/33399295
has title: Simple POST request/response method?

http://stackoverflow.com/a/22023118
upvote count: 4
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/100931981
has body: So to rephrase, the problem is that the program never terminates, what I do see is that it prints all integers from 1 to 113383, presumably from the first .peek(System.out::println) call. This is happening because you are assuming all the numbers that will be generated in the collatz will be in range of a int type. But it's not. That is why it is failing. Try making everything to long - PrimitiveIterator.OfLong, StreamSupport.longStream, etc., and it will work. I'd like to get rid of the boxing and use the IntStream::collect method, however I do not understand how to do it. I don't understand why you would like to do that. Boxing will still be done somewhere, as you can't create a Map of primitive int. Still, if you want, you would in fact need to do some more work. Here's how you do it: @Override public void run() { ObjIntConsumer&lt;Map&lt;Integer, Long&gt;&gt; objIntConsumer = (map, value) -&gt; map.put(value, Iterators.longStream(new CollatzGenerator(value)).count()); BiConsumer&lt;Map&lt;Integer, Long&gt;, Map&lt;Integer, Long&gt;&gt; biConsumer = (targetMap, accumulatorMap) -&gt; targetMap.putAll(accumulatorMap); result = IntStream.range(1, maximum) .collect(LinkedHashMap::new, objIntConsumer, biConsumer) .entrySet().stream() .peek(System.out::println) .max(Comparator.&lt;Entry&lt;Integer, Long&gt;&gt;comparingLong(entry -&gt; entry.getValue())) .get().getKey(); }
accepted answer of: http://stackoverflow.com/q/22020887
answers question: http://stackoverflow.com/q/22020887
score: 4

http://stackoverflow.com/comment/33542628
comment on: http://stackoverflow.com/a/22111230
score: 0
type: AnswerComment
type: Comment
has text: Hey @Bohemian, congrats for the Diamond :)

http://stackoverflow.com/a/22087050
has body: What this exception really means is you are telling Hibernate to remove object from database but at the same time this object still exist (that means still exist in java or database) in mapped collection via Persistent entity which has CascadeType.PERSIST annotated over it. It's like having something tied through elastic rubber on the window and then poke it hoping it will drop. Hibernate is smart it is saving you from doing meaningless stuff, it tells you what to do deleted object would be re-saved by cascade (remove deleted object from associations) Sine you are doing appointment.setDoctor(null); it will remove object from collection (only in java as you are not explicitly or implicitly updating appointment).You have CascadeType.PERSIST on doctor that means when hibernate is going to commit the transaction it will find that appointment has association to doctor you just deleted that means if you remove that doctor from table, hibernate has to go and create same doctor as you have not told him to make appropriate changes in appointment as he follows all the entity rules set by you. Since hibernate is smart he knows this and he will throw a exception for you saying don't be an oxymoron and do the right thing. Now there are more than one solution that I can think of here Use cascade={CascadeType.PERSIST,CascadeType.REMOVE} or cascade=CascadeType.ALL on getDoctor() in AppointmentRequest As mentioned in hibernate document here It doesn't usually make sense to enable cascade on a @ManyToOne or @ManyToMany association. Cascade is often useful for @OneToOne and @OneToMany associations. remove cascade from getDoctor Since you have FetchType.EAGER on getDoctor() with cascade specified it is little complicated for me interpret the behaviour of hibernate but in this questions they have solved by using FetchType.LAZY am not sure if it will work out for you. You can do session.saveOrUpdate(appointment) on all the AppointmentRequest which has this doctor and then go for session.…
type: Answer
upvote count: 7
score: 7
downvote count: 0
answers question: http://stackoverflow.com/q/22085467

http://stackoverflow.com/comment/33535941
has text: "in a runnable is increased by 1" <-- how often?
comment on: http://stackoverflow.com/q/22107323
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/a/22040067
accepted answer of: http://stackoverflow.com/q/22039991
answers question: http://stackoverflow.com/q/22039991
downvote count: 0
score: 43
has comment: http://stackoverflow.com/comment/45638023
has body: Since Date implements Comparable&lt;Date&gt;, it is as easy as: date1.compareTo(date2); As the Comparable contract stipulates, it will return a negative integer/zero/positive integer if date1 is considered less than/the same as/greater than date2 respectively (ie, before/same/after in this case). Note that Date has also .after() and .before() methods which will return booleans instead.
upvote count: 43
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/45638437
type: Answer

http://stackoverflow.com/comment/46148065
score: 0
comment on: http://stackoverflow.com/q/22051626
type: Comment
type: QuestionComment
has text: @caleb, Did you ever get any insight into this issue? I'm having what looks like a possibly related issue with IE11 sometimes not sending the JSESSIONID and it's driving me nuts.

http://stackoverflow.com/comment/33369389
score: 0
type: Comment
type: QuestionComment
has text: You use `-` to negate (swap positive number for the same negative), and `~` to invert (flip all the bits). They are very similar, but not the same.
comment on: http://stackoverflow.com/q/22014733

http://stackoverflow.com/comment/50238065
score: 12
type: AnswerComment
type: Comment
has text: On some android Rom,Google Play service is not installed,will encounter this issue,not the staff relating permissions
comment on: http://stackoverflow.com/a/22118365

http://stackoverflow.com/comment/46332264
type: QuestionComment
comment on: http://stackoverflow.com/q/22007341
has text: @jm0 As far as you remember, how many tables had BLOB columns?
score: 0
type: Comment

http://stackoverflow.com/q/22121080
tagged with: android
has answer: http://stackoverflow.com/a/22129180
tagged with: bitmap
type: AnsweredQuestion
has title: Android - Manipulate Twitter Profile Picture
tagged with: java
tagged with: twitter
type: Question
score: 0
has body: I'm using Twitter4J library. I want to display the user picture profile in a circle. I'm new to using bitmaps and new to get something from a server. Now, searching around, I'm using this way: private class DownloadImageTask extends AsyncTask&lt;String, Void, Bitmap&gt; { ImageView bmImage; public DownloadImageTask(ImageView bmImage) { this.bmImage = bmImage; } protected Bitmap doInBackground(String... urls) { String urldisplay = urls[0]; try { SharedPreferences mSharedPreferences = getActivity().getSharedPreferences("MyPref",0); ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setOAuthConsumerKey(TWITTER_CONSUMER_KEY); builder.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET); // Access Token String access_token = mSharedPreferences.getString( PREF_KEY_OAUTH_TOKEN, ""); // Access Token Secret String access_token_secret = mSharedPreferences.getString( PREF_KEY_OAUTH_SECRET, ""); AccessToken accessToken = new AccessToken(access_token, access_token_secret); Twitter twitter = new TwitterFactory(builder.build()) .getInstance(accessToken); User user = twitter.showUser(accessToken.getUserId()); urldisplay = user.getProfileImageURL(); } catch (TwitterException e) { // Error in updating status Log.d("Twitter Update Error", e.getMessage()); } Bitmap mIcon11 = null; try { InputStream in = new java.net.URL(urldisplay).openStream(); mIcon11 = BitmapFactory.decodeStream(in); } catch (Exception e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } final int width = mIcon11.getWidth(); final int height = mIcon11.getHeight(); final Bitmap outputBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); final Path path = new Path(); path.addCircle( (float)(width / 2) , (float)(height / 2) , (float) Math.min(width, (height / 2)) , Path.Direction.CCW); final Canvas canvas = new Canvas(outputBitmap); canvas.clipPath(path); canvas.drawBitmap(mIcon11, 0, 0, null); return outputBitmap; } protected void onPostExecute(Bitmap result) { bmImage.setImageBitmap(…
accepted answer: http://stackoverflow.com/a/22129180
answer count: 1

http://stackoverflow.com/a/22156787
has comment: http://stackoverflow.com/comment/33624352
has body: Lists are not covariant. If you use ? extends Number then you can only read from the list, you can't write to it. Why not? m1.add(new Object()); It should be obvious why this doesn't work. The list is supposed to contain Numbers and an Object is not a Number. ml.add(new Integer(1)); This one's not so obvious. Imagine that you had a different instantiation of m1: List&lt;? extends Number&gt; ml = new Vector&lt;Double&gt;(); ml.add(new Integer(1)); Now m1 is a vector of doubles. Adding an integer to this list would be illegal. The compiler doesn't in general know what the concrete type of ? extends Number is. To be conservative, it disallows calling the add method entirely. You can iterate over the list and read what's in it, and you can delete items from it, but you can't add new items to it. Or to put it another way, for List&lt;E&gt; you can call methods that return E but you can't call ones that take E as a parameter.
has comment: http://stackoverflow.com/comment/33624563
score: 4
has comment: http://stackoverflow.com/comment/33624453
upvote count: 4
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22156690
answers question: http://stackoverflow.com/q/22156690
type: Answer
has comment: http://stackoverflow.com/comment/33624803
has comment: http://stackoverflow.com/comment/33625005
has comment: http://stackoverflow.com/comment/33624545

http://stackoverflow.com/comment/33615288
comment on: http://stackoverflow.com/q/22150417
score: 0
type: Comment
type: QuestionComment
has text: switching to DefaultCodec works, but now it is using the deflate algorithm, which is not as fast as snappy.

http://stackoverflow.com/comment/33551500
type: Comment
type: QuestionComment
has text: Your url points to a `404 - Page Not Found` when opened in the browser. Are you sure the url is correct?
comment on: http://stackoverflow.com/q/22116201
score: 0

http://stackoverflow.com/comment/33575408
has text: Also see: http://stackoverflow.com/questions/2417485/file-separator-vs-slash-in-paths
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22129161

http://stackoverflow.com/a/22149682
score: 0
has comment: http://stackoverflow.com/comment/45937326
has comment: http://stackoverflow.com/comment/47522948
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/47525625
has body: I managed to fixed my error, i had a syntax error from my side... getVCFrame = IplImage.createFrom(frame); This fixed my error, i will test if its possible with 1 image once my code is complete
type: Answer
answers question: http://stackoverflow.com/q/22117579

http://stackoverflow.com/a/22167824
has body: '*' and '.' are special characters you have to blackshlash it. String sepIds[]=ids.split("\\*"); To read more about java patterns please visit that page.
score: 1
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/22167735
type: Answer

http://stackoverflow.com/comment/33400106
comment on: http://stackoverflow.com/a/22031541
has text: cd C:\Documents and Settings\amth\workspace\OneReports\src\test javac LoginOneReports.java after this
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33572194
score: 0
type: AnswerComment
has text: I thought counting of arrays starts at 0 ?
comment on: http://stackoverflow.com/a/22127464
type: Comment

http://stackoverflow.com/a/22131817
has comment: http://stackoverflow.com/comment/33580581
has comment: http://stackoverflow.com/comment/33580366
score: 0
has body: Update the code as below:: HashMap&lt;String, String[]&gt; map = new HashMap&lt;String, String[]&gt;(); map.put("Nos", dataF); // Pass the Array instead String ArrList.add(map);
answers question: http://stackoverflow.com/q/22131782
type: Answer

http://stackoverflow.com/comment/33403184
comment on: http://stackoverflow.com/a/22033312
has text: @user3145749 have you used + in used regex as `\\r?\\n+`?
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33549770
has text: @AndrewThompson I'm so sorry, I meant GridLayout. One of the standard layout managers in Java Swing. I changed the text now.
type: Comment
comment on: http://stackoverflow.com/q/22109440
score: 0
type: QuestionComment

http://stackoverflow.com/q/22105991
tagged with: java
has answer: http://stackoverflow.com/a/22106155
type: Question
has title: Java string split with tabs
possible better answer: http://stackoverflow.com/a/22106110
has answer: http://stackoverflow.com/a/22106110
has body: Given that string is a String, what does string.split("[\t]"); do? I don't understand what the brackets are for. Thanks!
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/33533416
accepted answer: http://stackoverflow.com/a/22106155
has comment: http://stackoverflow.com/comment/33533378
type: AnsweredQuestion

http://stackoverflow.com/q/22147219
has title: jpa criteria error or misplaced
has body: Hi I got a table as follow (User table) +----------+------------+ | Code | reference | +----------+------------+ | adfasd | hello | +----------+------------+ | wertwtw | it works | +----------+------------+ when I make a method ==> findByCodeContaining(String param) -it works as this link says when I make a method ==> findByreferenceContaining(String param) -it works But, when I make a method ==> findByCodeContainingOrfindByreferenceContaining(String param) it does not work. even though I follow this link I would like to know why it does not work and where did I make it wrong. Thanks.
tagged with: spring
has answer: http://stackoverflow.com/a/22147520
score: 0
tagged with: java
tagged with: hibernate
type: Question
tagged with: spring-data-jpa
answer count: 2
has answer: http://stackoverflow.com/a/22147384
type: UnansweredQuestion

http://stackoverflow.com/a/22051681
answers question: http://stackoverflow.com/q/22051665
has comment: http://stackoverflow.com/comment/33436045
has body: You need to implement method in EventField class EventField{ Event[] field; public void sort(){ Arrays.sort(field, yourCustomComparatorInstance } } that does sorting using a custom Comparator on Event Related: Sorting a list of points with Java See Arrays.sort()
score: 0
type: Answer

http://stackoverflow.com/a/22164145
has comment: http://stackoverflow.com/comment/33637261
score: 0
has comment: http://stackoverflow.com/comment/33638993
answers question: http://stackoverflow.com/q/22164046
has body: In Oracle you can use ALL_TAB_COLUMNS table and in MS SQL server and MySQL you can use INFORMATION_SCHEMA.COLUMNS table to get information about tables and columns. SELECT * FROM ALL_TAB_COLUMNS WHERE OWNER = 'SchemaName' AND TABLE_NAME = 'TableName';
has comment: http://stackoverflow.com/comment/33637020
type: Answer

http://stackoverflow.com/a/22141895
has body: It looks like it has something to do with your variables being declared static. Unless the isBlack method is static, these variables (judging by what they do) should not be static. static means that there is only one copy of the member, and that in any instance that you create containing a static member, it will still remain the same, even in different instances. I cannot know for sure though, as you have no code to show. But my best guess is that this is why your problem is occuring.
answers question: http://stackoverflow.com/q/22141786
score: 0
type: Answer

http://stackoverflow.com/comment/33558633
type: AnswerComment
score: 0
type: Comment
has text: @user3369285: don't take my word on it, use your IDE to count the number of times you call it. Seriously. The method shouldn't take a parameter either.
comment on: http://stackoverflow.com/a/22120169

http://stackoverflow.com/a/23769833
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22167192
type: Answer
has body: Take a look at the source (version 2.3.4_r1, last time Bitmap was updated on Grepcode prior to 4.4) for Bitmap::copyPixelsFromBuffer() The wording of the error is a bit unclear, but the code clarifies-- it means that your buffer is calculated as not having enough data to fill the pixels of your bitmap. This is (possibly) because they use the buffer's remaining() method to figure the capacity of the buffer, which takes into account the current value of its position attribute. If you call rewind() on your buffer before you invoke copyFromPixels(), you might see the runtime exception disappear. I say 'might' because the ByteBuffer::wrap() method should set the position attribute value to zero, removing the need to call rewind, but judging by similar questions and my own experience resetting the position explicitly may do the trick. Try ByteBuffer buffer = ByteBuffer.wrap(os.toByteArray()); buffer.rewind(); bitmap_tmp.copyPixelsFromBuffer(buffer);
has comment: http://stackoverflow.com/comment/38325790
answers question: http://stackoverflow.com/q/22167192
score: 12
upvote count: 12

http://stackoverflow.com/a/22113101
accepted answer of: http://stackoverflow.com/q/22113072
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33546014
has comment: http://stackoverflow.com/comment/33546084
type: Answer
answers question: http://stackoverflow.com/q/22113072
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/33546217
downvote count: 0
has body: You likely will have to write a custom sort. Look into Comparable and Comparator. Something along the lines of: public class MyComparator implements Comparator&lt;List&lt;MyObject&gt; { int columnToSortOn; public MyComparator(int columnToSortOn) { this.columnToSortOn = columnToSortOn; } @Override public int compare(List&lt;MyObject&gt; list1, List&lt;MyObject&gt; list2) { return list1.get(columnToSortOn).compareTo(list2.get(columnToSortOn)); } }

http://stackoverflow.com/comment/33363781
has text: This have been taken care properly that connections are closed in finally.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22010704
score: 0

http://stackoverflow.com/a/22054742
has body: Each region in AWS is independent of the others, and the API endpoints are different. It you aren't specifically configuring your code to send your request to the "us-west-1" region, then by default you're actually asking us-east-1 to create the instance in an availability zone that it's never heard of. The AWS SDK for Java uses the US East (Northern Virginia) Region as the default region if you do not specify a region in your code. — http://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/java-dg-region-selection.html
type: Answer
downvote count: 0
score: 5
has comment: http://stackoverflow.com/comment/33442019
accepted answer of: http://stackoverflow.com/q/22048081
answers question: http://stackoverflow.com/q/22048081
type: AcceptedAnswer
upvote count: 5

http://stackoverflow.com/comment/33503201
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22089144
has text: Hi John, I've added the break statement as you've proposed. However, I still encounter the same problem, as the method still always returns as false.

http://stackoverflow.com/comment/33643911
score: 0
comment on: http://stackoverflow.com/a/22167532
type: AnswerComment
has text: Exactly the same logcat error, down to the letter... No change.
type: Comment

http://stackoverflow.com/q/22047074
type: AnsweredQuestion
tagged with: java
has body: I have a function public void get(Object s) { while (s.getClass().getSuperclass() != null) { s = s.getClass().getSuperclass(); } } The thing is that the s.getClass().getSuperclass() never returns null, even though Object has no superclass. I don't understand why this is happening, although I debugged the project several times.
tagged with: superclass
type: Question
has answer: http://stackoverflow.com/a/22047448
tagged with: oop
has answer: http://stackoverflow.com/a/22047114
has title: Object.getClass().getSuperclass() not returning null?
score: 0
answer count: 3
possible better answer: http://stackoverflow.com/a/22047114
accepted answer: http://stackoverflow.com/a/22047448
has answer: http://stackoverflow.com/a/22047514

http://stackoverflow.com/comment/33643096
has text: It seems that the number printed in position `i` in row `j` is `( i + j - 1 ) % 10`. Also, your code draws a rectangle, not a triangle.
type: Comment
comment on: http://stackoverflow.com/a/22167461
type: AnswerComment
score: 0

http://stackoverflow.com/q/22016401
has answer: http://stackoverflow.com/a/22018425
has comment: http://stackoverflow.com/comment/33373481
answer count: 2
upvote count: 1
possible better answer: http://stackoverflow.com/a/22017602
favorite count: 0
has comment: http://stackoverflow.com/comment/33372292
has title: How can I replace each group individually using Matcher?
has comment: http://stackoverflow.com/comment/33372431
tagged with: regex
has comment: http://stackoverflow.com/comment/33372200
has comment: http://stackoverflow.com/comment/33372333
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/22018425
has answer: http://stackoverflow.com/a/22017602
type: Question
has body: all the examples I found was for cases where people had some regex pattern searched and needed to replaces all groups found with some specific value, or with a known number of groups in the searched string. But in my case I need to change each group depending on the values found, how can I change each changed result value? This is what I have/tried: Pattern pattern = Pattern.compile(DEFINITION_WITH_OR); Matcher matcher = pattern.matcher(s); StringBuffer sb = new StringBuffer(); while (matcher.find()){ String ss = matcher.group(); /*Some string manupilation*/ // matcher.appendReplacement(sb, bestMatchedDefinition); // matcher.appendReplacement(sb,Matcher.quoteReplacement(ss)); // s = s.replace(s.substring(matcher.start(),matcher.end()),ss); } What I wish to do is to iterate through all groups found, perform some actions on the group found, and edit only that group, the content &amp; number of groups is not known prior to running. All my tries so far either changed everything or not at all, any suggestions? What I do with the string is split it by |, and get the shortest part, and remove braces so : Example input string: Note: the following input string is a simplification to show what my final outcome should be, the full string has a lot more annoying chars the I cleared using the DEFINITION_WITH_OR pattern a commissioned general officer in the United States Army, Marine Corps, or Air Force superior to a lieutenant general. A general is equal in rank or grade to a four star admiral. In the US Army, a general is junior to a general of the army. In the US Marine Corps, a general is the highest rank of commissioned officer. In the US Air Force, a general is junior to a general of the air force. Should output as: a commissioned general officer in the United States Army, Marine Corps, or Air Force superior to a lieutenant general. A general is equal in rank or grade to a four star admiral. In the US Army, a genera…

http://stackoverflow.com/comment/33359440
type: Comment
comment on: http://stackoverflow.com/a/22007716
has text: The result is not as I expected. But thanks for your response.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/60851275
type: Comment
has text: I guess so. JVMTI allows to get *all* existing `String` instances, but afaik there is no way of checking whether a particular instance is pooled…
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22098863

http://stackoverflow.com/comment/33419978
score: 0
has text: @JohnSkeet while import 'java.nio.charset.StandardCharsets;' this package it tells: The import java.nio.charset.StandardCharsets cannot be resolved
type: AnswerComment
comment on: http://stackoverflow.com/a/22042303
type: Comment

http://stackoverflow.com/comment/33547973
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22062346
has text: The build was success and the target directory was generated. The solution was to downgrade Maven to 3.0.5 as @joe advised. Thanks Again joe for your clear and simple solution.
type: AnswerComment

http://stackoverflow.com/comment/33430350
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22047654
has text: It can [mess up a few things](http://sjbaker.org/steve/omniv/projection_abuse.html).
score: 0

http://stackoverflow.com/q/22067134
tagged with: java
has comment: http://stackoverflow.com/comment/33463804
type: Question
has body: I am using SoapRequst For my Desktop application. but There is one Soap request in which i hav to Send xml Document but when i tried to add that xml file means Document then that is converted into the String format i means all "&lt;>" clauses converted into the String formate "&lt;" like this. So what i should do to make them remain into the XMl format. &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;soap:Body&gt; &lt;Update xmlns="http://tempuri.org/"&gt; &lt;doc&gt;xml&lt;/doc&gt; &lt;/Update&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; when i am sending file its converted to this. **&amp;gt;&amp;lt;Folder&amp;gt;&amp;lt;** that has to be this &lt;Folder&gt; Can i have your valuble suggestion for this thanks in advance. here my method is. public static SOAPMessage UpdateAllGroupWithSwitchUserConfiguration() { try { File f = new File("/com/package/package/TreeModel.xml"); BufferedReader br = new BufferedReader(new FileReader(f)); StringBuffer builder = new StringBuffer(); String xml = ""; while ((xml = br.readLine()) != null) { builder.append(xml.trim()); } MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = "http://tempuri.org/"; // SOAP Envelope SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("tem", serverURI); SOAPElement sOAPElement = envelope.addChildElement("UpdateAllGroupWithSwitchUserConfiguration", "tem"); String XML_String = builder.toString(); // DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); // DocumentBuilder doc_builder = factory.newDocumentBuilder(); // // Document document = doc_builder.parse(new InputSource(new StringReader(XML_String))); // // TransformerFactory factory1 = TransformerF…
has comment: http://stackoverflow.com/comment/33463434
score: 0
linked to: http://stackoverflow.com/q/3136375
has comment: http://stackoverflow.com/comment/33463079
has answer: http://stackoverflow.com/a/22068197
answer count: 1
tagged with: string
has comment: http://stackoverflow.com/comment/33463132
tagged with: soap
has title: While Sending Xml File into the Soap Reqest Getting Problems in java
tagged with: http://stackoverflow.com/tag/xml
type: UnansweredQuestion

http://stackoverflow.com/comment/33501238
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22088319
has text: i should get 10-01-2014 20:18:18 as O/P but getting 01-01-2014 20:18:18 why?
score: 0

http://stackoverflow.com/comment/33522493
type: AnswerComment
has text: this comes from the fact that a new list is created and so the existing arraylists must not re-arranged (like Marco13 described). The usage of the List interface has nothing todo with the problem.
type: Comment
comment on: http://stackoverflow.com/a/22099331
score: 0

delimiter
tags question: http://stackoverflow.com/q/22026415
tag name: delimiter
type: Tag
tags question: http://stackoverflow.com/q/22167735
tags question: http://stackoverflow.com/q/22010955
tags question: http://stackoverflow.com/q/22133297

hql
tag name: hql
tags question: http://stackoverflow.com/q/22020409
tags question: http://stackoverflow.com/q/22157227
tags question: http://stackoverflow.com/q/22074729
type: Tag
tags question: http://stackoverflow.com/q/22110231

http://stackoverflow.com/comment/33638837
has text: or abc,def. How can i separate abcdef. Two strings abc and def concatenate in a single string abcdef
comment on: http://stackoverflow.com/q/22165106
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22099436
has comment: http://stackoverflow.com/comment/33522057
accepted answer of: http://stackoverflow.com/q/22099352
has body: Assuming you're viewing the applet from C:\Users\Valentin\workspace and the class hello is declared in the first package then you need to add the codebase attribute: &lt;applet code="first.hello.class" width="800" height="600" codebase="test/bin"&gt; Read: Using applet, object and embed Tags
type: Answer
answers question: http://stackoverflow.com/q/22099352
has comment: http://stackoverflow.com/comment/33521041
has comment: http://stackoverflow.com/comment/33521935
has comment: http://stackoverflow.com/comment/33521157
score: 0
has comment: http://stackoverflow.com/comment/33521566
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33521255
has comment: http://stackoverflow.com/comment/33522152

http://stackoverflow.com/comment/72216180
has text: Unfortunately this is a reality for the JUnit runner in surefire and failsafe, no way around it that I've found. Note that TestNG is a much better experience from this perspective, giving you real time logs when running in parallel / forking modes.
comment on: http://stackoverflow.com/q/22006824
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/33636834
type: QuestionComment
type: Comment
has text: Yes @ray. I cannot get the code to either inserAtFront() or insertAtLast() working. thank you.
comment on: http://stackoverflow.com/q/22162814
score: 0

http://stackoverflow.com/a/37565118
type: Answer
answers question: http://stackoverflow.com/q/22105318
score: 0
has body: When you want to print the "SELECT ele,ele,ele,ele FROM" String out, then the following could be what you want: ListModel a = myList.getModel(); System.out.print("SELECT "); for (int i = 0; i &lt; a.getSize(); i++) { System.out.print(a.getElementAt(i); if (i &lt; a.getSize() - 1) { System.out.print(","); } } System.out.print(" FROM ");

http://stackoverflow.com/comment/33592697
type: Comment
type: QuestionComment
has text: @msknapp , yes. Actually I am looking for some best practice, this is my first webapp so want to know what people follow generally.
comment on: http://stackoverflow.com/q/22095983
score: 0

http://stackoverflow.com/comment/33634985
comment on: http://stackoverflow.com/a/22162898
has text: You can use arguments to a main method, unless the client is supposed to stay running.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33595605
comment on: http://stackoverflow.com/q/22140776
score: 0
type: QuestionComment
type: Comment
has text: @ThomasPadron-McCarthy, my string generator (which is called excuseGenerator() ) does change the tex via setText() function

http://stackoverflow.com/a/22125026
has body: Problem is with the comparison you are doing. (Double)result==obj.get_xmonthreq() == is used to compare primitive values. You have two options : Either Use doubleValue() method ((Double)result).doubleValue() == obj.get_xmonthreq().doubleValue() Or Use equals() method ((Double)result).equals(obj.get_xmonthreq()) Hope this helps.
answers question: http://stackoverflow.com/q/22124457
has comment: http://stackoverflow.com/comment/33591752
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/33567769
has comment: http://stackoverflow.com/comment/33572931

http://stackoverflow.com/comment/33463761
has text: This is wrong, it excludes the last index in the word. An array's bounds are ``0 <= i < length`` or ``0 <= i <= length - 1``
comment on: http://stackoverflow.com/a/22068042
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/q/22064144
answer count: 4
tagged with: android
has title: Can i Fill LinkedHashMap With an ArrayList
has comment: http://stackoverflow.com/comment/33457389
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22064560
has answer: http://stackoverflow.com/a/22064434
tagged with: java
type: Question
possible better answer: http://stackoverflow.com/a/22064339
has comment: http://stackoverflow.com/comment/33457261
has answer: http://stackoverflow.com/a/22064339
has body: My Question is can i fill LinkedHashmap Using ArrayList Elements? Because every time it throws IndexOutOfBoundsException.Below is my code, ArrayList&lt;String&gt; contactsArray = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; numbersArray = new ArrayList&lt;String&gt;(); linkedMap = new ArrayList&lt;LinkedHashMap&lt;String, String&gt;&gt;(); linked = new LinkedHashMap&lt;String, String&gt;(); int x = contactsArray.size(); if (contactsArray.size() &gt; 0) { for (int i = 0; i &lt; x - 1; i++) { linked.put("1", contactsArray.get(i)); linked.put("2", numbersArray.get(i)); } linkedMap.add(linked); }else{ msg("0"); } Logcat: 02-27 11:05:24.859: E/AndroidRuntime(3223): Caused by: java.lang.IndexOutOfBoundsException: Invalid index 4, size is 4
tagged with: arraylist
has answer: http://stackoverflow.com/a/22064265
accepted answer: http://stackoverflow.com/a/22064265
score: 0
has comment: http://stackoverflow.com/comment/33457425

http://stackoverflow.com/comment/33371972
comment on: http://stackoverflow.com/a/22016219
has text: Yeah I thought about it, but `describe` adds the `class` property and reports nested objects as .. objects (I use `@Embedded on them`) and not as a set of their properties.
type: AnswerComment
score: 0
type: Comment

mamp
tags question: http://stackoverflow.com/q/22128631
tag name: mamp
type: Tag

http://stackoverflow.com/comment/33593900
score: 2
comment on: http://stackoverflow.com/q/22139941
type: QuestionComment
has text: What column are you talking about?
type: Comment

http://stackoverflow.com/q/22066387
tagged with: jtable
has answer: http://stackoverflow.com/a/22067320
has comment: http://stackoverflow.com/comment/33460910
answer count: 4
favorite count: 0
type: UnansweredQuestion
tagged with: swing
has body: I have made a JTable in java. I can do everything except search an element in my table. I want to work a input dialog so this is what I have at this moment: btnSearch = new JButton("Search"); btnSearch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String name = JOptionPane.showInputDialog("Wat wil je zoeken?"); } }); add(btnSearch); I thought to do it with a for loop. but I don't know how. Can someone help me pls?
score: 14
has title: how to search an element in a JTable java?
tagged with: java
has answer: http://stackoverflow.com/a/22066938
downvote count: 1
tagged with: search
type: Question
upvote count: 15
has answer: http://stackoverflow.com/a/39053201
has answer: http://stackoverflow.com/a/22066561

http://stackoverflow.com/q/22132042
tagged with: java
has title: how to pass a parsed doccument?
tagged with: dom
type: Question
has answer: http://stackoverflow.com/a/22155847
has answer: http://stackoverflow.com/a/22132757
score: 0
answer count: 2
has body: Hi all and thanks for your time and help. Im trying to parse a xml file in the "res/raw" folder and passing the result to other class to work with it. I'm stuck and cannot find any solution, Im trying to learn programming, so, the whole code may be wrong and I failed catastrophically from the beginning. this is the parser, it get a document from the raw folder and return the parsed document. import java.io.IOException; import java.io.InputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.SAXException; import android.app.Activity; public class Pars extends Activity{ public Document doc(){ InputStream is = getResources().openRawResource(R.raw.talechap01); Document docout = null; DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = null; try { builder = domFactory.newDocumentBuilder(); docout = builder.parse(is); } catch (ParserConfigurationException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return docout; } } this class get the parsed document and find some content using xpath and pass it in a return. I can not pass the parsed document "docout" from the class "Pars" 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.NodeList; public class Commanders { public static String getStory(String spage) { XPathExpression expr; XPath xpath = XPathFactory.newInstance().newXPath(); Object result = null; String num = spage; String par = null; Document doc = //Here I need the document parsed from the "Pars" class …
tagged with: parsing
type: UnansweredQuestion
tagged with: android
tagged with: xpath

http://stackoverflow.com/comment/33503523
has text: http://docs.spring.io/spring/docs/3.0.x/api/org/springframework/util/ReflectionUtils.html + http://docs.spring.io/spring/docs/3.2.2.RELEASE/javadoc-api/org/springframework/core/annotation/AnnotationUtils.html ... or maybe check how `RequestMappingHandlerMapper` is working - https://github.com/spring-projects/spring-framework/blob/master/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22089501
score: 0

http://stackoverflow.com/q/22010606
linked to: http://stackoverflow.com/q/10628492
linked to: http://stackoverflow.com/q/10055005
tagged with: swing
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22011588
has body: I'm developing some kind of videogame, so I am not interested in calling paint, repaint or any sort of those methods on each updating from keylistening, since they call also the update(Graphics g) method which cleans the whole screen. That's why I do want to @Override the update method, not allowing it to cleaning the screen at first. Doing this I can update what I want when I want. However, sometimes it goes in a loop auto painting the components (such as jButtons) cleaning the screen(I couldn't track anything special happening whenever this occurs, I have already tried overriding some methods in order to catch which one's the troublesome and I couldn't find it, I'm likely missing something). I do not want this happening, because this auto painting cleans the screen which makes me draw everything once again. Moreover I don't feel comfortable with something looping until the player press any key. Do you have any clue? One solution could simply be using a timer with a boolean that each time a screen is completed and the next one is being loaded it calls update(g) from my JFrame (which contains the jPanel). But I would like something better.. Maybe I am doing something wrong, even if I tried to improve my painting methods thousand times surfing throughout the net and netbeans's suggs. This is how my painting methods looks with some flags written and the ones that are called after running: @Override public void paint(java.awt.Graphics g){ paintComponents(g); System.out.println("Flag"); update(g); } @Override public synchronized void update(Graphics g) { g.setColor(java.awt.Color.GREEN); w.getDrawer().draw(g); g.drawRect (0, 0, w.getActive().getW(), w.getActive().getH()); }` The overriding on paint(Graphics g) method is not needed at all, just did it in order to see what was going on. I never called repaint() but update(getGraphics()) and it just spam Flags all around. Also thought that maybe I was making it run in a loop with paint and paintComponents, but deleting pai…
score: 0
tagged with: java
type: Question
tagged with: user-interface
answer count: 1
accepted answer: http://stackoverflow.com/a/22011588
tagged with: paintcomponent
tagged with: paint
has title: Auto calls to painting methods (Java) when I'm app-triggering (not interested in synchronously but async) in a loop

http://stackoverflow.com/comment/33468572
type: Comment
type: QuestionComment
score: 3
has text: If you fixed the indentation then the error would be easier to spot.
comment on: http://stackoverflow.com/q/22070535

http://stackoverflow.com/q/22125169
tagged with: java-8
type: AnsweredQuestion
tagged with: java-stream
tagged with: java
has title: Why is Java 8 Stream class AutoCloseable?
type: Question
accepted answer: http://stackoverflow.com/a/22125223
score: 18
downvote count: 0
upvote count: 18
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/22125223
has body: In Java 8, the Stream class implements AutoCloseable. This means that a stream instance should be closed explicitly. I understand why file handlers and DB connections are closeable. But why streams?

http://stackoverflow.com/a/22094784
has comment: http://stackoverflow.com/comment/33515526
has comment: http://stackoverflow.com/comment/33515923
type: Answer
has comment: http://stackoverflow.com/comment/33513679
score: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/33512280
has comment: http://stackoverflow.com/comment/33537097
has comment: http://stackoverflow.com/comment/33515875
has comment: http://stackoverflow.com/comment/33512166
answers question: http://stackoverflow.com/q/22094644
has body: A common bug is you expect that the tests are run after each other. Each test is fully independed, so don't expect states from other runs. Try putting your constructor logic in a init method which you invoke on start of each test. That helped me. If this does not work directly try this also with your other constant values. public class ThreeMinuteRun { String cameraId = "cam1test"; String videoStream = "http://xxx.xxx.xxx.xxx/mjpg/video.mjpg"; //ip obfuscated for this online question String format = "MJPG"; MotionDetectionType motionType= MotionDetectionType.basic; AwarenessAnalytics AA; // &lt;--------------- CHANGED ------------- String maskFilename = "/home/will/odev/MotionDetect/src/main/resources/DrivewayMaskWhite.png"; MotionDetectionState motionDetectionState = MotionDetectionState.on; String directoryStore = "/media/PENDRIVE/alertImageTest/"; private void init() { AA = new AwarenessAnalytics(); } @Test public void testSetVideoSource() { init(); try { AA.setVideoSource(cameraId, videoStream, format, motionType); } catch (IOException e) { fail("IOException in setVideoSource"); } }
has comment: http://stackoverflow.com/comment/33514637
has comment: http://stackoverflow.com/comment/33513963
upvote count: 3
has comment: http://stackoverflow.com/comment/33516203
has comment: http://stackoverflow.com/comment/33512134
has comment: http://stackoverflow.com/comment/33516265

http://stackoverflow.com/comment/33579827
type: Comment
comment on: http://stackoverflow.com/q/22123810
score: 0
has text: some more details - prod is Linux with tomcat 7.0.22. Local is windows running tomcat under eclipse. Now I am looking at heap dump using MAT , it shows 49 MB used by objects. Still wondering out of 350 MB if java objects is just 49 MB then who is consuming rest ??
type: QuestionComment

http://stackoverflow.com/q/22052479
has body: I'm having a rather mysterious error: All of my imports have been redlined with the message "the import cannot be resolved". However, the types referenced by those same imports are also redlined, and the auto fix suggests adding those exact imports. The imports in question are from another project in my workspace, and that project is definitely in this project's workspace. Does anybody know what the hell is going on here? EDIT: I got the issue to go away by removing the project from the build path, copying it, deleting it, then pasting it back into the workspace and re-adding it to the build path. I'd still like to know if anybody knows what the heck happened though.
score: 2
tagged with: buildpath
upvote count: 2
tagged with: java
tagged with: import
type: Question
has answer: http://stackoverflow.com/a/22053105
has title: Eclipse imports inexplicably not resolved
tagged with: eclipse
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/22053036
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33437253

http://stackoverflow.com/comment/78773486
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22119036
has text: @weston i decided to move accepted answer to mine because of high rate and comment. Sorry
score: 0

http://stackoverflow.com/comment/33466914
type: Comment
has text: Since using `currentTimeMillis` is worse than omitting the argument, what is the point of including it?
comment on: http://stackoverflow.com/a/22069155
score: 0
type: AnswerComment

http://stackoverflow.com/a/22042130
downvote count: 0
answers question: http://stackoverflow.com/q/22041968
type: Answer
score: 1
upvote count: 1
has body: Setup your device do be debuggable: Link. Start a debug from Eclipse, choosing your device. check the output in the LogCat View in Eclipse. There you will see the Exception Stack Trace.

slidingmenu
tags question: http://stackoverflow.com/q/22096867
tag name: slidingmenu
type: Tag

http://stackoverflow.com/q/22131140
has title: how does osgi security model work?
score: 0
answer count: 1
tagged with: securitymanager
tagged with: equinox
tagged with: osgi
type: UnansweredQuestion
has body: I would like to know how exactly OSGI can check their own Permissions like PackagePermission. I have read that they use a self-made ProtectionDomain but that is not true (for the new releases I was looking at). It would be ok if you just refer to Equinox. Would the implementation check befor every bundle exports its resources for a PackagePermission like that? public void export(BundleContext ctx) { SecurityManager manager = System.getSecurityManager(); if(manager != null) { manager.checkPermission(new PackagePermission(ctx, "export")); } } 'cause i thought that it isn't quiet easy to check such self-made permissions.
has answer: http://stackoverflow.com/a/22133171
tagged with: java
type: Question

http://stackoverflow.com/a/22131421
type: Answer
has body: Well... First answering your question: lines.size() is very small at the end of the program, because you first loop through all lines via readLine(), and overwrite the value of readLine().split(";") on inputs on every iteration. Then just before your program ends, you add the contents of your last line, split up by ';', to lines. The solution would be to move the for-loop that adds the split up lines to the loop, inside the while loop. Also observe that you could call lines.addAll(inputs) to add all of them to lines, then you do not need to loop over them, which essentially clutters your code as it is an unneccessary operation. This could also be done in the following way in Java 8: try { List&lt;String&gt; lines = new BufferedReader(new FileReader("D:\\input.txt")).lines().collect(Collectors.toList()); } catch (FileNotFoundException ex) { Logger.getLogger(MultiMapJava8.class.getName()).log(Level.SEVERE, null, ex); } So assuming you have a reader available, it is even as simple as: List&lt;String&gt; lines = reader.lines().collect(Collectors.toList()); Explanation: Obtain a BufferedReader instance. Call lines() on it to get a Stream&lt;String&gt;. Nb. Streams is a really nice new concept of Java 8, read up about it! Collect the Stream&lt;String&gt; into a List&lt;String&gt;, which is done by calling collect(Collectors.toList()) on the stream. And just now I realized that you split the lines itself on a ; aswell, so glad we have a Stream&lt;String&gt;, the code now would be: BufferedReader reader = new BufferedReader(new FileReader("D:\\input.txt")); List&lt;String&gt; lines = reader.lines() .flatMap(line -&gt; Arrays.stream(line.split(";"))) .collect(Collectors.toList()); The extra step added is flatMap(line -&gt; Arrays.stream(line.split(";"))), this contains a lambda expression from String to a Stream&lt;String&gt;, where the stream has been created by creating a stream from line.split(";"), which returned a String[]. All flatMap(...) does is add those resulted el…
answers question: http://stackoverflow.com/q/22131029
score: 3
downvote count: 0
upvote count: 3

http://stackoverflow.com/q/22007246
has comment: http://stackoverflow.com/comment/33357265
type: AnsweredQuestion
score: 3
has comment: http://stackoverflow.com/comment/33357186
downvote count: 0
has title: How do I remove an element from a hashtable using its value and not the key?
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22007318
has comment: http://stackoverflow.com/comment/33356274
has comment: http://stackoverflow.com/comment/33356140
upvote count: 3
answer count: 3
has comment: http://stackoverflow.com/comment/33357172
possible better answer: http://stackoverflow.com/a/22007320
favorite count: 0
has answer: http://stackoverflow.com/a/22007320
tagged with: hashtable
has body: I'm new to hash table and I'm just figuring out the basic operations on it. I have a hash table created as shown below and inserted values also. Hashtable&lt;Integer , String&gt; ht = new Hashtable&lt;Integer , String&gt;(); ht.put(1234, "ABCD"); ht.put(2345, "EFGH"); ht.put(4567, "IJKL"); I am able to delete the element needed using the key as shown below System.out.println("Deleting entry with key 2345"); ht.remove(2345); System.out.println(ht.toString()); which gives the following output Deleting entry with key 2345 {4567=IJKL, 1234=ABCD} I am not able to find any method which helps with locating the element in the hashtable using the value as an index and deleting the element. How do I go about it?
has answer: http://stackoverflow.com/a/22007294
accepted answer: http://stackoverflow.com/a/22007294

http://stackoverflow.com/q/22026539
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22027933
has title: Fragment Not Displaying In Activity
tagged with: android-fragments
tagged with: java
has body: Currently when running my application, going to this activity does not display my fragment. Am I adding the fragment wrong and so nothing in the fragment is displayed? Or is there something wrong the dynamic behavior in the fragment onCreateView method? My Activity Code public class AskQuestionActivity extends FragmentActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.ask_question); } } My Activity XML <?xml version="1.0" encoding="UTF-8"?> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:hint="@string/header_text"/> <fragment android:name="com.mypackage.AskQuestionFragment" android:id="@+id/question_fragment" android:layout_weight="1" android:layout_width="0dp" android:layout_height="match_parent" /> My Fragment Code public class AskQuestionFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { String questionText = "What is your favorite color?"; List<String> answers = Arrays.asList("Red", "Blue", "Yellow"); LinearLayout layout = (LinearLayout)inflater.inflate(R.layout.question, container); Resources res = getResources(); int id = res.getIdentifier("question_text", "id", layout.getContext().getPackageName()); TextView questionTextView = (TextView)layout.findViewById(id); questionTextView.setText(questionText); id = res.getIdentifier("question_answers", "id", layout.getContext().getPackageName()); RadioGroup radioGroup = (RadioGroup)layout.findViewById(id); Collections.reverse(answers); for (String s : answers) { RadioButton button = new RadioButton(layout.getContext()); button.setText(s); radioGroup.addView(button, 0); } return layout; } } My Fragment XML <?xml version="1.0" encoding="utf-8"?> <TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/question_text"/>
type: Question
score: 0
answer count: 3
tagged with: android
has answer: http://stackoverflow.com/a/22028049
has answer: http://stackoverflow.com/a/22026996

http://stackoverflow.com/a/22091804
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/22091577
has body: As per the exception getServletContext().getInitParameter("time-to-expire-cookie") value is null.
upvote count: 1
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/22091577

http://stackoverflow.com/comment/33594459
comment on: http://stackoverflow.com/a/22139452
has text: did you declare `elementsToAdd2` as `String elementsToAdd2[] = new String[30]`? You must provide a size and use `elementsToAdd2.length` instead of `30` in the `for` loop.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/22087373
accepted answer: http://stackoverflow.com/a/22105765
tagged with: java
tagged with: gradle
type: Question
tagged with: debugging
score: 5
tagged with: intellij-idea
upvote count: 5
downvote count: 0
answer count: 1
has answer: http://stackoverflow.com/a/22105765
has body: I've used previously maven 3 and it was easy to run anything from IntelliJ IDEA 13, be at main classes or tests - it worked through maven settings. But now I am trying to debug my java project in IDEA with Gradle 1.11. The problem is that idea now creates /out/* directory and trying to run my classes from there instead of using gradle settings and build setups - I mean, with maven I could debug my java project by this: Set debug configurations Run it under debug 2 step will call maven install and will run my java project from target/classes/ directory But with gradle project idea not uses gradle structure. How can I debug my java project right from IDEA IDE with gradle? P.S. I can run gradle test under debug in IDEA and it works perfectly, but I need something like gradle debug or gradle run to set breakpoint in IDE, run my Main class and launch my java application through IDE. Hope it is clear what I want to do.
favorite count: 0
tagged with: maven
type: AnsweredQuestion
has title: Gradle Java debugging project in IntelliJ IDEA

http://stackoverflow.com/q/22093349
has answer: http://stackoverflow.com/a/22094038
has comment: http://stackoverflow.com/comment/33509830
has answer: http://stackoverflow.com/a/22093481
upvote count: 1
possible better answer: http://stackoverflow.com/a/22093481
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22093763
score: 1
tagged with: java
linked to: http://stackoverflow.com/q/17158875
has title: Not asking for input after the while loop starts again
has body: My program is to enter a substring and return all the books based upon the search.i want to ask the user again to search again from the same records.The code is not asking for the user input for the second time.Kindly help boolean runnable=true; while(runnable) { System.out.println("\n\nInput Books you wish for search"); String search; search=br.nextLine(); System.out.println("\n\nBooks by your search"); for(int i=0;i&lt;noOfrecords;i++) { if(books[i].toLowerCase().contains(search.toLowerCase())) { System.out.println(books[i]); } } System.out.println("\n\nMore Books"); for(int i=0;i&lt;noOfrecords;i++) { if(!(books[i].toLowerCase().contains(search.toLowerCase()))) { System.out.println(books[i]); } } System.out.println("do you wish to search again from the same records?? (y/n)"); char searchagain=br.next().charAt(0); if(searchagain!='y') { runnable=false; } else if(searchagain=='y') { runnable=true; } }
type: Question
downvote count: 0
tagged with: while-loop
has answer: http://stackoverflow.com/a/22093763
answer count: 4
has answer: http://stackoverflow.com/a/22093532
favorite count: 0

http://stackoverflow.com/a/22034752
has comment: http://stackoverflow.com/comment/33405640
score: 0
answers question: http://stackoverflow.com/q/22034009
has body: Do like this over an iteration Map&lt;Integer,Artical&gt; outPuts = new HashMap&lt;Integer,Artical&gt;(); for(Artical artical1 : articals ){ for(Artical artical2 : articals ){ if(artical1.getarticalid() == artical2.getarticalid()){ int retval = Double.compare(artical1.getarticalVersion(), artical2.getarticalVersion()); if(retval &gt; 0) { if(outPuts.containsKey(artical1.getarticalid())){ outPuts.remove(artical1.getarticalid()); outPuts.add(artical1.getarticalid(),artical1); }else{ outPuts.add(artical1.getarticalid(),artical1); } } else{ if(outPuts.containsKey(artical1.getarticalid())){ outPuts.remove(artical1.getarticalid()); outPuts.add(artical1.getarticalid(),artical1); }else{ outPuts.add(artical1.getarticalid(),artical1); } } } } }
type: Answer

http://stackoverflow.com/q/22140049
tagged with: java
has title: How to create same token for same input in Java
type: Question
has comment: http://stackoverflow.com/comment/33594335
score: 0
has answer: http://stackoverflow.com/a/22140964
has comment: http://stackoverflow.com/comment/33594123
has comment: http://stackoverflow.com/comment/33594577
answer count: 1
tagged with: string
has body: I am a beginner in java, I need to generate a token which should be same for the same input, otherwise it should be different.
has comment: http://stackoverflow.com/comment/33594800
has comment: http://stackoverflow.com/comment/33594497
type: UnansweredQuestion

http://stackoverflow.com/a/22124371
answers question: http://stackoverflow.com/q/22123828
score: 0
has comment: http://stackoverflow.com/comment/33567523
upvote count: 1
has body: You can get some insight from my implementation of Infix To Postfix program, which is based on the standard algorithm for doing such conversions. Here it is: import java.util.Scanner; import java.util.Stack; public class InfixPostfix { private Stack&lt;Character&gt; stack; private StringBuilder postfixExpression; public InfixPostfix() { stack = new Stack&lt;&gt;(); postfixExpression = new StringBuilder(); String infix = getInfixExpression(); if (isValidInfix(infix)) { System.out.println(convertToPostfix(infix)); } else { System.out.println("Invalid Expression"); } } private boolean isValidInfix(String infix) { int parenthesisCounter = 0; for (int i = 0; i &lt; infix.length(); i++) { char ch = infix.charAt(i); if (ch == '(') parenthesisCounter++; else if (ch == ')') parenthesisCounter--; if (parenthesisCounter &lt; 0) return false; } if (parenthesisCounter == 0) return true; return false; } private String convertToPostfix(String infix) { for (int i = 0; i &lt; infix.length(); i++) { char ch = infix.charAt(i); switch (ch) { case '+': case '-': processOperatorOfPrecedence(ch, 1); break; case '*': case '/': processOperatorOfPrecedence(ch, 2); break; case '(': stack.push(ch); break; case ')': processParenthesis(ch); break; default: postfixExpression.append(ch); break; } } while (!stack.isEmpty()) { postfixExpression.append(stack.pop()); } return postfixExpression.toString(); } private void processOperatorOfPrecedence(char operator, int precedence) { while (!stack.isEmpty()) { char topOperator = stack.pop(); if (topOperator == '(') { stack.push(topOperator); break; } else { int operatorPrecedence; if (topOperator == '+' || topOperator == '-') operatorPrecedence = 1; else operatorPrecedence = 2; if (operatorPrecedence &lt; precedence) { stack.push(topOperator); break; } else postfixExpression.append(topOperator); } } stack.push(operator); } private void processParenthesis(char ch) { while (!stack.isEmpty()) { char character = stack.pop(); if (character == '(') break; else …
type: Answer
downvote count: 1

http://stackoverflow.com/q/22087153
has comment: http://stackoverflow.com/comment/33499354
has answer: http://stackoverflow.com/a/22087217
answer count: 3
upvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/33530528
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33499227
score: -3
has answer: http://stackoverflow.com/a/22087182
has body: Can someone please explain to me why I am still getting the following error? I'm trying to include a calculation of the commission. illegal start of type public static void GalleryCommission("Price * .20" Here is my code: import java.util.Scanner; import javax.swing.JOptionPane; public class Painting { private static Object paintingTitle; private static Object artist; private static Object medium; private static Object price; private static Oblect GalleryCommission; public static void main(String[] args){ String result; result = JOptionPane.showInputDialog(null, "What is Paint Title?"); JOptionPane.showMessageDialog(null, "Paint Title is " + result + "!"); result = JOptionPane.showInputDialog(null, "What is Artist name?"); JOptionPane.showMessageDialog(null, "Artist is " + result + "!"); result = JOptionPane.showInputDialog(null, "What is Medium?"); JOptionPane.showMessageDialog(null, "Medium is " + result + "!"); result = JOptionPane.showInputDialog(null, "What is Price?"); JOptionPane.showMessageDialog(null, "Price is $" + result + "!"); result = JOptionPane.showInputDialog(null, "To Calculate Gallery Commission Price is?"); JOptionPane.showMessageDialog(null, "GalleryCommission is $" + "result *.20"); } public static Object getPrice() { return price; } public static void setPrice(Object price) { return ObjectPrice; } public static void GalleryCommission("Price * .20") { return GalleryCommission; } }
tagged with: java
downvote count: 3
has answer: http://stackoverflow.com/a/22087187
type: Question
has title: Illegal start of type error in method declaration

http://stackoverflow.com/comment/33445380
has text: `AT THE END of the statement` means at the end of the corresponding `try` block.
comment on: http://stackoverflow.com/q/22056960
type: Comment
type: QuestionComment
score: 2

finalize
type: Tag
tags question: http://stackoverflow.com/q/22117656
tag name: finalize

http://stackoverflow.com/comment/33354175
type: Comment
type: QuestionComment
has text: What about some code? Difficult to answer your problem when it's not even being asked ;)
score: 0
comment on: http://stackoverflow.com/q/22005692

http://stackoverflow.com/a/22111185
type: Answer
has body: Make sure that all the classes remain in same package. You can call the method of other classes by creating a object for class being called .. then use the object to call the method name.. classbeingcalled obj= new classbeingcalled(); obj.methodname(); or declare your method as a static method so you can call the method by using the class name public static returntype methodname(){ ... } from any class in the package classname.methodname(); PS: If you are not satisfied with this answer or dint expect this answer please be clear with your question.
answers question: http://stackoverflow.com/q/22110855
has comment: http://stackoverflow.com/comment/33652751
has comment: http://stackoverflow.com/comment/33543571
score: 0

http://stackoverflow.com/q/22120122
has title: Invoking to type the team name twice instead of once
favorite count: 0
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/22119883
score: -4
duplicate of: http://stackoverflow.com/q/22119883
has answer: http://stackoverflow.com/a/22120169
has comment: http://stackoverflow.com/comment/33558621
tagged with: java
has body: I have been asked to check if the team name is present in the text file I had created on my computer. I have written the complete code but the output is always invoking me type the name of the team twice before counting the number of times the team's name is present in the file. Please do see this, and let me know. Thanks. import java.util.*; import java.io.*; public class worldSeries { public String getName(String teamName) { Scanner keyboard = new Scanner(System.in); System.out.println(" Enter the Team Name : " ); teamName = keyboard.nextLine(); return teamName; } public int checkSeries1 () throws IOException { String teamName=""; String[] winners = new String[50]; int i = 0 ; File file = new File ("WorldSeriesWinners.txt"); Scanner inputFile = new Scanner(file); while ( inputFile.hasNext () &amp;&amp; i &lt; winners.length ) { winners[i] = inputFile.nextLine(); i++; } inputFile.close(); int count = 0; String nameOfTeam = getName(teamName); for ( int index = 0 ; index &lt; winners.length ; index ++ ) { if ( nameOfTeam.equals(winners[index])) { count++; } } return count; } public static void main(String[]Args) { String teamName = ""; worldSeries object1 = new worldSeries(); try { System.out.println(" The Number of times " + object1.getName(teamName) + "won the Championship is : " +object1.checkSeries1()); } catch ( IOException ioe ) { System.out.println(" Exception!!! "); ioe.printStackTrace(); } } }
has comment: http://stackoverflow.com/comment/33558838
tagged with: methods
has answer: http://stackoverflow.com/a/22120462
has answer: http://stackoverflow.com/a/22120329
type: Question
downvote count: 4
upvote count: 0
tagged with: printing
answer count: 3

http://stackoverflow.com/q/22129492
has body: everyone. I'm currently working on a project which is written in Java. As one of my features I want the application to display List of workout plans that are saved in the databases. Furthermore, I want the user to be able to click on particular instance of the workout Plan so that new JFrame is opened with further details which will be populated from the database. You can see what I mean in the picture below, this is how I want my list to look like. For this application I'm using Swing components to model my GUI. Its very important for me that those items within a list will act as a button so that you can open up new JFrame, but at the same time the content must be populated from database. Also when a new Workout Plan is added to the database the list must be updated and the item that will be added to that list has to be of the same format. My question is whether it's possible to design that kind of list using Swing components, and if it is how would you do it. Any suggestions or help will be appreciated.
score: 0
has comment: http://stackoverflow.com/comment/33583129
answer count: 1
has answer: http://stackoverflow.com/a/22130154
type: UnansweredQuestion
tagged with: swing
tagged with: java
has title: Swing (Java) Category List
type: Question

http://stackoverflow.com/q/22146441
favorite count: 0
possible better answer: http://stackoverflow.com/a/22146579
has answer: http://stackoverflow.com/a/22146535
answer count: 5
has title: Select by field hibernate
accepted answer: http://stackoverflow.com/a/22146535
type: AnsweredQuestion
score: 1
tagged with: java
tagged with: hibernate
has answer: http://stackoverflow.com/a/22146565
has answer: http://stackoverflow.com/a/22146541
has answer: http://stackoverflow.com/a/22146666
upvote count: 1
type: Question
tagged with: sql
has answer: http://stackoverflow.com/a/22146579
downvote count: 0
has body: i have such structure package logic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; import org.hibernate.annotations.GenericGenerator; @Entity @Table(name="users") public class user { private Long id; private String name; private String pass; public user(){ name = null; } public user(user u){ name = u.getName(); } @Id @GeneratedValue(generator = "increment") @GenericGenerator(name="increment", strategy = "increment") @Column(name="id") public Long getId(){ return id; } @Column(name = "username", unique = true) public String getName() { return name; } @Column(name = "password") public String getPass(){ return pass; } public void setId(Long i){ id = i; } public void setName(String n){ name = n; } public void setPass(String p){ pass = p; } } i want to select from this table by username, in SQL smth like this select * from users where username = "abc";, but how i can do it with hibernate?

http://stackoverflow.com/a/22023042
accepted answer of: http://stackoverflow.com/q/22022862
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22022862
type: Answer
has body: I'm not sure how it's different from sorting any other type of list. Try this: List&lt;String&gt; mixedStuff = new ArrayList&lt;String&gt;(); mixedStuff.add("hello123"); int sevens = 777; mixedStuff.add("alpha" + sevens); Integer eights = 888; mixedStuff.add("bravo" + eights.toString()); Collections.sort(mixedStuff);
score: 0

http://stackoverflow.com/a/22028073
downvote count: 0
answers question: http://stackoverflow.com/q/22027984
type: Answer
upvote count: 3
has body: Error: Type mismatch: cannot convert from double to int - you are initializing an array using double as the size, which is not allowed, change NUM_GRADES type to int: static final int NUM_GRADES = 5; Error: grades cannot be resolved to a variable - you don't have a variable called grades, that's why the compiler is complaining; probably your variable scores should be called grades Error: Type mismatch: cannot convert from double to int - you are using double to index an array in for loop, change it to int: for (int index = 0; index &lt; NUM_GRADES; ++index) EDIT (few more): variable grade doesn't exist in this piece of code: if(grades[index] &gt; highestGrade) { highestGrade = grade[index]; //&lt;------- change it to grades } your print() statement is outside for loop, so index variable will not be accessible; move it inside the loop avgScores is also not declared as variable, it should probably be avgGrades, which you declared at the beginning
score: 3

http://stackoverflow.com/q/22117927
answer count: 2
downvote count: 0
tagged with: jar
tagged with: dependencies
possible better answer: http://stackoverflow.com/a/22118203
favorite count: 0
has answer: http://stackoverflow.com/a/22118169
tagged with: jenkins
has comment: http://stackoverflow.com/comment/33554667
tagged with: maven
has body: I have a Jenkins build server that automatically builds the project into a jar when a new commit has been pushed to the GitHub project. I looked at file size of the artifacts that Jenkins creates and I was surprised. I came to the conclusion that all the third-party dependencies were included in the jar artifact! I don't need Maven to include them in the artifact as that will increase the size dramatically and it isn't useful. So I fiddled around with my pom.xml file, but I couldn't get it working. The dependencies keep being included in the jar. I'm relatively new to Maven and I would appreciate it a lot if someone can help me out! Sources (if you need any): Pom.xml
type: AnsweredQuestion
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33554609
upvote count: 1
accepted answer: http://stackoverflow.com/a/22118169
type: Question
has title: Stop Maven from including dependencies in the built artifact (jar)
has comment: http://stackoverflow.com/comment/33554997
has answer: http://stackoverflow.com/a/22118203

http://stackoverflow.com/comment/33365263
score: 0
type: Comment
type: QuestionComment
has text: It depends on what's your need. Internally RowMapper uses ResultSet. RowMapper is kinda my favorite because it makes my code simple and readable.
comment on: http://stackoverflow.com/q/22012522

http://stackoverflow.com/q/22161146
upvote count: 1
downvote count: 7
type: Question
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33632120
has body: int j = 0; while (j &lt; A.length) { i = j + 1; while (i &lt; A.length) { if(A[i] &lt; A[j]) //swap int temp = A[i]; A[i] = A[j]; A[j] = temp; } i++; } j++; } a program that will output the number of swaps that will be executed for different array lengths as enumerated below: a. 100 b. 1,000 c. 10,000 d. 100,000 e. 1,000,000
has answer: http://stackoverflow.com/a/22161401
tagged with: java
tagged with: http://stackoverflow.com/tag/c
accepted answer: http://stackoverflow.com/a/22161401
answer count: 2
favorite count: 0
has comment: http://stackoverflow.com/comment/33632045
has comment: http://stackoverflow.com/comment/33632351
has title: Can I see another sample of this program? I'm having difficulty in understanding it
score: -6
possible better answer: http://stackoverflow.com/a/22161278
has answer: http://stackoverflow.com/a/22161278

http://stackoverflow.com/comment/33529756
type: QuestionComment
has text: Observe when you encounter each node as you do an inorder traversal. Debug the code and step through it. Where to put your parenthesis outputs should become obvious to you then.
type: Comment
comment on: http://stackoverflow.com/q/22104023
score: 0

http://stackoverflow.com/tag/csv
tags question: http://stackoverflow.com/q/22050978
type: Tag
tags question: http://stackoverflow.com/q/22036492
tag name: csv
tags question: http://stackoverflow.com/q/22044902
tags question: http://stackoverflow.com/q/22145933
tags question: http://stackoverflow.com/q/22070173
tags question: http://stackoverflow.com/q/22035229
tags question: http://stackoverflow.com/q/22067525
tags question: http://stackoverflow.com/q/22150527
tags question: http://stackoverflow.com/q/22005722
tags question: http://stackoverflow.com/q/22158208
tags question: http://stackoverflow.com/q/22064409
tags question: http://stackoverflow.com/q/22011011
tags question: http://stackoverflow.com/q/22145513
tags question: http://stackoverflow.com/q/22055163
tags question: http://stackoverflow.com/q/22134643
tags question: http://stackoverflow.com/q/22085365
tags question: http://stackoverflow.com/q/22076896

http://stackoverflow.com/q/22066619
tagged with: java
has answer: http://stackoverflow.com/a/22067024
tagged with: notify
type: Question
score: 0
has answer: http://stackoverflow.com/a/22068411
has comment: http://stackoverflow.com/comment/33469141
tagged with: wait
answer count: 5
has answer: http://stackoverflow.com/a/22066937
possible better answer: http://stackoverflow.com/a/22066909
linked to: http://stackoverflow.com/q/22063249
has answer: http://stackoverflow.com/a/22066909
has body: If I know the ID of the thread I wish to notify, and share no other common resource, can I notify it? Both the threads have been initiated by the same application. the other thread went into wait by using Thread.currentThread().wait(500);
has title: Is it possible for threads not sharing a common resource to notify based on thread-id/name?
tagged with: multithreading
linked to: http://stackoverflow.com/q/1323408
has answer: http://stackoverflow.com/a/22066788
accepted answer: http://stackoverflow.com/a/22066788
type: AnsweredQuestion

http://stackoverflow.com/comment/33610253
score: 0
comment on: http://stackoverflow.com/q/22149201
type: Comment
has text: Oops yes sorry, forgot to complete it.
type: QuestionComment

http://stackoverflow.com/comment/33592157
comment on: http://stackoverflow.com/a/22138346
type: Comment
has text: @user3316776 `String#split()` means a split method in `String` class, in your case you should use like: `System.out.println(line.split(","));`
score: 0
type: AnswerComment

http://stackoverflow.com/a/22120985
score: 1
type: AcceptedAnswer
downvote count: 0
has body: Sorry, but java doesn't allow multiple inheritance. So you cannot make your CustomAdapter that extends ArrayAdapter and Activity. There is an interesting discussion about that here So you need to find another way of doing that
type: Answer
accepted answer of: http://stackoverflow.com/q/22120920
answers question: http://stackoverflow.com/q/22120920
upvote count: 1

http://stackoverflow.com/q/22077187
tagged with: java
has comment: http://stackoverflow.com/comment/33481721
downvote count: 1
type: Question
upvote count: 0
score: -1
has body: My problem is that I have a big String and I want to change all the "i " into "I ". However I cannot do this efficiently enough. I know there are previous questions asked on replacing parts of a String, but I am unsure what is the fastest method. Some kind I have tried: a) if (question.charAt(i)=='i' &amp;&amp; question.charAt(i+1)==' ') { question = question.substring(0,i) + 'I' + question.substring(i+1); } b) (100-200x slower than attempt a) question = question.replace("i ", "I "); c) (About 100x slower than atempt a) question = question.replaceAll("i ", "I "); I have never done much efficient programming and neither of these cuts it for how efficient I need this to be. Is there a faster way that I don't know about?
tagged with: search
has title: Efficiency - Replacing word in middle of sentence
answer count: 1
tagged with: string
has answer: http://stackoverflow.com/a/22077587
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33481788
has comment: http://stackoverflow.com/comment/33482423
tagged with: performance

http://stackoverflow.com/q/22034537
has comment: http://stackoverflow.com/comment/33404831
upvote count: 1
has title: Java Recursive functions, single initialization of value
downvote count: 0
has comment: http://stackoverflow.com/comment/33404918
type: AnsweredQuestion
tagged with: recursion
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33404884
accepted answer: http://stackoverflow.com/a/22034607
type: Question
has body: I want to use a recursive function to achieve some stuff, which includes printing output. I want to give increasing levels of tab in the output being printed. I was able to successfully achieve this using the following methodology int count =0; public void m1 (Object n) { count++; List nl = n.getChildren(); int nlsize = nl.size(); for (int i = 0 ; i &lt; nlsize ; i++) { String objName = nl.getObjAt(i).getText(); for (int tab=0; tab&lt;count ; tab++) {System.out.print("\t");} System.out.println(objName); m1(nl.getObjAt(i)); } count--; } But the limitations and problems of this approach, what with the initialization of count outside, are pretty obvious. Is there some way to achieve this? I know java doesn't accept default values for parameters being passed, or else that could be a possible solution. How else can this be achieved?
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/22034607

http://stackoverflow.com/comment/33629230
comment on: http://stackoverflow.com/a/22139486
type: AnswerComment
has text: Thanks. Apparently MultimapBuilder wasn't in guava 15.0 (which is what our private API currently depends on), so before I upgrade it I need to make sure nothing depends on the various deprecated stuff that got removed between 15 and 16.
score: 0
type: Comment

http://stackoverflow.com/q/22096093
tagged with: java
tagged with: mysql
type: Question
has answer: http://stackoverflow.com/a/22096191
has answer: http://stackoverflow.com/a/22096260
has answer: http://stackoverflow.com/a/22096223
downvote count: 0
has title: Update data programmatically in code(Java) or in database using trigger (MySQL)?
tagged with: sql
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/22096297
upvote count: 2
type: UnansweredQuestion
score: 2
has body: Edit : I need the program to do computational faster, the update process is needed to be real time (calculating 100.000 to 200.000 records for about 0-5 seconds), this process will be doing in multi threading (about 2-8 thread) I will create program that will update data in database. The update process will be triggered if I do insert data in table. The update process will computational costly. This is the idea of my update process : I will have 3 tables (A,B,C) and each of it will have data aroud 100.000-200.000 records I will have table D to save table A, B, C record count I will have table E to save table A, B, C, D calculation, the calculation including multiplication, division and log base 2 I will insert data to table A, B, C and after that data in table D and E must be updated This process can be repeated 3-5 times in every update Which one is computationally faster, doing update programmatically or using trigger?

http://stackoverflow.com/comment/33490415
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22081817
score: 0
has text: So I discovered that you don't want to solve a problem. You want to argue because you have lot of time!!! and I don't have. Please let others solve the problem and help me. bye

http://stackoverflow.com/q/22097071
has answer: http://stackoverflow.com/a/22097353
has answer: http://stackoverflow.com/a/22097187
tagged with: forms
has answer: http://stackoverflow.com/a/22097294
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22097233
type: Question
has answer: http://stackoverflow.com/a/22097343
tagged with: http://stackoverflow.com/tag/html
has body: I have a form in one of my html files and I want to form to submit the email directly to the email specified in the MAILTO attribute of the form. Form: &lt;form role="form" action="mailto:sm.ayman10@gmail.com" method="get" enctype="text/plain"&gt; &lt;div class="form-group"&gt; &lt;label for="emailinput"&gt;&lt;h4&gt;&lt;span class="glyphicon glyphicon-envelope"&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;E-mail&lt;/h4&gt;&lt;/label&gt; &lt;input class="form-control" type="email" id="emailinput" placeholder="Entrez votre e-mail"&gt; &lt;/input&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="messageinput"&gt;&lt;h4&gt;&lt;span class="glyphicon glyphicon-pencil"&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;Message&lt;/h4&gt;&lt;/label&gt; &lt;textarea class="form-control" id="messageinput" placeholder="Ecrivez votre message" rows="3"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;br/&gt; &lt;div class="text-right"&gt; &lt;button type="submit" class="btn btn-default"&gt; &lt;span class="glyphicon glyphicon-upload"&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;Envoyer &lt;/button&gt; &lt;/div&gt; &lt;/form&gt; When I test and click on it,I have a windows live mail window that opens instead of sending the email to the right address. What do I need to do to make it send the email? (info: my back end is implemented in Java)
answer count: 6
score: 0
accepted answer: http://stackoverflow.com/a/22097343
has answer: http://stackoverflow.com/a/22097392
has title: how to implement an html email form?
possible better answer: http://stackoverflow.com/a/22097187
tagged with: java

http://stackoverflow.com/a/22107581
accepted answer of: http://stackoverflow.com/q/22107195
has comment: http://stackoverflow.com/comment/33552586
has comment: http://stackoverflow.com/comment/33553632
answers question: http://stackoverflow.com/q/22107195
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33553323
has comment: http://stackoverflow.com/comment/33552478
has body: You can do it using the intent worn the action intent_SEND. This is a similar question and the first accepted answer is what you are looking for .... how to get list of installed instant messenger apps?
upvote count: 3
has comment: http://stackoverflow.com/comment/33553358
type: Answer
has comment: http://stackoverflow.com/comment/33553429
has comment: http://stackoverflow.com/comment/33553612
downvote count: 0
has comment: http://stackoverflow.com/comment/33553535
has comment: http://stackoverflow.com/comment/33553403
has comment: http://stackoverflow.com/comment/33553551
has comment: http://stackoverflow.com/comment/33553448
has comment: http://stackoverflow.com/comment/33553129
score: 3
has comment: http://stackoverflow.com/comment/33552571
has comment: http://stackoverflow.com/comment/33553283

search
tags question: http://stackoverflow.com/q/22156284
tags question: http://stackoverflow.com/q/22160647
type: Tag
tags question: http://stackoverflow.com/q/22024900
tags question: http://stackoverflow.com/q/22077187
tags question: http://stackoverflow.com/q/22010326
tags question: http://stackoverflow.com/q/22084519
tags question: http://stackoverflow.com/q/22066387
tag name: search
tags question: http://stackoverflow.com/q/22098035
tags question: http://stackoverflow.com/q/22100626

http://stackoverflow.com/comment/33430152
type: AnswerComment
score: 0
type: Comment
has text: I think you probably meant `.lastIndexOf()`; the sample input contains two colons
comment on: http://stackoverflow.com/a/22048549

http://stackoverflow.com/comment/33453925
comment on: http://stackoverflow.com/q/22062094
has text: I m not insulting anyone,just say u need algo and key without it no one cant decode it. @spt if u hurt thn sry dear
score: 0
type: Comment
type: QuestionComment

console
tags question: http://stackoverflow.com/q/22133654
tags question: http://stackoverflow.com/q/22027276
type: Tag
tags question: http://stackoverflow.com/q/22100038
tag name: console
tags question: http://stackoverflow.com/q/22147080

http://stackoverflow.com/comment/33555252
comment on: http://stackoverflow.com/a/22118325
score: 0
type: AnswerComment
type: Comment
has text: List is of type ActivityPerformed, mean list will contain object of this class.When u try to get any element with index then it will return the object of the ActivityPerformed.So i m not sure which attribute of class ActivityPerformed u want to saw in the report.

http://stackoverflow.com/a/22153286
type: AcceptedAnswer
downvote count: 0
upvote count: 2
type: Answer
has body: FileWriter filewriter = new FileWriter("Random.txt", true); As per java doc Constructs a FileWriter object given a File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning. Parameters: file - a File object to write to append - if true, then bytes will be written to the end of the file rather than the beginning
score: 2
accepted answer of: http://stackoverflow.com/q/22153215
answers question: http://stackoverflow.com/q/22153215

http://stackoverflow.com/comment/33595730
has text: myLambda.getClass() throws ClassNotFoundException
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/22140955

http://stackoverflow.com/comment/33579063
type: QuestionComment
has text: It always listens for events, especially from the keyboard.
comment on: http://stackoverflow.com/q/22131146
score: 0
type: Comment

http://stackoverflow.com/q/22029382
favorite count: 0
has comment: http://stackoverflow.com/comment/33396593
has comment: http://stackoverflow.com/comment/33396571
has comment: http://stackoverflow.com/comment/33396509
has title: This method won't work... Is it a syntax error?
downvote count: 2
upvote count: 1
has answer: http://stackoverflow.com/a/22029552
has comment: http://stackoverflow.com/comment/33396712
has comment: http://stackoverflow.com/comment/33396515
type: Question
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33396738
tagged with: syntax
has comment: http://stackoverflow.com/comment/33396618
has body: So, I've been having issues with this. I'm trying to make this method return the first character of the string given to it, but I keep getting java.util.NoSuchElementException... I think I may be using some syntax wrong but really I have no idea. Any help? public static char nthChar (){ Scanner sc = new Scanner(in); String input = sc.nextLine(); char [] userCharArray = new char[input.length()]; userCharArray = input.toCharArray(); sc.close(); return userCharArray[0]; } Note that I imported the static members of java.lang.System I changed it to this... public static char nthChar (){ Scanner sc = new Scanner(System.in); String input = sc.nextLine(); char [] userCharArray = input.toCharArray(); sc.close(); return userCharArray[0]; } Still doesn't work.
tagged with: java
score: -1
has comment: http://stackoverflow.com/comment/33396646
has comment: http://stackoverflow.com/comment/33396948
accepted answer: http://stackoverflow.com/a/22029552
answer count: 1

http://stackoverflow.com/comment/33447210
score: 1
has text: I'm unable to reproduce this. I changed the width of `panelSize` in `MainPanel` to 340000 (that's an extra 0 there) and it paints fine. Can you post a screen shot of what you are seeing and also describe the steps you are taking that causes it?
comment on: http://stackoverflow.com/q/22057038
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33583823
type: Comment
score: 0
comment on: http://stackoverflow.com/q/22133590
has text: @ChristopherRene System.out.print prints to the console
type: QuestionComment

http://stackoverflow.com/q/22087828
has comment: http://stackoverflow.com/comment/33500649
has body: I am having an issue with a certain lab assignment, The goal is to return a user's text on the screen. However, after looking in the deepest darkest depths of the interweb, I have found no answer. Here is my code,please tell me how to return User's input AcitivityLoaderActivity class's code for starting the activity ExplicitlyLoadedActivity: // TODO - Create a new intent to launch the ExplicitlyLoadedActivity class Intent explicitActivity = new Intent(ActivityLoaderActivity.this,ExplicitlyLoadedActivity.class); // TODO - Start an Activity using that intent and the request code defined above startActivity(explicitActivity); This is the code for receiving the result for User Edit Text protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.i(TAG, "Entered onActivityResult()"); // TODO - Process the result only if this method received both a // RESULT_OK result code and a recognized request code // If so, update the Textview showing the user-entered text. if(requestCode==GET_TEXT_REQUEST_CODE){ if(resultCode==RESULT_OK){ mUserTextView.setText(data.getStringExtra("givenText")); }//end if }//end if } ExplicitlyLoaderActivity class's code: private void enterClicked() { final int GET_TEXT_REQUEST_CODE = 1; Log.i(TAG,"Entered enterClicked()"); // TODO - Save user provided input from the EditText field String givenText = mEditText.getText().toString(); // TODO - Create a new intent and save the input from the EditText field as an extra Intent editText = new Intent(); editText.putExtra("givenText",givenText); // TODO - Set Activity's result with result code RESULT_OK setResult(RESULT_OK,editText); // TODO - Finish the Activity finish(); }
has title: How to correctly return User's Text Input with onActivityRequest
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33500768
has answer: http://stackoverflow.com/a/22088239
accepted answer: http://stackoverflow.com/a/22088239
type: Question
has comment: http://stackoverflow.com/comment/33500825
has comment: http://stackoverflow.com/comment/33500702
has comment: http://stackoverflow.com/comment/33500597
has answer: http://stackoverflow.com/a/22088180
has comment: http://stackoverflow.com/comment/33500907
has comment: http://stackoverflow.com/comment/33500635
score: 0
answer count: 2
possible better answer: http://stackoverflow.com/a/22088180
tagged with: android
has comment: http://stackoverflow.com/comment/33500538

http://stackoverflow.com/q/22113310
has comment: http://stackoverflow.com/comment/33546345
has comment: http://stackoverflow.com/comment/33546269
type: AnsweredQuestion
downvote count: 0
has title: Write Multiple objects in a File and Read them
has body: I am trying to create a simple program with user interface. The user from gui inserts a name, surname and age, of a class Person Implements Serializable. Everything works just fine, but only for one person, the first person! It seems that every time I send a new object to my file it is indeed written to the file since the file size is getting larger. The problem is that when I read the file with objects it returns just one, I want all the objects of class person that are stored in myFile to be returned. Here is a sneak peek of my code: Write object Button: try { per = new Person(name, sur, age); FileOutputStream fos = new FileOutputStream("myFile", true); ObjectOutputStream oos; oos = new ObjectOutputStream(fos); oos.writeObject(per); oos.flush(); oos.close(); //some other code here } catch (IOException e) { //some code here } Read object button: try { FileInputStream fis = new FileInputStream("myFile"); ObjectInputStream ois; ois = new ObjectInputStream(fis); try { rper = (Person) ois.readObject(); ois.close(); JOptionPane.showMessageDialog(null, "People:" + rper, "Saved Persons", JOptionPane.INFORMATION_MESSAGE); } catch (ClassNotFoundException e) { //some code here } } catch (IOException e) { //some code here } Thanks for any info!
type: Question
has comment: http://stackoverflow.com/comment/33546404
score: 3
has comment: http://stackoverflow.com/comment/33546435
possible better answer: http://stackoverflow.com/a/22113490
tagged with: java
has answer: http://stackoverflow.com/a/22113490
upvote count: 3
answer count: 2
has answer: http://stackoverflow.com/a/22114467
accepted answer: http://stackoverflow.com/a/22114467
favorite count: 0
tagged with: serialization
has comment: http://stackoverflow.com/comment/33546516

http://stackoverflow.com/comment/33552571
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22107581
type: Comment
has text: All the apps that can handle the messaging feature are programatically registered in the `BroadCastReceiver` with filter of `intent_SEND`. **So, you cannot prevent apps from receiving this intent** It is out of your scope

http://stackoverflow.com/comment/33538422
type: QuestionComment
has text: The code does appear "ok" (look at the return statements which is where the recursion occurs; However I don't understand the question .. what "first statement" do you think is run 4 times and why?
comment on: http://stackoverflow.com/q/22108710
score: 0
type: Comment

http://stackoverflow.com/a/22109931
has body: "Enter 5 names:" is misleading. Consider "Enter name " + (x + 1) + " (of " + 5 + "):" or something similar. But to answer your question: You are running generateNewName before you get any names! It's being executed for an array of only null elements! Change this: Output = generateNewName(getNames); System.out.println(Output); for(int x = 0; x &lt; 5; x++){ System.out.println("Enter 5 names: "); getNames[x] = input.nextLine(); } to this for(int x = 0; x &lt; 5; x++){ System.out.println("Enter 5 names: "); getNames[x] = input.nextLine(); } Output = generateNewName(getNames); System.out.println(Output); :) Also consider renaming your variables to (a) follow naming conventions such as variable names should be lowercase, and (b) to be more indicative of what they hold and what they are (string, char, array, etc.). Such as names or nameArray instead of getNames and newName or outputName instead of Output. Finally, and as stated by others, you're using and returning a char in the generateNewName, and obviously a name is a string, not a char.
answers question: http://stackoverflow.com/q/22109881
type: Answer
downvote count: 0
score: 1
upvote count: 1

http://stackoverflow.com/comment/33427049
type: Comment
has text: I don't think this works, because you actually need to implement 'create' for every type K that you might create. Plus the fact that at runtime all the Somethings are exactly the same anyway.
comment on: http://stackoverflow.com/a/22046548
type: AnswerComment
score: 0

http://stackoverflow.com/q/22093911
linked to: http://stackoverflow.com/q/22072834
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22094339
has body: I need some help, as I am quite the noob. The program im trying to make here, used to work for my intentions, but as I tried to make my code more readable, I ran into a problem regarding ActionListener. Before I made a new class to have all the methods in, I used button.addActionListener(this); and it worked just fine. Now that I wanted to put things in a separate class, I have absolutely no idea what to do. So I guess my question is, how can I make ActionListener work in a situation like this, or am I just doing everything wrong here? Here's the part of my code that I think is relevant(edited out most of it): //Class with frame, panels, labels, buttons, etc. class FemTreEnPlus { FemTreEnPlus() { //Components here! //Then to the part where I try to add these listeners cfg.addActionListener(); Exit.addActionListener(); New.addActionListener(); } } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run(){ //Start the Program in the FemTreEnPlus Class new FemTreEnPlus(); } }); } That was the class with the frame, here's the other class, with the methods public class FemTreEnMethods extends FemTreEnPlus implements ActionListener { //Perform Actions! public void actionPerformed(ActionEvent ae){ if(ae.getSource() == cfgButton){ configureSettings(); } if(ae.getSource() == newButton){ newProject(); } if(ae.getSource() == exitButton){ exitProgram(); } } //All methods are down here Thanks in advance for any help.
type: Question
linked to: http://stackoverflow.com/q/21790021
tagged with: java
score: 0
tagged with: swing
answer count: 1
has answer: http://stackoverflow.com/a/22094339
has title: Adding ActionListeners and calling methods in other classes
tagged with: actionlistener

http://stackoverflow.com/a/22120348
score: 0
has comment: http://stackoverflow.com/comment/33565650
type: Answer
has body: Following construct is problematic with Hibernate, because hibernate tends to create proxies for entities because of need for lazy loading: if (getClass() != obj.getClass()) return false; Proxy is subclass of Metrics and thats why code above does not work, but code likely does: if (!(obj instanceof Metrics)) { return false; } More instructions about overriding equals and hashcode for entities can be found from Hibernate documentation. Also instanceof can bring surprises, as is told in this blog post.
answers question: http://stackoverflow.com/q/22118114

weblogic-10.x
tags question: http://stackoverflow.com/q/22168459
tag name: weblogic-10.x
type: Tag
tags question: http://stackoverflow.com/q/22165436

concurrency
tag name: concurrency
tags question: http://stackoverflow.com/q/22133214
tags question: http://stackoverflow.com/q/22042750
tags question: http://stackoverflow.com/q/22156155
tags question: http://stackoverflow.com/q/22038348
tags question: http://stackoverflow.com/q/22167910
tags question: http://stackoverflow.com/q/22067533
tags question: http://stackoverflow.com/q/22039990
tags question: http://stackoverflow.com/q/22095719
tags question: http://stackoverflow.com/q/22068772
tags question: http://stackoverflow.com/q/22039466
tags question: http://stackoverflow.com/q/22070894
tags question: http://stackoverflow.com/q/22090256
tags question: http://stackoverflow.com/q/22109357
tags question: http://stackoverflow.com/q/22129955
tags question: http://stackoverflow.com/q/22147494
tags question: http://stackoverflow.com/q/22129471
tags question: http://stackoverflow.com/q/22135000
type: Tag
tags question: http://stackoverflow.com/q/22069423
tags question: http://stackoverflow.com/q/22135449
tags question: http://stackoverflow.com/q/22098904
tags question: http://stackoverflow.com/q/22112469

http://stackoverflow.com/comment/33585916
comment on: http://stackoverflow.com/a/22133362
has text: Damn. Fedora has it's default java directory named differently than normal: /usr/lib/jvm/java; ubuntu /usr/lib/jvm/default-java if you have default-java installed, which i didn't for some reason. So you need to build with for instance: ./configure --prefix=/home/i30817/systemtap --with-java=/usr/lib/jvm/default-java
score: 1
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33410349
score: 0
comment on: http://stackoverflow.com/q/22037573
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/33632544
has text: oh I see ok ok thanks a lot @user2203521 yes it's incomplete
type: Comment
comment on: http://stackoverflow.com/a/22161401
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33493268
score: 0
comment on: http://stackoverflow.com/q/22083494
type: Comment
type: QuestionComment
has text: As a general suggestion, it is a good idea to either use an IDE that will tell you immediately when you have written something with incorrect syntax, or to write a little code, compile, test, repeat. It looks like you wrote a fair amount of code without checking whether it worked or even compiled. Once you get to that point it can be difficult to narrow down the problem.

http://stackoverflow.com/a/22043095
score: 0
has body: I would suggest you to XML serialize your HashMap : https://stackoverflow.com/a/4602230/1788704 Then, put it in your MySQL table in a TEXT column. It is certainly not the best way, but it works and you can see easily if what inside your database is correct or not. But the problem is that storing your Hashmap in database is certainly not a good solution.
answers question: http://stackoverflow.com/q/22042836
type: Answer

http://stackoverflow.com/comment/33454356
has text: onPostExecute is already in ui thread.
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22062226

http://stackoverflow.com/a/22066603
has comment: http://stackoverflow.com/comment/33461653
has comment: http://stackoverflow.com/comment/33461533
has comment: http://stackoverflow.com/comment/33462653
has comment: http://stackoverflow.com/comment/33461828
score: 5
accepted answer of: http://stackoverflow.com/q/22066469
has body: 20 million records isn't actually that many so first off I would try just processing it normally, you may find performance is fine. After that you will need to measure things. You need to read from the disk sequentially for good speed there so that must be single threaded. You don't want the disk read waiting for the networking or the networking waiting for the disk reads so dropping the data read into a queue is a good idea. You probably will want a chunk size larger than one line though for optimum performance. Measure the performance at different chunk sizes to see. You may find that network sending is faster than disk reading already. If so then you are done, if not then at that point you can spin up more threads reading from the queue and test with them. So your tuning factors are: chunk size number of threads. Make sure you measure performance over a decent sized amount of data for various combinations to find the one that works best for your circumstances.
type: AcceptedAnswer
upvote count: 5
downvote count: 0
answers question: http://stackoverflow.com/q/22066469
has comment: http://stackoverflow.com/comment/33465935
has comment: http://stackoverflow.com/comment/33485705
has comment: http://stackoverflow.com/comment/33477841
has comment: http://stackoverflow.com/comment/33462253
type: Answer

http://stackoverflow.com/comment/33515478
type: QuestionComment
score: 0
has text: `revalidate()` tells the layout managers to re-layout their components.
comment on: http://stackoverflow.com/q/22095838
type: Comment

http://stackoverflow.com/comment/40858972
score: 0
has text: I am sorry that I wasted your time. But that was the way it was taught to us: to give a connection to database in the deployment descriptor using context listener.
type: Comment
comment on: http://stackoverflow.com/a/22077274
type: AnswerComment

http://stackoverflow.com/comment/33443587
has text: There's not enough information: in fact this isn't even a complete class without the declarations of `x` and `y.`
comment on: http://stackoverflow.com/q/22055829
score: 4
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/33583761
comment on: http://stackoverflow.com/q/22133590
type: QuestionComment
type: Comment
has text: @NPE I want the return value to print to the console if the "if" condition is not met. If the "if" condition is met, I want it to print what is inside the condition.
score: 0

http://stackoverflow.com/a/22357375
answers question: http://stackoverflow.com/q/22092538
type: AcceptedAnswer
type: Answer
has body: Ok, I ended up with a properties file now, which I did not pack with the application but which resides on the server. So I can have different ones for development and production, where I reference the current version of an external webservice. The properties filename comes from context.xml.
accepted answer of: http://stackoverflow.com/q/22092538
score: 0

http://stackoverflow.com/q/22116028
tagged with: types
answer count: 1
has body: The class VectorQueue here is a queue data structure implementing vector methods. In my test class at the bottom I can successfully compile code such as " myVector.enqueue(20); " where myVector is an instance of the VectorQueue class. It's actual type is Queue - see here Queue&lt;Integer&gt; myVector = new VectorQueue&lt;Integer&gt;(); My question is this: Is there no way to use the vector methods on the instance "myVector" once it has been actualized as type Queue? I've tried the following: ((Vector&lt;T&gt;) myVector).insertAtRank(2,5); I also tried making my main class VectorQueue implement Queue and Vector interfaces, but it didn't help. I wondered to myself also, why can't something have multiple actualized types? package W7; public class VectorQueue&lt;T&gt; implements Queue&lt;T&gt; { public Vector&lt;T&gt; myVector = new ArrayVector&lt;T&gt;(); public void enqueue(T e) { myVector.insertAtRank(myVector.size(), e); } public T front() { return myVector.elemAtRank(0); } public T dequeue() { return myVector.removeAtRank(0); } public boolean isEmpty() { return myVector.isEmpty(); } public int size() { return myVector.size(); } public String toString(){ return myVector.toString(); } public static void main(String[] args) throws VectorFullException, RankOutOfBoundsException { Queue&lt;Integer&gt; myVector = new VectorQueue&lt;Integer&gt;(); try { myVector.enqueue(10); System.out.println(myVector); myVector.enqueue(5); System.out.println(myVector); myVector.dequeue(); System.out.println(myVector); myVector.enqueue(15); System.out.println(myVector); myVector.enqueue(3); System.out.println(myVector); myVector.dequeue(); System.out.println(myVector); myVector.enqueue(7); System.out.println(myVector); myVector.dequeue(); System.out.println(myVector); myVector.enqueue(20); System.out.println(myVector); ((Vector&lt;T&gt;) myVector).insertAtRank(2,5); } catch (VectorFullException RankOutOfBoundsException) { System.out.println("Error"); } int total = 0; while(! myVector.isEm…
type: UnansweredQuestion
tagged with: interface
tagged with: abstract-data-type
has answer: http://stackoverflow.com/a/22116610
has title: Why can't I implement my Vector methods on this instance of VectorQueue?
score: 0
tagged with: java
tagged with: queue
type: Question

http://stackoverflow.com/q/22124885
accepted answer: http://stackoverflow.com/a/22124895
tagged with: java
has comment: http://stackoverflow.com/comment/33567476
type: Question
has answer: http://stackoverflow.com/a/22124931
score: -1
has title: Cannot compare Chars in java, code running but results don't come
answer count: 3
possible better answer: http://stackoverflow.com/a/22124927
downvote count: 1
has comment: http://stackoverflow.com/comment/33567413
favorite count: 0
has body: /* Program to search a character in a sentence and tell the occurrence of that character in that sentence and also prints all the indexes. */ package com.shobhit.string1; import java.util.Scanner; public class StringSearch1 { public static void main(String args[]) { String sentence; char c; // takes first character of input char duplicate; // finds duplicates of c in code int length; // find sentence length int index; // index of character in sentence int numberOfOccurrence = 0; Scanner in = new Scanner(System.in); System.out.println("Enter a sentence:"); sentence = in.nextLine(); System.out.println("Enter a character you want to find in the sentence:"); c = in.next().charAt(0); length = sentence.length(); System.out.println("The indexes of the character are:"); for (int i = 0; i &gt;= length - 1; i++) { duplicate = sentence.charAt(i); if (c == duplicate) { numberOfOccurrence = numberOfOccurrence + 1; index = sentence.indexOf(c); System.out.println("Index is:" + index); } } System.out.println("The number of times " + c + " has occured is:" + numberOfOccurrence); } } Unexpected output: Enter a sentence: I don't want to type another long sentence Enter a character you want to find in the sentence: t The indexes of the character are: The number of times t has occured is:0
type: AnsweredQuestion
upvote count: 0
has answer: http://stackoverflow.com/a/22124927
has answer: http://stackoverflow.com/a/22124895

http://stackoverflow.com/q/22086582
has body: I have been trying to read a image in netbeans using ImageIO.read .. This is the code below .. try{ buffimg = ImageIO.read(new File(getClass().getResource("output.png").toURI())); } catch(Exception e){ out.println(e); } I run the code and the following exception is thrown .. What shoud i do ? Is this a bug ? java.lang.IndexOutOfBoundsException
upvote count: 1
downvote count: 1
has title: java.lang.IndexOutOfBoundsException while ImageIO.read in NetBeans?
tagged with: java
tagged with: indexoutofboundsexception
tagged with: image-processing
has comment: http://stackoverflow.com/comment/33498226
type: Question
has comment: http://stackoverflow.com/comment/33505375
has answer: http://stackoverflow.com/a/22087936
favorite count: 0
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/33516873
tagged with: netbeans
type: UnansweredQuestion

http://stackoverflow.com/q/22123548
has comment: http://stackoverflow.com/comment/33569255
type: AnsweredQuestion
has title: Duplicate classes when using Maven AspectJ weave dependencies
tagged with: java
accepted answer: http://stackoverflow.com/a/22182360
tagged with: maven
upvote count: 7
type: Question
score: 7
tagged with: aspectj
has body: We are using the Maven AspectJ plugin to build our web application. It makes use of "weaveDependencies" to add aspects to some dependency jar files. Now we end up with two versions of some classes in the web application archive, one in WEB-INF/classes and one in the original jar file in WEB-INF/lib. It seems that only the one in classes has the aspects. I am afraid that this can cause problems. What is the best way to fix this? The same problem is discussed (without solution) over at the Eclipse forums. The whole pom.xml itself is huge, and of course the sub-projects that are included have their own, too. I hope the extract below from the WAR project is informative enough. org.apache.maven.plugins maven-war-plugin 2.1.1 <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors> ${basedir}/src/etc/${environment}/environment.properties org.codehaus.mojo aspectj-maven-plugin 1.2 org.aspectj aspectjrt ${aspectj.version} org.aspectj aspectjtools ${aspectj.version} compile test-compile true org.springframework spring-aspects OURPROJECT OURPROJECT-api OURPROJECT OURPROJECT-service 1.6 1.6
downvote count: 0
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33587474
has answer: http://stackoverflow.com/a/22182360

http://stackoverflow.com/q/22123233
tagged with: custom-painting
has comment: http://stackoverflow.com/comment/33564731
possible better answer: http://stackoverflow.com/a/22123316
answer count: 2
has answer: http://stackoverflow.com/a/22123316
has comment: http://stackoverflow.com/comment/33565224
has body: I'm trying to write some custom painting code. Specifically, I want to have a bunch of extended JPanels which paint different aspects of my GUI, but each of these extended panels holds the instructions for how it is to be painted. I've created the code, but for some reason, the extended JPanel isn't being painted on the main JPanel in my JFrame regardless of what I do. Here is a gist of my main class and one of my extended JPanels. What am I missing? Breakout //Java imports import javax.swing.JFrame; import java.awt.Dimension; import javax.swing.JPanel; //Personal imports import Ball; public class Breakout { public static void main (String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() {//start the GUI in a new thread public void run(){ showGUI(); } }); } private static void showGUI() { JFrame frame = new JFrame("Breakout"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Dimension d = new Dimension(640,480); frame.setMinimumSize(d); frame.setResizable(false); JPanel p = new JPanel(); p.add(new Ball(200,200,50,255,0,0)); frame.add(p); frame.setVisible(true); } } Ball import javax.swing.JPanel; import java.awt.Color; import java.awt.Graphics; public class Ball extends JPanel { public int x; public int y; public int radius; public Color colour; public Ball(int x, int y, int radius, int r, int g, int b) { super(); this.x = x; this.y = y; this.radius = radius; colour = new Color(r,g,b); } public void paintComponent(Graphics g) { super.paintComponent(g); //define constants int topLeftX = x+radius; int topLeftY = y+radius; int diameter = radius *2; //draw outline g.setColor(Color.BLACK); g.drawOval(topLeftX, topLeftY, diameter, diameter); //fill it in g.setColor(colour); g.fillOval(topLeftX, topLeftY, diameter, diameter); } }
has comment: http://stackoverflow.com/comment/33564398
downvote count: 0
has comment: http://stackoverflow.com/comment/33564572
favorite count: 0
linked to: http://stackoverflow.com/q/22059165
has answer: http://stackoverflow.com/a/22123463
linked to: http://stackoverflow.com/q/21868170
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33564801
score: 1
tagged with: java
upvote count: 1
tagged with: swing
has title: Custom painting not being performed when the custom painting code is in another class
has comment: http://stackoverflow.com/comment/33564532
type: Question
accepted answer: http://stackoverflow.com/a/22123463

http://stackoverflow.com/q/22031542
has comment: http://stackoverflow.com/comment/33400027
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22033240
has comment: http://stackoverflow.com/comment/33400747
tagged with: swing
has title: Creating a leaderboard?
tagged with: algorithm
tagged with: java
type: Question
score: 0
answer count: 1
tagged with: user-interface
has comment: http://stackoverflow.com/comment/33402879
has comment: http://stackoverflow.com/comment/33403079
has body: I'm in the process of building an algorithm for a leaderboard for my game, but now I'm stuck. It is a two-player game. The leaderboard is supposed to display the top 5 players. Scores will be saved to an external .txt file as a reference. Also, may I add that I still cannot decide if I should only consider the winner's score for the leaderboard, or also the loser's. For example: Player 1 is Juliet. Player 2 is Romeo. At the end of the match, Juliet's score is greater than Romeo's. Should I only evaluate Juliet's score for the leaderboard, or both of their scores? As of now my algorithm considers only the winner's score. As of the moment I'm also only thinking of using JLabel to display the scores, but I'm not sure if this is the most efficient way to do it. I'm considering JTable. So here's my current algorithm: 1) When the user starts a new match/returns to menu/exits game: (I provided 4 options: new game (scores remain but the board is reset), new match (everything is reset), menu, and exit.) public class Game { //This class also holds the code for the operation of the game if (event.getSource() == newmatch)//or menu or exit { if (p1score != 0 || p2score != 0) { Leaderboard x; if (p1score &gt; p2score) { x = new Leaderboard (player1name, p1score); } else { x = new Leaderboard (player2name, p2score); } } else { //some code //This check is whether the game ends up in a draw/or both the users' scores are == 0 } } } 2) Save the name &amp; score in Leaderboard class: public class Leaderboard { //This class is where I originally planned to write the code that will perform the evaluation of the scores String playerid; int playerscore; public Leaderboard(String name, int score) { playerid = name; playerscore = score; } } 3) The next step which is I'm highly unsure of is to create an ArrayList for the scores (I'm missing the part about the player's name because well I'm not sure as well how I will approach it) and then sort it, but the problem after that would be how to ma…

http://stackoverflow.com/comment/33373061
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22013074
has text: No, it was just a spelling mistake in the question - the actual problem was having double quotes in the jstl as answered below. Thanks
score: 0

http://stackoverflow.com/comment/33443784
comment on: http://stackoverflow.com/q/22056112
type: Comment
type: QuestionComment
score: 6
has text: [Because Java is pass by value.](http://stackoverflow.com/questions/40480/is-java-pass-by-reference)

http://stackoverflow.com/q/22090890
tagged with: svn
tagged with: java
has title: netbeans loading svn error :
type: Question
has body: Netbeans SVN loading Error: Setting up SVN for NetBeans already took me lots of time, finally I got it the error you need to get a newer Subversion client, or to downgrade this working copy. See http://subversion.tigris.org/faq.html#working-copy-format-change We strongly recommend to either install a newer Subversion client or downgrade your working copy. Any local changes might corrupt your working copy and some file operations as copying, renaming and deleting will not work correctly.
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/33505663
has comment: http://stackoverflow.com/comment/33676842
tagged with: netbeans
answer count: 0
upvote count: 2
type: UnansweredQuestion
score: 2

http://stackoverflow.com/comment/33641128
type: Comment
has text: put configuration.xml file in filesystem.and write code to read and load the file.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22166319

http://stackoverflow.com/a/22156952
has body: you advance the cursor by calling usersIterator.next(). Possibly your flow of execution stops going into the IF loop, and the next() never gets called. that's why you get an infinite loop. Make sure you call usersIterator.next() for each iteration, or call break when the IF condition fails.
accepted answer of: http://stackoverflow.com/q/22156857
answers question: http://stackoverflow.com/q/22156857
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33624702
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/a/22097724
has comment: http://stackoverflow.com/comment/33524302
has comment: http://stackoverflow.com/comment/33520673
score: 0
answers question: http://stackoverflow.com/q/22097486
has body: You could try this code: HTML pretend this is an image click here to change manually jQuery: $(document).ready(function () { setInterval(function () { //change this to setInterval to make it constantly flip through rather than one time change(); }, 2400); }); var image = [ ["pretend this is an image", "link1.html"], ["and lets pretend this is another", "link2.html"], ["and one more for show", "link3.html"] ]; var index = 1; $(".bullet").click(function () { change(); }); function change() { if (index == 3) { index = 0; } $(".picture").fadeOut(1000, function () { $(".picture").html(image[index][0]); $(".picture").attr("href", image[index][1]); $(".picture").fadeIn(1000); index++; }); } Check your updated Fiddle.
type: Answer

http://stackoverflow.com/q/22010195
has body: I am working on a play application which allows client to upload large tar.gz files . i To give an example , user can use this curl command to upload a file name "testfile.tar.gz". curl -v -F "corpusFile=@testfile.tar.gz" -F "description=Large File Test" API_ENDPOINT When a user to try to upload a really large file like around 3GB . It always fails returning this error :- curl: (55) Send failure: Connection was aborted Also the exception which I see in play server logs :- java.nio.channels.ClosedChannelException at org.jboss.netty.channel.socket.nio.AbstractNioWorker.cleanUpWriteBuffer(AbstractNioWorker.java:409) at org.jboss.netty.channel.socket.nio.AbstractNioWorker.writeFromUserCode(AbstractNioWorker.java:127) at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleAcceptedSocket(NioServerSocketPipelineSink.java:99) at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:36) at org.jboss.netty.channel.Channels.write(Channels.java:725) at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.doEncode(OneToOneEncoder.java:71) at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:59) at com.typesafe.netty.http.pipelining.HttpPipeliningHandler.handleDownstream(HttpPipeliningHandler.java:87) at play.core.server.netty.PlayDefaultUpstreamHandler.sendDownstream(PlayDefaultUpstreamHandler.scala:428) at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$play$core$server$netty$PlayDefaultUpstreamHandler$$handle$1$6$$anonfun$13.apply(PlayDefaultUpstr eamHandler.scala:210) at I am using Play 2.2.1 version. I have tried setting max length size in application.conf and also setting request timeout but that does not seem to help . I added the following lines in my application.conf file :- #Max Length parsers.text.maxLength = 10024K #Request Timeout ws.timeout=1200000 If other people who faced similar issue or have idea what's going on here , that would be great help…
type: UnansweredQuestion
tagged with: netty
tagged with: curl
tagged with: playframework-2.0
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22023726
score: 0
answer count: 1
has title: Getting java.nio.channels.ClosedChannelException excetion in Play Application

http://stackoverflow.com/comment/33579395
type: Comment
has text: yes,to exist the loop we need to write break inside it
comment on: http://stackoverflow.com/a/22131017
score: 0
type: AnswerComment

http://stackoverflow.com/q/22073657
type: UnansweredQuestion
score: 0
has comment: http://stackoverflow.com/comment/33474605
tagged with: java
has body: The nums.indexOf keeps getting an error that states indexOf cannot be resolved or is not a field. Am I supposed to import something? I have already imported java.util.*; public static int search(int[] nums) { Scanner keyboard = new Scanner(System.in); System.out.println("What value do you want?"); int value = keyboard.nextInt(); for(int i = 0; i &lt; nums.length; i++) { if(nums.indexOf[i] == value) return value; else return "Value is not in the list"; } }
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/33474311
tagged with: arrays
has answer: http://stackoverflow.com/a/22073823
has title: indexOf cannot be resolved to a type when called on an array
has answer: http://stackoverflow.com/a/22073706

http://stackoverflow.com/comment/33545780
has text: @Peter Yes, it was the first thing I do. I did it before in Debian (and i think also Ubuntu) some months ago and it runs perfectly. But in Windows 8 (and XP), ever I run a jsp file, Eclipse returns me a error about Tomcat.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22112688

http://stackoverflow.com/q/22150567
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22153575
tagged with: swing
score: 0
tagged with: java
tagged with: treetablecelleditor
type: Question
tagged with: jtree
has body: I have a Java app that displays the users file system in a tree. I display the folder with a checkbox, icon and text. To do this I had to created a custom component for the tree cell. The component subclasses JLabel and contains JCheckBox and JLabel. I wrote my own renderer and editor to display and edit the component. When you click on the checkbox the first time it goes into edit mode but the code to turn off editing does not happen. All subsequent clicks on the checkbox work properly. I have done a lot of searching and cannot resolve this problem. Here is the code for my renderer and editor. The tree has been set to allow editing and the renderer and editor are set. class MyRenderer implements TreeCellRenderer { private CheckBoxPanel m_panel; public MyRenderer() { m_panel = new CheckBoxPanel(); } @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)value; MyState state = (MyState)node.getUserObject(); m_panel.setState(state); return m_panel; } } class MyEditor extends AbstractCellEditor implements TreeCellEditor { private CheckBoxPanel m_panel; private JCheckBox m_checkbox; private MyState m_state; public MyEditor() { m_panel = new CheckBoxPanel(); // m_panel.setColor(Color.red); } @Override public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) { DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)value; m_state = (MyState)treeNode.getUserObject(); m_panel.setState(m_state); m_checkbox = m_panel.getCheckBox(); m_checkbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { fireEditingStopped(); m_checkbox.removeItemListener(this); } }); return m_panel; } @Override public Object getCellEditorValue() { m_state.setSelected(m_checkbox.isSelected()); return m_state; } @Override public boole…
answer count: 1
has title: JTree custom Cell Editor for a custom component is not responding to first click

http://stackoverflow.com/a/22140510
has body: If your child class and Parent class in same package than you can access this object directly [If you wish], Otherwise you have two option. 1 - Create a public getter method in Parent class and access your protected field using that method 2 - Inside child class fetch the Parent protected field using reflection like given below public void callMethod(ParentClass o) { try { Field f = o.getClass().getDeclaredField("protVar"); f.setAccessible(true); Object value = f.get(o); } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } }
score: 0
answers question: http://stackoverflow.com/q/22139513
type: Answer

http://stackoverflow.com/comment/104849649
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/36024874
has text: why does no tutorial mention this?

http://stackoverflow.com/comment/33635365
comment on: http://stackoverflow.com/q/22163144
type: Comment
type: QuestionComment
score: 1
has text: Learn Java from basics & study the difference between static and non static methods.

http://stackoverflow.com/q/22006206
accepted answer: http://stackoverflow.com/a/22006368
has comment: http://stackoverflow.com/comment/33354509
has title: unable to extract contents from html using jsoup in java?
linked to: http://stackoverflow.com/q/22011133
downvote count: 0
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33354772
has body: I am trying to use jsoup to extract the contents from the below HTML code in the following &lt; td > tags which has class css-sched-table-title and css-sched-waypoints. But i am not able to understand whats going wrong can someone help ? Document doc = Jsoup.parse("somelink.html"); Elements row = doc.select(".css-sched-table-title td"); Iterator&lt;Element&gt; iterator = row.listIterator(); while(iterator.hasNext()) { Element element = iterator.next(); String value = element.text(); System.out.println("value : " + value); } . &lt;tr&gt; &lt;td ALIGN="CENTER" COLSPAN="16" CLASS="css-sched-table-title"&gt;&lt;b&gt;Saturday - &lt;/b&gt;&lt;b&gt;Afternoon&lt;/b&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr VALIGN="BOTTOM"&gt; &lt;TD&gt;&amp;nbsp;&lt;/TD&gt; &lt;TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints"&gt;Townline and Southern&lt;/TD&gt; &lt;TD&gt;&amp;nbsp;&lt;/TD&gt; &lt;TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints"&gt;Clearbrook and Blueridge&lt;/TD&gt; &lt;TD&gt;&amp;nbsp;&lt;/TD&gt; &lt;TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints"&gt;Clearbrook and South Fraser&lt;/TD&gt; &lt;TD&gt;&amp;nbsp;&lt;/TD&gt; &lt;TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints"&gt;Ar. Bourquin Exchange&lt;/TD&gt; &lt;TD&gt;&amp;nbsp;&lt;/TD&gt; &lt;TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints"&gt;Lv. Bourquin Exchange&lt;/TD&gt; &lt;TD&gt;&amp;nbsp;&lt;/TD&gt; &lt;TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints"&gt;Downtown Abbotsford&lt;/TD&gt; &lt;TD&gt;&amp;nbsp;&lt;/TD&gt; &lt;TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints"&gt;McMillan and Old Yale&lt;/TD&gt; &lt;TD&gt;&amp;nbsp;&lt;/TD&gt; &lt;TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints"&gt;Sandy Hill and Old Clayburn&lt;/TD&gt; &lt;/tr&gt;
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22006368
upvote count: 1
type: Question
score: 1
tagged with: java
linked to: http://stackoverflow.com/q/21694216
tagged with: jsoup

http://stackoverflow.com/a/22129511
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/22129488
upvote count: 3
answers question: http://stackoverflow.com/q/22129488
has body: You return the original string in its base64-encoded form: return Base64.getMimeEncoder().encodeToString(string.getBytes()); You'd want to use the cipher in there as well: return Base64.getMimeEncoder().encodeToString(cipher.doFinal(string.getBytes())); Independent of that, when depolying own crypto please be aware of the impacts of cipher modes, padding, etc. For example the ECB mode you're using will produce the same ciphertext from the same plaintext, e.g. the ciphertext might lead hints about the original text, as in the famous encrypted tux image: Image Copyright: All uses are permitted provided that Larry Ewing, the owner of the original image, who requires that you mention him, his email address, lewing@isc.tamu.edu, and The GIMP, according to http://www.isc.tamu.edu/~lewing/linux/. For more details on that, see Wikipedia's article about block cipher modes.
score: 3

http://stackoverflow.com/q/22023169
duplicate of: http://stackoverflow.com/q/3524150
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33384879
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/22023415
has comment: http://stackoverflow.com/comment/33385168
linked to: http://stackoverflow.com/q/3524150
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33384774
has body: I found that sometimes, if not always, static final fields will be inlined at the bytecode level. For some reason, I don't like this to happen. How do I switch this compile option off? Especially within Eclipse 4. (Without touching the source code.) Thanks
tagged with: java
has comment: http://stackoverflow.com/comment/33385036
type: Question
has title: Force Java compiler not to inline final static fields

http://stackoverflow.com/q/22150647
has comment: http://stackoverflow.com/comment/33613747
tagged with: java
has body: I am doing mutual information for 50 words for a big corpus. I need to count the concurrence for those target words and the neighbour words for each of them. There is an object array with size of 50, one for each word. I have a thread to read lines. When there is a new line comes in, I need to update the values of all those objects. I want to write in a multithread way. Should I use 50 threads, and each thread is responsible for one object in this array? If I use one thread for each object, should I use 50 queues to store the input lines, and one queue for each thread? I am thinking Producer-Consumer pattern, but it looks a little different where there is just one queue...
type: Question
has title: Should I use one thread to update the value of each object in an array
has answer: http://stackoverflow.com/a/22150901
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/33613075
type: UnansweredQuestion
tagged with: multithreading
has answer: http://stackoverflow.com/a/22150923
has comment: http://stackoverflow.com/comment/33612775

http://stackoverflow.com/q/22045587
favorite count: 0
tagged with: view
type: UnansweredQuestion
answer count: 0
has title: Android close TYPE_SYSTEM_ALERT, back to main_activity view
score: 1
tagged with: java
tagged with: ontouchlistener
upvote count: 1
type: Question
downvote count: 0
has body: i have a code where a system overlay opens, but how can i close it and send back to the main_activity view. I tried it with wm.removeView(myView); and also with myView.setVisibility(View.GONE);, but it is still visible, do i have to load the view of the main activity? Thanks for your help! here the main activity class: public class MainShakeDetector_2 extends Activity { Context myContext; InvisibleView myInvisibleView; View overlayView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_shake_detector_2); myInvisibleView = new InvisibleView(this); } // ------- --------- --------- --------- ---------- // ------- method to open the system layout view // ------- --------- --------- --------- ---------- public void startApp(View activity_main_shake_detector_2){ myContext = this.getApplicationContext(); myInvisibleView.onCreate(myContext); overlayView = new View(myContext); setContentView(R.layout.overlay); overlayView= (View) findViewById(R.id.overlayViewId); } @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_shake_detector_2, menu); return true; } } here the system over class public class InvisibleView extends Service { View myView; Activity parent; @Override public IBinder onBind(Intent intent) { return null; } public InvisibleView (Activity parent) { this.parent = parent; } public void onCreate(final Context myContext) { super.onCreate(); LayoutInflater inflater = (LayoutInflater) myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); myView = new View(myContext); myView = inflater.inflate(R.layout.overlay, null); WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT); final Window…
tagged with: android
tagged with: android-activity

http://stackoverflow.com/comment/33537567
comment on: http://stackoverflow.com/a/22107557
score: 0
type: AnswerComment
type: Comment
has text: Okay, only for me, the Viewport is a rectangle, which the user can see? So I don´t move the viewport, but the camera? The once problem is, i must create the objects at the game start? I develop with LibGDX

http://stackoverflow.com/q/22026736
tagged with: weblogic
has answer: http://stackoverflow.com/a/22027053
has title: OutOfMemoryError in Weblogic FileStore
accepted answer: http://stackoverflow.com/a/22040401
answer count: 2
tagged with: file-io
downvote count: 0
tagged with: jms
favorite count: 0
tagged with: out-of-memory
linked to: http://stackoverflow.com/q/14158606
type: AnsweredQuestion
score: 2
has answer: http://stackoverflow.com/a/22040401
upvote count: 2
has body: I'm trying to stress my Application into Weblogic11g and I'm sending it many JMS Message on the queues. But, the FileStore crashes with an OOE around 20K messages and a max size of 647,169 ko Exception in thread "Thread-13" java.lang.OutOfMemoryError: Java heap space at java.nio.HeapByteBuffer.&lt;init&gt;(HeapByteBuffer.java:39) at java.nio.ByteBuffer.allocate(ByteBuffer.java:312) at weblogic.store.io.file.StoreFile.expand(StoreFile.java:324) at weblogic.store.io.file.Heap.reserveSpace(Heap.java:305) at weblogic.store.io.file.Heap.multiWrite(Heap.java:438) at weblogic.store.io.file.FileStoreIO.flush(FileStoreIO.java:497) at weblogic.store.internal.PersistentStoreImpl.run(PersistentStoreImpl.java:638) at weblogic.store.internal.PersistentStoreImpl$2.run(PersistentStoreImpl.java:383) And a few line of the log file Feb 25, 2014 7:53:19 PM CET Warning JTA BEA-110484 The JTA health state has changed from HEALTH_OK to HEALTH_WARN with reason codes: Resource WLStore_MyFS_stores-Node1-file-jms declared unhealthy. Feb 25, 2014 7:53:19 PM CET Warning JTA BEA-110030 XA resource [WLStore_MyFS_stores-Node1-file-jms] has not responded in the last 120 second(s). Feb 25, 2014 7:53:19 PM CET Warning JTA BEA-110405 Resource WLStore_MyFS_stores-Node1-file-jms was not assigned to any of these servers: Node1 Feb 25, 2014 7:54:19 PM CET Warning JTA BEA-110486 Transaction BEA1-5DA4B1F8A57C83AEDB1B cannot complete commit processing because resource [WLStore_MyFS_stores-Node1-file-jms] is unavailable. The transaction will be abandoned after 3,420 seconds unless all resources acknowledge the commit decision. Is it possible to increase the size of this FileStore ?
tagged with: java
type: Question
possible better answer: http://stackoverflow.com/a/22027053

http://stackoverflow.com/comment/33586266
has text: The code will compile fine, but if you have no memory, it will throw an `OutOfMemoryError` at runtime.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22135163

http://stackoverflow.com/a/22086543
type: Answer
has body: Though it doesn't say it, HttpURLConnection is treated as an abstract base class (without actually being abstract). When you call URL#openConnection(), you actually get an instance of a compiler-specific class; for the Sun/Oracle compiler, it's sun.net.www.protocol.http.HttpURLConnection. You'll find that the implementation of getHeaderField in there makes more sense.
downvote count: 0
score: 3
accepted answer of: http://stackoverflow.com/q/22086295
upvote count: 3
answers question: http://stackoverflow.com/q/22086295
type: AcceptedAnswer

http://stackoverflow.com/q/22152907
has title: Php web application with java desktop application for a POS?
tagged with: java
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33617172
has body: I have to develop a POS software, I was going to develop it in php with mysql, but, I'm worried about what happens if we have internet problems, so, I was thinking on use a desktop java application for the store, with its own local data base, and daily update a remote data base; besides, I would have a php page to get information about sales, storage, etc, but I'm not sure if this is a good approach, or even if is possible. Should I keep going with this approach, or is best to do all in the same language?
answer count: 0
type: Question
tagged with: php
score: 0
tagged with: mysql
has comment: http://stackoverflow.com/comment/33617135
has comment: http://stackoverflow.com/comment/33621244

http://stackoverflow.com/q/22104161
has comment: http://stackoverflow.com/comment/33530806
has comment: http://stackoverflow.com/comment/33529772
has title: How do I display HTML as plain text in a JTree?
has comment: http://stackoverflow.com/comment/33530914
tagged with: swing
type: Question
tagged with: jtree
tagged with: java
score: 4
has body: Problem: The content of the leaf nodes of my tree is HTML, but I don't want them rendered as HTML. Many Swing components can include snippets of HTML in order to change how they are rendered. This includes the nodes of a JTree: DefaultMutableTreeNode myLeafNode = new DefaultMutableTreeNode(" Hello World "); If this node is added to the DefaultTreeModel, and the model to the JTree, it will render the content as HTML. How do I prevent this? How do I force it to be rendered as plain text? Edit: @David Wallace's answer (see below) works. Here's how it looks:
answer count: 1
downvote count: 0
favorite count: 0
tagged with: http://stackoverflow.com/tag/html
upvote count: 4
has answer: http://stackoverflow.com/a/22104723
accepted answer: http://stackoverflow.com/a/22104723
has comment: http://stackoverflow.com/comment/33531341
has comment: http://stackoverflow.com/comment/33529831
has comment: http://stackoverflow.com/comment/33529823
type: AnsweredQuestion

http://stackoverflow.com/comment/33583690
type: Comment
score: 0
type: AnswerComment
has text: that is not the problem, my problem is I don't know how to pass the parsed document to another class. Thanks anyway.
comment on: http://stackoverflow.com/a/22132757

http://stackoverflow.com/comment/33539864
type: AnswerComment
type: Comment
has text: It works great. I meant there is no isOkeyDokey() function. Thanks!!! (and my program is a hack job anyways, so a little more hacking is just par for the course)
comment on: http://stackoverflow.com/a/22109566
score: 0

http://stackoverflow.com/q/22107384
has title: setting an entity property using a form and controller
type: Question
score: 0
has comment: http://stackoverflow.com/comment/33536545
has comment: http://stackoverflow.com/comment/33536627
tagged with: spring
answer count: 1
tagged with: spring-mvc
has body: In a Spring MVC application using hibernate, I am encountering an error when the user tries to specify the location (entity is FacilityAddress) of an appointment (entity is Encounter) using a JSP. Specifically, the property Encounter.location needs to be set by the JSP. The list of possible locations is given to the user by a model attribute praddrs, which is correctly populated in the JSP form by the GET method in the controller. Can someone show me how to get this functionality to work properly without throwing an error? I can create the 400 error when I add the following line of code to my JSP: <form:select path="location" items="${praddrs}" size="3" style="min-width:200px"/> The 400 error states: The request sent by the client was syntactically incorrect. There is no stack trace in the eclipse console. I have read a number of other stack overflow postings on this, and have done google searches along with tinkering with my code, but I cannot seem to isolate the solution for my unique situation. Can someone show me how to get past this error? Here is the form in the JSP: <form:form modelAttribute="encounter" method="${method}" class="form-horizontal"> Patient <c:out value="${encounter.patient.firstName} ${encounter.patient.lastName}"/> Date and Time <joda:format value="${encounter.dateTime}" style="SM"/> Office <form:select path="location" items="${praddrs}" size="3" style="min-width:200px"/> <petclinic:inputField label="Duration (mins)" name="numMins"/> <c:choose> <c:when test="${encounter['new']}"> Add Encounter </c:when> <c:otherwise> Update Encounter Link to delete will go here. </c:otherwise> </c:choose> </form:form> Here is the controller method for handling the POST for this JSP: //THIS IS THE METHOD THAT HANDLES THE FORM @RequestMapping(value = "/patients/{patientId}/encounters/new", method = RequestMethod.POST) public String processCreationForm(@ModelAttribute("encounter") Encounter encounter, @RequestParam("providerId") int providerId, BindingResult resu…
tagged with: java
tagged with: hibernate
has comment: http://stackoverflow.com/comment/33536358
has comment: http://stackoverflow.com/comment/33536473
tagged with: jsp
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22133683

http://stackoverflow.com/comment/33636108
comment on: http://stackoverflow.com/q/22163197
type: Comment
type: QuestionComment
has text: Sorry this is the correct code.. earlier one was to check the format.. `DateFormat df = new SimpleDateFormat(Date_format_text.getText()); df.setLenient(false); Date d1 = df.parse(Lower_date_text.getText());` //in the above.. I am trying to parse the Text to date so wen its not in the specified format it will gv exception but it does work for one purpose as i mentioned in the ques `validator_LD.setVisible(false); } catch (ParseException p) { System.out.println("Wrong"); }`
score: 0

http://stackoverflow.com/a/22070032
accepted answer of: http://stackoverflow.com/q/22069923
type: AcceptedAnswer
downvote count: 1
has comment: http://stackoverflow.com/comment/33467762
answers question: http://stackoverflow.com/q/22069923
has body: Other than differences with synchronization, there is also a difference internally when you insert new elements. For both classes, the array within must be increased in size to prevent it from running out of room. Vectors double their size by default. ArrayLists increase their size by half their present size. Edit: Also, a couple answers mentioned that Vectors are thread safe. That's true to some extent, but the whole reason they're sort-of-deprecated (I think) is because they're not very useful for most synchronization needs, which is because it synchronizes on every operation (not safe). What you want to do usually is synchronize on a sequence of operations. Vectors don't do that (neither do ArrayLists though) so it's not really the way to go even in situations that require synchronization (basically it's out of your control).
type: Answer
score: 5
upvote count: 6

http://stackoverflow.com/comment/33619132
type: Comment
comment on: http://stackoverflow.com/a/22153200
type: AnswerComment
has text: javac: invalid flag: src.* Usage: javac <options> use -help for a list of possible options
score: 0

http://stackoverflow.com/comment/33638312
comment on: http://stackoverflow.com/a/22161193
has text: thank you and excuse me. I had a writing error. My issue is that `String result = path + file;` results in `/home/myuser/relativepath/nullfile.txt`. How can I fix it? I'll try to concatenate with File.Separator, checking variable initializations and full create and edit config file in Linux.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/22109643
has comment: http://stackoverflow.com/comment/33540103
downvote count: 0
has comment: http://stackoverflow.com/comment/33539966
upvote count: 2
type: Answer
score: 2
has body: You can create a ZipFile with just a path and then put each entry into a BufferedReader using the ZipInputStream like this: ZipFile zipFile = new ZipFile("file_path"); Enumeration&lt;? extends ZipEntry&gt; entries = zipFile.entries(); while(entries.hasMoreElements()) { ZipEntry zipEntry = entries.nextElement(); System.out.println(zipEntry.getName()); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(zipFile.getInputStream(zipEntry))); String line; while((line = bufferedReader.readLine()) != null){ System.out.println(line); } bufferedReader.close(); } zipFile.close(); } To get the file in res/raw you'll have to do something like this: getResources().getIdentifier("myfile","raw", getPackageName()); //for res/raw/myfile.zip
answers question: http://stackoverflow.com/q/22109375

http://stackoverflow.com/a/22129180
score: 1
has comment: http://stackoverflow.com/comment/33587295
has body: There are libraries you can you to cache the bitmaps. Have a look at these: Android-Universal-Image-Loader (Currently using this) Picasso (Just discovered this) As for loading the images has a circle, went with this library: RoundedImageView
answers question: http://stackoverflow.com/q/22121080
upvote count: 1
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/22121080

http://stackoverflow.com/a/22129946
has comment: http://stackoverflow.com/comment/33577329
upvote count: 3
type: Answer
has comment: http://stackoverflow.com/comment/33578916
accepted answer of: http://stackoverflow.com/q/22128150
answers question: http://stackoverflow.com/q/22128150
has comment: http://stackoverflow.com/comment/33583098
score: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/64436345
has body: Seems like Spring is not ready for cross context request processing (at least not without a bit of hacking). FrameworkServlet always tries to get WebAsyncManager from the request attributes. And the way it is extracted can not work across different contexts (class loaders). I see two possibilities how to workaround this: Implement your own include JSP tag, which will wrap the original request so that Spring specific attributes are not visible (usually the ones starting with org.springframework) to the second context. Put Spring JARs in a shared class loader path (that would be probably the easier way).
has comment: http://stackoverflow.com/comment/64402885
type: AcceptedAnswer

http://stackoverflow.com/comment/33405904
comment on: http://stackoverflow.com/q/22034046
score: 0
type: Comment
type: QuestionComment
has text: @ Qix Firstly it is not a duplicate question because I want to get thumbnail using JAVA not PHP and Secondly I know the difference between Java and Javascript I wrote Javascript here because I was thinking if somebody could tell me some API for this as we use API for google maps.If you can't help me it's alright but don't tell me that this question is useless.

http://stackoverflow.com/q/22096274
tagged with: serialization
type: Question
has title: Object Serialization to JSON (using Gson). How to set field names in UpperCamelCase?
upvote count: 34
has body: I need to serialize a list of simple Java objects to JSON using Google Gson library. The object: public class SimpleNode { private String imageIndex; private String text; public String getImageIndex() { return imageIndex; } public void setImageIndex(String imageIndex) { this.imageIndex = imageIndex; } public String getText() { return text; } public void setText(String text) { this.text = text; } } I have written the following code for serialization: List&lt;SimpleNode&gt; testNodes = repository.getElements(0); Gson gson = new Gson(); String jsonNodesAsString = gson.toJson(testNodes); It works, but the field name of the JSON objects is lowerCamelCase. Like this: [ { "imageIndex": "1", "text": "Text 1" }, { "imageIndex": "2", "text": "Text 2" } ] How do I get a JSON with UpperCamelCase field name, like this: [ { "ImageIndex": "1", "Text": "Text 1" }, { "ImageIndex": "2", "Text": "Text 2" } ] I think that I can rename member variables in to UpperCamelCase, but may be there is another way?
tagged with: java
tagged with: http://stackoverflow.com/tag/json
tagged with: gson
has answer: http://stackoverflow.com/a/22096369
score: 34
type: AnsweredQuestion
downvote count: 0
answer count: 1
accepted answer: http://stackoverflow.com/a/22096369
favorite count: 0

http://stackoverflow.com/comment/33545232
type: QuestionComment
comment on: http://stackoverflow.com/q/22103622
has text: Please read http://itextpdf.com/book/digitalsignatures to find out how to sign a PDF document using a smart card. As the two comments already indicated: you don't sign a document with a public key certificate! If that were possible, you'd have a serious security problem.
score: 0
type: Comment

http://stackoverflow.com/comment/33403944
type: AnswerComment
score: 0
type: Comment
has text: I'd love to accept your answer but the way it's right now it returns a `Map<String, Player>` rather than `List<Map<String,Object>>`.. and the key to that map is `this`, lol.
comment on: http://stackoverflow.com/a/22016359

http://stackoverflow.com/comment/33442588
type: AnswerComment
has text: yeah, I'm getting true and false for empty and non-empty returns. still the texts are getting printed in both the cases simultaneously!
type: Comment
score: 0
comment on: http://stackoverflow.com/a/22055157

http://stackoverflow.com/comment/33560699
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22121210
has text: @chrylis Yeah, agreed. Only thing you can do is downvote appropriately (RTFM falls under "research effort" IMHO) and move on these days. It's a shame, really.

http://stackoverflow.com/comment/33593707
comment on: http://stackoverflow.com/a/22139691
score: 1
has text: oh so this is exactly like linked lists, an object pointing to same memory? Explains everything!
type: AnswerComment
type: Comment

http://stackoverflow.com/a/29024290
answers question: http://stackoverflow.com/q/22042278
score: 0
has body: This PHP library has an option to send via notification key: https://github.com/CoreProc/gcm-php $gcmClient = new GcmClient('your-gcm-api-key-here'); $message = new Message($gcmClient); $message-&gt;setNotificationKey('xxxxxxxxxx'); $message-&gt;setData([ 'title' =&gt; 'Sample Push Notification', 'message' =&gt; 'This is a test push notification using Google Cloud Messaging' ]); $message-&gt;send()
type: Answer

http://stackoverflow.com/comment/33626426
has text: I've read this three times now. You don't seem to actually ask a question.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22156913
score: 0

http://stackoverflow.com/comment/33578560
has text: I know - hence the inquiry. Can a java program ensure that only a user with administrator privileges of the end users network can utilize a specific delete() method within a program
comment on: http://stackoverflow.com/q/22130692
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22156066
answer count: 2
has comment: http://stackoverflow.com/comment/33640155
tagged with: bufferedreader
has answer: http://stackoverflow.com/a/22156350
has comment: http://stackoverflow.com/comment/33623029
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22156354
tagged with: text
has comment: http://stackoverflow.com/comment/33623087
score: 0
tagged with: java
has title: Writing something to a text file at a specific point Java
tagged with: file
type: Question
tagged with: bufferedwriter
has body: So I want to write a String at a specific point in a text file. Should be quite easy but this is my first time using the BufferedWriter class. My source is as follows: public static String readFile(String fileName) throws IOException { String toReturn = ""; BufferedReader br = null; try { String sCurrentLine; br = new BufferedReader(new FileReader("test.txt")); while ((sCurrentLine = br.readLine()) != null) { toReturn = toReturn+"\n"+sCurrentLine; } } catch (IOException e) { e.printStackTrace(); } finally { try { if (br != null)br.close(); } catch (IOException ex) { ex.printStackTrace(); } } return toReturn; } public static void addAfter(String toAdd, char after, String fileName) throws IOException { String file = readFile(fileName); int length = file.length(); char[] chr = file.toCharArray(); boolean pos[] = new boolean[length]; for(int i = 0; i &lt; length; i++) { if(chr[i] == after) { pos[i] = true; } } BufferedWriter out = new BufferedWriter(new FileWriter(fileName, true)); } I would like to add the String toAdd at position i using the BufferedWriter class. How would I go about jumping to the desired point and writing toAdd? Thanks in advance
linked to: http://stackoverflow.com/q/3935791

http://stackoverflow.com/comment/33621433
score: 1
has text: have you considered chaining item processors? http://docs.spring.io/spring-batch/reference/html/readersAndWriters.html#chainingItemProcessors
comment on: http://stackoverflow.com/q/22153726
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/33673012
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22156394
has text: Thank you, using -XX:-UseSplitVerifier helped me.
score: 0

http://stackoverflow.com/comment/33489915
has text: _"the test fails when the element is not there"_ I may be out of my Selenium practice for a while. With what exception does it fail? If the element is present, but not visible, you have to catch [a different exception](http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/ElementNotVisibleException.html) or actually use the value of `elementstatus`...
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22081270
type: Comment

http://stackoverflow.com/comment/33605227
comment on: http://stackoverflow.com/a/22146611
score: 0
type: Comment
type: AnswerComment
has text: @assylias That's what I know too.

http://stackoverflow.com/a/22167532
has comment: http://stackoverflow.com/comment/33644553
accepted answer of: http://stackoverflow.com/q/22167341
upvote count: 2
answers question: http://stackoverflow.com/q/22167341
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33643911
has comment: http://stackoverflow.com/comment/33643142
type: Answer
has comment: http://stackoverflow.com/comment/33645174
has body: Here : JSONObject json_data = jArray.getJSONObject(i); when i==-1 then getJSONObject return null because not object available at index -1 in JSONArray.so change iteration condition as: for(int i=0;i&lt;jArray.length();i++){ Object obj = jArray.get(i); if (obj instanceof JSONObject) { // is JSONObject JSONObject json_data = (JSONObject)obj; }else{ //String.... } }
has comment: http://stackoverflow.com/comment/33643424
score: 2

http://stackoverflow.com/q/22045514
tagged with: eclipse
tagged with: servlets
accepted answer: http://stackoverflow.com/a/22045754
type: AnsweredQuestion
downvote count: 0
score: 1
favorite count: 0
type: Question
has title: Is the version of the Dynamic Web Module facet the same as the servlet version?
has answer: http://stackoverflow.com/a/22045754
tagged with: java
upvote count: 1
tagged with: gradle
answer count: 1
has body: We are setting the version of the jst.web facet using Gradle as such: eclipse { wtp{ facet { facet name: 'java', version: '1.7' facet name: 'jst.web', version: '2.5' } } } My question is about the version number '2.5'. Does this version number reflect the version of the Servlet API supported by the project or is it the version of the facet itself? What I want to do is pull the versions into variables like so: eclipse { wtp{ facet { facet name: 'java', version: javaVersion facet name: 'jst.web', version: servletVersion } } } But I'm not sure if servletVersion is an accurate name (it would also be used to specify the providedCompile version of the servlet API). Is it possible that the version of the facet is different from the version of the Servlet API used by the project?

http://stackoverflow.com/comment/33606796
type: Comment
type: QuestionComment
has text: The purpose for me was to make one class... It's not a problem, it's just not for my purposes.
comment on: http://stackoverflow.com/q/22146798
score: 0

http://stackoverflow.com/a/22010728
upvote count: 6
accepted answer of: http://stackoverflow.com/q/22010727
answers question: http://stackoverflow.com/q/22010727
type: AcceptedAnswer
score: 6
type: Answer
downvote count: 0
has body: Try not to use same names of built-in classes! Since you're using the same name of the class java.lang.Integer, you're hiding the built-in class with your own. So, if you're accessing an Integer in your example, you're accessing your own class that is not the built-in java.lang.Integer class of the JDK. The first and the second error occur, because your class is not compatible with a real java.lang.Integer. The third error occurs, because you don't have a constructor in your Integer class that accepts an int as parameter. So the easiest way to get rid of the errors is just by naming your class different. For example, name it IntegerTest or something that fits your intention. Consider the following example of a really bad practice of using the name Integer in different cases: package Integer; class Integer { public static void main(String[] lnteger) { System.out.println(Integer(new Integer(42)).Integer); } java.lang.Integer Integer; Integer(java.lang.Integer Integer) { this.Integer = Integer; } static Integer Integer(Integer lnteger) { Integer Integer; Integer: for (Integer = lnteger; Integer.Integer &lt; Integer.new lnteger(lnteger).Integer.Integer; Integer.Integer++) { Integer(new Integer(--lnteger.Integer)); continue Integer; } return lnteger; } class lnteger { Integer Integer; lnteger(Integer Integer) { this.Integer = Integer; } } } Unfortunately, this compiles. You're not really able to distinguish between the different kinds of Integer. Without an IDE you're lost. With an IDE you're probably lost, too. Even the formatter from SO can not display this in a good manner since Integer is a package name, class name, member name, parameter name, method name, and label name. So give all things a meaningful (and at best unique) name to avoid such confusion.

http://stackoverflow.com/comment/33483068
has text: The key for your map would be your entry (of type Integer in your case) and the value could be anything (a dummy placeholder, say null) should do it. You could also use a HashSet - does not require values and just your entries would do it. Keep in mind that in the case of a set, duplicates would be eliminated and if you need to preserve them, then go with TreeMap.
comment on: http://stackoverflow.com/a/22075804
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/22163326
tagged with: fonts
tagged with: java
type: Question
has body: I have the following code: headerLabel.setText("TEST APPLICATION DATA"); // headerLabel.setFont(new Font("",Font.ITALIC,25)); headerLabel.setFont(new Font("Century Schoolbook L",Font.BOLD,22)); THe font that is required is Century SchoolBook and I want the first letter of each word to be bigger in size than other letters of the word. All letters in capitals but first letter of each word should have bigger size than other letters . How should I apply this?
has answer: http://stackoverflow.com/a/22163359
accepted answer: http://stackoverflow.com/a/22163359
has comment: http://stackoverflow.com/comment/33635683
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/33635704
has title: Apply small caps to a text in java swing
tagged with: swing
type: AnsweredQuestion

http://stackoverflow.com/q/22101145
type: UnansweredQuestion
score: 1
type: Question
has title: What is a proper update() method for my GUI (JAVA)
favorite count: 0
upvote count: 1
has body: Im displaying a 8x8 grid of pictures for a new game and these pictures are places randomly using a two dimensional array and math.random() There is also a "new game" button I want the user to be able to refresh the page without opening a new GUI and re displaying the grid aswell. This is my method for displaying the grid for (int r = 0; r &lt; ShinyButtons.ROWS; r++){ for (int c = 0; c &lt; ShinyButtons.ROWS; c++) { newbuttonTable[r][c] = new JButton(icons[(int) (Math.random()*7)]); newbuttonTable[r][c].setLocation(10+c*69, 10+r*69); newbuttonTable[r][c].setSize(69, 69); add(newbuttonTable[r][c]); }
answer count: 1
linked to: http://stackoverflow.com/q/21459718
tagged with: java
has answer: http://stackoverflow.com/a/22101482
has comment: http://stackoverflow.com/comment/33524070
tagged with: user-interface
downvote count: 0

http://stackoverflow.com/comment/33385427
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22020500
has text: I didn't get any errors. After a certain number of queries, the front end simply doesn't connect to the database.
score: 0

http://stackoverflow.com/q/22008588
has title: How to refer to list view in Action Bar Android
has body: I followed a tutorial and learned how to display a custom list right in the Action Bar. The problem is that now I want to highlight (or select) a specific item in list programatically for example when user quits the app the app should take a note what was the last item the user has selected in the list (I can do that using shared preferences) and then when user opens my app again the list view should restore itself back to the last selected item. I don't know how to select a item programatically in a custom list view. Maybe I have to reffer it first. But I don't know that also. Here's my code : bus_names.xml : &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:yourapp="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="5dp" &gt; &lt;ImageView android:id="@+id/busIcon" android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center_vertical" android:layout_marginRight="5dp" android:src="@drawable/ic_launcher" /&gt; &lt;TextView android:id="@+id/busTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:text="Alaknanda" android:textColor="@color/white" android:textSize="18sp" android:textStyle="bold" /&gt; &lt;/LinearLayout&gt; SpinnerNavItem.java : package com.hpubts50.hpubustracker.model; public class SpinnerNavItem { private String title; private int icon; public SpinnerNavItem(String title, int icon){ this.title = title; this.icon = icon; } public String getTitle(){ return this.title; } public int getIcon(){ return this.icon; } } BusNavigation.java : package com.hpubts50.hpubustracker.adapter; import java.util.ArrayList; import android.content.Context; import android.support.v7.app.ActionBarActivity; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup;…
type: UnansweredQuestion
tagged with: android
tagged with: android-actionbar
has answer: http://stackoverflow.com/a/22008655
tagged with: java
type: Question
score: 0
tagged with: android-listview
answer count: 1

http://stackoverflow.com/comment/33549720
has text: You just did it :-) I added a sentence in the first paragraph. Thanks.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/22115303
type: Comment

http://stackoverflow.com/comment/33467374
comment on: http://stackoverflow.com/q/22067856
has text: what error message are you getting? Are you getting any result by printing first window and second window.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22017250
answers question: http://stackoverflow.com/q/22015013
downvote count: 0
has comment: http://stackoverflow.com/comment/33408980
type: Answer
score: 1
upvote count: 1
has body: Let me give you my thoughts. What i need to is a way to return this particular subset of the data on the API level, apparently spring data JPA doesn't allow returning a dynamic subset of the table. This is not correct, JPA allow to retrieve some part of the entity, is not required to return the complete entity when you select specific columns in the query of @Query method as you are using jpql or native query you should only return a part of the entity and spring data automatically will return List, read more here Now to manage the access to the methods I suggest implement something with Spring Security, it allow to annotate some methods with @PreAuthorize @PreAuthorize("hasRole('ROLE_USER')") public void create(Contact contact); which means that access will only be allowed for users with the role "ROLE_USER". So it will restrict the execution depending on the role, so my suggestion is restrict the access based in the role and have several spring jpa methods to retrieve only the subset of columns according to the role. Another option is just create the dynamic jpql and executing directly in the entityManager, it will give you the possibility to map using @SqlResultMapping to obtain directly entities not a list of objects.

http://stackoverflow.com/comment/33627194
comment on: http://stackoverflow.com/q/22156913
score: 0
has text: I have 2 questions at the very bottom.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33366732
has text: Go through the linked tutorial. You need to add ListView in the xml layout file or you can programatically create the ListView.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22013128
type: Comment

http://stackoverflow.com/comment/33561801
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22120876
type: Comment
has text: thanks, but if the employee returned by getReference is uninitialized, it may be not existant at all correct ? I mean the entity manager can return an employee that does not exist ?

http://stackoverflow.com/q/22047654
has body: So i'm trying to zoom in and out of a sphere drawn at (0,0,0) with radius of 0.6, except once i reach Z of about -1.6, it and the axis i draw for orientation have vanished and i'm not sure why. Here's my code for translation : glMatrixMode(GL_PROJECTION); glLoadIdentity(); glRotatef(rotX,1.0f,0.0f,0.0f); glRotatef(-rotY,0.0f,1.0f,0.0f); help2.setText("xShift : " +xShift+ " yShift : " +yShift+ " zShift : " + zShift); glTranslatef(xShift,yShift,zShift);` Here it is for drawing : static Sphere temp = new Sphere(); temp.draw(0.6f, 100, 100); And here is my pre-gl setup stuff : glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(50f, 1.0f, 0.01f, 1000f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_DEPTH_TEST); glEnable(GL_LINE_SMOOTH); glShadeModel(GL_SMOOTH);
has comment: http://stackoverflow.com/comment/33430693
has comment: http://stackoverflow.com/comment/33430375
has comment: http://stackoverflow.com/comment/33430350
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22052707
has comment: http://stackoverflow.com/comment/33434620
has comment: http://stackoverflow.com/comment/33430400
has comment: http://stackoverflow.com/comment/33431565
tagged with: opengl
tagged with: java
tagged with: lwjgl
type: Question
has comment: http://stackoverflow.com/comment/33429660
has comment: http://stackoverflow.com/comment/33430441
has title: Strange perspective issue in OpenGL
score: 0
has comment: http://stackoverflow.com/comment/33429539
answer count: 1
has comment: http://stackoverflow.com/comment/33430991

http://stackoverflow.com/comment/33500904
has text: I have never used `WebAppAccess` before, only addressed your problem which have nothing to do with this specific class. Check the documentation how to get a `WebAppAccess` instance..
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/22087956

http://stackoverflow.com/comment/33424936
type: Comment
has text: I wrote: ArrayStack tempStack = new ArrayStack<String>(); That should be it. Thanks!
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22045760

http://stackoverflow.com/comment/33583437
has text: General noobishness and confusion with my thread about the checkbox. I threw out the checkbox but I kept thinking I would need Multithreading...
score: 0
comment on: http://stackoverflow.com/q/22133356
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/40610516
type: AnswerComment
has text: Links to personal blogs don't really belong in an answer. Instead, why don't you put that in your personal profile? Your response has been flagged for deletion because of that link.
type: Comment
comment on: http://stackoverflow.com/a/25937648
score: 0

parsing
tags question: http://stackoverflow.com/q/22016489
tags question: http://stackoverflow.com/q/22020635
tags question: http://stackoverflow.com/q/22134842
tags question: http://stackoverflow.com/q/22054403
tags question: http://stackoverflow.com/q/22119981
tags question: http://stackoverflow.com/q/22073870
tags question: http://stackoverflow.com/q/22119137
tags question: http://stackoverflow.com/q/22012602
tag name: parsing
tags question: http://stackoverflow.com/q/22099845
tags question: http://stackoverflow.com/q/22119983
tags question: http://stackoverflow.com/q/22073535
tags question: http://stackoverflow.com/q/22078564
tags question: http://stackoverflow.com/q/22087273
tags question: http://stackoverflow.com/q/22077485
tags question: http://stackoverflow.com/q/22072714
type: Tag
tags question: http://stackoverflow.com/q/22033117
tags question: http://stackoverflow.com/q/22005369
tags question: http://stackoverflow.com/q/22118782
tags question: http://stackoverflow.com/q/22062056
tags question: http://stackoverflow.com/q/22080452
tags question: http://stackoverflow.com/q/22056799
tags question: http://stackoverflow.com/q/22085954
tags question: http://stackoverflow.com/q/22024929
tags question: http://stackoverflow.com/q/22060560
tags question: http://stackoverflow.com/q/22047468
tags question: http://stackoverflow.com/q/22042109
tags question: http://stackoverflow.com/q/22080527
tags question: http://stackoverflow.com/q/22047162
tags question: http://stackoverflow.com/q/22078472
tags question: http://stackoverflow.com/q/22128107
tags question: http://stackoverflow.com/q/22095766
tags question: http://stackoverflow.com/q/22152073
tags question: http://stackoverflow.com/q/22079805
tags question: http://stackoverflow.com/q/22132042

http://stackoverflow.com/q/22046832
accepted answer: http://stackoverflow.com/a/22047191
type: Question
answer count: 1
downvote count: 0
favorite count: 0
tagged with: timer
has answer: http://stackoverflow.com/a/22047191
upvote count: 1
has title: How do I make a java action perform smoother?
tagged with: graphics
tagged with: refresh
type: AnsweredQuestion
has body: I have created a simple program that fills a meter by how many times you press a button, eventually resulting into a "Mash the button to win" style game. I have it set up where every time the spacebar is pressed, the meter fills by 10/440, and if you reach the maximum, 440, you win. The issue I am having is how to make the increments added smoother, and less abrupt; as if you are pumping a bike tire up: continuous, less incrememntal. Here is the problematic code: import javax.swing.JOptionPane; import javax.swing.*; import java.util.*; import static java.lang.System.*; import static java.lang.Math.*; import java.awt.*; import java.awt.event.*; import java.io.*; //for files public class MyClicker { public static void main(String args[]) { new Clicker(); //Make a window } } class Clicker extends Frame implements KeyListener, MouseListener { // global variables private final static int SCHEIGHT=768,SCWIDTH=1024; // direction constants final static int N = 0,NE = 1,E = 2,SE = 3, S = 4, SW = 5, W = 6, NW =7,STILL = 8; // movement change constants final int X = 0,Y = 1,Z = 2; final int TITLE = 30, STATUS = 40; final static int size = 2; Image myPic; private boolean gameNotOver = true; private boolean keyPressed = false; private Image myScreen; private int whichScreen; private int timePassed; private int numScreen; private int maxAmt=450; private int timer; private int amt; public Clicker() { setSize(SCWIDTH,SCHEIGHT); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); timer = -1; this.setVisible(true); out.println(amt); this.addKeyListener(this); gameLoop(); } public void gameLoop() { do { if (keyPressed) { amt = amt + 50; out.println(keyPressed + " " +gameNotOver+" "+ "Time "+timer); this.repaint(); keyPressed = false; } if(amt &gt;= 400) gameNotOver = false; pause(1000); timer++; this.setVisible(true); //this.repaint(); pause(0); if(amt &gt; maxAmt - 10) amt = maxAmt - 10; } while (gameNotOver); if(!gameNotOver) { pa…
score: 1
tagged with: java

http://stackoverflow.com/comment/33360195
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22009283
has text: The book goes kinda backwards from this assignment letting the interface have code and the class just send in information to the code and return some value. In this assignment its backwards and this is where im stuck. From my understanding the MyMath uses T as an object and I'm not sure how to .. Dont know how to put it but link the interface to my class.
type: AnswerComment

http://stackoverflow.com/comment/33419726
type: AnswerComment
type: Comment
has text: And you still got the same exception ?
comment on: http://stackoverflow.com/a/22042285
score: 0

http://stackoverflow.com/comment/33537156
score: 0
type: AnswerComment
has text: It seems like the `apply-templates` part isn't working quite right. It indents, but doesn't put the tags.
comment on: http://stackoverflow.com/a/22035977
type: Comment

http://stackoverflow.com/a/22134613
type: Answer
has comment: http://stackoverflow.com/comment/33586304
score: 5
has comment: http://stackoverflow.com/comment/33585934
upvote count: 5
has comment: http://stackoverflow.com/comment/33585794
has body: You should write a class that implements Comparator&lt;String&gt; for this. A quick approach using anonymous class: String a = s.min(list, new Comparator&lt;String&gt;() { @Override public int compare(String s1, String s2) { return s1.compareTo(s2); } }); Since you need to compare based on String length, just change the comparison logic in the compare method: String a = s.min(list, new Comparator&lt;String&gt;() { @Override public int compare(String s1, String s2) { return (s1.length() &gt; s2.length()) ? 1 : (s1.length() &lt; s2.length()) ? -1 : 0; } }); If you happen to use Java 7, then use Integer#compare: String a = s.min(list, new Comparator&lt;String&gt;() { @Override public int compare(String s1, String s2) { return Integer.compare(s1.length(), s2.length()); } }); If you use Java 8, you can use a lambda expression: String a = s.min(list, (s1, s2) -&gt; Integer.compare(s1.length(), s2.length()));
has comment: http://stackoverflow.com/comment/33586329
accepted answer of: http://stackoverflow.com/q/22134406
has comment: http://stackoverflow.com/comment/33585902
has comment: http://stackoverflow.com/comment/33585646
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/22134406
has comment: http://stackoverflow.com/comment/33585795
has comment: http://stackoverflow.com/comment/33585407

http://stackoverflow.com/a/22084748
type: Answer
answers question: http://stackoverflow.com/q/22083964
accepted answer of: http://stackoverflow.com/q/22083964
type: AcceptedAnswer
has body: Take a look at Hibernate Filters. @FilterDef(name="activeOnly") @Filter(name="activeOnly", condition= "archived &lt;&gt; 1") // assumes that all tables have a numeric column "archived" // as you can notice, this is a filter at the SQL Level // (not at the Entity level) @MappedSuperclass public class AbstractEntity // .... I've never used Spring Data, but the Adding custom behavior to all repositories section of the official documentation lead me to belieave that it is quite easy to obtain an injected EntityManager and customize its behaviour. Just unwrap it and enable the filter. Session session = entityManager.unwrap(Session.class); session.enableFilter("activeOnly"); If you want the filter to be applied for all subclasses of the @MappedSuperclass use a recent version of Hibernate. Only version 3.5 and greater (see HHH-4332) supports this behaviour. Also, there is one gotcha, you may need to repeat the filter on associations (See Hibernate Filters on related table with MappedSuperClass). If you want to customize the delete operations as well, use @SQLDelete to mark archived = 1 (see Soft deletes using Hibernate annotations). But to the best of my knowledge this only works on mapped entities (nothing can be done at the @MappedSuperclass level)
score: 0

http://stackoverflow.com/q/22033266
has body: So, after reading numerous questions on this, I am still stuck here, here's what I want to do: Change the color of the shape (id="myShape") from Java. Picking ClipDrawable, and calling setColorFilter(color) does not help. Picking GradientDrawable doesn't help either. There are 3 colors that this progress bar can have. Currently I have made 3 xmls, 1 corresponding to each color, and I load that depending on my condition. I have referred here, but he did not Clip the progress bar, thats the extra thing that I am doing. The problem is, the color values in the xml are dynamic, and I get it from the server, so those three xmls are not of much use, until I can change the color from java. There is a possible solution in level-lists, but I am not very keen in going in that direction, it will be a lot of rework &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;item android:id="@+id/progress_front"&gt; &lt;clip android:clipOrientation="horizontal" &gt; &lt;shape android:shape="rectangle" android:id="myShape"&gt; &lt;corners android:bottomLeftRadius="360dp" android:topLeftRadius="360dp" android:bottomRightRadius="360dp" android:topRightRadius="360dp" /&gt; **&lt;solid android:color="@color/bigfoodie_text" /&gt;** &lt;/shape&gt; &lt;/clip&gt; &lt;/item&gt; &lt;/layer-list&gt; Any help is appreciated.
tagged with: layout
downvote count: 0
linked to: http://stackoverflow.com/q/20705992
favorite count: 0
tagged with: android
has title: Change color of GradientDrawable in a Layer List programatically
answer count: 0
type: UnansweredQuestion
tagged with: drawable
upvote count: 1
score: 1
tagged with: java
type: Question

http://stackoverflow.com/q/22072506
has answer: http://stackoverflow.com/a/22076126
has body: I am working the Apache Cloudstack API. I am generally working with the org.apache.commons.codec.binary.Base64 base64 encoder. In generating the command I use the following code (from the example given): private String generateUrl(String commands) throws Exception { //Signature: This is the hashed signature of the Base URL that is generated using a combination of the user’s Secret Key and the HMAC SHA-1 hashing algorithm. /* 1. For each field-value pair (as separated by a '&') in the Command String, URL encode each value so that it can be safely sent via HTTP GET. 2. Lower case the entire Command String and sort it alphabetically via the field for each field-value pair. The result of this step would look like the following. 3. Take the sorted Command String and run it through the HMAC SHA-1 hashing algorithm (most programming languages offer a utility method to do this) with the user’s Secret Key. Base64 encode the resulting byte array in UTF-8 so that it can be safely transmitted via HTTP. The final string produced after Base64 encoding should be "Lxx1DM40AjcXU%2FcaiK8RAP0O1hU%3D". By reconstructing the final URL in the format Base URL+API Path+Command String+Signature, the final URL should look like: */ commands += "&id=" + apiReferenceId; commands += "&response=json"; // Step 1: Make sure your APIKey is toLowerCased and URL encoded String encodedApiKey = URLEncoder.encode(apiKey.toLowerCase(), "UTF-8"); // Step 2: toLowerCase all the parameters, URL encode each parameter value, and the sort the parameters in alphabetical order // Please note that if any parameters with a '&' as a value will cause this test client to fail since we are using '&' to delimit // the string List<String> sortedParams = new ArrayList<String>(); sortedParams.add("apikey="+encodedApiKey); StringTokenizer st = new StringTokenizer(commands, "&"); while (st.hasMoreTokens()) { String paramValue = st.nextToken().toLowerCase(); String param = paramValue.substring(0, paramValue.indexOf("=")); Str…
score: 0
tagged with: java
type: Question
tagged with: base64
has title: Different version of Base64 and Apache Cloudstack
tagged with: api
answer count: 1
type: UnansweredQuestion
tagged with: apache-cloudstack

http://stackoverflow.com/comment/33449392
score: 0
has text: What does `System.out.println(numbers.getClass());` output?
type: Comment
comment on: http://stackoverflow.com/q/22059271
type: QuestionComment

http://stackoverflow.com/a/22101474
score: 2
upvote count: 2
has body: Usualy, you will have a public class with your main method. It seems that you are compiling your class and you are not able to execute it. Do this to solve your problem: 1 - Create a file with your class name, example "MyClass.java" 2 - Your class declaration needs to be public: public class MyClass { // your code here } 3 - Place your main method inside the created class: public class MyClass { public static void main( String[] args ) { // your code here } } 4 - Compile it (javac MyClass.java) 5 - Execute it: java MyClass Your code seems to have some problems too. If you want to cast some primitive or reference type, you need to put the desired type inside parenthesis. Something like: // a char char c = 'a'; // casting that char to an integer int i = (int) c; Let me know if it worked.
answers question: http://stackoverflow.com/q/22101359
type: Answer
downvote count: 0

http://stackoverflow.com/comment/33534338
comment on: http://stackoverflow.com/q/22106329
score: 2
has text: It'd help to mention which GUI framework you're using (e.g. Swing, SWT, etc.), but most GUI frameworks provide a way to fire a custom event from non-UI threads whose handler should run on the UI thread.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33544463
type: Comment
has text: I am sorry i should of known, apologies I have hopefully edited it properly now.
score: 0
comment on: http://stackoverflow.com/q/22112212
type: QuestionComment

http://stackoverflow.com/comment/33500031
type: QuestionComment
type: Comment
has text: I don't think this is possible. It would ruin the use of `setEnabled(false)`
comment on: http://stackoverflow.com/q/22087617
score: 0

http://stackoverflow.com/a/22149877
score: 1
upvote count: 1
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22149006
has body: A simple example of what is happening you: package snippet; public class MainExample { public static void main(String[] args) throws Exception { MainExample s = null; //A variable containing null MainExample[] ss = {s}; //An array containing, the object referenced by your variable, errr... null s = new MainExample(); //The varible references a new object System.out.println(ss[0]); //The array still contains null } } To avoid this issue, you can make these changes: package snippet; public class MainExample { public static void main(String[] args) throws Exception { MainExample s = null; MainExample[] ss = null; s = new MainExample(); ss = new MainExample[]{s}; System.out.println(ss[0]); } } Hope it helps.
type: Answer
answers question: http://stackoverflow.com/q/22149006
has comment: http://stackoverflow.com/comment/33611421

http://stackoverflow.com/q/22039675
type: Question
has answer: http://stackoverflow.com/a/22039838
has answer: http://stackoverflow.com/a/22039820
tagged with: grouping
has title: Grouping classes with an interface in Java
accepted answer: http://stackoverflow.com/a/22039838
favorite count: 0
has answer: http://stackoverflow.com/a/22039825
tagged with: interface
has answer: http://stackoverflow.com/a/22039858
possible better answer: http://stackoverflow.com/a/22039825
answer count: 4
type: AnsweredQuestion
score: 2
tagged with: oop
upvote count: 3
tagged with: java
has comment: http://stackoverflow.com/comment/33413760
has body: I have 40 classes of tags that extend from 4 super classes. I would like to categorize each of these 40 classes to either a technical tag or a user tag. I am only interested in technical tags. Would it be good design to make an interface TechnicalTag that has no methods inside it and implement it in say each of that class that I want to be a technical tag so that I can use instanceOf to pick them? The reason I do not want a method isTechnicalTag that returns a boolean is because that would mean I will have to implement them in all the 40 classes. And the technical tag for now is perhaps only 4 of them. Kindly advise me. OOP is not exactly what I am trained on.
downvote count: 1

response
tags question: http://stackoverflow.com/q/22099945
tags question: http://stackoverflow.com/q/22053689
tag name: response
type: Tag

http://stackoverflow.com/a/22108879
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/33538644
score: 1
upvote count: 1
accepted answer of: http://stackoverflow.com/q/22108865
has comment: http://stackoverflow.com/comment/33538633
has body: You can pass an ArrayList the same way as you pass any other object and you access individual fields through ${list[i]}. You can find more on el language syntax in this tutorial.
answers question: http://stackoverflow.com/q/22108865
type: AcceptedAnswer

http://stackoverflow.com/comment/40103119
comment on: http://stackoverflow.com/a/25380114
type: Comment
has text: @M.Deinum only shorter
score: 1
type: AnswerComment

http://stackoverflow.com/comment/33417986
comment on: http://stackoverflow.com/a/22040627
score: 0
type: AnswerComment
has text: What do you mean "an edge case involving octal"? Please explain.
type: Comment

aide-ide
tag name: aide-ide
type: Tag
tags question: http://stackoverflow.com/q/22115674

http://stackoverflow.com/q/22161777
tagged with: java
has comment: http://stackoverflow.com/comment/33700002
type: Question
linked to: http://stackoverflow.com/q/996819
has comment: http://stackoverflow.com/comment/33729748
tagged with: restlet
score: 0
linked to: http://stackoverflow.com/q/18161517
tagged with: multipartform-data
has title: Sending a Multipart request to a restlet web serivce
tagged with: rest
has body: I was trying to send a Multipart post request to a restlet based web service, and then I stumble upon this link. http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&amp;dsMessageId=2401065 It says that its possible to parse a Multipart request with Restlet 1.1 or 2.x but there is no provision for sending a multipart/form data.
has comment: http://stackoverflow.com/comment/33878250
has comment: http://stackoverflow.com/comment/33746579
answer count: 0
has comment: http://stackoverflow.com/comment/33729943
type: UnansweredQuestion

http://stackoverflow.com/comment/33357199
has text: +1, I think to always MD5 hash the selected key would also ensure 128 bits
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22007882

http://stackoverflow.com/a/22059903
upvote count: 1
answers question: http://stackoverflow.com/q/22059822
has body: You can try some thing like this // get the string from the end-user Scanner scan = new Scanner(System.in); System.out.println("Please enter any string: "); String userInput = scan.nextLine(); // find the length of the string int stringLength = userInput.length(); int firstWordEnd = userInput.indexOf(" "); String firstWord = userInput.substring(0, firstWordEnd); String newFirstWord = firstWord.toUpperCase(); System.out.println(userInput.replace(firstWord, newFirstWord));
has comment: http://stackoverflow.com/comment/33450664
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/33450241
downvote count: 0

http://stackoverflow.com/comment/33489077
type: Comment
score: 0
has text: nope sir...I already graduated! :)
comment on: http://stackoverflow.com/q/22081336
type: QuestionComment

http://stackoverflow.com/comment/33471489
type: Comment
score: 0
comment on: http://stackoverflow.com/q/22067965
type: QuestionComment
has text: The bucket expression values are not comparable and no comparator specified

http://stackoverflow.com/q/22123614
upvote count: 1
tagged with: swing
downvote count: 1
has comment: http://stackoverflow.com/comment/33565377
tagged with: java
has comment: http://stackoverflow.com/comment/33565567
type: Question
has body: So my code is supposed to display a dialog box that has choices on it and the user is supposed to choose. Whichever the user chooses, it will display a certain portion of a file as an array, which then sparks another choice for the user out of that portion. I don't know exactly what I am doing and I have tried everything to the best of my knowledge. ArrayList&lt;String&gt; position = new ArrayList&lt;String&gt;(); int pick = 1; boolean checkForSameStrings = false; for(int pickCount = 0; pickCount &lt; numOfTeams; pickCount++) { String pickPosition = JOptionPane.showInputDialog(null, "What position do you plan on drafting?"); for(int checkForSameArrayStrings = 0; checkForSameArrayStrings &lt; positionLabel.size(); checkForSameArrayStrings++) { while(numOfTeams.equals(position.get(checkForSameArrayStrings))) { String nextPick; checkForSameStrings = true; nextPick = JOptionPane.showInputDialog(null, "Please enter a different team position " + pick); break; } } position.add(pickPosition); System.out.println(position.get(pickCount)); pick++; }
favorite count: 0
has title: How to display choices to the user for them to pick
tagged with: joptionpane
answer count: 0
type: UnansweredQuestion
score: 0

http://stackoverflow.com/a/22072241
answers question: http://stackoverflow.com/q/22071595
score: 1
upvote count: 1
has body: If you get all the WSDL from http://grpsvil-webservice.si2001.it/RestChannelApp.svc?WSDL you can see all the operations that you have defined. CheckCoupon is not there, BUT there's a CheckPromotionalCode. Could be that one?
type: Answer
downvote count: 0

http://stackoverflow.com/a/22009966
downvote count: 0
has body: Do it in for loop: for (char ch = 'A'; ch &lt;= 'Z'; ++ch) map.put(String.valueOf(ch), 0);
score: 27
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22009900
answers question: http://stackoverflow.com/q/22009900
type: Answer
upvote count: 27

http://stackoverflow.com/comment/33533191
score: 0
comment on: http://stackoverflow.com/a/22105767
type: Comment
has text: I've tried using the activity context. In the activity i call checkEligible(this). In the utility class I use the activity I passed in as the context to create the dialog. So they should both be equal to the same thing in the end
type: AnswerComment

http://stackoverflow.com/q/22127833
answer count: 1
favorite count: 0
has title: Swing change the JSpinner back and fore colors
upvote count: 2
accepted answer: http://stackoverflow.com/a/22128350
tagged with: swing
score: 2
type: AnsweredQuestion
tagged with: jspinner
tagged with: java
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/22128350
has body: How can I change the background and foreground color of a JSpinner in swing? is there any simple solution except override the paint() method? setting the background or foreground color doesn't work, at least for me. I also tested with all default look and feels, no success. JDK: 1.7.0.51 Win764 Thanks in advance

http://stackoverflow.com/comment/33356842
score: 1
type: AnswerComment
has text: Not an OOP solution ... Field designing type is not a useful replacement for polymorphism at all. Similar to the `instanceof` "issue" since MANUAL decision has to be taken into account.
type: Comment
comment on: http://stackoverflow.com/a/22007680

http://stackoverflow.com/a/22010857
type: Answer
score: 2
answers question: http://stackoverflow.com/q/22010727
downvote count: 0
upvote count: 2
has body: Rename your class to e.g. IntegerTest and all will works public class IntegerTest { public static void main(String[] args) { Integer num1 = 42; } }

http://stackoverflow.com/q/22098904
has comment: http://stackoverflow.com/comment/33523075
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33520885
has comment: http://stackoverflow.com/comment/33522160
has comment: http://stackoverflow.com/comment/33520216
upvote count: 24
has answer: http://stackoverflow.com/a/22106659
type: Question
has answer: http://stackoverflow.com/a/22115813
tagged with: performance
has comment: http://stackoverflow.com/comment/33520225
tagged with: simpledateformat
tagged with: java
has answer: http://stackoverflow.com/a/22149399
score: 24
tagged with: concurrency
has comment: http://stackoverflow.com/comment/33523020
has body: This is on Java 7 (51) on RHEL with 24 cores We are noticing a rise in average response times of a java SimpleDateFormat wrapped in thread local as we increase the thread pool size. Is this expected? or, I am just doing something stupid ? Test program public class DateFormatterLoadTest { private static final Logger LOG = Logger.getLogger(DateFormatterLoadTest .class); private final static int CONCURRENCY = 10; public static void main(String[] args) throws Exception { final AtomicLong total = new AtomicLong(0); ExecutorService es = Executors.newFixedThreadPool(CONCURRENCY); final CountDownLatch cdl = new CountDownLatch(CONCURRENCY); for (int i = 0; i &lt; CONCURRENCY; i++) { es.execute(new Runnable() { @Override public void run() { try { int size = 65000; Date d = new Date(); long time = System.currentTimeMillis(); for (int i = 0; i &lt; size; i++) { String sd = ISODateFormatter.convertDateToString(d); assert (sd != null); } total.addAndGet((System.currentTimeMillis() - time)); } catch (Throwable t) { t.printStackTrace(); } finally { cdl.countDown(); } } }); } cdl.await(); es.shutdown(); LOG.info("TOTAL TIME:" + total.get()); LOG.info("AVERAGE TIME:" + (total.get() / CONCURRENCY)); } } DateFormatter class: public class ISODateFormatter { private static final Logger LOG = Logger.getLogger(ISODateFormatter.class); private static ThreadLocal&lt;DateFormat&gt; dfWithTZ = new ThreadLocal&lt;DateFormat&gt;() { @Override public DateFormat get() { return super.get(); } @Override protected DateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.ENGLISH); } @Override public void remove() { super.remove(); } @Override public void set(DateFormat value) { super.set(value); } }; public static String convertDateToString(Date date) { if (date == null) { return null; } try { return dfWithTZ.get().format(date); } catch (Exception e) { LOG.error("!!! Error parsing dateString: " + date, e); return null; } } } Someone suggested to take out the AtomicLong …
has title: How to improve performance of SimpleDateFormat wrapped in ThreadLocal?
downvote count: 0
has comment: http://stackoverflow.com/comment/33520160
has comment: http://stackoverflow.com/comment/33522226
favorite count: 0
has answer: http://stackoverflow.com/a/22100487
linked to: http://stackoverflow.com/q/12540282
has comment: http://stackoverflow.com/comment/33520563
has comment: http://stackoverflow.com/comment/33520006
answer count: 4
has comment: http://stackoverflow.com/comment/33521571
tagged with: thread-local

http://stackoverflow.com/a/22095443
type: AcceptedAnswer
downvote count: 0
upvote count: 2
type: Answer
score: 2
accepted answer of: http://stackoverflow.com/q/22095401
answers question: http://stackoverflow.com/q/22095401
has body: What you want is a list of strings, not a list of an undefined, imaginary type E: List&lt;String&gt; s = new ArrayList&lt;String&gt;(); or simpler, if you're using Java 7: List&lt;String&gt; s = new ArrayList&lt;&gt;(); Learn about generics by reading the tutorial.

http://stackoverflow.com/comment/33551769
score: 0
has text: Programming cryptography is like arming a bomb. It's difficult enough for a professional; it's unreasonable to expect a beginner to produce secure code. In this case you should probably use an existing protocol that's designed for this, like TLS or SSH. If you feel those are difficult to configure, I'd like to point out that writing your own protocol is at least 100 times harder.
comment on: http://stackoverflow.com/q/22109799
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33366535
comment on: http://stackoverflow.com/a/22010985
score: 0
has text: **No** ,they are evaluated on startup.
type: AnswerComment
type: Comment

http://stackoverflow.com/q/22045108
has answer: http://stackoverflow.com/a/34614351
type: Question
has comment: http://stackoverflow.com/comment/75517863
tagged with: java
linked to: http://stackoverflow.com/q/26868233
tagged with: mysql
possible better answer: http://stackoverflow.com/a/34614351
has title: How to ignore placeholder expressions for Flyway?
score: 12
tagged with: flyway
upvote count: 12
has answer: http://stackoverflow.com/a/22054334
has answer: http://stackoverflow.com/a/62930102
downvote count: 0
answer count: 7
favorite count: 0
has answer: http://stackoverflow.com/a/70019096
has answer: http://stackoverflow.com/a/28640696
has answer: http://stackoverflow.com/a/58689368
has body: I am using flyway version 2.3, I have an sql patch which inserts a varchar into a table having character sequence that Flyway treats as placeholders. I want to flyway to ignore placeholders and run the script as is. The script file is insert into test_data (value) values ("${Email}"); And the Java code is package foobar; import com.googlecode.flyway.core.Flyway; public class App { public static void main( String[] args ) { // Create the Flyway instance Flyway flyway = new Flyway(); // Point it to the database flyway.setDataSource("jdbc:mysql://localhost:3306/flywaytest", "alpha", "beta"); // Start the migration flyway.migrate(); } }
has answer: http://stackoverflow.com/a/59372151
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22054334

http://stackoverflow.com/comment/33597745
comment on: http://stackoverflow.com/q/22142145
has text: there is a bug introduced in netbeans 7.2 https://netbeans.org/bugzilla/show_bug.cgi?id=215210
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33441552
score: 0
type: Comment
type: QuestionComment
has text: I am naive in hadoop and java. I think I have only .jar file of hadoop-*-example.jar that contains the randomwriter class file
comment on: http://stackoverflow.com/q/22053594

http://stackoverflow.com/comment/33439712
score: 0
has text: Replaced what I had wrote with what the guy on here said, but it only fixed the errors in that file
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22053715

http://stackoverflow.com/a/22292324
accepted answer of: http://stackoverflow.com/q/22166234
answers question: http://stackoverflow.com/q/22166234
type: AcceptedAnswer
has body: First use a debugger or a println() statement to see what getResource(path) returns. Then you can tell if the URL is to the correct directory and, if not, how to adjust it. If I'm not mistaken, the normal case is to call getResource() or getResourceAsStream() on the class object, not its class loader. E.g. SikuliTest.class.getResource("/images/image1.png"). This might not make a difference. You might need to pass it a relative path (one that doesn't begin with a /) if you want it to look in the test class's package. Pattern image = new Pattern(String.valueOf(BaseImage)); I assume that Pattern is a Selenium class, not java.util.regex.Pattern. This line of code does not like a workable way to read an image from an InputStream, but I don't know what the Pattern() constructor requires. [Finally, there's a strong Java naming convention for starting class names with an upper case letter and variable names with a lower case letter. Thus BaseImage should be baseImage or baseImageStream. This convention exists because . is heavily overloaded, so the naming convention keeps aPackage.AClass distinct from AClass.aVariable.]
score: 0
type: Answer

http://stackoverflow.com/a/22037236
answers question: http://stackoverflow.com/q/22036788
has body: You won't make this process any faster with multi-threading, unless there are multiple connections, but if there are, just call this stuff from multiple threads with multiple sockets, streams, etc. There's nothing inherently non-thread safe here, as you aren't using any static or instance variables. NB Get rid of the available() test. It doesn't do what you think. See the Javadoc.
score: 0
type: Answer

http://stackoverflow.com/q/22116810
type: UnansweredQuestion
tagged with: android
has title: NullPointerException in my BluetoothCommandService
has body: I'm creating a home automation android application with my arduino uno and HC-05 Bluetooth Module. Everything works fine already. It can scan, connect, on/off bluetooth, control the bulb on and off using buttons and switch control. My biggest problem is that it stops and automatically end the app when the switch control is clicked while the application is not yet connected to my bluetooth module is . I've been trying so hard to fix the error but still nothing happend. Thanks in advance to those who have ideas for this. Here are what is being listed in the LogCat: 03-02 00:02:48.807: E/AndroidRuntime(13767): FATAL EXCEPTION: main 03-02 00:02:48.807: E/AndroidRuntime(13767): java.lang.NullPointerException 03-02 00:02:48.807: E/AndroidRuntime(13767): at com.example.javac101.BluetoothCommandService.write(BluetoothCommandService.java:222) 03-02 00:02:48.807: E/AndroidRuntime(13767): at com.example.javac101.ControllerTab.sendData(ControllerTab.java:390) 03-02 00:02:48.807: E/AndroidRuntime(13767): at com.example.javac101.ControllerTab.onCheckedChanged(ControllerTab.java:271) 03-02 00:02:48.807: E/AndroidRuntime(13767): at android.widget.CompoundButton.setChecked(CompoundButton.java:126) 03-02 00:02:48.807: E/AndroidRuntime(13767): at android.widget.Switch.setChecked(Switch.java:666) 03-02 00:02:48.807: E/AndroidRuntime(13767): at android.widget.CompoundButton.toggle(CompoundButton.java:87) 03-02 00:02:48.807: E/AndroidRuntime(13767): at android.widget.CompoundButton.performClick(CompoundButton.java:99) 03-02 00:02:48.807: E/AndroidRuntime(13767): at android.view.View$PerformClick.run(View.java:17476) 03-02 00:02:48.807: E/AndroidRuntime(13767): at android.os.Handler.handleCallback(Handler.java:800) 03-02 00:02:48.807: E/AndroidRuntime(13767): at android.os.Handler.dispatchMessage(Handler.java:100) 03-02 00:02:48.807: E/AndroidRuntime(13767): at android.os.Looper.loop(Looper.java:194) 03-02 00:02:48.807: E/AndroidRuntime(13767): at android.app.ActivityThread.main(ActivityT…
tagged with: java
type: Question
tagged with: bluetooth
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/22116869
has comment: http://stackoverflow.com/comment/33552427

http://stackoverflow.com/a/22021409
has body: You could put it in a directory in the external storage and then read it like a java.io.File: File myProperties = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "myDir/myPorperties.properties"); obviously you could put the default properties file in assets and copy from asset to the external storage at the first app's run. NB: you need this permissions in manifest &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
answers question: http://stackoverflow.com/q/22020871
type: Answer
has comment: http://stackoverflow.com/comment/33406333
has comment: http://stackoverflow.com/comment/33383591
has comment: http://stackoverflow.com/comment/33408151
has comment: http://stackoverflow.com/comment/33410148
score: 0

http://stackoverflow.com/a/22031110
score: 0
has body: Pseudocode: function stars(n): c1 = 0 c2 = n for i = 1 to n print ' ' * c1 print '*' * c2 if (i &lt; (n+1) / 2): c1 ++; c2 -=2; else: c1-- c2 +=2 print newline This should get you close to your answer... now translate into java ** note - this works for odd number. You may need to tweak for even n **
type: Answer
answers question: http://stackoverflow.com/q/22031016

http://stackoverflow.com/comment/33474249
has text: just use `try-catch` block when you'll get "natives" value.
score: 0
comment on: http://stackoverflow.com/q/22073535
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33656942
has text: the project encoding wasn't wrong
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22152277
score: 0

http://stackoverflow.com/comment/33389042
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22025335
has text: I've tried to use `@Repository` or `@Component` annotation on DAO class. Still got UnsatisfiedDependencyException

http://stackoverflow.com/a/22087669
has comment: http://stackoverflow.com/comment/33500067
has comment: http://stackoverflow.com/comment/33500267
answers question: http://stackoverflow.com/q/22087494
has comment: http://stackoverflow.com/comment/33500211
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/33500141
has comment: http://stackoverflow.com/comment/33500295
has body: Instead to pass Scanner object in method processTransactions,pass File path: public void processTransactions(String filepath){ for (String string : id) { // Assume id is array of String Scanner transFile = new Scanner(new File(filepath)); while (transFile.hasNext()){ String key = transFile.next(); int value = transFile.nextInt(); for(i = 0; i &lt; ids.length; i++){ finalInventory[i] = startingInventory[i]; if(ids[i].equals(key)){ finalInventory[i] += value; } } } } }

http://stackoverflow.com/a/22159144
downvote count: 0
type: Answer
has body: You can get an image using this code image = (new ImageIcon(this.getClass().getResource("Image001.png"))).getImage(); assumed the file with an image is in the same folder as this class.
answers question: http://stackoverflow.com/q/22158992
score: 1
upvote count: 1

http://stackoverflow.com/comment/33368064
has text: Hi Vinoth, the thing is form is not getting submitted by submit button thats why I have to submit it manually.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22012591
type: Comment

http://stackoverflow.com/q/22005666
tagged with: distributed-caching
has answer: http://stackoverflow.com/a/39618997
answer count: 2
has answer: http://stackoverflow.com/a/22007021
upvote count: 1
has title: Distributed cache for key-value pairs
possible better answer: http://stackoverflow.com/a/39618997
favorite count: 0
has comment: http://stackoverflow.com/comment/33353701
has comment: http://stackoverflow.com/comment/33356425
tagged with: redis
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
has body: I'm looking for a distributed cache for key-value pairs with these features - Persistence to disk Open Source Java Interface Fast read/write with minimum memory utilisation Easy to add more machines to the database (Horizontally Scalable) What are the databases that fit the bill?
type: Question
accepted answer: http://stackoverflow.com/a/22007021
tagged with: caching

http://stackoverflow.com/comment/34328832
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22050842
type: Comment
has text: Perhaps the accepted answer to the following question helps to understand, how UmbrellaExceptions can be handled: [GWT client umbrellaexception get full error message in java](http://stackoverflow.com/questions/11029002/gwt-client-umbrellaexception-get-full-error-message-in-java/11033699#11033699)

http://stackoverflow.com/a/22097202
type: Answer
score: 2
has body: You are already overriding your colorwith new Paint() in the constructor. Then when you call color.set(Color) you are not changing it. I suggest you pass the color as int in the constructor and then use setColor public Particle(Context context, int locationX, int locationY, int sizeX, int sizeY, int paintColor) { (...) color = new Paint(); color.setColor(paintColor); }
has comment: http://stackoverflow.com/comment/33517503
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22096891
answers question: http://stackoverflow.com/q/22096891
upvote count: 2

http://stackoverflow.com/a/22029761
score: 89
upvote count: 89
has body: Default Property map Looking at http://logging.apache.org/log4j/2.x/manual/configuration.html#PropertySubstitution you can specify a default property map in the configuration file. That takes this form: default/location/of/oauth2.log ... <Appenders> <Appender type="File" name="File" fileName="${sys:oauthLoginLogPath}"> ... Then, if you start your app with system property -DoauthLoginLogPath=/path/oauth2.log, the File appender fileName value will first be looked up in system properties, but if that fails, it will fall back to the property defined in the Properties section at the top of the log4j2.xml configuration file. Inline A second way is to provide the default value inline: <Appender type="File" name="File" fileName="${sys:oauthLoginLogPath:-default/location/of/oauth2.log}"> Generally, all Log4j2 lookups follow this pattern: ${type:key:-defaultValue}. Env vs sys By the way, the env prefix is for environment variables (like %PATH% on Windows), and is not related to sys, which is Java system properties. See also http://logging.apache.org/log4j/2.x/manual/lookups.html
answers question: http://stackoverflow.com/q/22028399
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/123090406
type: Answer
has comment: http://stackoverflow.com/comment/63074535
accepted answer of: http://stackoverflow.com/q/22028399

http://stackoverflow.com/q/22132069
has answer: http://stackoverflow.com/a/22150155
type: AnsweredQuestion
tagged with: netbeans
tagged with: java
type: Question
linked to: http://stackoverflow.com/q/3316315
tagged with: derby
has body: I have a database-driven application (Apache Derby). I connect to the database by a URL: jdbc:derby://localhost:1527/kcal_calc_db My database was created via NetBeans, and is in the '.netbeans-derby' folder. How can I include this database with my JAR/EXE file?
has comment: http://stackoverflow.com/comment/33580821
score: 0
accepted answer: http://stackoverflow.com/a/22150155
answer count: 1
has comment: http://stackoverflow.com/comment/33580715
has title: How to provide java application with database?

http://stackoverflow.com/a/22140708
has comment: http://stackoverflow.com/comment/33595165
upvote count: 3
type: AcceptedAnswer
has body: Get rid of the type variable declared in your parse method public &lt;T&gt; T parse(Class&lt;T&gt; target, String inputString, String rootNode, String requiredNode, // ^ get rid of this That &lt;T&gt; bit declares a new type variable that shadows (has the same name) the type variable declared in the class name expression. The type variable T here and the one declared at class level are unrelated.
type: Answer
answers question: http://stackoverflow.com/q/22140684
score: 3
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22140684

http://stackoverflow.com/comment/33580396
type: Comment
comment on: http://stackoverflow.com/a/22131688
has text: I guess because I have no compiler available right now, anyway I'd say newFile = new File(photo.getPath(),"hhhhhhh.jpg");
type: AnswerComment
score: 0

http://stackoverflow.com/a/22090559
score: -1
upvote count: 0
answers question: http://stackoverflow.com/q/22090291
type: Answer
has body: You can implement this by event onChange.
downvote count: 1

http://stackoverflow.com/q/22071595
has answer: http://stackoverflow.com/a/22072243
answer count: 4
tagged with: android-json
possible better answer: http://stackoverflow.com/a/22071812
accepted answer: http://stackoverflow.com/a/22071737
has comment: http://stackoverflow.com/comment/33470604
has answer: http://stackoverflow.com/a/22072241
has title: HTTPPOST returns 404 ANDROID
has answer: http://stackoverflow.com/a/22071812
tagged with: android
has comment: http://stackoverflow.com/comment/33470422
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33470407
has comment: http://stackoverflow.com/comment/33471442
type: Question
has body: Im trying to post to a REST API json object but i keep getting responce 404 but the url is working fine. Can anyone tell me why is this happeninig? Here is my code: new AsyncTask&lt;Void, Void, Void&gt;() { @Override protected Void doInBackground(Void... params) { HttpPost request = new HttpPost( "http://grpsvil-webservice.si2001.it/RestChannelApp.svc/CheckCoupon"); // request.setHeader("Accept", "application/json"); request.setHeader("Accept", "application/json"); request.setHeader("Content-type", "application/json"); try { // Build JSON string JSONStringer vehicle = new JSONStringer() .object() .key("CouponVerificationCode") .value("adf") .key("ApiKey") .value("adfadf123") .key("Token") .value("fgsg342==") .endObject(); Log.v("--", vehicle.toString()); StringEntity entity = new StringEntity(vehicle.toString()); request.setEntity(entity); // Send request to WCF service DefaultHttpClient httpClient = new DefaultHttpClient(); HttpResponse response = httpClient.execute(request); int resCode = response.getStatusLine().getStatusCode(); Log.v("--", response.getStatusLine().getStatusCode() + ""); if (resCode == 200) { Toast.makeText(getApplicationContext(), response.getStatusLine().getStatusCode() + "", Toast.LENGTH_LONG).show(); BufferedReader in = new BufferedReader( new InputStreamReader(response.getEntity() .getContent())); String line = ""; StringBuffer returnFromServer = new StringBuffer(); while ((line = in.readLine()) != null) { returnFromServer.append(line); } // Toast what we got from server Log.v("--", "!@# " + returnFromServer.toString()); if (entity != null) { entity.consumeContent(); } } } catch (Exception e) { // TODO: handle exception } Intent i = new Intent(Splash.this, Login.class); startActivity(i); finish(); return null; }
has comment: http://stackoverflow.com/comment/33470564
tagged with: androidhttpclient
has answer: http://stackoverflow.com/a/22071737
score: 0
has comment: http://stackoverflow.com/comment/33470513

http://stackoverflow.com/comment/33492093
type: QuestionComment
comment on: http://stackoverflow.com/q/22082112
type: Comment
has text: There is usually updating a textview, I can then take that string? Because I want to launch a notification every day at this time. Would work?
score: 0

http://stackoverflow.com/a/22021707
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/22021619
has body: I assume you want to read only the nth line, skipping the previous ones. Then you should update this piece of code: br = new BufferedReader(fr); for(int i = 0; i &lt; numeroRandom; i++){ br.readLine(); linea = br.readLine(); } Into this: br = new BufferedReader(fr); for(int i = 0; i &lt; numeroRandom; i++){ br.readLine(); } linea = br.readLine(); // move this line You were getting null when numeroRandom was 0 because linea wasn't being updated. The other strange results happened because you were reading 2 lines in each cycle. There will be a point where getLine() will simply return null from not having more lines to read.
upvote count: 1
type: Answer

http://stackoverflow.com/comment/33621127
score: 0
has text: I dint give the full ENUm structure i tried. Inlcuded the full definition above. Is this still in-correct with the way i have defined my enum?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22155039

http://stackoverflow.com/q/22011465
answer count: 2
has body: I have some problem. I have two methods, one called with Api 11 and above, second method for old api. There are settings of my project: Project Build Target - Google APIs 2.3.3 Manifest file: uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" My code: abstract class DoAsyncRequest { protected abstract void DoRequest(Connection conn) throws Exception; } class DoAsyncRequestLegacy extends DoAsyncRequest { protected void DoRequest(Connection conn) throws Exception{ new FetchTask(conn).execute();// FOR OLD API } } @TargetApi(11) class DoAsyncRequest_SDK11 extends DoAsyncRequest { protected void DoRequest(Connection conn) throws Exception{ new FetchTask(conn).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null); //FOR NEW API, but compiller says, that THREAD_POOL_EXECUTOR cannot be resolved or is not a field } } Best regards.
score: 0
has title: how support different android os?
tagged with: android
has answer: http://stackoverflow.com/a/22011491
tagged with: android-asynctask
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22011632
tagged with: java
type: Question

http://stackoverflow.com/comment/33386094
comment on: http://stackoverflow.com/q/22023777
type: QuestionComment
has text: added the Code. BTW the site (stackoverflow) looks not like it used too?? its liek a simple Dark-blue design and im irritated why its liek that now.. i didnt changed anything :/ any idea how i can reset it?
score: 0
type: Comment

http://stackoverflow.com/a/22026458
has comment: http://stackoverflow.com/comment/33391518
has comment: http://stackoverflow.com/comment/33391897
has body: This: int width = Integer.parseInt(args[0]); already throws a NumberFormatException if the String in question is not a valid string representation of an integer. EDIT: To address your comments: public class CubeVolume { private int width; private int depth; private int height; public static void main(String [] args) { if (args.length != 3) { throw new Exception("Width, height and depth are required arguments"); } width = Integer.parseInt(args[0]); depth = Integer.parseInt(args[1]); height = Integer.parseInt(args[2]); // more stuff here } }
has comment: http://stackoverflow.com/comment/33390976
has comment: http://stackoverflow.com/comment/33391063
has comment: http://stackoverflow.com/comment/33391156
has comment: http://stackoverflow.com/comment/33391400
has comment: http://stackoverflow.com/comment/33426762
has comment: http://stackoverflow.com/comment/33391625
has comment: http://stackoverflow.com/comment/33391010
accepted answer of: http://stackoverflow.com/q/22026301
has comment: http://stackoverflow.com/comment/33395264
type: Answer
answers question: http://stackoverflow.com/q/22026301
has comment: http://stackoverflow.com/comment/33391682
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/33392351
has comment: http://stackoverflow.com/comment/33394228
has comment: http://stackoverflow.com/comment/33390986
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33392687
has comment: http://stackoverflow.com/comment/33392461

http://stackoverflow.com/q/22112212
favorite count: 0
has comment: http://stackoverflow.com/comment/33544383
has comment: http://stackoverflow.com/comment/33544446
type: UnansweredQuestion
score: 6
downvote count: 1
has title: How to skip the first iteration in a for each loop?
has body: Programming is new to me and i am trying to get my head around some of the concepts. I am trying to make a simple applet that displays the capital cities of Europe on a map on join them using the drawLine method. I have encountered a problem where i cannot successfully join the 2 capital cities together with a line. I think i understand why but i cannot think of a way to around it. The second two parameters in the draw method are the same as the first two, but i cannot make it skip the first iteration. This is all new to me and i am trying to learn from a book and the web at the moment. public void paint(Graphics g) { super.paint(g); g.drawImage(image, 0, 0, this); for (Entry&lt;String, co&gt; entry : map.entrySet()) { g.setColor(Color.BLUE); g.fillOval(entry.getValue().a, entry.getValue().b, 5, 5); g.setColor(Color.BLUE); g.drawString(entry.getKey(), entry.getValue().a+7, entry.getValue().b+7); g.setColor(Color.RED); g.drawLine(entry.getValue().a, entry.getValue().b, 0, 0);//Problem } } Can some one push me in the right direction? I was thinking of using an iterator instead of a for each loop, that is the only idea i have in my head at the moment.
answer count: 4
tagged with: java
tagged with: loops
upvote count: 7
type: Question
has answer: http://stackoverflow.com/a/22112266
tagged with: hashmap
has answer: http://stackoverflow.com/a/22112304
has comment: http://stackoverflow.com/comment/33544717
has answer: http://stackoverflow.com/a/22112277
has answer: http://stackoverflow.com/a/22112272
has comment: http://stackoverflow.com/comment/33544463

http://stackoverflow.com/comment/33387811
comment on: http://stackoverflow.com/q/22024030
has text: It is in the component package. It might be exiting before the windows shows indeed, how can I fix it then?
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22101275
has comment: http://stackoverflow.com/comment/33525479
tagged with: java
has answer: http://stackoverflow.com/a/22102041
tagged with: graph
answer count: 1
has comment: http://stackoverflow.com/comment/33524537
has comment: http://stackoverflow.com/comment/33525162
score: 0
has comment: http://stackoverflow.com/comment/33524413
type: UnansweredQuestion
has body: I had an assignment to create a Kruskal algorithm, which went fine there was a nice tutorial online, but I'm having difficulty trying to add the edges to all of my nodes with the assigned weights. Here is what I'm doing and hopefully you guys can help me out. main function public static void main(String[] args) { int maximumVertices = 50; Random ran = new Random(); Graph g = new Graph(maximumVertices); for(int i=0; i&lt;maximumVertices-1; i++){ int weight = ran.nextInt(50); int connectedNode = ran.nextInt(10); //the idea here is to create random connections between nodes g.addVertex(i); g.addBidirectionalEdge(i, connectedNode, weight); g.addBidirectionalEdge(i+1, connectedNode, weight); System.out.println(Arrays.toString((g.getAdjacentVertexNumbers(i)))); } Kruskal k = new Kruskal(g); List&lt;Edge&gt; mst = k.getMSTEdges(); System.out.println ("Minimum Spanning Tree Edges are:"); ListIterator&lt;Edge&gt; it = mst.listIterator(); while(it.hasNext()){ Edge e = (Edge)it.next(); System.out.println ("v" + e.getFrom().getVertexNo() + " --- v" + e.getTo().getVertexNo()); } Kruskal class public class Kruskal { private Graph graph; private int[] sets; //represent set for vertices public Kruskal(Graph g) { this.graph = g; this.sets = new int[g.getTotalNumberOfVertices()]; } private void makeSet(Vertex v){ this.sets[v.getVertexNo()] = v.getVertexNo(); //simply set the set name to each vertex no } private int findSet(Vertex v){ return this.sets[v.getVertexNo()]; //gets the set name/number of a vertex } private void union(Vertex u, Vertex v){ int findWhat, replaceWith; if(u.getVertexNo() &lt; v.getVertexNo()){ findWhat = this.sets[v.getVertexNo()]; replaceWith = this.sets[u.getVertexNo()]; } else{ findWhat = this.sets[u.getVertexNo()]; replaceWith = this.sets[v.getVertexNo()]; } //make both sets same for(int i=0; i&lt;this.sets.length; i++){ if(this.sets[i] == findWhat){ this.sets[i] = replaceWith; } } } private void sortEdges(Edge[] edges){ for(int i=0; i&lt;edges.length-1; i++…
has comment: http://stackoverflow.com/comment/33525100
has title: I get a Null Pointer when I add to my edges to my graph (tree)
type: Question
tagged with: tree

http://stackoverflow.com/a/22154914
has comment: http://stackoverflow.com/comment/33624404
has comment: http://stackoverflow.com/comment/33622778
answers question: http://stackoverflow.com/q/22154812
has comment: http://stackoverflow.com/comment/33623194
score: 0
has comment: http://stackoverflow.com/comment/33622876
has body: When you construct the ImageIcon you are not loading the image into memory fully at that moment with a blocking operation, your ClassLoader.getResource is only returning you a URL. Reading the constructor details of ImageIcon it says that it starts the loading of the URL, but doesn't block. You can check for when the image is done loading by imageIcon.getImageLoadStatus() method. When that returns complete, perhaps then set window.setVisible(true).
has comment: http://stackoverflow.com/comment/33622402
type: Answer
has comment: http://stackoverflow.com/comment/33624054
has comment: http://stackoverflow.com/comment/33622273
has comment: http://stackoverflow.com/comment/33621855

http://stackoverflow.com/q/22158923
tagged with: oracle-database
has answer: http://stackoverflow.com/a/42599407
has title: The full pathname of a JDK installation for Oracle SQL Developer
has answer: http://stackoverflow.com/a/60670811
has answer: http://stackoverflow.com/a/22491812
accepted answer: http://stackoverflow.com/a/27174629
favorite count: 0
tagged with: oracle-sqldeveloper
has answer: http://stackoverflow.com/a/41500006
possible better answer: http://stackoverflow.com/a/39636689
has answer: http://stackoverflow.com/a/39636689
upvote count: 23
has body: I want to run Oracle SQL Devloper on Ubuntu with this command: sh sqldeveloper/sqldeveloper.sh Then I got this message: Type the full pathname of a JDK installation (or Ctrl-C to quit), the path will be stored in /home/aimad/.sqldeveloper/4.0.0/product.conf So I gave the path of jdk as the following: /usr/lib/jvm/java-7-openjdk-i386/ But then I got this message: Error: Java home /usr/lib/jvm/java-7-openjdk-i386//bin/java is not a JDK. Running SQL Developer under a JRE is not supported.
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/25585614
has answer: http://stackoverflow.com/a/69858116
tagged with: java
score: 23
type: Question
has answer: http://stackoverflow.com/a/27174629
downvote count: 0
has answer: http://stackoverflow.com/a/25610634
has answer: http://stackoverflow.com/a/57712055
tagged with: ubuntu
answer count: 11
has answer: http://stackoverflow.com/a/50779324
tagged with: linux

http://stackoverflow.com/a/22100250
score: 1
answers question: http://stackoverflow.com/q/22099845
downvote count: 0
has comment: http://stackoverflow.com/comment/33526877
type: Answer
upvote count: 1
has body: "{ 'paramsArray': ['first', '100']," + "'paramsObj': { 'one': 'two'," + "'three': 'four'}," + "'paramsStr': 'some string'}" Use single quotes inside double ones to increase readability like so...

http://stackoverflow.com/a/22078148
score: 0
answers question: http://stackoverflow.com/q/22077706
has body: add a TableModelListener to your JTable you should override its tableChanged method somewhat like this : public void tableChanged(TableModelEvent e) { int row = e.getFirstRow(); int column = e.getColumn(); TableModel model = (TableModel)e.getSource(); String columnName = model.getColumnName(column); Object data = model.getValueAt(row, column); //Check the data!!! //Check the data!!! //Check the data!!! //disable the button if needed right here } ref:http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#modelchange
type: Answer

authentication
tags question: http://stackoverflow.com/q/22099886
tags question: http://stackoverflow.com/q/22167784
tags question: http://stackoverflow.com/q/22156567
tags question: http://stackoverflow.com/q/22021379
tags question: http://stackoverflow.com/q/22076657
tags question: http://stackoverflow.com/q/22014744
tags question: http://stackoverflow.com/q/22085173
tags question: http://stackoverflow.com/q/22093696
tag name: authentication
tags question: http://stackoverflow.com/q/22130692
tags question: http://stackoverflow.com/q/22115493
type: Tag
tags question: http://stackoverflow.com/q/22007151
tags question: http://stackoverflow.com/q/22045285
tags question: http://stackoverflow.com/q/22153339
tags question: http://stackoverflow.com/q/22057636
tags question: http://stackoverflow.com/q/22016953
tags question: http://stackoverflow.com/q/22117512

http://stackoverflow.com/comment/33622667
type: Comment
type: QuestionComment
has text: Using multiple JFrames in your application is a bad design. Always create only 1 JFrame (which is your main window) and use auxiliary JDialogs if needed.
score: 1
comment on: http://stackoverflow.com/q/22155853

http://stackoverflow.com/comment/33403648
score: 0
type: Comment
has text: Nope. The command would give me an error saying: Error: Could not find or load main class addition
comment on: http://stackoverflow.com/a/22026019
type: AnswerComment

http://stackoverflow.com/comment/33409166
type: AnswerComment
has text: I replaced the bitmap.recycle() line in the loadImage method with this however I still get the error
type: Comment
comment on: http://stackoverflow.com/a/22036929
score: 1

http://stackoverflow.com/q/22055978
type: Question
tagged with: long-integer
accepted answer: http://stackoverflow.com/a/22056170
has comment: http://stackoverflow.com/comment/33477971
has answer: http://stackoverflow.com/a/22056062
has body: So I am trying to find an answer to question 3 on project Euler. I need to determine the largest prime factor of a given number. Quote Project Euler : "The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?" I have built my code and it works perfectly on anything the size of an int. But due to the gigantic number they give, my code has conversionproblems. Originally I tried switching to long variables and long arrays but I get the error : 'possible lossy conversion from long to int' So how I can I make my code accept extremely long numbers? public class Test { long[] delers; public static void main(String[] args) { Test test = new Test(); test.determineDividers(600851475143,determineNumberOfDividers(600851475143)); long a = test.determineHighestPrime(test.delers); System.out.println(a); } public void determineDividers(long getal,long aantalDelers) { delers= new long[aantalDelers]; long k = 0; for (long i = 1; i &lt; getal; i++) { if (getal % i == 0) { delers[k]=i; k++; } } } public long determineNumberOfDividers(long getal) { int k = 0; for (long i = 1; i &lt; getal; i++) { if (getal % i == 0) { k++; } } return k; } public boolean determinePrime(long getal) { for (long i = 2; i &lt; getal; i++) { if (getal % i == 0) { return false; } } return true; } public long determineHighestPrime(long[] deler) { for (long i = deler.length - 1; i &gt; 0; i--) { if (determinePrime(deler[i]) == true) { return deler[i]); } } return 0; } } Thank you for your time EDIT 1 : Added example from PE. EDIT 2 : Added solution public class Test { long[] delers; public static void main(String[] args) { Test test = new Test(); test.determineDividers(600851475143L,test.determineNumberOfDividers(600851475143L)); long a = test.determineHighestPrime(test.delers); System.out.println(a); } public void determineDividers(long getal,int aantalDelers) { delers= new long[aantalDelers]; int k = 0; for (long i = 1; i &lt; getal; i++) { if (getal % i == …
has comment: http://stackoverflow.com/comment/33443616
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/33443675
has comment: http://stackoverflow.com/comment/33490412
has comment: http://stackoverflow.com/comment/33444787
possible better answer: http://stackoverflow.com/a/22056062
has title: How can I determine extremely large prime factors?
tagged with: primes
has answer: http://stackoverflow.com/a/22056170
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33443643
tagged with: java
has comment: http://stackoverflow.com/comment/33487124
has comment: http://stackoverflow.com/comment/33443837

http://stackoverflow.com/a/22162443
has comment: http://stackoverflow.com/comment/33635132
downvote count: 0
has comment: http://stackoverflow.com/comment/33636438
answers question: http://stackoverflow.com/q/22162231
has comment: http://stackoverflow.com/comment/76016336
has comment: http://stackoverflow.com/comment/33634284
has comment: http://stackoverflow.com/comment/76791964
has comment: http://stackoverflow.com/comment/33634923
type: Answer
score: 6
upvote count: 6
has body: if(name!=null &amp;&amp; name.length &gt; 0) { // This means there are some elements inside name array. } else { // There are no elements inside it. }

http://stackoverflow.com/comment/33491017
comment on: http://stackoverflow.com/q/22082339
score: 0
type: QuestionComment
type: Comment
has text: Also what you do here `board[j] = null;` is that you set each "row" of your array to null!

http://stackoverflow.com/q/22068618
type: Question
score: 1
tagged with: java
has title: Cannot find the scanner
has comment: http://stackoverflow.com/comment/33465131
has comment: http://stackoverflow.com/comment/33465037
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/22069202
has body: I have a very bad experienced about the scanner because I am using GUI and JOptionPane. So I am not be able to do the program's interns of scanner because. I am new to it so Please help me, "cannot find the scanner". This is my code so far . import java.io.*; import java.util.*; class MultiplicationTables{ public static void main(String args[]){ int n, c; System.out.println("Enter an integer to print its multiplication table"); Scanner in = new Scanner(System.in); n = in.nextInt(); System.out.println("Multiplication table of "+n+" is :-"); for ( c = 1 ; c &lt;= 10 ; c++ ) System.out.println(n+"*"+c+" = "+(n*c)); } }
favorite count: 0
has comment: http://stackoverflow.com/comment/33465088
has comment: http://stackoverflow.com/comment/33465040
has comment: http://stackoverflow.com/comment/33464985
has comment: http://stackoverflow.com/comment/33465070
tagged with: java.util.scanner
has answer: http://stackoverflow.com/a/22069199
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33465104
upvote count: 1

http://stackoverflow.com/q/22130500
accepted answer: http://stackoverflow.com/a/22300396
score: 0
possible better answer: http://stackoverflow.com/a/22172963
tagged with: mahout
has answer: http://stackoverflow.com/a/22172963
has title: Mahout : Cannot convert into sequence file
has answer: http://stackoverflow.com/a/22300396
tagged with: sequencefile
type: AnsweredQuestion
tagged with: java
tagged with: mapreduce
type: Question
tagged with: hadoop
answer count: 2
has body: I'm trying to convert some text files into mahout sequence files. So I do mahout seqdirectory -i inputFolder -o outputFolder But I always get this exception java.lang.Exception: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:403) Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at org.apache.hadoop.mapreduce.lib.input.CombineFileRecordReader.initNextRecordReader(CombineFileRecordReader.java:164) at org.apache.hadoop.mapreduce.lib.input.CombineFileRecordReader.&lt;init&gt;(CombineFileRecordReader.java:126) at org.apache.mahout.text.MultipleTextFileInputFormat.createRecordReader(MultipleTextFileInputFormat.java:43) at org.apache.hadoop.mapred.MapTask$NewTrackingRecordReader.&lt;init&gt;(MapTask.java:491) at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:734) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:339) at org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:235) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.apache.hadoop.mapreduce.lib.input.CombineFileRecordReader.initNextRecordReader(CombineFileRecordReader.java:155) ... 11 more Caused by: java.lang.IncompatibleClassChangeError: Found interface org.a…

http://stackoverflow.com/comment/33464460
comment on: http://stackoverflow.com/a/22068139
type: AnswerComment
type: Comment
has text: I tried doing what you suggested, but I'm still stuck at it printing just until the returned index.
score: 0

http://stackoverflow.com/q/22148397
has comment: http://stackoverflow.com/comment/33609758
has comment: http://stackoverflow.com/comment/33609480
tagged with: javascript
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33610797
score: 2
answer count: 0
downvote count: 0
tagged with: websocket
has title: Tomcat port 80 - corrupted websocket messages
has comment: http://stackoverflow.com/comment/33609417
tagged with: tomcat
favorite count: 0
type: Question
has comment: http://stackoverflow.com/comment/33609927
has body: I am currently trying to write a small web application that makes use of websockets. The application is doing a broadacast to all connected clients. This works quite well as long as the Tomcat Container is running on a port different from port 80. For this scenario think of the web application broadcasting messages all the time. The working behaviour is the following (i.e. running on port different from 80): Client (Browser) connects to the server successfully Client immediately receives messages (i.e. websocket callback function is invoked) As soon as I configure it to run on port 80 the following behaviour could be observed: Client (Browser) connects to the server successfully From the start no invocation of callback can be observed via console.log(...) After some time the debug output from the onmessage callback is shown all at once having all the same timestamp, though the timespan between 5 broadcasts is definitely more than a second Console Log: Event data: {"aktuell":50,"total":788,"msg":"Indexiere Artikel"} at Mon Mar 03 2014 14:24:22 GMT+0100 Event data: {"aktuell":55,"total":788,"msg":"Indexiere Artikel"} at Mon Mar 03 2014 14:24:22 GMT+0100 Event data: {"aktuell":60,"total":788,"msg":"Indexiere Artikel"} at Mon Mar 03 2014 14:24:22 GMT+0100 Event data: {"aktuell":65,"total":788,"msg":"Indexiere Artikel"} at Mon Mar 03 2014 14:24:22 GMT+0100 Event data: {"aktuell":70,"total":788,"msg":"Indexiere Artikel"} at Mon Mar 03 2014 14:24:22 GMT+0100 Event data: {"aktuell":75,"total":788,"msg":"Indexiere Artikel"} at Mon Mar 03 2014 14:24:22 GMT+0100 Event data: {"aktuell":80,"total":788,"msg":"Indexiere Artikel"} at Mon Mar 03 2014 14:24:22 GMT+0100 Event data: {"aktuell":85,"total":788,"msg":"Indexiere Artikel"} at Mon Mar 03 2014 14:24:22 GMT+0100 Event data: {"aktuell":90,"total":788,"msg":"Indexiere Artikel"} at Mon Mar 03 2014 14:24:22 GMT+0100 Event data: {"aktuell":95,"total":784{"aktuell":50,"total":788, at Mon Mar 03 2014 14:24:22 GMT+0100 This behaviour …
upvote count: 2
tagged with: java

http://stackoverflow.com/comment/33602861
comment on: http://stackoverflow.com/a/22069554
has text: look at http://stackoverflow.com/questions/22145321/cachelong-blockingdequepeer-combined-with-stripedreadwritelock-is-it-thr please
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/121207119
score: 0
type: Comment
has text: Btw, in that case, `GET_SIGNATURES` can't be used (for anyone that needs it). If the app is signed with only one, that's cool. If it's signed with multiple ones, all certificates must be verified, from what I'm been reading. (With `GET_SIGNING_CERTIFICATES` it's alright to just verify one though.)
comment on: http://stackoverflow.com/a/22260395
type: AnswerComment

http://stackoverflow.com/comment/33614601
type: Comment
type: QuestionComment
has text: @robermann, No, I meant I need to be able to be writing to the database concurrently from two different threads, different commits.
comment on: http://stackoverflow.com/q/22151347
score: 0

http://stackoverflow.com/comment/33538466
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22108684
has text: @1Poseidon3: Make sure that the `findControl` won't return a `null`.
score: 0

http://stackoverflow.com/a/22166741
has comment: http://stackoverflow.com/comment/33641909
score: 2
has body: threading in a managed environment is generally a bad idea. why not use some sort of abstraction like JMS to start a background handler every time someone sends a request ? that way you can control the number of active threads (jms pool size)
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22166639
answers question: http://stackoverflow.com/q/22166639
type: Answer
has comment: http://stackoverflow.com/comment/33643597
has comment: http://stackoverflow.com/comment/33641821
upvote count: 2

http://stackoverflow.com/comment/33528965
comment on: http://stackoverflow.com/q/22096052
type: QuestionComment
has text: @SimonAndréForsberg If you can be bothered, could you please give an example of a use case that you've came up with ? Genuine question.
type: Comment
score: 0

http://stackoverflow.com/comment/33489763
score: 0
type: Comment
type: QuestionComment
has text: I believe the class files are in binary form only. Only the source code java file contains all the comments required to generate a javadoc. You would need to have access to the source code file and programmatically run the javadoc.exe program. Assuming you had access to the source code, you could use ProcessBuilder to execute javadoc.exe and point it to the source code.
comment on: http://stackoverflow.com/q/22081639

http://stackoverflow.com/comment/33491383
has text: first, why are you setting the choice mode only after clicking submit button? I believe, you should set it right before allowing the user to select items.
comment on: http://stackoverflow.com/q/22082551
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/33455461
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22062906
score: 0
has text: what happen it's that the file rotates and the last reference points a file with 0 bytes. Anyway, I'm going to review the code again.

http://stackoverflow.com/q/22135866
downvote count: 0
has answer: http://stackoverflow.com/a/22135908
score: 1
tagged with: java
type: Question
tagged with: combinations
has body: I have this case that works for the inputs: {-5,0,5}, 2, 0 // which correctly evaluates to true {-5,0,5}, 3, 4 // which correctly evaluates to false {-5,0,5}, 3, 0 // which correctly evaluates to true but with the input: {6,5,6}, 2, 12 // says false when true it doesn't get give the correct boolean value... Can someone help debug the problem? public static boolean subset(int[] array, int n, int target) { for (int i = 0; i &lt; array.length; i++) { int[] list = new int[array.length - 1]; for (int j = 0; j &lt; array.length - 1; j++) { list[j] = array[j+1]; } subset(list, n, target); } int sum = 0; for (int i = 0; i &lt; array.length; i++) { sum += array[i]; } if (sum == target) { return true; } else { return false; } }
answer count: 2
upvote count: 1
favorite count: 0
has title: Recursively adding subet
has comment: http://stackoverflow.com/comment/33587733
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22135915
tagged with: recursion

http://stackoverflow.com/comment/34012406
has text: It turned out the method = RequestMethod.GET in your error pages was the issue as Dave said. Removing the method option solved it.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22048511

http://stackoverflow.com/comment/33579375
type: QuestionComment
score: 0
has text: im using eclipse. i have all the .jars needed on my classpath. lwjgl.jar, lwjgl-util.jar, nifty.jar, nifty-lwjgl-renderer.jar, nifty-default-controls.jar, nifty-examples.jar, nifty-style-black.jar, xpp3-1.1.4c.jar
comment on: http://stackoverflow.com/q/22131206
type: Comment

http://stackoverflow.com/q/22156667
has title: JButton added to JPanel doesn't show
has comment: http://stackoverflow.com/comment/33639242
type: UnansweredQuestion
tagged with: swing
has comment: http://stackoverflow.com/comment/33624700
downvote count: 1
type: Question
tagged with: java
has comment: http://stackoverflow.com/comment/33625630
score: -1
has body: I can't seem to add a JButton to a JPanel. I have a PropWindow (JFrame) that has a PropView (JPanel) in it. the PropView-JPanel seems to be added correctly because I can draw shapes on it with paint(). But when I use this to try adding a button it just won't show up att all :/ JButton testButton; public PropView(int width, int height) { super(true); setLayout(null); setSize(width, height); //TestButton testButton = new JButton("Test"); testButton.setLocation(10,10); testButton.setSize(100, 50); testButton.setVisible(true); add(testButton); setFocusable(true); setVisible(true); } The JFrame and the JPanel are both 250x600 px.
has answer: http://stackoverflow.com/a/22156773
answer count: 2
upvote count: 0
has comment: http://stackoverflow.com/comment/33624484
has answer: http://stackoverflow.com/a/22156874
has comment: http://stackoverflow.com/comment/33624346
favorite count: 0

http://stackoverflow.com/comment/33546964
score: 1
comment on: http://stackoverflow.com/q/22113710
type: QuestionComment
type: Comment
has text: Can you provide your stack trace?

http://stackoverflow.com/comment/33375576
has text: Actually you can but only one can be public!
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/22018338
score: 0

http://stackoverflow.com/q/22039173
upvote count: 3
answer count: 3
favorite count: 0
downvote count: 0
linked to: http://stackoverflow.com/q/675730
has answer: http://stackoverflow.com/a/41474740
has title: I need to create absolute URL's for my SPRING application using Thymeleaf
accepted answer: http://stackoverflow.com/a/22120313
tagged with: spring
has body: I have a SPRING application running (using spring boot) either directly on Java or on a Tomcat 7 server. I need to create absolute URL's for a couple of pages (mappings) so that these links can be sent via e-mail. I thought this would be simple, but now it seems hard. I would prefer a solution that is 100% written in Thymeleaf, but if that is not possible, I can certainly provide Thymeleaf with some variables from my Java code. Anyone solved this before in Thymeleaf?
tagged with: spring-mvc
type: AnsweredQuestion
score: 3
tagged with: java
possible better answer: http://stackoverflow.com/a/27276451
has answer: http://stackoverflow.com/a/22120313
has answer: http://stackoverflow.com/a/27276451
type: Question
tagged with: thymeleaf

http://stackoverflow.com/comment/33598781
score: 0
type: QuestionComment
has text: maybe you want to check out http://github.com/NiklasRosenstein/beak-lang. The code is documented a little (not well, not bad though)
type: Comment
comment on: http://stackoverflow.com/q/22142761

http://stackoverflow.com/comment/33567356
type: Comment
comment on: http://stackoverflow.com/a/22124582
score: 0
type: AnswerComment
has text: An array is a list of data. The array's size is fixed; we must declare its size when we initialize it. The ArrayList is dynamic. We're allowed to add as many items as we want to an ArrayList. In the code above, I've declared an ArrayList of type String. I created a Scanner that took in a File with a given file name. The Scanner class has a method called .hasNextLine() that checks whether or not the current Scanner object still has input. The code inside the loop adds the next line of the Scanner to the ArrayList.

http://stackoverflow.com/comment/33507306
type: Comment
has text: thanks for your answer. Yes I understand what you mean. I am just learning, so it is hard for me to read all the errors. Okay when I add: time-to-expire-cookie 20 I get a blank screen :-/
comment on: http://stackoverflow.com/q/22091577
score: 0
type: QuestionComment

http://stackoverflow.com/comment/33436802
type: Comment
has text: C# looks a lot like Java, but just different enough for Microsoft to avoid getting sued again. :) :) [It's a good language, though.]
comment on: http://stackoverflow.com/a/22052217
score: 0
type: AnswerComment

http://stackoverflow.com/a/22129958
has body: Default maximum number of open files and or sockets on Linux machines is 1024. If your test exceeds it although shouldn't you need to inspect your test and detect and fix leaks. If it's expected and you just increase limits on files/sockets it should be possible to increase them to reasonably higher value. See ulimit command reference and information on limits.conf file.Alternatively you could try running JMeter as root user. To get maximum number of allowed open files execute ulimit -n in terminal References: JMeter Performance and Tuning Tips - guide on JMeter tuning and best practices Linux ulimit command reference limits.conf file documentation Hope this helps
score: 1
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/22128363
type: Answer

http://stackoverflow.com/q/22057333
type: Question
has comment: http://stackoverflow.com/comment/33446019
has body: I get a NPE when I run a test on an activity whose onCreate() method checks if a particular service is running. In the setup method of the test, I call: ActivityController&lt;MyActivity&gt; ac = Robolectric.buildActivity(MyActivity.class).create(); mActivity = ac.get(); In the onCreate() method of the activity, I call isServiceRunning() ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); if(manager != null) { for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (service.service != null &amp;&amp; "MyService".equals(service.service.getClassName())) { return true; } } } return false; It fails with NPE when it executes this: for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) manager is not null, but the NPE is thrown in ActivityManager.getRunningServices(int) in the android library. What should I do if I need this method to pass? I was using Roboelectric 2.2-20130612.001729-6-jar-with-dependencies.jar but I see the problem now even with the latest version. I was using android SDK version 19, but I now switched to 18 and I still see the problem. Any ideas? Stack trace: java.lang.NullPointerException at android.app.ActivityManager.getRunningServices(ActivityManager.java:1106) at com.example.MyActivity.isServiceRunning(MyActivity.java:151) at com.example.MyActivity.onCreate(MyActivity.java:43) at android.app.Activity.performCreate(Activity.java:5133) at org.fest.reflect.method.Invoker.invoke(Invoker.java:112) at org.robolectric.util.ActivityController$1.run(ActivityController.java:116) at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:257) at org.robolectric.util.ActivityController.create(ActivityController.java:111) at org.robolectric.util.ActivityController.create(ActivityController.java:123) at com.example.test.MyActivityTest.setUp(MyActivityTest.java:44) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at …
tagged with: android-testing
answer count: 1
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/31759387
type: UnansweredQuestion
tagged with: android
score: 6
upvote count: 6
has title: Nullpointerexception when I check for running service in Roboelectric test
tagged with: java

http://stackoverflow.com/comment/33543086
has text: Advice: Use `!CONFLAG` instead of `CONFLAG == false`. Also, UPPERCASE words are used for constants. You could name that variable `conflag`.
comment on: http://stackoverflow.com/q/22111465
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33592171
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/22138865
type: Comment
has text: Please read [How to ask](https://stackoverflow.com/questions/how-to-ask) and then [edit] your question accordingly.

http://stackoverflow.com/comment/33589948
comment on: http://stackoverflow.com/q/22137333
type: Comment
type: QuestionComment
has text: Any of the JSON parsing libraries available (the only exception being to horrid simple json thing) will parse this JSON, and provide you with an array of Java objects.
score: 0

http://stackoverflow.com/comment/33638966
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22164938
has text: U are not using annotations but mapping file whitch is fine. I personally prefer annotations. Any way, you have to either pull existing project from DB, OR create UPDATE query that will fullfil your specific requirements.
type: AnswerComment

http://stackoverflow.com/comment/33472833
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22072845
has text: Out of curiosity, did you set such a path up on your own system? Was it simple?

http://stackoverflow.com/a/63517855
has body: The best way for me : Fragment: if content is given from model: else:
downvote count: 0
score: 1
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/22093149

http://stackoverflow.com/q/22034910
accepted answer: http://stackoverflow.com/a/22037932
tagged with: java
has comment: http://stackoverflow.com/comment/33409100
has comment: http://stackoverflow.com/comment/33408571
has comment: http://stackoverflow.com/comment/33409892
has comment: http://stackoverflow.com/comment/33408874
type: Question
has title: Implementing basic REST API - ServletException
tagged with: jersey
has answer: http://stackoverflow.com/a/22037932
has comment: http://stackoverflow.com/comment/33410469
tagged with: tomcat
score: 0
has comment: http://stackoverflow.com/comment/33409496
tagged with: rest
answer count: 3
has comment: http://stackoverflow.com/comment/33406856
has answer: http://stackoverflow.com/a/22035700
possible better answer: http://stackoverflow.com/a/22034977
has body: I'm trying to run a sample basic REST API on Eclipse but have been getting ServletException. Here is the code: Employee.java package net.javabeat.articles.spring.rest.simple; public class Employee { private String id; private String name; private String department; public Employee(){} public Employee(String id, String name, String department){ this.id = id; this.name = name; this.department = department; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDepartment() { return department; } public void setDepartment(String department) { this.department = department; } public String toString(){ StringBuilder result = new StringBuilder(); result.append("[employee]"); result.append("[id]" + id + "[id]"); result.append("[name]" + name + "[name]"); result.append("[department]" + department + "[department]"); result.append("[employee]"); return result.toString(); } public String toXmlString(){ StringBuilder result = new StringBuilder(); result.append(" "); result.append(" " + id + " "); result.append(" " + name + " "); result.append(" " + department + " "); result.append(" "); return result.toString(); } } EmployeeManager.java package net.javabeat.articles.spring.rest.simple; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Path("employee-manager") public class EmployeeManager { private static Set employees; @GET @Produces(MediaType.TEXT_XML) @Path("employeelist") public String getEmployeesInXmlFormat(){ StringBuilder xmlResult = new StringBuilder(); xmlResult.append(" "); Iterator iterator = employees.iterator(); while (iterator.hasNext()){ Employee employee = iterator.next(); String employeeAsXml = employee.toXmlString(); xmlResult.append(employeeAsXml); } xmlResult.append(" "); return xm…
has comment: http://stackoverflow.com/comment/33408553
has answer: http://stackoverflow.com/a/22034977
has comment: http://stackoverflow.com/comment/33405934
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33409332

http://stackoverflow.com/a/22147045
upvote count: 3
has comment: http://stackoverflow.com/comment/33608021
downvote count: 3
accepted answer of: http://stackoverflow.com/q/22146899
answers question: http://stackoverflow.com/q/22146899
has comment: http://stackoverflow.com/comment/33608618
has comment: http://stackoverflow.com/comment/33608714
score: 0
has comment: http://stackoverflow.com/comment/33641470
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33635697
has comment: http://stackoverflow.com/comment/33797834
has comment: http://stackoverflow.com/comment/102663674
type: Answer
has comment: http://stackoverflow.com/comment/33645224
has comment: http://stackoverflow.com/comment/33611629
has body: Your main thread is not closed - // ... System.out.println("Main close..."); // &lt;--- Your main method is here while all the other threads complete (sort of). } On part 2 of your question - There is no connection between join and synchronized. They are almost opposite. join - Wait for the thread to complete before resuming. synchronized - Only one thread can enter here, all others must wait.
has comment: http://stackoverflow.com/comment/33643673
has comment: http://stackoverflow.com/comment/33607749
has comment: http://stackoverflow.com/comment/33797399

http://stackoverflow.com/comment/33582383
comment on: http://stackoverflow.com/a/22073211
type: AnswerComment
has text: I guess you should be able to pass the message along. Instead of writing your own you can always look at Spring Integration. That way you would only need to configure things and don't need to program anything. All the heavy lifting will be done by Spring Integration that way.
score: 0
type: Comment

http://stackoverflow.com/comment/33539190
type: Comment
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/22109197
has text: I am not sure if it's proper to do your homework for you, what is your specific question other than the use of main which I would consider part of your assignment to learn.

http://stackoverflow.com/q/22135449
type: AnsweredQuestion
tagged with: java
tagged with: concurrency
has title: Maintaining unique objects for names with concurrent delete
has comment: http://stackoverflow.com/comment/34520716
type: Question
has comment: http://stackoverflow.com/comment/33587335
has comment: http://stackoverflow.com/comment/33587538
has answer: http://stackoverflow.com/a/22664794
tagged with: hashmap
score: 2
downvote count: 0
answer count: 6
linked to: http://stackoverflow.com/q/19278443
has answer: http://stackoverflow.com/a/22696966
possible better answer: http://stackoverflow.com/a/22141825
has answer: http://stackoverflow.com/a/22141825
has body: I am using the following programming idiom. I keep a synchronized HashMap with an association of names to objects. To lookup an object for a name I use the following code: MyObject getObject(String name) { synchronized(map) { MyObject obj = map.get(name); if (obj == null) { obj = new MyObjec(); map.put(name, obj); } } } When I then want to work exclusively on such an object I will use a synchronized on such an object: synchronized(obj) { /* do something exclusively on obj (work type I) */ } This has been working fine so far until recently. The new requirement is that there are type I and type II exclusive works. Type I will keep the object and type II should remove the object after it has completed the work. If I do something along the following: synchronized(obj) { /* do something exclusively on obj (work type II) */ } synchronized(map) { /* not good! */ map.remove(obj); } I might grant some object some type I work, although the object has already been removed from the map. So basically the synchronized(obj) for type I work should be replaced by some new semaphore which rejoins the object to the map in case a type II work was granted before. Respectively the object should only leave the map when no sychronized are pending on it. Best would be if the objects are not seen. I would go with an API with the names only. The objects are only used to maintain some state for the names. But the HashMap should be freed from the name after type II work has been completed. But during type I or type II work, the HashMap should not be locked. Any ideas how to do that? Is this a known pattern? Bye
has answer: http://stackoverflow.com/a/22670976
favorite count: 0
has comment: http://stackoverflow.com/comment/34212843
upvote count: 2
accepted answer: http://stackoverflow.com/a/22696966
has comment: http://stackoverflow.com/comment/33587478
has answer: http://stackoverflow.com/a/22499653
has answer: http://stackoverflow.com/a/22686537

http://stackoverflow.com/q/22054383
answer count: 2
has answer: http://stackoverflow.com/a/22054486
linked to: http://stackoverflow.com/q/14548808
linked to: http://stackoverflow.com/q/19648833
downvote count: 0
has title: How to resize a BufferedImage in Java
favorite count: 0
has body: I am looking for the simplest (and still non-problematic) way to resize a BufferedImage in Java. In some answer to a question, the user coobird suggested the following solution, in his words (very slightly changed by me): ** The Graphics object has a method to draw an Image while also performing a resize operation: Graphics.drawImage(Image, int, int, int, int, ImageObserver) method can be used to specify the location along with the size of the image when drawing. So, we could use a piece of code like this: BufferedImage originalImage = // .. created somehow BufferedImage newImage = new BufferedImage(SMALL_SIZE, SMALL_SIZE, BufferedImage.TYPE_INT_RGB); Graphics g = newImage.createGraphics(); g.drawImage(originalImage, 0, 0, SMALL_SIZE, SMALL_SIZE, null); g.dispose(); This will take originalImage and draw it on the newImage with the width and height of SMALL_SIZE. ** This solution seems rather simple. I have two questions about it: Will it also work (using the exact same code), if I want to resize an image to a larger size, not only a smaller one? Are there any problems with this solution? If there is a better way to do this, please suggest it. Thanks
has answer: http://stackoverflow.com/a/22055136
type: UnansweredQuestion
score: 3
linked to: http://stackoverflow.com/q/11959758
linked to: http://stackoverflow.com/q/14115950
upvote count: 3
tagged with: java
linked to: http://stackoverflow.com/q/7951290
tagged with: bufferedimage
type: Question

http://stackoverflow.com/q/22105318
favorite count: 0
type: Question
tagged with: jlist
tagged with: jdbc
has comment: http://stackoverflow.com/comment/33533472
has comment: http://stackoverflow.com/comment/33533203
has comment: http://stackoverflow.com/comment/33532502
has answer: http://stackoverflow.com/a/37565118
score: -1
has comment: http://stackoverflow.com/comment/33533583
has title: Working with JList
tagged with: swing
downvote count: 1
has comment: http://stackoverflow.com/comment/33532511
has comment: http://stackoverflow.com/comment/33609375
has comment: http://stackoverflow.com/comment/33532316
tagged with: java
type: UnansweredQuestion
has body: I I have JList and JList model that contains values of database fields (student table). I want to get all the data form the JList and store the data in String variable call mySql I want the data to be stored like this: -"SELECT " - then the data from jList separated by comma -" FROM" How can I do this? This is what I did so far: ListModel a = myList.getModel(); String obj = null; String obj2 = null; System.out.print("SELECT "); for (int i = 0; i &lt; a.getSize(); i++) { if (i == a.getSize() - 1) { obj = (String) a.getElementAt(i); System.out.print(obj); } else { obj2 = a.getElementAt(i) + ","; System.out.print(obj2); } } System.out.print(" FROM "); I changed the code to this ListModel a = list2.getModel(); String obj = null; String obj2 = null; // System.out.print("SELECT "); for (int i = 0; i &lt; a.getSize(); i++) { if (i == a.getSize() - 1) { obj = (String) a.getElementAt(i); // System.out.print(obj); } else { obj2 = a.getElementAt(i) + ","; // System.out.print(obj2); } System.err.println("This is obj2 "+obj2 +"This is obj "+ obj); } // System.out.print("SELECT "+obj2+obj+" FROM ");
answer count: 2
has comment: http://stackoverflow.com/comment/33533040
upvote count: 0
tagged with: string-concatenation
has answer: http://stackoverflow.com/a/22106142

http://stackoverflow.com/comment/33574054
comment on: http://stackoverflow.com/a/22127116
has text: Hey @DaveNewton 1) Since the assertion expects the method to return a non-null value 2) And the signature explicitly expects a Properties to be returned. Which means that a non-null value will definitely be a Properties. Can I say that it is sufficient for test that the method returns a non null value, since non null value will definitely be a Properties. Appreciate if you have any more opinions on this!
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33630058
comment on: http://stackoverflow.com/q/22158475
type: Comment
type: QuestionComment
has text: Please define "can't read the message sent from my application". The server cannot distinguish these two cases. You must be doing something else wrong, for example incorrect or absent line termination.
score: 1

http://stackoverflow.com/comment/33463831
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22067933
has text: temp1 = temp.replace('-', temp.charAt(p)); In this line, instead of temp.charAt(p) use word.charAt(p) because temp is ----- and not sample when you have written temp = word.replaceAll(word, "-"); This will help you.....

http://stackoverflow.com/a/22084990
has comment: http://stackoverflow.com/comment/33495566
accepted answer of: http://stackoverflow.com/q/22084891
has body: You can read the file and translate it like below: BufferedReader br = new BufferedReader(new FileReader(file)); String line; int num = 0; NumberTranslator myAwesomeTranslator = new NumberTranslator(); while ((line = br.readLine()) != null) { try { num = Integer.parseInt(line); System.out.println(myAwesomeTranslator.translate(num)); } catch (NumberFormatException e) { System.out.println("I thought you were an int :("); } } br.close();
has comment: http://stackoverflow.com/comment/33495834
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/33495626
score: 1
has comment: http://stackoverflow.com/comment/33495959
answers question: http://stackoverflow.com/q/22084891
has comment: http://stackoverflow.com/comment/33495881
has comment: http://stackoverflow.com/comment/33495955
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33495924
has comment: http://stackoverflow.com/comment/33495751
has comment: http://stackoverflow.com/comment/33495533
has comment: http://stackoverflow.com/comment/33495584
has comment: http://stackoverflow.com/comment/33495669

http://stackoverflow.com/comment/33495170
type: QuestionComment
has text: Also, you have `protected String doInBackground()` but you are returning null.
score: 0
comment on: http://stackoverflow.com/q/22084766
type: Comment

http://stackoverflow.com/a/22060056
has comment: http://stackoverflow.com/comment/33455772
has comment: http://stackoverflow.com/comment/33452720
score: 0
type: AcceptedAnswer
type: Answer
answers question: http://stackoverflow.com/q/22042973
has body: A few suggestion to make it work - don't forget to set mime type in your case "text/xml" or "application/xml" You can not use both together out.println() and requestdispatcher as it will throw exception. out.println() will print the value in response body but request dispatcher will redirect you to some other page and incase of ajax what you will get is the whole content of the page where you redirected. so in your case you should only use out.println() So your final code should look like this - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/xml"); String forward = ""; try { String fluxXML = ""; ServicesCodeTypeFluxGlobaux servicesCodeTypeFluxGlobaux = new ServicesCodeTypeFluxGlobauxImpl(); fluxXML = "&lt;lescodetypeflux&gt;"; fluxXML += "&lt;/lescodetypeflux&gt;"; PrintWriter printWriter = response.getWriter(); printWriter.println(fluxXML); printWriter.close(); } } catch (Exception e) { //print xml with error value } }
accepted answer of: http://stackoverflow.com/q/22042973

jogl
tag name: jogl
type: Tag
tags question: http://stackoverflow.com/q/22031559

http://stackoverflow.com/q/22025169
type: UnansweredQuestion
upvote count: 1
has title: Button ActionListener runs both combo box choices at the same time why?
score: 1
tagged with: java
type: Question
tagged with: actionlistener
downvote count: 0
answer count: 1
tagged with: button
has answer: http://stackoverflow.com/a/22025212
has body: Hello I have a problem with my comboBox. In app that im making my panel has a combo box with two choices and a button next to the combo box to proceed to the choice selected in the combo box but instead both if Statements run and no I have no idea why. Combo box code is simple private JComboBox mainChoice = new JComboBox(); mainChoice.addItem("") etc... class mainPanelGoButtonListener implements ActionListener { public void actionPerformed(ActionEvent ae) { String choice = (String)mainChoice.getSelectedItem(); System.out.printf(choice); if(choice == "View Passenger Details"); { JTextField first = new JTextField(); JTextField last = new JTextField(); Object[] message = { "First Name:", first, "Last Name:", last }; int option = JOptionPane.showConfirmDialog(null, message, "Enter passenger name", JOptionPane.PLAIN_MESSAGE); if (option == JOptionPane.OK_OPTION) { // Load passenger data p = dataHandler.getPassengerData(first.getText(), last.getText()); if(p != null) { updateTextfields( p); // Display passenger data getContentPane().removeAll(); getContentPane().add(passengerDetailsPanel); setSize(400,340); setLocationRelativeTo(null); validate(); repaint(); printAll(getGraphics()); } } } if(choice == "Add New Passenger") { if(displayPassengerInputForm()); { // Display passenger data getContentPane().removeAll(); getContentPane().add(passengerDetailsPanel); setSize(400,340); setLocationRelativeTo(null); validate(); repaint(); printAll(getGraphics()); } } } } // EXAMPLE OF MY PROGRAM THAT RETURNS BOTH WINDOW A and WINDOW B import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class Frame extends JFrame { private JPanel mainPanel = new JPanel(); private JComboBox&lt;String&gt; mainChoice = new JComboBox&lt;String&gt;(); private JButton goButton = new JButton("GO"); public Frame() { createMainPanel(); this.add(mainPanel); } private void createMainPanel() { // Fill choice bo…
tagged with: combobox
favorite count: 0
tagged with: listener

http://stackoverflow.com/comment/33646266
type: QuestionComment
comment on: http://stackoverflow.com/q/22168156
score: 0
has text: @A4L Unknown error occurred: Class mapping not found by map-id: SRC-CLASS company DST-CLASS-> company MAP-ID-> company.This is the error i m getting when deploy the ear file in websphere application server.
type: Comment

http://stackoverflow.com/comment/33455856
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22062925
has text: the percentage i got starting from 100.0 and increasing based on intersection but it's not between 0 and 100% ?

http://stackoverflow.com/comment/33368940
has text: Note however that this is rather "definitive". If you intend to change that one day, going the custom serializer route will prove more suitable in the long run.
comment on: http://stackoverflow.com/a/22014693
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33454220
type: QuestionComment
comment on: http://stackoverflow.com/q/22062226
has text: i mean i dont need type . i want the word that i set can automatic filter without i type because i've set the text bro. thank you @ASP
type: Comment
score: 0

http://stackoverflow.com/comment/33398615
score: 0
comment on: http://stackoverflow.com/q/22030654
type: QuestionComment
type: Comment
has text: Your log shows that the error was `caused by` the method `getListSongs()` - can you post that code please

http://stackoverflow.com/comment/33621998
has text: Make your models observable. Follow MVC pattern.
type: Comment
comment on: http://stackoverflow.com/q/22155532
type: QuestionComment
score: 1

http://stackoverflow.com/q/22160198
answer count: 2
tagged with: google-maps
has comment: http://stackoverflow.com/comment/33631749
linked to: http://stackoverflow.com/q/15607427
tagged with: jmapviewer
has title: JMapViewer draw a polygon that will look like arrow
has comment: http://stackoverflow.com/comment/33631203
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22160995
tagged with: java
has body: I want to create an arrow (---->) on my map, connecting 2 given coordinates. By now I used the draw line using polygon implementation suggested here and here Is there a way to acheieve it? Thanks, Ozrad
linked to: http://stackoverflow.com/q/20252592
type: Question
linked to: http://stackoverflow.com/q/10744798
possible better answer: http://stackoverflow.com/a/22182544
has answer: http://stackoverflow.com/a/22182544
has comment: http://stackoverflow.com/comment/33631711
linked to: http://stackoverflow.com/q/20129281
accepted answer: http://stackoverflow.com/a/22160995
has comment: http://stackoverflow.com/comment/33631691
score: 0

http://stackoverflow.com/a/22118437
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33555592
accepted answer of: http://stackoverflow.com/q/22117933
type: Answer
has body: NoClassDefFoundError in Java comes when Java Virtual Machine is not able to find a particular class at runtime which was available during compile time. Please ck whether u have the req. jars under \WebContent\WEB-INF\lib in the project explorar as well as on the project build path.
answers question: http://stackoverflow.com/q/22117933
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/33555753

http://stackoverflow.com/comment/33545159
score: 0
comment on: http://stackoverflow.com/a/22112388
has text: I think so. But I use this one.
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33419094
score: 1
comment on: http://stackoverflow.com/q/22042120
type: Comment
type: QuestionComment
has text: Add *rejection policy* to the list of googlable keywords.

http://stackoverflow.com/q/22076643
score: 0
tagged with: java
tagged with: javafx
has answer: http://stackoverflow.com/a/22080421
has comment: http://stackoverflow.com/comment/33487948
has title: JavaFX media player burns resources
type: Question
answer count: 1
tagged with: media-player
has comment: http://stackoverflow.com/comment/33520824
has comment: http://stackoverflow.com/comment/33488094
tagged with: memory-leaks
tagged with: javafx-2
has comment: http://stackoverflow.com/comment/33488206
type: UnansweredQuestion
has body: I am currently using Javafx 2 for a project, where I might need to play a video in an infinite loop for a long time. On windows, when the video is playing my proifiler tool shows pretty normal pictures, cpu load is not very hard (running on 2 cores it is around 2x40-50%), and memory usage spikes around 250 MB, wich is normal. But, when I deploy the application on an Ubuntu machine, cpu load is spiking around 70% per core (altough it is a dual core atom processor, so let's say this is normal), and memory usage increases continually, while finally killing the JVM, and the device itself, under like 1,5-2 hours. I really need a solution, or at least a workaround to this issue, because it is a showstopper right now. I am currently thinking to hack around the infinite loop, and create a new Media/MediaPlayer object for each loop, but I am not sure, if it would solve the issue. Can you give me some insight on the issue? My code for initializing the MediaView: final Media m = new Media(new File(new ClientParameters().getProperty("video.path", String.class)).toURI() .toString()); final MediaPlayer player = new MediaPlayer(m); player.setMute(true); player.setCycleCount(MediaPlayer.INDEFINITE); player.setOnError(new Runnable() { @Override public void run() { log.warn("Video error", player.getError()); Main.loadAcceptablePrompt(Main.getCurrentLocaleResources().getString("Video_Hiba"), FxmlView.START_SCREEN, Main.DEFAULT_LOCALE, ScreenSaverVideoController.this); } }); m.setOnError(new Runnable() { @Override public void run() { showLoader(); Main.getScheduler().submit(new Runnable() { @Override public void run() { log.warn("Video error", player.getError()); Main.loadAcceptablePrompt(Main.getCurrentLocaleResources().getString("Video_Hiba"), FxmlView.START_SCREEN, Main.getCurrentLocale(), ScreenSaverVideoController.this); } }); } }); video.setMediaPlayer(player); video.getMediaPlayer().play(); Main.getScheduler() returns this Scheduler object: private static final ScheduledExecutor…

http://stackoverflow.com/a/22071538
has comment: http://stackoverflow.com/comment/33470486
has comment: http://stackoverflow.com/comment/33470589
answers question: http://stackoverflow.com/q/22071427
has body: Obviously this is because you did not create a JDBC realm user /Hans/
has comment: http://stackoverflow.com/comment/33584700
has comment: http://stackoverflow.com/comment/33505062
score: 0
has comment: http://stackoverflow.com/comment/33602770
type: Answer
has comment: http://stackoverflow.com/comment/33575101
has comment: http://stackoverflow.com/comment/33607101

http://stackoverflow.com/comment/33682033
comment on: http://stackoverflow.com/q/22109799
has text: Try running the message through md5 hash, which is sensitive to the numbers of bits digested, and compare hashes
type: Comment
type: QuestionComment
score: 0

layout
tags question: http://stackoverflow.com/q/22155760
tags question: http://stackoverflow.com/q/22076597
tags question: http://stackoverflow.com/q/22050639
tag name: layout
tags question: http://stackoverflow.com/q/22050591
tags question: http://stackoverflow.com/q/22025029
tags question: http://stackoverflow.com/q/22158288
tags question: http://stackoverflow.com/q/22081292
tags question: http://stackoverflow.com/q/22088820
tags question: http://stackoverflow.com/q/22082112
type: Tag
tags question: http://stackoverflow.com/q/22102497
tags question: http://stackoverflow.com/q/22115857
tags question: http://stackoverflow.com/q/22143307
tags question: http://stackoverflow.com/q/22033266
tags question: http://stackoverflow.com/q/22127307

http://stackoverflow.com/comment/33400477
has text: @StinePike `substring` doesn't help, I don't know the index, need to 'find' the decimal point.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22031789

http://stackoverflow.com/a/22080337
has body: the next value of directory[i+1] is never going to be null @"if (directory[i+1] != null){" because before the else statment you check to see if directory[i+1] == null my guess is a small typo in iteration maybe you ment directory[k+1]?
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/22080109
upvote count: 1

http://stackoverflow.com/comment/33601833
comment on: http://stackoverflow.com/a/22141540
type: AnswerComment
score: 0
type: Comment
has text: You are correct, it should be xerces (I was mixing another thread) - I've just edited the answer, thank you

http://stackoverflow.com/q/22011553
tagged with: android
has comment: http://stackoverflow.com/comment/63210515
score: 3
upvote count: 3
tagged with: java
has title: java.lang.RuntimeException: Unable to get provider - for System group app (system/priv-app/)
type: Question
has comment: http://stackoverflow.com/comment/36764950
has comment: http://stackoverflow.com/comment/36814965
tagged with: runtimeexception
has body: I have my application installed along with the android kitkat binary itself (built with whole binary) under system/priv-app/FileSample.apk I am getting the below exception in some rare case. But could not reproduce it again. I am not using proguard also. I checked all the related issues from StackOverflow, but none of them were related to this kind of system app issue. So kindly some one help me to find out the root cause for this FATAL Exception. java.lang.RuntimeException: Unable to get provider com.file.SearchProvider: java.lang.ClassNotFoundException: Didn't find class "com.file.SearchProvider" on path: DexPathList[[zip file "/system/priv-app/FileSample.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] 01-04 03:16:03.005 8340 8340 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:5115) 01-04 03:16:03.005 8340 8340 E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:4707) 01-04 03:16:03.005 8340 8340 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4590) 01-04 03:16:03.005 8340 8340 E AndroidRuntime: at android.app.ActivityThread.access$1600(ActivityThread.java:169) 01-04 03:16:03.005 8340 8340 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1337) 01-04 03:16:03.005 8340 8340 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102) 01-04 03:16:03.005 8340 8340 E AndroidRuntime: at android.os.Looper.loop(Looper.java:136) 01-04 03:16:03.005 8340 8340 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5476) 01-04 03:16:03.005 8340 8340 E AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method) 01-04 03:16:03.005 8340 8340 E AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:515) 01-04 03:16:03.005 8340 8340 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268) 01-04 03:16:03.005 8340 8340 E Androi…
answer count: 1
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/23882095
type: UnansweredQuestion

http://stackoverflow.com/q/22022387
type: Question
has title: Running Web Logic 8.1 Web Service using JAX-RPC Stack on Web Logic 12
downvote count: 0
favorite count: 0
answer count: 0
type: UnansweredQuestion
score: 1
tagged with: jax-ws
upvote count: 1
tagged with: web-services
has body: We are currently in the upgrade phase of upgrading to Java7/Weblogic12c (from Java1.5/WebLogic10.1). Our builds is using Maven 2.5. Our focus is to change as little java code as possible to narrow the scope of where to look for what went wrong in case it did. Hence we would like to ideally not rewrite our code (That would be the next phase that will be handled later). Our Web services are still using the RPC style like in Web Logic 8.1. This video basically out line the differences Module 13.2 JAXRPC vs. JAXWS And in the oracle documentation they describe how the code should be changed to be WS compliant: Upgrading an 8.1 Web Logic Web Service to the Web Logic JAX-RPC Stack Is there no way to use the RPC as is running web logic 12?
tagged with: jax-rpc
tagged with: weblogic12c
tagged with: java

http://stackoverflow.com/a/22037080
has comment: http://stackoverflow.com/comment/33412002
has comment: http://stackoverflow.com/comment/33447480
has body: Error here delegate.processFinish(result); need to assign instance for delegate.
downvote count: 0
has comment: http://stackoverflow.com/comment/33410712
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/22037005
score: 2
has comment: http://stackoverflow.com/comment/33417232

http://stackoverflow.com/a/22078139
answers question: http://stackoverflow.com/q/22078111
type: Answer
score: 2
downvote count: 0
has body: Change getFSResultsTitleOne setFSResultsTitleOne to getFsResultsTitleOne setFsResultsTitleOne
upvote count: 2
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22078111
has comment: http://stackoverflow.com/comment/33482825

http://stackoverflow.com/a/22089579
upvote count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33504482
has comment: http://stackoverflow.com/comment/33503423
has comment: http://stackoverflow.com/comment/33503340
has comment: http://stackoverflow.com/comment/33503554
answers question: http://stackoverflow.com/q/22089481
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/33503689
has body: A lot depends on your processes...for example, depending on you installation process, you could execute a specific piece of code which builds the database and tables when the application is installed. Many installers do provide the means to do this, but are typically focused on the platform they are designed for (such as executing a .exe on Windows) OR You could, when the application is launched, do a check for the existence of the database/tables and do a "first" run setup process OR You could pre-create the database and tables and package it as part of the installer...

http://stackoverflow.com/q/22088064
type: UnansweredQuestion
tagged with: slf4j
has body: In my current Java application.. I should create separate log files with the different string received from multiple threads and corresponding messages should go to that particular log file.. Is there any way to change the log file name in log4j.properties dynamically without doing in a programmatic way.I tried setting System.setProperty("logFile.name", str); but once SystemProperty is set the class loader wont change each and every time. Is there any way to of setting it many time or any other way ?
downvote count: 0
answer count: 0
score: 1
tagged with: log4j
favorite count: 0
has comment: http://stackoverflow.com/comment/33594437
type: Question
has title: passing File name programmatically for log4j.property file
tagged with: java
upvote count: 1
has comment: http://stackoverflow.com/comment/33501073

http://stackoverflow.com/a/22024602
type: Answer
answers question: http://stackoverflow.com/q/22023377
upvote count: 3
accepted answer of: http://stackoverflow.com/q/22023377
score: 3
has body: Jackson uses a MapSerializer to serialize Map types and uses a StdKeySerializer to serialize the keys. It's implemented as @Override public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if (value instanceof Date) { provider.defaultSerializeDateKey((Date) value, jgen); } else { jgen.writeFieldName(value.toString()); } } which you can see just gets the toString() value of your object. So you can override the toString() method in your enum as such public String toString() { return getValue(); } The @JsonValue becomes useless. Alternatively, if you need the toString() to remain the same (or default), you can create a custom type that wraps your Map class CustomType { private Map&lt;ClusterType, String&gt; map; @JsonAnyGetter // necessary to unwrap the Map to the root object, see here: http://jira.codehaus.org/browse/JACKSON-765 @JsonSerialize(keyUsing = ClusterTypeKeySerializer.class) public Map&lt;ClusterType, String&gt; getMap() { return map; } public void setMap(Map&lt;ClusterType, String&gt; map) { this.map = map; } } and uses a custom JsonSerializer class ClusterTypeKeySerializer extends StdSerializer&lt;ClusterType&gt; { protected ClusterTypeKeySerializer() { super(ClusterType.class); } @Override public void serialize(ClusterType value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { jgen.writeFieldName(value.getValue()); } } that uses the ClusterType#getValue() method. Again, we don't use @JsonValue.
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/33500091
has text: see also http://stackoverflow.com/questions/3522454/java-tree-data-structure?rq=1
score: 0
comment on: http://stackoverflow.com/q/22087657
type: QuestionComment
type: Comment

http://stackoverflow.com/q/22088738
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33501882
tagged with: testng
has answer: http://stackoverflow.com/a/22088775
tagged with: java
tagged with: unit-testing
has answer: http://stackoverflow.com/a/22088830
type: Question
has body: Consider the test messageTest(see below) publicclassmessageTest { @Test publicvoidtestMessageLength() { String message = "Test Message"; } } Add Assert method to verify that text in message contains 12 characters.
score: -1
answer count: 2
downvote count: 2
has comment: http://stackoverflow.com/comment/33502257
upvote count: 1
favorite count: 0
has title: Java: How to verify that String has many characters

http://stackoverflow.com/q/22141856
has body: Well For Showcase View I using this: https://github.com/amlcurran/ShowcaseView After importing files it gives error. this is my errors and improted .jar files Errors says in java R cannot be resolved to a variable in style error: Error retrieving parent for item: No resource found that matches the given name 'Theme.Sherlock.Light'. again, in style error: Error: No resource found that matches the given name: attr 'android:fontFamily'. Also Are there any tutorial to use Showcase view in my project. I can not find and I didnt understant from github project. it is not clear.
upvote count: 5
tagged with: java
answer count: 5
has answer: http://stackoverflow.com/a/22142336
tagged with: showcaseview
has answer: http://stackoverflow.com/a/52619873
has answer: http://stackoverflow.com/a/24136896
type: AnsweredQuestion
downvote count: 0
possible better answer: http://stackoverflow.com/a/45743345
tagged with: github
has answer: http://stackoverflow.com/a/45743345
favorite count: 0
has comment: http://stackoverflow.com/comment/33597625
type: Question
has comment: http://stackoverflow.com/comment/33597418
tagged with: android
accepted answer: http://stackoverflow.com/a/52619873
has title: Android Showcase View how to use?
score: 5
has answer: http://stackoverflow.com/a/53303841
tagged with: import-libraries

http://stackoverflow.com/a/22150503
has comment: http://stackoverflow.com/comment/33613095
upvote count: 2
has body: there is no need for a while loop. The value of moviearray[i].getTitle() never changes, so it will remain true if it was not null to begin with, which means the while loop will loop forever. Just do a if(moviearray[i].getTitle() != null) instead.
downvote count: 1
has comment: http://stackoverflow.com/comment/33612809
has comment: http://stackoverflow.com/comment/33612942
answers question: http://stackoverflow.com/q/22150454
type: Answer
score: 1

http://stackoverflow.com/q/22032342
upvote count: 3
has comment: http://stackoverflow.com/comment/33401264
tagged with: java
has body: I have a problem on my homework, and I am having trouble getting the last part to work. What am I doing wrong here? It will not print "Circle 2 overlaps Circle 1." or "Circle 2 does not overlap Circle 1." The first two cases do print. Here is the question: Write a program (TwoCircles.java) that prompts the user to enter the center coordinates and radii of two circles and determines the geometrical relationship between the two and print one of the following messages accordingly: 1. Circle 1 is inside Circle 2. 2. Circle 2 is inside Circle 1. 3. Circle 2 overlaps Circle 1. 4. Circle 2 does not overlap Circle 1. Here is what i have so far for my code: import java.util.Scanner; public class TwoCircles { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.print("Enter Circle 1 center x-, y-coordinates, and radius: "); double X1 = input.nextDouble(); double Y1 = input.nextDouble(); double radius1 = input.nextDouble(); System.out.print("Enter Circle 2 center x-, y-coordinates, and radius: "); double X2 = input.nextDouble(); double Y2 = input.nextDouble(); double radius2 = input.nextDouble(); double distance = Math.pow((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2), 0.5); if (radius2 &gt;= radius1){ if (distance &lt;= (radius2 - radius1)) System.out.println("Circle 1 is inside Circle 2.");} else if (radius1 &gt;= radius2){ if (distance &lt;= (radius1 - radius2)) System.out.println("Circle 2 is inside Circle 1.");} else if (distance &gt; (radius1 + radius2)){ System.out.println("Circle 2 does not overlap Circle 1.");} else { System.out.println("Circle 2 overlaps Circle 1.");} } } Any guidance appreciated
type: Question
answer count: 2
has title: Java - Two Circles overlap or inside
downvote count: 0
has comment: http://stackoverflow.com/comment/33401513
has answer: http://stackoverflow.com/a/22032519
score: 3
favorite count: 0
has comment: http://stackoverflow.com/comment/33401299
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22032522

http://stackoverflow.com/q/22075355
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/22076503
tagged with: android
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22076503
has body: I'm new with java/android development so please help if you can. I would like to have a method which is getting me data from web service (async) and once done (onSuccess or onFailure) it should call another method on activity class. Lets say I have WebManager class, this isn't real method, I'm going to add more still plus try/catch and so on: public class WebManager { public MyObject1 getObject1() { AsyncHttpClient client = new AsyncHttpClient(); client.get(QUERY_URL, new JsonHttpResponseHandler() { @Override public void onSuccess(JSONObject jsonObject) { //Call method on my Activity and pass jsonObject (in the other method I want to pass my custom object instead of json) } @Override public void onFailure(int statusCode, Throwable throwable, JSONObject error) { //Call method on my Activity and pass statusCode, throwable and error } }); } public MyObject2 getObject2() { AsyncHttpClient client = new AsyncHttpClient(); // The same as above } } Now in my MainActivity I would like to call let's say getObject1() and when the data are download I would like to call method: WebManager wm = new WebManager(); //... protected void onObject1DataDownload(JSONObject jsonObject) { //Do something with the data } protected void onObject2DataDownload(CUSTOMOBJECT obj) { //Do something with the data } How can I achieve something like that? Thanks in advance
type: Question
tagged with: java
has title: Call method from onSuccess to another class
has answer: http://stackoverflow.com/a/22075928
accepted answer: http://stackoverflow.com/a/22075928

http://stackoverflow.com/a/22100053
type: Answer
accepted answer of: http://stackoverflow.com/q/22041026
answers question: http://stackoverflow.com/q/22041026
type: AcceptedAnswer
has body: Having attached the OpenSessionInViewFilter source and put some stops in the getSession() and closeSession() methods, it became clear that it was not being used. Further searching revealed that the order of the filter-mappings in web.xml is significant in this respect. Moving the filter-mapping for OpenSessionInViewFilter to before the one for my servlet filter solved the problem. Thanks to all who replied.
score: 0

http://stackoverflow.com/comment/33631734
comment on: http://stackoverflow.com/q/22160936
type: Comment
type: QuestionComment
has text: What do you mean? `new int[1500]` will give you an array of `int` -- it's impossible for it to do anything else.
score: 0

http://stackoverflow.com/q/22031319
upvote count: 0
has answer: http://stackoverflow.com/a/22032245
answer count: 1
favorite count: 0
has body: I need help tweaking my code. I need to write a program that outputs the count of individual ascii characters in a txt file that the user uploads, but I'm having a lot of problems trying to get the array that I count into the GUI portion of the program that "draws" the data on the screen. I have the output looking how I want, but I can't figure out how to get the character count up there I want to put the number of times a character/punction/number is used in a file that the user uploads on a graphic display. For instance, 33 or ! there are 3 instances. Or 65 A there are 4354 instances in the file. However I'm having a large problem with getting the counter to count the characters in the word correctly, and even more trouble getting the stored array of numbers of characters to the GUI (g.draw) section of the program. Instead of a number, I just get a blank output column. import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.FileReader; // both needed import java.io.BufferedReader; import java.io.IOException; public class textreader extends Frame implements ActionListener { String dataFilePath = null; String dataFileName = null; int[] counter = new int[256]; String command = ""; public static void main(String[] args) { Frame frame = new textreader(); frame.setResizable(true); frame.setSize(1000,850); frame.setVisible(true); } public textreader() { setTitle("Text File Processing"); // Menu Creation MenuBar mn = new MenuBar(); setMenuBar(mn); // Create "File" and add it Menu fileMenu = new Menu("File"); mn.add(fileMenu); // Create Menu Items, Add action Listener, Add to "File" Menu Group // Open file MenuItem miOpen = new MenuItem("Open"); miOpen.addActionListener(this); fileMenu.add(miOpen); // Process file MenuItem miProcess = new MenuItem("Process"); miProcess.addActionListener(this); fileMenu.add(miProcess); // Exit program MenuItem miExit = new MenuItem("Exit"); miExit.addActionListener(this); fileMenu.add(miExit); // To Terminate Window…
has comment: http://stackoverflow.com/comment/33400997
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22032245
has title: Java: Moving arrays to different methods in regards to text
tagged with: java
downvote count: 2
type: Question
has comment: http://stackoverflow.com/comment/33399795
has comment: http://stackoverflow.com/comment/33399857
score: -2
tagged with: arrays
tagged with: text-processing
tagged with: sorting

http://stackoverflow.com/comment/33538732
type: QuestionComment
has text: +1 to the batch search option for avoiding jar name changes. Added benefit, especially since OP says the batch script is to guard against future updates, is that if new releases have additional classpath requirements (other jars) they will be auto-included (assuming `for` loop builds `-cp` value via concatenation).
type: Comment
comment on: http://stackoverflow.com/q/22108606
score: 0

http://stackoverflow.com/comment/33535550
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22106840
has text: More likely what you've got is leftover classfiles from the last successful compilation...

http://stackoverflow.com/a/50295872
upvote count: 3
answers question: http://stackoverflow.com/q/22070173
score: 3
downvote count: 0
has body: Boris's answer still works but deprecated. It is recommended to use builder class: CSVReader reader = new CSVReaderBuilder(new FileReader("yourfile.csv")) .withSkipLines(13) .withCSVParser(new CSVParserBuilder().withSeparator('\t').withEscapeChar('\'').build()) .build();
type: Answer

http://stackoverflow.com/q/22125394
tagged with: coding-style
type: AnsweredQuestion
has body: For consistency I want to add "this." prefix to all classes members. I have done it when I wrote the code, mostly. How can I get Eclipse to add "this." to the members I forgot. I found that Java Editor Coding style has a check option for that, but when I clean up, or format the code the prefix is not added where it is missing.
has title: Eclipse IDE: complete class member names with "this." prefix
score: 1
tagged with: java
tagged with: eclipse
type: Question
answer count: 1
downvote count: 0
has answer: http://stackoverflow.com/a/22125922
favorite count: 0
has comment: http://stackoverflow.com/comment/33568435
has comment: http://stackoverflow.com/comment/33568840
upvote count: 1
accepted answer: http://stackoverflow.com/a/22125922

http://stackoverflow.com/comment/33486770
comment on: http://stackoverflow.com/q/22080109
score: 0
has text: Sorry for not making the question clear, I have fixed the question now :)
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22070764
answer count: 1
downvote count: 0
tagged with: tomcat
favorite count: 0
has title: ClassNotFoundException with wicket on Tomcat, Spring, Maven and Eclipse during server startup
has answer: http://stackoverflow.com/a/22083016
has comment: http://stackoverflow.com/comment/33469216
upvote count: 2
tagged with: maven
has comment: http://stackoverflow.com/comment/33475152
tagged with: spring
has comment: http://stackoverflow.com/comment/33469676
score: 2
type: AnsweredQuestion
has body: ClassNotFoundException with wicket on Tomcat, Spring and Eclipse during server startup. In Eclipse when i try to load the server i'm experiencing some errors causing a 404 page. Here's the stackTrace : org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'plop0' defined in ServletContext resource [/WEB-INF/spring-config/dependenciesInjectionContext.xml]: Cannot resolve reference to bean 'plop1' while setting bean property 'plop1'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'plop1': Injection of persistence fields failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.plop2.plop3.presentation.WicketApplication] for bean with name 'wicketApplication' defined in ServletContext resource [/WEB-INF/spring-config/wicketContext.xml]; nested exception is java.lang.ClassNotFoundException: com.plop2.plop3.presentation.WicketApplication at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275) ... at java.lang.Thread.run(Unknown Source) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'plop1': Injection of persistence fields failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.plop2.plop3.presentation.WicketApplication] for bean with name 'wicketApplication' defined in ServletContext resource [/WEB-INF/spring-config/wicketContext.xml]; nested exception is java.lang.ClassNotFoundException: com.plop2.plop3.presentation.WicketApplication at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessAfterInstantiation(PersistenceAnnotationBeanPostProcessor.java:311) ... at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) ... 26 more Caused by: org.…
has comment: http://stackoverflow.com/comment/33469239
accepted answer: http://stackoverflow.com/a/22083016
tagged with: java
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33468888
type: Question
has comment: http://stackoverflow.com/comment/33469420

http://stackoverflow.com/q/22154734
accepted answer: http://stackoverflow.com/a/22154850
has body: When I am trying to execute the below code,the compiler is throwing error at line 13 as "java.lang.ClassCastException". Can someone let me know what's wrong with below code? package chapter11; import java.util.*; public class ComparableExample { public static void main(String[] args) { // TODO Auto-generated method stub Item[] items = new Item[3]; items[0] = new Item(102, "Duct Tape"); items[1] = new Item(103, "Bailing Wire"); items[2] = new Item(104, "Chewing Gum"); Arrays.sort(items); for (Item i : items) { System.out.println(i.getNumber() + ":" + i.getDescription()); } } } interface Comparable { int compareTo(Object o); } class Item implements Comparable { private int number; private String description; public Item(int number, String description) { this.number = number; this.description = description; } public int getNumber() { return number; } public String getDescription() { return description; } public int compareTo(Object o) { Item i = (Item) o; if (this.getNumber() &lt; i.getNumber()) return -1; if (this.getNumber() &lt; i.getNumber()) return 1; return 0; } } Any help is appreciated, Thanks!!
has comment: http://stackoverflow.com/comment/33620682
upvote count: 1
has title: Class cast Exception while using Comparable interface
has comment: http://stackoverflow.com/comment/33620505
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22154850
score: 1
tagged with: java
tagged with: comparable
type: Question
has comment: http://stackoverflow.com/comment/33620329
answer count: 1
downvote count: 0
favorite count: 0
tagged with: classcastexception
has comment: http://stackoverflow.com/comment/33621086
has comment: http://stackoverflow.com/comment/33620460

http://stackoverflow.com/comment/33575893
has text: I did use a shared fixed thread pool in Java 6, but the Java 8 code is much more concise. With the thread pool I have to define an ArrayList of Futures, submit the worker to the executor, collect the results from the Futures. While this is the main motivation, I had the impression that the streams are more efficient (by about 10%).
type: Comment
comment on: http://stackoverflow.com/q/22129471
score: 0
type: QuestionComment

http://stackoverflow.com/a/22082375
has comment: http://stackoverflow.com/comment/33491504
downvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/33491321
has comment: http://stackoverflow.com/comment/33490923
has comment: http://stackoverflow.com/comment/33490961
has comment: http://stackoverflow.com/comment/33490966
answers question: http://stackoverflow.com/q/22082268
has body: The problem is with area and floors. You use them in static main method. That is not allowed. What is static and why is it so important? In Java everything you create has declared scope of visibility. You allocate files in packages, in files you create classes and in those you store members. The general concept is that a class is an template from witch you create objects. When you have object you can set the values to its field and call his methods and the action will be reflected only inside the object and all value will be assigned to object. When you use the static key word you mark a member to be no longer part of object but only element of class common to all object. Lets see the example class Sample { private int instance_value; private static int class_value; Sample(int first, int second) { instance_value = first; class_value = second; } public void print() { System.out.printf("instance_value=%i, class_value=%i\n",instance_value, class_value); } } We create now two objects of class Sample. Sample objectOne = new Sample(1,2); objectOne.print(); Sample objectTwo = new Sample(3,4); objectOne.print(); The output will be: instance_value=1, class_value=2 instance_value=1, class_value=4 The reason why in class_value has changed to 4 is because it is static and is the same for all element that use it. Note, you can access the static member from non static, what you can not do is to access the non static from static. Instead of using the names that you have declared in class body set the values in main You have this b.set_squarefootage(area); b.set_stories(stories); you may want to have this b.set_squarefootage(50.0); b.set_stories(5); Or define them once again to cover the scope. double area = 50.0; int storied = 5; b.set_squarefootage(area); b.set_stories(stories);
upvote count: 1
has comment: http://stackoverflow.com/comment/33491084
score: 0

http://stackoverflow.com/q/22052330
type: Question
accepted answer: http://stackoverflow.com/a/22062535
type: AnsweredQuestion
score: 26
has title: Usage of multiple inheritance in Java 8
favorite count: 0
has comment: http://stackoverflow.com/comment/33450195
answer count: 1
tagged with: java-8
tagged with: oop
has answer: http://stackoverflow.com/a/22062535
tagged with: java
upvote count: 26
has body: Am I using a feature of Java 8 or misusing it? Refer the code and explanation below to know as to why it was chosen to be like this. public interface Drawable { public void compileProgram(); public Program getProgram(); default public boolean isTessellated() { return false; } default public boolean isInstanced() { return false; } default public int getInstancesCount() { return 0; } public int getDataSize(); public FloatBuffer putData(final FloatBuffer dataBuffer); public int getDataMode(); public boolean isShadowReceiver(); public boolean isShadowCaster(); //TODO use for AABB calculations default public void drawDepthPass(final int offset, final Program depthNormalProgram, final Program depthTessellationProgram) { Program depthProgram = (isTessellated()) ? depthTessellationProgram : depthNormalProgram; if (isInstanced()) { depthProgram.use().drawArraysInstanced(getDataMode(), offset, getDataSize(), getInstancesCount()); } else { depthProgram.use().drawArrays(getDataMode(), offset, getDataSize()); } } default public void draw(final int offset) { if (isInstanced()) { getProgram().use().drawArraysInstanced(getDataMode(), offset, getDataSize(), getInstancesCount()); } else { getProgram().use().drawArrays(getDataMode(), offset, getDataSize()); } } default public void delete() { getProgram().delete(); } public static int countDataSize(final Collection&lt;Drawable&gt; drawables) { return drawables.stream() .mapToInt(Drawable::getDataSize) .sum(); } public static FloatBuffer putAllData(final List&lt;Drawable&gt; drawables) { FloatBuffer dataBuffer = BufferUtils.createFloatBuffer(countDataSize(drawables) * 3); drawables.stream().forEachOrdered(drawable -&gt; drawable.putData(dataBuffer)); return (FloatBuffer)dataBuffer.clear(); } public static void drawAllDepthPass(final List&lt;Drawable&gt; drawables, final Program depthNormalProgram, final Program depthTessellationProgram) { int offset = 0; for (Drawable drawable : drawables) { if (drawable.isShadowReceiver()) { drawable.d…
has comment: http://stackoverflow.com/comment/33453366
has comment: http://stackoverflow.com/comment/33446406
downvote count: 0
tagged with: multiple-inheritance
tagged with: inheritance
has comment: http://stackoverflow.com/comment/33439199

http://stackoverflow.com/comment/33613854
score: 0
comment on: http://stackoverflow.com/q/22151158
type: Comment
type: QuestionComment
has text: When are you instantiating switchArray ? You need to instantiate it after you do your "findViewById" calls

http://stackoverflow.com/a/22024495
type: Answer
has body: Add a RIGHTWARDS ARROW (U+2192) → to the axis label. JFreeChart jfreechart = ChartFactory.createScatterPlot( title, "Performance →", "Leadership →", createSampleData(), PlotOrientation.VERTICAL, true, true, false);
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/22021178
has comment: http://stackoverflow.com/comment/33388180
has comment: http://stackoverflow.com/comment/33387797
downvote count: 0

http://stackoverflow.com/comment/33623199
comment on: http://stackoverflow.com/q/22156112
score: 0
has text: To clarify, you get the exception when you try to do a GET on `/create`?
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33560255
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22121031
has text: @zjuventus14 when should the while loop stop executing?
type: Comment

http://stackoverflow.com/a/22037932
score: 1
upvote count: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22034910
answers question: http://stackoverflow.com/q/22034910
type: Answer
has body: I see you followed a tutorial. I can't find a Jersey version in it, but based on the date of the article, I don't think they use Jersey 2.x. If you do use the latest, try your project with Jersey 1.x. I got it working with 1.11.1 which is bundled with GlassFish 3.1.2.2.
downvote count: 0

http://stackoverflow.com/comment/33580878
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/22132175
type: Comment
has text: What is your question? Have you tried using a debugger?

http://stackoverflow.com/comment/33377409
score: 0
comment on: http://stackoverflow.com/q/22017592
type: Comment
type: QuestionComment
has text: Oh, I'm sorry I didn't mean to be rude. I think my comment may have sounded a bit harsh in which case I apologize and don't have any problems on delete it. My point is every day we find too many questions involving this kind of issues generated by the incorrect use of methods I've pointed out. I was trying to emphasize (maybe too much:P) this is not the way to work with swing. @NickRippe

http://stackoverflow.com/q/22050368
score: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33447387
tagged with: file
tagged with: java
type: Question
answer count: 2
tagged with: uri
has title: "Access Denied" when trying to access file in web app
tagged with: jsp
has comment: http://stackoverflow.com/comment/33476569
has comment: http://stackoverflow.com/comment/33439105
has answer: http://stackoverflow.com/a/22075080
has answer: http://stackoverflow.com/a/22050411
has body: I have an xslt file stored in the folder Project/tools. (I'm using Netbeans IDE.) I try to access this file in my code, but at run time, I get an AccessControlException: access denied. The code is: java.net.URI xsltURI = new java.net.URI(myUtil.getUri("xsltFile.xslt")); Transformer transformer = factory.newTransformer(new StreamSource(new File(xsltURI))); The myUtil instance must be used to access the URI for reasons not important here. I printed its output, and it correctly gives the relative path of the file. I have tried to prefix the relative path with file:/// and file:///[fulldomain], but in each of these cases, it actually tries to access a hard drive on the server, even though I did not give a drive name anywhere. (!) It tries to access C:[relative-path], which isn't even where the file is anyway. If I omit file:/// then I get that the URI is not absolute, and if I just give the full web address of the file I get a NullPointerException. Any help at all would be greatly appreciated. UPDATE: Following my comment below, my code resembles java.net.URI xsltURI = new java.net.URI("https://host" + myB2U.getUri("xsltFile.xslt")); java.net.URL xsltURL = xsltURI.toURL(); java.net.URLConnection myConnection = xsltURL.openConnection(); myConnection.connect(); //AccessControlException: access denied ("java.net.SocketPermission"... java.io.InputStream xsltStream = myConnection.getInputStream(); Transformer transformer = factory.newTransformer(new StreamSource(xsltStream)); Is there something obvious that is wrong?

http://stackoverflow.com/comment/33414757
score: 0
has text: No, once deployed the schedule cannot be changed. Take look to [this][1]. [1]:http://stackoverflow.com/questions/21679760/dynamically-change-timeout-interval-in-timer
type: Comment
comment on: http://stackoverflow.com/q/22031538
type: QuestionComment

hudson
type: Tag
tag name: hudson
tags question: http://stackoverflow.com/q/22152200

http://stackoverflow.com/comment/33528492
score: 0
type: AnswerComment
type: Comment
has text: @HarryKitchener When you add a component to a container you have to use the method [add(component, constraints)](http://docs.oracle.com/javase/7/docs/api/java/awt/Container.html). You have to give him a component and an object representing the constraints. What class of object is actually constraints depends on the layout of that container. With BorderLayout it's a string indicating NORTH, EAST... For the GridBagLayout constraints is of the class GridBagConstraints. It's the object that gives all the information about how/where to add the component in the container.
comment on: http://stackoverflow.com/a/22054381

http://stackoverflow.com/comment/33582950
has text: I tried creating a rule similar to this and using the Jena reasoner to add an individual which would drive a truck to the class of truck drivers. After creating an inferred model the individual does not show when I call for a list of members of the TruckDriver class. I wanted to know if perhaps there was something wrong with my rule syntax as no errors are generated upon compiling.
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22100820

http://stackoverflow.com/comment/33530012
has text: 4 Objects without counting the internal Char[] array ("I know the 3 String literals are in the String Constant Pool and the StringBuilder object is at the heap")
type: Comment
comment on: http://stackoverflow.com/a/22103501
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33556405
type: AnswerComment
type: Comment
has text: Let me put it this way- are you willing to spend the next 10-20 years of your life full time on this project? Because that's the kind of effort being put into professional efforts to turn speech into text. Once you have a speech to text library making it work with fixed commands is a matter of a few minutes, I've done it a dozen times.
comment on: http://stackoverflow.com/a/22110321
score: 0

http://stackoverflow.com/comment/33621302
has text: @MarkBennett Then you've to get appropriate constructor for every class using `Class#getConstructor()` method, giving the `Class` instance for the parameter types the constructor takes as argument of this method, and then use `Constructor#newInstance()` method passing actual arguments to instantiate the class.
comment on: http://stackoverflow.com/a/22152125
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/22167212
has comment: http://stackoverflow.com/comment/33642690
score: 0
type: Answer
has body: ApplicationContext#getBean - Return the bean instance getBean method available in BeanFactory interface which returns the bean instance from spring context. For Example - StudentController obj = (StudentController) context.getBean("studentcontroller"); Dependency will be injected as you configured, conext will automatically resolve dependency and inject to bean class.
has comment: http://stackoverflow.com/comment/33642472
has comment: http://stackoverflow.com/comment/33642612
has comment: http://stackoverflow.com/comment/33642444
answers question: http://stackoverflow.com/q/22167177
has comment: http://stackoverflow.com/comment/33642628

http://stackoverflow.com/comment/33533931
type: QuestionComment
score: 0
has text: Baz, I see the file in the plugins subfolder, but that does not help me to create a new SWT application, as Eclipse does not enumerate SWT in the list of project types, as I show in the screenshot above.
comment on: http://stackoverflow.com/q/22099190
type: Comment

http://stackoverflow.com/a/22046807
has comment: http://stackoverflow.com/comment/33427531
upvote count: 0
has body: If you need to create the right generic type for an explicit small number of classes, you could use the instanceof operator ... something like if (o instanceof T) { x = new Something&lt;T&gt;();} else if (o instanceof String) {x = new Something&lt;String&gt;();} else if ....
downvote count: 2
score: -2
answers question: http://stackoverflow.com/q/22046474
type: Answer

http://stackoverflow.com/comment/33372648
comment on: http://stackoverflow.com/q/22016405
has text: If you would like to return instance of base class(supposing it is not abstract) you should use key word "super". public void methodA(){ MHandle mh = super.getMHandle(); }
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/q/22058092
linked to: http://stackoverflow.com/q/3875184
has body: The idea is when the TCP server receives a String message, if it is equal to "::turnOnBluetoothOn::". Will simply turn on the bluetooth on the device. By using the runCommand Method of the MessageHandler class. The problem is that I am getting the error Can't create handler inside thread that has not called Looper.prepare() Here is my code: import android.os.Looper; import android.util.Log; import java.io.*; import java.net.InetAddress; import java.net.Socket; public class TCPClient { private String serverMessage; // &lt;&lt;&lt;&lt;&lt;&lt;&lt; .mine public static final String SERVERIP = "xx.xxx.xx.xx"; // your computer IP public static final int SERVERPORT = 4444; private OnMessageReceived mMessageListener = null; private boolean mRun = false; PrintWriter out; BufferedReader in; // Test for Thread private volatile Looper mMyLooper; /** * Constructor of the class. OnMessagedReceived listens for the messages * received from server */ public TCPClient(OnMessageReceived listener) { mMessageListener = listener; } /** * Sends the message entered by client to the server * * @param message * text entered by client */ public void sendMessage(String message) { if (out != null &amp;&amp; !out.checkError()) { out.println(message); out.flush(); } } public void stopClient() { mRun = false; } public void run() { mRun = true; try { // here you must put your computer's IP address. InetAddress serverAddr = InetAddress.getByName(SERVERIP); Log.e("TCP Client", "C: Connecting..."); // create a socket to make the connection with the server Socket socket = new Socket(serverAddr, SERVERPORT); try { // send the message to the server out = new PrintWriter(new BufferedWriter( new OutputStreamWriter(socket.getOutputStream())), true); Log.e("TCP Client", "C: Sent."); Log.e("TCP Client", "C: Done."); // receive the message which the server sends back in = new BufferedReader(new InputStreamReader( socket.getInputStream())); // in this while the client listens for the messages sent by the // ser…
has answer: http://stackoverflow.com/a/22060171
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/22058282
type: UnansweredQuestion
duplicate of: http://stackoverflow.com/q/3875184
tagged with: multithreading
tagged with: android
tagged with: tcp
tagged with: java
has title: Can't create handler inside thread that has not called Looper.prepare() android
type: Question

http://stackoverflow.com/q/22025386
has comment: http://stackoverflow.com/comment/33433735
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/31304661
has comment: http://stackoverflow.com/comment/33421620
tagged with: apache-pig
downvote count: 0
has body: I've seen this asked but I haven't seen an answer yet.. Is it possible to call a UDF from pig just a single time? I basically want the transformation of a text file I store to handled by a single call to the java UDF. The internals of the transformation are easier to handle within Java, and the overhead is small, so I'd rather not convert the logic to pig.. The only way i've successfully called a UDF is as part of a FOREACH statement over some dataset. I thought that I could just create a dummy tuple that was of size one, then use this as part of the 'foreach', but I can't figure out the syntax to create this dummy tuple either.. The UDF does not need to return anything, it will handle the FS logic itself, I just want to be able to exec it from within the pig script as it makes more sense to instrument it here then as part of the greater workflow.. Any help would be greatly appreciated! Thanks!
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33397796
type: Question
has answer: http://stackoverflow.com/a/56596165
answer count: 2
upvote count: 1
linked to: http://stackoverflow.com/q/11110403
has title: Executing a UDF in Pig only once
favorite count: 0

http://stackoverflow.com/comment/33408980
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/22017250
has text: That sounds like an interesting idea, but it'll mean we have to implement a function per user rule per a predefined static set of fields that need to be returned. It might be the only solution but i was really wondering if there is something that spring offers out of the box to do this.

http://stackoverflow.com/comment/33636281
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22161571
has text: what it does is, it allows both the test and testing in each textArea but doesn't allow you to drop them the second time, before you can drop the strings in the textArea more than once.
type: AnswerComment

http://stackoverflow.com/comment/33541687
has text: helpful link :http://www.blackwasp.co.uk/SpeedTestIfElseSwitch.aspx
score: 0
comment on: http://stackoverflow.com/q/22110707
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22055898
has comment: http://stackoverflow.com/comment/33443604
has answer: http://stackoverflow.com/a/22056163
has answer: http://stackoverflow.com/a/22056521
favorite count: 0
has comment: http://stackoverflow.com/comment/33463086
has comment: http://stackoverflow.com/comment/33443440
has comment: http://stackoverflow.com/comment/33446006
type: UnansweredQuestion
downvote count: 2
has body: I am passing a value from android to java file via Intent. The value is getting passed. WHen I write system.out.print, the value is displayed in log cat, but when i try to write in the file, the file does not get created. I donot get any error but nothing is displayed. I tried to changed the location of file, still not working. I have right to keep txt file anywhere though i doble checked it and changed the location also. Code: Intent i= new Intent(context, JavaServiceClass.class); i.putExtra("stock_list", temparr); context.startService(i); JavaServiceClass.java public void onStart(Intent intent, int startId) { ArrayList&lt;String&gt; stock_list = (ArrayList&lt;String&gt;) intent.getExtras().get("stock_list"); // System.out.println(stock_list.get(1) ); writeInFile(stock_list.get(1)); } If, I do system.out.println, value is diplayed in log cat public void writeInFile(String stock_list ) { File file = new File("F:/abc.txt"); if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } try { BufferedWriter bw=new BufferedWriter(new FileWriter(file,true)); //for (int i1=0;i1&lt;stock_list.length();i1++) { bw.append(stock_list.toString()); bw.write("\t"); //} bw.newLine(); bw.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } Log Cat Warnings : java.io.IOException: open failed: ENOENT (No such file or directory) java.io.File.createNewFile(File.java:940) com.example.wifisignalstrength.JavaServiceClass.writeInFile(JavaServiceClass.java:100) com.example.wifisignalstrength.JavaServiceClass.onStart(JavaServiceClass.java:42) android.app.Service.onStartCommand(Service.java:438) android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2373) android.app.ActivityThread.access$1900(ActivityThread.java:128) android.app.ActivityThread$H.handleMessage(ActivityThread.java:1224) android.os.Handler.dispatchMessage(Handler.java:99) android.os.Looper.loop(Looper.ja…
has comment: http://stackoverflow.com/comment/33443737
has comment: http://stackoverflow.com/comment/33445923
tagged with: java
has comment: http://stackoverflow.com/comment/33445909
type: Question
answer count: 2
upvote count: 0
score: -2
has comment: http://stackoverflow.com/comment/33443486
has title: Unable to Create File
has comment: http://stackoverflow.com/comment/33443510
has comment: http://stackoverflow.com/comment/33444605
tagged with: android
has comment: http://stackoverflow.com/comment/33443392

http://stackoverflow.com/comment/33450345
comment on: http://stackoverflow.com/a/22059281
has text: change that to : package helloWorld;
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/22125643
has body: Yes, in java The operator ^ (bitwise xor) is undefined for the argument type(s) double, double. Use Math.pow(double , double) instead of ^. So your code will look like this: resultPA = ((dMA * (Math.pow((1+dIR/12),dTL-1))/(Math.pow((1+dIR/12),dTL)*dIR/12)),2);
type: Answer
has comment: http://stackoverflow.com/comment/33590624
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/22125600
has comment: http://stackoverflow.com/comment/33592359
upvote count: 1

http://stackoverflow.com/a/22162817
answers question: http://stackoverflow.com/q/22161755
type: Answer
has body: try making the JFrame frameToPrint static See if it solves the problem.
score: 0

http://stackoverflow.com/a/22193941
type: Answer
has comment: http://stackoverflow.com/comment/33744748
has body: if you want to send single email to 200 clients. Than u can add an array of reciever's email addresses of size upto 50. but i you want to send different msg for each email. Then you can create a new connection to email server with a counter that counts send emails as well as it counts 15 it should create a new connection. to test your code use mailtrap.io
upvote count: 1
has comment: http://stackoverflow.com/comment/33710830
downvote count: 1
answers question: http://stackoverflow.com/q/22154327
score: 0

http://stackoverflow.com/comment/33413903
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22038348
has text: @fge yes. But still, explain me if I need some synchronization during operations with `Cache`?
score: 0

http://stackoverflow.com/comment/33622585
comment on: http://stackoverflow.com/q/22155812
score: 0
has text: how about using a global variable? ;) bubble sort is predicated on storing nodes and swapping...
type: QuestionComment
type: Comment

indexoutofboundsexception
tags question: http://stackoverflow.com/q/22134510
tags question: http://stackoverflow.com/q/22067933
tag name: indexoutofboundsexception
tags question: http://stackoverflow.com/q/22141209
tags question: http://stackoverflow.com/q/22029021
tags question: http://stackoverflow.com/q/22086582
tags question: http://stackoverflow.com/q/22057121
tags question: http://stackoverflow.com/q/22140643
tags question: http://stackoverflow.com/q/22031648
tags question: http://stackoverflow.com/q/22029459
tags question: http://stackoverflow.com/q/22030654
tags question: http://stackoverflow.com/q/22028853
tags question: http://stackoverflow.com/q/22133871
tags question: http://stackoverflow.com/q/22063681
tags question: http://stackoverflow.com/q/22026683
type: Tag

http://stackoverflow.com/comment/33400331
type: Comment
comment on: http://stackoverflow.com/q/22008715
has text: @ErkiM, Thanks for the link. Its one of my post. Here the question is why firefox doesn't have UnhandledAlertException and why it has only one read only capability for alert handling i.e. handlesAlerts.
score: 0
type: QuestionComment

http://stackoverflow.com/a/22124849
type: Answer
has body: return (other.numerator.equals(this.numerator) &amp;&amp; other.denominator.equals(this.denominator)) Of couse this doesn't consider that 1/2 == 2/4.
answers question: http://stackoverflow.com/q/22124710
score: 0

http://stackoverflow.com/comment/33495571
has text: Thank you! I will edit appropriately to keep the signature as it was before! Much appreciated. Didn't think of setting the recursive spots where you have them. Must be having a down spell!
comment on: http://stackoverflow.com/a/22084991
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33423138
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22043838
type: AnswerComment
has text: @PopoFibo i am using MySql database and in my table i have a field named links where the link is the one that we are using now. I have to extract the data as we did and display it on a text area on my application. Is this easy to do?

http://stackoverflow.com/q/22051031
has body: I was wondering if Java main method was a thread or not. I noticed that if the main method returns, all threads are killed. Can you explain me why this happens? Thank you in advance.
downvote count: 1
has answer: http://stackoverflow.com/a/22051078
type: UnansweredQuestion
upvote count: 4
score: 3
tagged with: program-entry-point
has comment: http://stackoverflow.com/comment/33435002
linked to: http://stackoverflow.com/q/17669159
favorite count: 0
has answer: http://stackoverflow.com/a/22051070
type: Question
duplicate of: http://stackoverflow.com/q/17669159
has title: Is java main method a thread?
has answer: http://stackoverflow.com/a/22051132
tagged with: java
tagged with: multithreading
answer count: 3

http://stackoverflow.com/q/22096307
downvote count: 0
answer count: 1
favorite count: 0
tagged with: android-listview
tagged with: android
has body: Hi I have a class that extends SQLiteOpenHelper named "KnowledgeBaseHelper". I've been using it for a while with my Classes that extends Activity, but then I decided to shift from using ListActivity to ListFragment, the problem is, when I tried to instantiate my class named KnowledgeBaseHelper like this "KnowledgeBaseHelper helper = new KnowledgeBaseHelper(ListActivity.this);" it gives me an error of "The constructor KnowledgeBaseHelper(ListActivity) is undefined" This usually works when I'm extendsing ListActivity but now I'm stock with this error. Does the instantiation differ from ListActivity and FragmentActivity? Thanks Below are my codes public class ListActivity extends ListFragment { ArrayList&lt;String&gt; symptomList; String name; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub return inflater.inflate(R.layout.fragment_generalsymptoms, container, false); } @Override public void onActivityCreated(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onActivityCreated(savedInstanceState); new LoadSymptoms().execute(); } class LoadSymptoms extends AsyncTask&lt;String, String, String&gt; { @Override protected String doInBackground(String... params) { // TODO Auto-generated method stub KnowledgeBaseHelper helper = new KnowledgeBaseHelper( ListActivity.this); return null; } } For the SQLiteOpenHelper, I have a very long code and methods so I decided to include only few. public class KnowledgeBaseHelper extends SQLiteOpenHelper { private static final int DATABASE_VERSION = 1; private static final String DATABASE_NAME = "docdroid"; //... I deleted the following lines public KnowledgeBaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder() .permitAll().build(); StrictMode.setThreadPolicy(policy); // Crea…
score: 2
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/22096392
type: Question
tagged with: android-fragments
has title: How to instantiate a SQLiteOpenHelper Class on a ListFragment?
has answer: http://stackoverflow.com/a/22096392
upvote count: 2

http://stackoverflow.com/q/22029729
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33397045
tagged with: stack
has comment: http://stackoverflow.com/comment/33397084
has comment: http://stackoverflow.com/comment/33397461
type: Question
has comment: http://stackoverflow.com/comment/33397094
has comment: http://stackoverflow.com/comment/33397183
tagged with: java
has comment: http://stackoverflow.com/comment/33397042
has comment: http://stackoverflow.com/comment/33397508
has comment: http://stackoverflow.com/comment/33397028
has title: How can I swap pairs of elements in a stack?
score: 0
accepted answer: http://stackoverflow.com/a/22029825
answer count: 1
has body: Trying to write a function that takes a stack of integers as a parameter. By only using one queue as auxiliary storage, I need to swap positions of each pair of elements. If the stack is odd numbered, leave the final integer where it is. INPUT [3, 8, 17, 9, 99, 9, 17, 8, 3, 1, 2, 3, 4, 14] DESIRED RESULT [8, 3, 9, 17, 9, 99, 8, 17, 1, 3, 3, 2, 14, 4] CURRENT RESULT [3, 8, 17, 9, 99, 9, 17, 8, 3, 1, 2, 3, 4, 14, 8, 3, 9, 17, 9, 99, 8, 17, 1, 3] public static void switchPairs(Stack&lt;Integer&gt; st){ Queue&lt;Integer&gt; q = new LinkedList&lt;Integer&gt;(); int size = st. size(); for(int i = 0; i &lt; st.size()-1; i++){ q.add(st.elementAt(i+1)); q.add(st.elementAt(i++)); } if(st.size()%2==1){ q.add(st.pop()); } for(int k = 0; k&lt;size; k++){ st.push(q.remove()); st.push(q.remove()); } } NEW VERSION public static void switchPairs(Stack&lt;Integer&gt; st){ Queue&lt;Integer&gt; q = new LinkedList&lt;Integer&gt;(); int a = 0; int b = 0; while(!st.isEmpty()){ a = st.pop(); b = st.pop(); st.push(a); } q.add(b); q.add(a); while(!q.isEmpty()){ st.push(q.remove()); } } Third attempt (infinite loop) public static void switchPairs(Stack&lt;Integer&gt; st){ Queue&lt;Integer&gt; q = new LinkedList&lt;Integer&gt;(); int a = 0; int b = 0; while(!st.isEmpty()){ a = st.pop(); if(st.isEmpty()){ st.push(a); } } b = st.pop(); q.add(a); q.add(b); while(!q.isEmpty()){ st.push(q.remove()); } } Fourth Attempt: Works only on even number of elements.. public static void switchPairs(Stack&lt;Integer&gt; st){ Queue&lt;Integer&gt; q = new LinkedList&lt;Integer&gt;(); int a = 0; int b = 0; while(st.size() &gt; 1){ a = st.pop(); b = st.pop(); q.add(b); q.add(a); } while(!q.isEmpty()){ st.push(q.remove()); } while(!st.isEmpty()){ q.add(st.pop()); } while(!q.isEmpty()){ st.push(q.remove()); } } FIFTH FINAL ATTEMPT: I just need to find out what to do with an odd stack: This works with even numbers of stacks; public static void switchPairs(Stack&lt;Integer&gt; st){ Queue&lt;Integer&gt; q = new Linked…
has comment: http://stackoverflow.com/comment/33397518
has answer: http://stackoverflow.com/a/22029825

http://stackoverflow.com/comment/33359818
score: 0
has text: @user2384416 : What's the data type of the `l_storieslist`?
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/22009333

http://stackoverflow.com/q/22119962
downvote count: 0
has comment: http://stackoverflow.com/comment/39192144
favorite count: 0
has comment: http://stackoverflow.com/comment/33558194
type: UnansweredQuestion
upvote count: 6
has comment: http://stackoverflow.com/comment/33558227
tagged with: java
has answer: http://stackoverflow.com/a/22120000
type: Question
has answer: http://stackoverflow.com/a/22120043
has answer: http://stackoverflow.com/a/22120039
score: 6
has title: The method ambiguous for the type - Why not resolving
has comment: http://stackoverflow.com/comment/33558215
answer count: 3
has comment: http://stackoverflow.com/comment/33558261
has body: public class Animal {} public class Bird extends Animal {} public class Mamal extends Animal {} public class Human extends Mamal {} public class Main { public void Hungry(Mamal mamal){ System.out.println("Mammal"); } public void Hungry(Human human){ System.out.println("Human"); } public void Hungry(Bird bird){ System.out.println("Bird"); } public static void main(String a[]){ Main main = new Main(); main.Hungry(null); } Compiler says The method Hungry(Mamal) is ambiguous. I would expect to execute the "Human" method as it is the lowest level. I failed to find the reason for ambiguity from http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.12

http://stackoverflow.com/comment/33586216
has text: Of course, that same definition also states that a function is supposed to have exactly one *input*, which is not a requirement that most languages impose. (There are some languages with that property, especially functional languages such as Standard ML and Haskell, but that's clearly not the sort of language the OP has in mind.)
type: AnswerComment
score: 1
type: Comment
comment on: http://stackoverflow.com/a/22135126

http://stackoverflow.com/comment/33449781
type: QuestionComment
has text: *UPDATE* I uninstalled Java 8 and it now works (Under 7). I will try to re-install JDK 8 to reproduce ...
comment on: http://stackoverflow.com/q/22058987
score: 0
type: Comment

http://stackoverflow.com/comment/33625341
score: 0
has text: `Down extends Up`? That is an a bit weird inheritance. Maybe better `Up extends Direction` and `Down extends Direction`
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22157350

http://stackoverflow.com/q/22102077
has comment: http://stackoverflow.com/comment/33529258
has answer: http://stackoverflow.com/a/22102315
answer count: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/33527141
favorite count: 0
has comment: http://stackoverflow.com/comment/33528438
has answer: http://stackoverflow.com/a/22102574
accepted answer: http://stackoverflow.com/a/22102623
has comment: http://stackoverflow.com/comment/33527759
has body: I'm a little confused by this error. I'm new to Java and the error seems pretty self explanatory, but I've checked my paths (even defined my own) and it still fails to find this library. Is there something I'm doing wrong? See directory screenshot and error screenshot below: UPDATE UPDATE 2 If I create a new NetBeans project this works fine. Same code and everything. If I create new IntelliJ project I get this error above. I must be missing something in IntelliJ UPDATE 3 Found the solution. Adding dependencies is a bit different in IntelliJ. Thanks all for the help. http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33528106
has comment: http://stackoverflow.com/comment/33530575
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33529334
upvote count: 1
has comment: http://stackoverflow.com/comment/33525943
has title: UnsatisfiedLinkError, but library is in path
type: Question
has comment: http://stackoverflow.com/comment/33532545
has comment: http://stackoverflow.com/comment/33526389
has comment: http://stackoverflow.com/comment/33525900
has comment: http://stackoverflow.com/comment/33527655
tagged with: intellij-idea
has answer: http://stackoverflow.com/a/22102623
possible better answer: http://stackoverflow.com/a/22102315

http://stackoverflow.com/comment/33479808
comment on: http://stackoverflow.com/q/22075391
has text: Fine for me, I just wanted to pointed out so that no one bothers writing an already given answer.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33362811
type: AnswerComment
type: Comment
has text: Sorry for that, next time my question will be in comment. I also edited my message
comment on: http://stackoverflow.com/a/22010436
score: 0

http://stackoverflow.com/comment/33381754
has text: Good, findings. What just i downloaded the maven zip from apache and setup the env.varaibles. Why is this downloading jars instead of refer the local folder ? If proxy is must , then how to define host ?
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22020494

http://stackoverflow.com/comment/33453189
has text: This this not work since the app name is specified under `application` tag.I think it works for all the properties under manifest tag. I am updating my pom and manifest file.
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/22041692

http://stackoverflow.com/q/22014507
tagged with: soap
has title: Should server certificates be added to the trust store for the client to receive the response from the server securely?
has answer: http://stackoverflow.com/a/22057402
tagged with: encryption
upvote count: 1
tagged with: web-services
has body: Requirment: Need to write a web service client to interact with server using the SSL encryption. Provided: provided with the key store file and the server cert. Coding: Have written a java code, forming the soap request.For adding(signing the soap) the encryption data, used the key store to get the public key using the certificates and encrypted with digital signature algorithm. Assumption In steps: signing the soap message using the key store and sending to the server. trust store(with certificates) by Certified authority validates the request and process the request. signing the response with the same key store(used by the client) in the server side to send to the client. client receives the response and validates using the trust store(with certificates) by Certified authority in the /JAVA_HOME/jre/lib/security/cacerts. In this case, do we need to import the server.cert file from the requirement to the /JAVA_HOME/jre/lib/security/cacerts.? from which the response is validated? Please correct me if i am wrong at any step.
type: AnsweredQuestion
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/22057402
type: Question
downvote count: 0
tagged with: ssl-certificate
favorite count: 0
answer count: 1

http://stackoverflow.com/comment/33528602
type: QuestionComment
has text: # jdk1.7.0_51/bin/java -cp /home/*/.gvm/groovy/current/lib/groovy-ant-2.2.2.jar:CnrIpUtilHistory.jar com...GetIpUtilization -jar CnrIpUtilHistory.jar Error: Could not find or load main class com...GetIpUtilization
comment on: http://stackoverflow.com/q/22100892
score: 0
type: Comment

http://stackoverflow.com/comment/33439050
score: 0
type: AnswerComment
type: Comment
has text: The like operator will work fine, thank you for reminding me it existed haha.
comment on: http://stackoverflow.com/a/22052858

http://stackoverflow.com/a/22126800
answers question: http://stackoverflow.com/q/22126787
has body: The problem is that int[] uses object identity for equals() and hashCode(), so it won't work with Map in java. You can use List&lt;Integer&gt; instead. List's hashCode() API says Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation: int hashCode = 1; Iterator&lt;E&gt; i = list.iterator(); while (i.hasNext()) { E obj = i.next(); hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode()); }
type: Answer
score: 2
downvote count: 0
upvote count: 2

http://stackoverflow.com/comment/33578706
comment on: http://stackoverflow.com/a/22130888
score: 0
type: Comment
has text: you don't need while loop. you can do your action with this. to finish taking input you can set a flag.
type: AnswerComment

http://stackoverflow.com/comment/33546528
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22100892
has text: Can you post the actual command you're running? That looks like just a part of it
score: 0

http://stackoverflow.com/comment/33556468
type: Comment
has text: @Aydomir It's Ok Glad i would help :)
type: AnswerComment
comment on: http://stackoverflow.com/a/22118995
score: 0

http://stackoverflow.com/q/22154572
linked to: http://stackoverflow.com/q/2660827
possible better answer: http://stackoverflow.com/a/22154626
answer count: 2
tagged with: covariance
has body: **since java 5; I know that if in the base class I write: public Number doSomething(){ ... } in the child class I can write something like this @Override public Integer doSomething(){ ... } But I have a question. If in base class method returns - primitive - array - or Collection. How can I use covariant at this case?
score: 0
has answer: http://stackoverflow.com/a/22154626
type: AnsweredQuestion
has title: method return value covariance for primitives. Is it works?
type: Question
has answer: http://stackoverflow.com/a/22154632
accepted answer: http://stackoverflow.com/a/22154632
tagged with: java
has comment: http://stackoverflow.com/comment/33620044

http://stackoverflow.com/comment/33452299
comment on: http://stackoverflow.com/q/22060752
score: 0
type: Comment
type: QuestionComment
has text: @Vulcan It is at http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html

http://stackoverflow.com/a/22184600
type: Answer
score: 30
has comment: http://stackoverflow.com/comment/127461098
downvote count: 0
upvote count: 30
has body: In my experience this is one of the biggest bugs in Maven. If you have more than one configuration for the same plugin in different profiles, the order is simply unpredictable. I even observed, that I had some plugin order in project B in a given phase, and as soon as some of the same plugins got a config in a parent project (not even in the same phase), the order was ruined. There is an obviously falsely closed bug related to this at https://issues.apache.org/jira/browse/MNG-2258. Possible workarounds Try to shift some of the plugins to previous phase if possible (prepare-test used for some of the plugins and test for the rest) Try to replace the functionality of multiple plugins with a groovy-maven-plugin script (quite handy with the ant integration, and you reach the list of the active profiles in the script) Write your own mojo and call the plugins in the correct order (See https://github.com/TimMoore/mojo-executor) Give a try to gradle. Maybe it fits your needs, and it comes with a lot of good things from Maven I do not think that there is any more you can do right now.
accepted answer of: http://stackoverflow.com/q/22150209
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22150209

http://stackoverflow.com/q/22037793
has comment: http://stackoverflow.com/comment/33411201
score: 0
tagged with: wsdl
has comment: http://stackoverflow.com/comment/33411730
has comment: http://stackoverflow.com/comment/33416100
has comment: http://stackoverflow.com/comment/33412398
answer count: 0
tagged with: cxf
type: UnansweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33411167
tagged with: web-services
type: Question
has comment: http://stackoverflow.com/comment/33411961
has body: I have a wsdl document from which I want to generate java classes into a client project. I do these steps: I have the wsdl file into a dynamic web project inside Eclipse; I create a new dynamic web project in Eclipse. Right click on the wsdl file on the first project, "Web Services" -> "Generate Client" On configuration client I select the new dynamic web project I just created; On Web service runtime - Apache CXF 2.x On Server runtime - Tomcat 6.0 I also check the box "Monitor Web Service" After I do all these steps it opens the web client into a localhost browser inside Eclipse, but the classes are not generated in the new project. Can you please tell me what am I doing wrong? Thanks in advance!
has title: Apache CXF 2.6.13 does not generate java classes
tagged with: eclipse

http://stackoverflow.com/a/22041217
type: AcceptedAnswer
downvote count: 0
score: 46
has comment: http://stackoverflow.com/comment/33447275
accepted answer of: http://stackoverflow.com/q/22038957
answers question: http://stackoverflow.com/q/22038957
type: Answer
upvote count: 46
has body: You can use an URIBuilder object URIBuilder builder = new URIBuilder("http://example.com/"); builder.setParameter("var1", "value1").setParameter("var2", "value2"); HttpGet request = new HttpGet(builder.build()); // get back the url parameters List<NameValuePair> params = builder.getQueryParams(); I think you are a bit confused about the getParams() method from the client or HttpMethod, getParams() does not return the URL parameters or something like that, returns the client parameteres like connection timeout, proxy, cookies... etc Before 4.3.2 you could set the parameters to the client using the getParams() method (deprecated now), after 4.3.2 you can set the request params via the RequestConfig class using a Builder Builder requestConfigBuilder = RequestConfig.custom(); requestConfigBuilder.setConnectionRequestTimeout(1000).setMaxRedirects(1); and then set to the HttpMethod only (not to client like before) request.setConfig(requestConfigBuilder.build()); Update: If you want to get the URI parameters from an HttpGet or HttPost request object you can use the URIBuilder in the same way HttpGet request = new HttpGet("http://example.com/?var=1&var=2"); URIBuilder newBuilder = new URIBuilder(request.getURI()); List<NameValuePair> params = newBuilder.getQueryParams();
has comment: http://stackoverflow.com/comment/119098869
has comment: http://stackoverflow.com/comment/33454273

http://stackoverflow.com/comment/33401703
type: Comment
score: 0
type: AnswerComment
has text: as you can see there is a if checking after it and it is anside after checking for wifi state ConnectivityManager.TYPE_WIFI!!
comment on: http://stackoverflow.com/a/22032381

http://stackoverflow.com/comment/33614923
score: 1
has text: Welcome to SO. You are going to have to clarify the question before anybody can answer.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22151731

http://stackoverflow.com/comment/33553129
score: 0
type: AnswerComment
has text: Got your point, I appreciate your efforts, I have one more question, can that be done like even though the application is opened by the user, but the user should not be able to type any text in that case ?
type: Comment
comment on: http://stackoverflow.com/a/22107581

http://stackoverflow.com/comment/33554690
type: QuestionComment
type: Comment
score: 1
has text: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
comment on: http://stackoverflow.com/q/22118079

http://stackoverflow.com/a/22019729
answers question: http://stackoverflow.com/q/22019624
downvote count: 5
has comment: http://stackoverflow.com/comment/33378284
type: Answer
has body: The object of type Item that is being passed must be instantiated. As pointed out by others, you cannot simply create it via: Item item = new Item(); // this does not work! However, you can extend the class and create all the abstract methopds required and then instantiate the new class. class ItemB extends Item { ... } Then you can work with the new class, ItemB item = new ItemB();
upvote count: 0
score: -5
has comment: http://stackoverflow.com/comment/33378285
has comment: http://stackoverflow.com/comment/33378307

http://stackoverflow.com/comment/33481189
type: Comment
score: 1
has text: You can sort it when the list is finalized. But with modern CPUs, as long as your list isn't a million records long, you won't have to worry about performance. The key is to use the data structure which is best for your purposes. If you want constant-time lookup, you could use a HashMap, and convert that to a sorted list on the fly.
type: AnswerComment
comment on: http://stackoverflow.com/a/22077198

http://stackoverflow.com/a/22079452
has body: You'd do best to generate a random number of Series objects in a for loop like this: List&lt;XYChart.Series&gt; seriesList = new ArrayList&lt;Series&gt; int randomCount = randomNumbers.nextInt(100); for(int i=0;i&lt;randomCount;i++){ XYChart.Series series = new XYChart.Series(); series.setName("series " + randomCount); seriesList.add(series); } Then later you can iterate over all the series and add numbers to them (or you can do it within the for loop above). You can easily iterate over every series with a for-each loop like this: for(XYChart.Series series:seriesList){ series.getData().add(...); ... }
accepted answer of: http://stackoverflow.com/q/22079274
has comment: http://stackoverflow.com/comment/33525766
answers question: http://stackoverflow.com/q/22079274
score: 1
has comment: http://stackoverflow.com/comment/33612086
has comment: http://stackoverflow.com/comment/33520744
upvote count: 1
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/33521168

http://stackoverflow.com/a/22149786
has body: What about using the method Enum.name() to create Strings as keys? String key=DiceEyes.ONE.name()+CardSuit.HEARTS.name(); //"ONEHEARTS".
answers question: http://stackoverflow.com/q/22149403
type: Answer
score: 1
upvote count: 1
downvote count: 0

http://stackoverflow.com/comment/33465517
type: Comment
type: QuestionComment
has text: Is there a reason you cannot simply read the [manual](http://msdn.microsoft.com/en-US/library/x9h8tsay.aspx)? EDIT: changed your tags to Java since you mentioned Java. If C# was right, change it back and include and explanation.
comment on: http://stackoverflow.com/q/22068928
score: 1

http://stackoverflow.com/comment/33503550
type: QuestionComment
comment on: http://stackoverflow.com/q/22089667
type: Comment
has text: ..and would `gson` support `maps`?
score: 0

awk
tag name: awk
type: Tag
tags question: http://stackoverflow.com/q/22154183

http://stackoverflow.com/q/22110624
downvote count: 0
type: UnansweredQuestion
type: Question
score: 3
tagged with: java
upvote count: 3
linked to: http://stackoverflow.com/q/22294181
tagged with: push-notification
answer count: 1
favorite count: 0
has body: I'm using Parse to send push notifications to Android devices, When I push a message from parse I get 7 push notifications on a single device. How can I fix this? PushService.subscribe(cont, "Abc", ParseActivity.class); PushService.setDefaultPushCallback(cont, Menu.class);
has title: Parse -Android Getting multiple push notifications
tagged with: android
has answer: http://stackoverflow.com/a/22297926
has comment: http://stackoverflow.com/comment/33873665
tagged with: parse-platform

http://stackoverflow.com/a/22161814
has comment: http://stackoverflow.com/comment/33644854
has body: Here's a simple example server: package com.mayapp.app; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.servlet.ServletContainer; /** * Hello world! */ public class App { public static void main(String[] args) { Server server = new Server(8112); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath("/"); server.setHandler(context); ServletHolder h = new ServletHolder(new ServletContainer()); h.setInitParameter(ServerProperties.PROVIDER_PACKAGES, "com.myapp.resources"); h.setInitOrder(1); context.addServlet(h, "/*"); server.setDumpAfterStart(true); try { server.start(); }catch(Exception ex) { ex.printStackTrace(); } } } and the resource: package com.myapp.resources; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; @Path("hello") public class HelloWorldResource { @GET @Produces("text/plain") public String getHello() { return "hello world"; } }
upvote count: 5
score: 5
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/22137920
accepted answer of: http://stackoverflow.com/q/22137920
has comment: http://stackoverflow.com/comment/33666263
type: Answer

http://stackoverflow.com/comment/33405710
score: 0
type: AnswerComment
type: Comment
has text: I test System.out.println(getMethod.invoke(clazz.newInstance()));It print null;
comment on: http://stackoverflow.com/a/22034140

http://stackoverflow.com/q/22079947
tagged with: eclipse
score: 0
answer count: 2
type: UnansweredQuestion
tagged with: android
has body: I'm trying to run an application through ADB using Eclipse. However the application doesn't launch on my phone. Here's the log from Android console: [2014-02-27 22:31:52 - HelloWorld-android] ------------------------------ [2014-02-27 22:31:52 - HelloWorld-android] Android Launch! [2014-02-27 22:31:52 - HelloWorld-android] adb is running normally. [2014-02-27 22:31:52 - HelloWorld-android] Performing com.teddygaming.helloworld.MainActivity activity launch [2014-02-27 22:31:52 - HelloWorld-android] Uploading HelloWorld-android.apk onto device '4790050082a3106c' [2014-02-27 22:31:53 - HelloWorld-android] Installing HelloWorld-android.apk... [2014-02-27 22:32:03 - HelloWorld-android] Success! [2014-02-27 22:32:03 - HelloWorld-android] Starting activity com.teddygaming.flappymuhittin.MainActivity on device 4790050082a3106c There doesn't seem to be any error here, but it just doesn't launch. I'm using Ubuntu 12.04 LTS, with adt-bundle installed, using OpenJDK 7. USB Debugging is enabled on my phone. I have edited /etc/udev/rules.d/51-android.rules and added my vendor id. I've tried restarting adb server but that didn't work either. Please help me with this, I can't understand why it doesn't work.
tagged with: adb
linked to: http://stackoverflow.com/q/10845365
has comment: http://stackoverflow.com/comment/33487232
has title: Eclipse ADB not launching
tagged with: java
has answer: http://stackoverflow.com/a/22081798
type: Question
has answer: http://stackoverflow.com/a/22080036
has comment: http://stackoverflow.com/comment/33486886

http://stackoverflow.com/comment/33594705
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22139452
has text: do one thing: add another section to your question and add the loop you are trying... it's really hard to see the error here.

http://stackoverflow.com/comment/33405335
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22033660
has text: Refer this http://blogs.msdn.com/b/jdbcteam/archive/2012/04/03/how-would-you-use-table-valued-parameters-tvp.aspx and this http://www.sommarskog.se/arrays-in-sql-2008.html for some insights.
score: 0

http://stackoverflow.com/comment/33608159
comment on: http://stackoverflow.com/q/22133475
type: Comment
type: QuestionComment
has text: Keep your engine as AC branch. Go to program files and find physics editor program, examples and then andengine. You should have two classes now, you need to edit the PhysicsEditorExample class so it is compatible with AC. It should be just a case of changing method names from like onLoadResources to onCreateResources etc.
score: 0

http://stackoverflow.com/comment/33533745
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22106021
has text: Sorry I mean KeyPressed. Key bindings is probably the best way, forgot about them!

http://stackoverflow.com/q/22043648
has body: I'm developing REST API with Jersey as JAX-RS implementation. In every resource I explicitly define expected parameters: @GET @Path("/someData") public Response getSomeData( @QueryParam("id") final Long id, @QueryParam("name") final String name) { ... } There are a number of fixed parameters, which are common for all resources (e.g. "locale"). Is there any way (I'm ok with introducing Jersey-specific dependencies) I can forbid any parameters that belong neither to method parameters nor to the common parameters? So for example if user invokes /api/resource/someData?id=10&amp;locale=en - he gets the data, but if he invokes /api/resource/someData?id=10&amp;locale=en&amp;fakeParam=AAA - status 400 is returned, with content stating that fakeParam is unknown parameter. Currently second request is processed the same way as the first one, and fakeParam is simply ignored. I think described validation will help users of my API to spot bugs earlier.
upvote count: 3
tagged with: java
type: Question
tagged with: jersey
has answer: http://stackoverflow.com/a/22048363
downvote count: 0
score: 3
answer count: 1
tagged with: jersey-2.0
tagged with: jax-rs
favorite count: 0
has title: Jersey: forbid unspecified parameters
tagged with: rest
type: UnansweredQuestion

http://stackoverflow.com/comment/33401963
type: AnswerComment
comment on: http://stackoverflow.com/a/22032488
score: 0
type: Comment
has text: @user2329162 check the updated answer, it might help you more

http://stackoverflow.com/a/22128350
has comment: http://stackoverflow.com/comment/33577079
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33575130
accepted answer of: http://stackoverflow.com/q/22127833
has comment: http://stackoverflow.com/comment/33576214
type: Answer
answers question: http://stackoverflow.com/q/22127833
score: 3
downvote count: 0
has body: The JSpinner is a compound component. Simply said: By default, it conains a JFormattedTextField that shows the value, and two buttons for increasing and decreasing the value. One way to set these colors may thus be to obtain the text field from the spinner, and set its foreground and background color: Component c = spinner.getEditor().getComponent(0); c.setForeground(Color.BLUE); c.setBackground(Color.RED); but you might have to make this more robust to make sure that it works for all LookAndFeels, and all editors, regardless of how the spinner (and the editor) are constructed internally. EDIT in response to the comment: Does it work in this case? import java.awt.Color; import java.awt.Component; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JSpinner; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.UIManager; public class SpinnerColors { public static void main(String[] args) { // Optionally: setLookAndFeel(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { createAndShowGUI(); } }); } private static void setLookAndFeel() { try { UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } } private static void createAndShowGUI() { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSpinner spinner = new JSpinner(); setColors(spinner, Color.BLUE, Color.RED); f.getContentPane().add(spinner); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); } private static void setColors( JSpinner spinner, Color foreground, Color background) { JComponent editor = spinner.getEditor(); System.out.println("Editor "+editor); int n = editor.getComponentCount(); for (int i=0; i&lt;n; i++) { Component c = editor.getComponent(i); System.out.println("Component "+i+": "+c); if (c instanceof JTextField) { c.setForeground(foreground); c.setBackground(background); } } } } Note that if you are using the "Nimbus" loo…
has comment: http://stackoverflow.com/comment/33577725
has comment: http://stackoverflow.com/comment/33576674
has comment: http://stackoverflow.com/comment/33576780
upvote count: 3

http://stackoverflow.com/q/22159233
favorite count: 0
has answer: http://stackoverflow.com/a/22159613
has comment: http://stackoverflow.com/comment/33629016
has comment: http://stackoverflow.com/comment/33629151
has comment: http://stackoverflow.com/comment/33629209
has comment: http://stackoverflow.com/comment/33628838
accepted answer: http://stackoverflow.com/a/22159613
type: AnsweredQuestion
score: -5
has title: Object and Classes: Finding balance ,annual interest rate, monthly interest rate, withdrawing, depositing
tagged with: java
has comment: http://stackoverflow.com/comment/33628805
has comment: http://stackoverflow.com/comment/33629700
has comment: http://stackoverflow.com/comment/33629082
type: Question
upvote count: 0
has comment: http://stackoverflow.com/comment/33628750
downvote count: 5
has comment: http://stackoverflow.com/comment/33629079
has body: Instructions: Design a class named Account that contains: A private int data field named id for the account ( default 0). A private double data field named balance for the account ( default 0). A private constant double data field named annualInterestRate that stores the current interest rate of 12%. Assume all accounts have the same interest rate. A private Date data field named dateCreated that stores the date when the account was created. A no-arg constructor that creates a default account. A constructor that creates an account with the specified id and initial balance. The accessor (setter) and mutator (getter) methods for id, balance, and annualInterestRate. The accessor method for dateCreated. A method named getMonthlyInterestRate() that returns the monthly interest rate in as a percentage. For example it returns 1, not .01, for a 1% monthly rate. A method named getMonthlyInterest() that returns the monthly interest. A method named withdraw that withdraws a specified amount from the account. A method named deposit that deposits a specified amount to the account. Create a project file in Bluej and implement the class. ( Hint: The method getMonthlyInterest() is to return monthly interest, not the interest rate. Monthly interest is balance * monthlyInterestRate. monthlyInterestRate is annualInterestRate /1200. Test the program using BlueJ. You should test each of the methods making sure that they are working properly. Write a second class called AccountTester which contains the main method. The account tester should do the following in this order: Create an account object Display the account balance Display the annualInterestRate Deposit $150 Display the account balance Withdraw $50 Display the account balance Deposits the monthly interest Display the account balance Here is my following code. I have errors I am just not sure how to fix them. Any help/tips would be appreciated import java.util.Scanner; import java.util.Date; public class Account { private int id …
answer count: 1
has comment: http://stackoverflow.com/comment/33628960

http://stackoverflow.com/comment/33403843
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22026019
has text: I don't think so. The code for addition command is in a package that is defined by me
type: AnswerComment

http://stackoverflow.com/comment/33587019
type: QuestionComment
has text: Perfect, glad @EJP's suggestion cleared it up!
comment on: http://stackoverflow.com/q/22134456
score: 0
type: Comment

http://stackoverflow.com/comment/33614515
type: Comment
has text: why Runnable ? hmm....
comment on: http://stackoverflow.com/a/22151524
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33666973
type: Comment
has text: Thanks. How can I only track the nested parentheses though? Is there a way to check if a matcher group contains something?
type: AnswerComment
comment on: http://stackoverflow.com/a/22158772
score: 0

http://stackoverflow.com/q/22014123
tagged with: spring
has body: I have the following log4j.xml file in my classpath: <level value="info"/> <level value="info"/> <level value="error"/> <level value="info"/> <level value="info"/> <level value="INFO"/> <appender-ref ref="Console"/> Here are the first few lines of output: log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@7220722. log4j: Using URL [file:/opt/app/cci/CCIImporter/jar/log4j.xml] for automatic log4j configuration. log4j: Preferred configurator class: org.apache.log4j.xml.DOMConfigurator log4j: System property is :null log4j: Standard DocumentBuilderFactory search succeded. log4j: DocumentBuilderFactory is: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl log4j: debug attribute= "true". log4j: reset attribute= "false". log4j: Threshold ="null". log4j: Retreiving an instance of org.apache.log4j.Logger. log4j: Setting [de.scm.cci.importer] additivity to [true]. log4j: Level value for de.scm.cci.importer is [info]. log4j: de.scm.cci.importer level set to INFO log4j: Retreiving an instance of org.apache.log4j.Logger. log4j: Setting [com.mchange] additivity to [true]. log4j: Level value for com.mchange is [info]. log4j: com.mchange level set to INFO log4j: Retreiving an instance of org.apache.log4j.Logger. log4j: Setting [jdbc] additivity to [true]. log4j: Level value for jdbc is [error]. log4j: jdbc level set to ERROR log4j: Retreiving an instance of org.apache.log4j.Logger. log4j: Setting [org.hibernate] additivity to [true]. log4j: Level value for org.hibernate is [info]. log4j: org.hibernate level set to INFO log4j: Retreiving an instance of org.apache.log4j.Logger. log4j: Setting [org.springframework] additivity to [true]. log4j: Level value for org.springframework is [info]. log4j: org.springframework level set to INFO log4j: Level value for root is [INFO]. log4j: root level set to INFO log4j: Class name: [org.apache.log4j.ConsoleAppender] log4j: Setting property [threshold] to [INFO]. log4j: Parsing layout of class: "org.apach…
has answer: http://stackoverflow.com/a/23428999
tagged with: java
has answer: http://stackoverflow.com/a/23472736
tagged with: logging
type: Question
possible better answer: http://stackoverflow.com/a/23428999
type: AnsweredQuestion
upvote count: 5
answer count: 2
score: 5
accepted answer: http://stackoverflow.com/a/23472736
downvote count: 0
has title: Duplicate log4j Logging
tagged with: log4j
favorite count: 0

http://stackoverflow.com/comment/33384050
comment on: http://stackoverflow.com/q/22022751
score: 0
type: Comment
type: QuestionComment
has text: Are you sure that gives compile-time error? It shouldn't.

http://stackoverflow.com/q/22112653
has answer: http://stackoverflow.com/a/22112989
has comment: http://stackoverflow.com/comment/33545838
has comment: http://stackoverflow.com/comment/33545097
upvote count: 0
score: -1
has comment: http://stackoverflow.com/comment/33545677
has title: Web Application based on Spring Security crashes during startup (NullPointerException)
has body: My application, which make use of Spring Security, is crashing during the startup. Tracking the execution of the application, I could verify the error is happening in method onStartup from class MainWebAppInitializer: public class MainWebAppInitializer implements WebApplicationInitializer { /** * Register and configure all Servlet container components necessary to power the web application. */ @Override public void onStartup(final ServletContext sc) throws ServletException { // Create the 'root' Spring application context final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); root.scan("com.spring.web.config"); // Manages the lifecycle of the root application context sc.addListener(new ContextLoaderListener(root)); // Handles requests into the application final ServletRegistration.Dynamic appServlet = sc.addServlet("horariolivreapp", new DispatcherServlet(new GenericWebApplicationContext())); appServlet.setLoadOnStartup(1); final Set<String> mappingConflicts = appServlet.addMapping("/"); if (!mappingConflicts.isEmpty()) { throw new IllegalStateException("'appServlet' could not be mapped to '/' due " + "to an existing mapping. This is a known issue under Tomcat versions " + "<= 7.0.14; see https://issues.apache.org/bugzilla/show_bug.cgi?id=51278"); } } } More specificly, the error occurs in the line appServlet.setLoadOnStartup(1) where a NullPointerException is triggered. Follow it is my configuration files, for reference: web.xml <?xml version="1.0" encoding="UTF-8"?> HorarioLivre horariolivreapp org.springframework.web.servlet.DispatcherServlet 1 horariolivreapp *.html contextClass org.springframework.web.context.support.AnnotationConfigWebApplicationContext contextConfigLocation com.spring.web.config org.springframework.web.context.ContextLoaderListener springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy springSecurityFilterChain /* horariolivreap-servlet.xml <?xml version="1.0" encoding="UTF-8"?>…
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33545632
type: UnansweredQuestion
tagged with: spring
tagged with: spring-mvc
has comment: http://stackoverflow.com/comment/33545857
has comment: http://stackoverflow.com/comment/33545552
tagged with: java
has comment: http://stackoverflow.com/comment/33545892
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33545706

http://stackoverflow.com/comment/33597553
has text: try removing / and .java from request dispatcher so request dispatcher should look like - request.getRequestDispatcher("servlet2").forward(request, response);
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22126807
score: 0

http://stackoverflow.com/comment/33544436
type: Comment
comment on: http://stackoverflow.com/a/22112267
type: AnswerComment
score: 0
has text: or jconsole: http://docs.oracle.com/javase/6/docs/technotes/tools/share/jconsole.html

http://stackoverflow.com/q/22100605
downvote count: 0
tagged with: image
has answer: http://stackoverflow.com/a/22100668
tagged with: jscrollpane
has title: Load image to JScrollPane
favorite count: 0
type: UnansweredQuestion
upvote count: 1
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22100717
type: Question
has body: I'm trying to create a simple map that will create a circle on a certain coordinate. I want to use an image with it's fixed size as the map and add it to a JScrollPane. My problem here is that I dont know how to add a scrollable image.
answer count: 2
has comment: http://stackoverflow.com/comment/33522995

http://stackoverflow.com/q/22010666
has comment: http://stackoverflow.com/comment/33362425
has comment: http://stackoverflow.com/comment/33362725
has title: Calling MS Sql server stored procedure which has cursor and temporal table in it from java?
upvote count: 3
tagged with: sql-server-2008
has comment: http://stackoverflow.com/comment/33363104
answer count: 1
tagged with: jdbc
favorite count: 0
has body: I have one stored proc written in MS Sql Server which has cursor and temporal table in it and returns result of one select query at the end. I am trying to call it from java with following piece of code final Connection conn = getConnection(); final CallableStatement statement = conn.prepareCall("{call dbo.storedProcName (?) }"); statement.setString(1, "value1,value2"); final ResultSet rs = statement.executeQuery(); while (rs.next()) { //some code } When I execute this code in java I get the resultset as null. The stored proc returns values when I run it on sql server console with the same parameters I am passing from java code. Any idea what causing this issue here? I am using sqljdbc4.jar, Java 7 and SQL Server 2008 R2. Error stack com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:392) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:338) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4026) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1416) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:185) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:160) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:281) Stored proc rough format create procedure [dbo].[storedProcName]( @inpurparam varchar(4000) ) as begin select some_values into #temp_table where value in (@inputparam) //declare some_variables declare @table2 table(col1 varchar(10), col2 varchar(10)) declare cursor for select * from #temp_table open cursor fetch next from cursor into some_params w…
has comment: http://stackoverflow.com/comment/33362930
has comment: http://stackoverflow.com/comment/33362993
type: AnsweredQuestion
score: 3
tagged with: stored-procedures
downvote count: 0
has answer: http://stackoverflow.com/a/22012521
accepted answer: http://stackoverflow.com/a/22012521
tagged with: java
type: Question

http://stackoverflow.com/a/22050565
has comment: http://stackoverflow.com/comment/33449600
has comment: http://stackoverflow.com/comment/33433708
answers question: http://stackoverflow.com/q/22050417
has comment: http://stackoverflow.com/comment/33433744
has body: To validate if parenthesis are all matched up, you can run through your String input of the math expression with a counter of initial value of 0, and if you find a (, increment your counter by 1, and if you find a ), decrement your counter by 1. If the counter ever reaches -1, break out, as it isn't a valid parenthesis match. In the end, you should have the counter's value as 0. If not, you have a mismatched parenthesis. For the infix to postfix case, here's a standard algorithm: Define a stack Go through each character in the string If it is between 0 to 9, append it to output string. If it is left brace push to stack If it is operator *,+,- or / then If the stack is empty push it to the stack If the stack is not empty then start a loop: If the top of the stack has higher precedence Then pop and append to output string Else break Push to the stack If it is right brace then While stack not empty and top not equal to left brace Pop from stack and append to output string Finally pop out the left brace.
accepted answer of: http://stackoverflow.com/q/22050417
score: 0
type: AcceptedAnswer
type: Answer
has comment: http://stackoverflow.com/comment/33439280
upvote count: 1
has comment: http://stackoverflow.com/comment/33433861
has comment: http://stackoverflow.com/comment/33433964
downvote count: 1

http://stackoverflow.com/comment/33488313
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22080761
has text: no, is not the entire code, but is the core, the problem is i dont know how to draw in the opositte direction.
score: 0

http://stackoverflow.com/comment/33376172
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22018599
type: Comment
has text: ok, so the constructor of the servlet is running only when I start tomcat, or the first time I call the servlet? and then won't be called any-more until a new restart of tomcat happens?

http://stackoverflow.com/comment/33391758
type: AnswerComment
type: Comment
score: 0
comment on: http://stackoverflow.com/a/22026049
has text: It's just one way to do it. Make the outer loop index go 0, 3, 6, 9 and your inner loop index go 1, 2, 1, 2, 1, 2, 1. Then the numbers with commas are the sums of the two indexes. But it's not the only way.

http://stackoverflow.com/comment/33609681
has text: I've provided three actual options in my comment. Besides, a comment does not need to be an answer, but rather help the answer along. Please refer to the stackoverflow faq. Telling the asker to make his apk available to the public, but password-protecting it, isn't "more reasonable."
type: Comment
comment on: http://stackoverflow.com/a/22148803
score: 0
type: AnswerComment

http://stackoverflow.com/a/51510605
has comment: http://stackoverflow.com/comment/107676453
type: Answer
has body: You can override FreeMarkerView like that public static class YourFreemarkerView extends FreeMarkerView { @Override protected void processTemplate(Template template, SimpleHash model, HttpServletResponse response) throws IOException, TemplateException { HttpRequestHashModel httpRequestHashModel = (HttpRequestHashModel)model.get(FreemarkerServlet.KEY_REQUEST); Environment env = template.createProcessingEnvironment(model, response.getWriter(), null); env.setLocale(RequestContextUtils.getLocale(httpRequestHashModel.getRequest())); env.setTimeZone(RequestContextUtils.getTimeZone(httpRequestHashModel.getRequest())); env.process(); } }
score: 1
has comment: http://stackoverflow.com/comment/139420395
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/22035553

http://stackoverflow.com/q/22129802
tagged with: swing
answer count: 1
score: 0
has comment: http://stackoverflow.com/comment/33576301
tagged with: java
tagged with: actionlistener
has comment: http://stackoverflow.com/comment/33576347
has answer: http://stackoverflow.com/a/22129861
tagged with: anonymous-class
type: Question
has body: I've been trying to implement this action listener as stated above but keep receiving two errors: -Cannot instantiate the type ActionListener -void is an invalid type for the variable incrementAction I've been looking up similar examples but they all seem to point to the same method of implementing it. This is where I've got to. increment.addActionListener(new ActionListener());{ public void incrementAction(ActionEvent e){ this.incrementCount(); this.setTextField(); } }
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22129861
tagged with: inner-classes
has title: Implementing an inner anonymous action listener

digest
tags question: http://stackoverflow.com/q/22117512
tag name: digest
type: Tag

http://stackoverflow.com/q/22111146
tagged with: java
upvote count: 1
type: Question
answer count: 1
downvote count: 0
score: 1
has body: I have given past one month to CAS server and CAS client as well but not get proper solution for my application yet, Please help. Here is my brief explanation:- I have two applications, one in Java and other is in ROR. I have setup CAS SERVER in JAVA, I am using self-signed certificate for CAS server and it is working well. ROR application:- Installed RubyCAS-client and it is also working well. I am facing problem in JAVA cas client. I have tried this on http and https both but every time it stuck in the redirection loop. My application(client) has started but no information is publishing in the logs on the other hand CAS server issued 11 tickets every time. here is the log: 2014-03-01 00:50:02,540 INFO [org.jasig.cas.authentication.AuthenticationManagerImpl] - <AuthenticationHandler: org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler successfully authenticated the user which provided the following credentials: [username: ankit@yopmail.com]> 2014-03-01 00:50:02,574 INFO [org.jasig.cas.CentralAuthenticationServiceImpl] - <Granted service ticket [ST-1-h6DqHWTp273M0N3IQTC5-localhost] for service [https://localhost:8444/Testing/j_spring_cas_security_check] for user [ankit@yopmail.com]> 2014-03-01 00:50:02,606 INFO [org.jasig.cas.CentralAuthenticationServiceImpl] - <Granted service ticket [ST-2-Qh2p1wolMX3j2UcVVeaF-localhost] for service [https://localhost:8444/Testing/j_spring_cas_security_check] for user [ankit@yopmail.com]> 2014-03-01 00:50:02,617 INFO [org.jasig.cas.CentralAuthenticationServiceImpl] - <Granted service ticket [ST-3-LiZI7QvcB43bKQiwi3xs-localhost] for service [https://localhost:8444/Testing/j_spring_cas_security_check] for user [ankit@yopmail.com]> 2014-03-01 00:50:02,630 INFO [org.jasig.cas.CentralAuthenticationServiceImpl] - <Granted service ticket [ST-4-QaXXQFaBc3CUIBJR1Woe-localhost] for service [https://localhost:8444/Testing/j_spring_cas_security_check] for user [ankit@yopmail.com]> 2014-03-01 00:50:02,645 INFO [org.jasig.cas.CentralA…
tagged with: spring-security
favorite count: 0
tagged with: cas
tagged with: spring-mvc
has title: Getting stuck in redirection loop after successful login in Java cas client
has answer: http://stackoverflow.com/a/22136091
type: UnansweredQuestion

http://stackoverflow.com/a/22140088
has comment: http://stackoverflow.com/comment/33597581
downvote count: 0
has comment: http://stackoverflow.com/comment/33595919
has comment: http://stackoverflow.com/comment/33594984
has comment: http://stackoverflow.com/comment/33595734
has comment: http://stackoverflow.com/comment/33595691
type: Answer
has comment: http://stackoverflow.com/comment/33596115
has comment: http://stackoverflow.com/comment/33594851
has body: Yes, a derived class can access a protected variable in a base class via both 'super' and another reference to the base class. EDIT It should be noted that I am here assuming the same package as you didn't state anything about different packages. The rules are different otherwise.
has comment: http://stackoverflow.com/comment/33595222
upvote count: 2
has comment: http://stackoverflow.com/comment/33595720
has comment: http://stackoverflow.com/comment/33596309
score: 2
answers question: http://stackoverflow.com/q/22139513

http://stackoverflow.com/a/22149190
answers question: http://stackoverflow.com/q/22146950
has comment: http://stackoverflow.com/comment/33639968
downvote count: 0
score: 1
type: Answer
upvote count: 1
has body: I see no reasons why following xpath wouldn't work driver.findElement(By.xpath("//span[contains(text(), \"" + document + "\")]")); Also, you probably need your input string to be constant //string document is words. public void testscenario123(final String document) throws Throwable { If you were to get ElementNotVisibleException then check if your locator is returning you the correct element, perhaps there is another &lt;span&gt; element present containing the text in the document variable.

http://stackoverflow.com/q/22148257
upvote count: 1
has title: Getting return values from a compiled string which contains java codes in a java program using javaCompiler
has body: I have been able to successfully call javaCompiler and even compiled a string that contains java codes as shown below. public class CompilerAPITest { final Logger logger = Logger.getLogger(CompilerAPITest.class.getName()) ; /**Java source code to be compiled dynamically*/ static String sourceCode = "package com.accordess.ca; class DynamicCompilationHelloWorld{ public static String main (String args[]){ String str=\"The return value\"; return str ;}}"; /** * Does the required object initialization and compilation. */ public void doCompilation (){ /*Creating dynamic java source code file object*/ SimpleJavaFileObject fileObject = new DynamicJavaSourceCodeObject ("com.accordess.ca.DynamicCompilationHelloWorld", sourceCode) ; JavaFileObject javaFileObjects[] = new JavaFileObject[]{fileObject} ; /*Instantiating the java compiler*/ JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); /** * Retrieving the standard file manager from compiler object, which is used to provide * basic building block for customizing how a compiler reads and writes to files. * * The same file manager can be reopened for another compiler task. * Thus we reduce the overhead of scanning through file system and jar files each time */ StandardJavaFileManager stdFileManager = compiler.getStandardFileManager(null, Locale.getDefault(), null); /* Prepare a list of compilation units (java source code file objects) to input to compilation task*/ Iterable&lt;? extends JavaFileObject&gt; compilationUnits = Arrays.asList(javaFileObjects); /*Prepare any compilation options to be used during compilation*/ //In this example, we are asking the compiler to place the output files under bin folder. String[] compileOptions = new String[]{"-d", "bin"} ; Iterable&lt;String&gt; compilationOptionss = Arrays.asList(compileOptions); /*Create a diagnostic controller, which holds the compilation problems*/ DiagnosticCollector&lt;JavaFileObject&gt; diagnostics = new DiagnosticCollector&lt;JavaFileObject&gt;(); /*Crea…
has comment: http://stackoverflow.com/comment/33608440
score: 1
tagged with: java
type: Question
tagged with: jakarta-ee
has comment: http://stackoverflow.com/comment/33670281
downvote count: 0
answer count: 1
has comment: http://stackoverflow.com/comment/33643086
has comment: http://stackoverflow.com/comment/33608497
has answer: http://stackoverflow.com/a/22148379
linked to: http://stackoverflow.com/q/12173294
has comment: http://stackoverflow.com/comment/33613399
favorite count: 0
type: UnansweredQuestion

http://stackoverflow.com/a/22132847
score: 0
has comment: http://stackoverflow.com/comment/33583229
has comment: http://stackoverflow.com/comment/33592298
type: Answer
answers question: http://stackoverflow.com/q/22121915
has body: Use enemigos.removeIndex(i++); After you remove one enemy, you need to go back one index.

http://stackoverflow.com/q/22166259
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/22166423
type: Question
linked to: http://stackoverflow.com/q/22182367
has body: I have 3 activities Add_Case1 , Add_Case2 and Add_Case3. I am using Swipe Gesture to switch back and forth between them. My problem is: I'm on Add_Case1 I fill in some data and then swipe to the Add_Case2 activity now fill in the data in Add_Case2 and swipe to the Add_Case3 activity now, if I swipe back to go to Add_Case1 or Add_Case2, I can see that the data which I filled in persists. But when I now again swipe from Add_Case1 to Add_Case2 or Add_Case3. The data has been lost . I tried using android:launchMode="singleTop" ,android:launchMode="singleTask" , even onSaveInstanceState but it's not working. Here is the relevant code for the files Add_Case1 public class Add_case1 extends Activity implements SimpleGestureListener{ private SimpleGestureFilter detector; public Spinner et5; public EditText et1,et2,et3,et4; public static String s1,s2,s3,s4,s5,s6[]; //variables defined as static so that it can be used in // Add_case3.java directly @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d("Oncreate()","Add Case 1"); if(savedInstanceState!=null) { Log.d("Oncreate() sis","Add Case 1"); et1.setText(savedInstanceState.getString("et1")); et2.setText(savedInstanceState.getString("et2")); et3.setText(savedInstanceState.getString("et3")); et4.setText(savedInstanceState.getString("et4")); } setContentView(R.layout.activity_add_case); et1=(EditText)findViewById(R.id.editText1); et2=(EditText)findViewById(R.id.editText2); et3=(EditText)findViewById(R.id.editText3); et4=(EditText)findViewById(R.id.editText4); et5=(Spinner)findViewById(R.id.case_stage); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.case_stages, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); et5.setAdapter(adapter); et5.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void…
answer count: 2
downvote count: 0
favorite count: 0
tagged with: android
has answer: http://stackoverflow.com/a/22166423
has title: Switching between swiping activities and maintaining data
upvote count: 1
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22169266
has answer: http://stackoverflow.com/a/22169266

http://stackoverflow.com/comment/33704135
comment on: http://stackoverflow.com/q/22032462
has text: Dev server perf is irrelevant.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33493419
type: QuestionComment
score: 0
has text: The line not compiling is just `String text = (JButton.get;` which is supposed to be `String text = buttons[i][j].getText();` I think. I'll fix that. edit: 2 imports were also missing
type: Comment
comment on: http://stackoverflow.com/q/22083429

http://stackoverflow.com/comment/33380878
comment on: http://stackoverflow.com/a/22021119
type: AnswerComment
score: 0
type: Comment
has text: how does in case of hibernate

http://stackoverflow.com/comment/33405351
score: 0
type: AnswerComment
has text: @ManuViswam It'll be the same complexity. As libik pointed out, there are equivalent methods to check for an empty string - use the one that is most clear. On neat "trick" is to do `"".equals(foo)`, which will also be false when `foo` is null, but not otherwise throw an Exception. This may or may not be useful here.
type: Comment
comment on: http://stackoverflow.com/a/22032413

http://stackoverflow.com/comment/33609487
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/22098086
has text: I don't think you should use an ApplicationContextProvider if it's not absolutely needed. I've updated my answer with a hello-world-like example geared to your situation, hope it helps.
score: 0

http://stackoverflow.com/a/22027571
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/135647136
downvote count: 0
has body: In Java, the javac compiler does next to nothing with volatile. It doesn't re-order statements and does almost no optimisation. The JIT on the other hand can do quite a bit of optimisation and re-ordering. The important features of volatile are; read/write access cannot be optimise away any write which occurs before a volatile write has to occur before the write. any read which occurs after a volatile read, must occur after the read.
accepted answer of: http://stackoverflow.com/q/22027496
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22027496
has comment: http://stackoverflow.com/comment/135700563
type: Answer

http://stackoverflow.com/comment/33556176
comment on: http://stackoverflow.com/q/22117738
score: 0
type: Comment
type: QuestionComment
has text: `aSun.getPosition()` allows calling the `getPosition()` method on the object referenced by the variable `aSun`. Don't you have a text book?

http://stackoverflow.com/a/22062495
has body: remove if statements from loop and create rows normally. change your loop with this for (int arrayCounter = 0; arrayCounter &lt; (documentList.size()/2); arrayCounter++) and for last row you can have if statement which will compare if (documentList.size()/2)-1 == arrayCounter).. then you will get what you are looking for else for (int arrayCounter = 0; arrayCounter &lt; documentList.size(); arrayCounter++) { if (documentList.size()/2)-1 == arrayCounter){ create 1 row}else{ create 1st row and then arraycounter ++ create 2nd row and then arraycounter ++ } }
score: 0
answers question: http://stackoverflow.com/q/22061414
type: Answer
has comment: http://stackoverflow.com/comment/33454398

http://stackoverflow.com/comment/33540426
type: QuestionComment
score: 1
has text: I think DriverManager instaces creates OutOfMemoryError,(it will create lot of Connection objects) try by using connection pooling.
comment on: http://stackoverflow.com/q/22106886
type: Comment

http://stackoverflow.com/comment/33580821
score: 1
has text: You can't include it in executable.
comment on: http://stackoverflow.com/q/22132069
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33579843
comment on: http://stackoverflow.com/q/22131527
score: 0
type: QuestionComment
type: Comment
has text: You should make your `description` field `final` and create a constructor in this abstract class which defined it; then in subclasses, create a no-arg constructor which calls `super(description)`.

http://stackoverflow.com/q/22102248
has body: I created SomeConfig to store there static data. However I try to understand witch options is better (or none of both) Before I had class SomeConfig written like: public class SomeConfig { private static int mValue = 8; private static String mString = "some String"; public static int getValue() { return mValue; } public static void setValue(int value) { mValue = value; } public static String getTheString() { return mString; } public static void setValue(String theString) { mString = theString; } } Now I changed it to: public class SomeConfig { private static SomeConfig mSomeConfig = new SomeConfig(); private int mValue = 8; private String mString = "some String"; public static int getValue() { return mSomeConfig.mValue; } public static void setValue(int value) { mSomeConfig.mValue = value; } public static String getTheString() { return mSomeConfig.mString; } public static void setValue(String theString) { mSomeConfig.mString = theString; } } Generally i changed private variables to non-static but API stays the same. What is a difference between two options I posted? Thanks,
upvote count: 2
type: UnansweredQuestion
score: 2
has answer: http://stackoverflow.com/a/22102427
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33526631
downvote count: 0
has comment: http://stackoverflow.com/comment/33526517
favorite count: 0
has answer: http://stackoverflow.com/a/22102563
tagged with: static
has comment: http://stackoverflow.com/comment/33526408
has title: How to create configuration class with static variables in java properly?
answer count: 4
has answer: http://stackoverflow.com/a/22102392
has comment: http://stackoverflow.com/comment/33526287
has answer: http://stackoverflow.com/a/22102421

http://stackoverflow.com/comment/33635243
comment on: http://stackoverflow.com/q/22162275
type: Comment
type: QuestionComment
has text: Btw, any time you have code like `if (something) { return true; } else { return false; }` you can just do `return something` instead. It's always a preferable form. So, in your case, just `return x == y && x == z`.
score: 0

http://stackoverflow.com/comment/33364039
has text: By quoting the alias for sibling level ( \"sibling_level\" ), you are making the column name case-sensitive. Unless you really need this (which I doubt), I'd suggest you get rid of the double quotes.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22010686

http://stackoverflow.com/comment/33565968
score: 0
has text: Ok I used one of the methods over there and imported it to libraries under project properties
type: Comment
comment on: http://stackoverflow.com/a/22123723
type: AnswerComment

http://stackoverflow.com/a/22508726
type: Answer
answers question: http://stackoverflow.com/q/22081336
score: 0
has body: Another point of view: Let's call c(n) the number of ways which lead to the top from the layer of depth n, thus we have c(0)=1. Since each node in the n-1 layer can be reached by two different ways from layer n (from the left or from the right), we have c(n) = 2*c(n-1). Combining this with c(0)=1 leads to c(n)=2^n.

http://stackoverflow.com/comment/33489952
comment on: http://stackoverflow.com/a/22081094
score: 0
has text: Which is exopected is Applied is the value..if you want to print the key use aJob.key
type: AnswerComment
type: Comment

game-loop
tag name: game-loop
tags question: http://stackoverflow.com/q/22128437
type: Tag
tags question: http://stackoverflow.com/q/22087399

http://stackoverflow.com/a/22163150
downvote count: 0
has comment: http://stackoverflow.com/comment/33635764
upvote count: 1
type: Answer
has body: You cannot call an instance method without an object reference. The instance method belongs, by definition, to an instance of the object's class. If the method were static, then you could call it using the name of the class. Static methods belong to the class definition itself, so no instance is required. Also, your syntax is off, it's not Byte().add(); It's Byte.add(); //static method or new Byte().add() //instance method or static method, either can be called this way.
score: 1
answers question: http://stackoverflow.com/q/22163144

http://stackoverflow.com/comment/33498584
type: QuestionComment
comment on: http://stackoverflow.com/q/22058416
score: 0
has text: Thanks for replying. I checked server logs, it just shows a warning every time I try to connect `[OServer] 2014-02-28 10:41:43:241 WARN Current implementation of storage does not support sbtree collections [ODatabaseRecordAbstract$1]`. I am not sure whether the WARN server log is the reason of the Java side error I am getting. Please advise.
type: Comment

http://stackoverflow.com/q/22138969
tagged with: jakarta-ee
has answer: http://stackoverflow.com/a/22139041
tagged with: java
type: AnsweredQuestion
downvote count: 0
score: 1
accepted answer: http://stackoverflow.com/a/22139041
type: Question
has title: How to set the first entry in treemap in java
has body: I have list of key and value pair in that i need one item to come in front. Eg :100 different type of fruits and fruitcode, i will sort alphabetically and put in JSON, i need to bring orange to be front so the order will be Orage,Apple,Banana .. etc. Is this possible Iterator itr = treeMap.entrySet().iterator(); while ( itr.hasNext() ) { Map.Entry me = (Map.Entry) itr.next(); String fruit_type="Orange"; if(fruit_type.equals(me.getValue())){ itr.remove(); } JSONObject frtObj = new JSONObject(); frtObj.put("fruitCode", me.getValue()); frtObj.put("fruitName", me.getKey()); frtArrayObj.add(frtObj);
favorite count: 0
upvote count: 1
tagged with: collections
answer count: 1

http://stackoverflow.com/q/22166048
type: Question
has answer: http://stackoverflow.com/a/22166126
has comment: http://stackoverflow.com/comment/48471980
has answer: http://stackoverflow.com/a/22166139
answer count: 3
upvote count: 1
tagged with: executable-jar
tagged with: jar
tagged with: netbeans-7
favorite count: 0
has body: I have created a Javafx project named MyProjectName in Netbeans 7.4 and I have added some external jars. Its running fine from Netbeans. After Clean and Build dist folder is created and few sub folder is created like 1-lib(containing all external jar file), 2-run321...(containing MyProjectName.jar,jnlp,html...etc), 3-webfile, 4-MyProjectName.html, 5-MyProjectName.jar(this executable jar), 6-MyProjectName.jnlp MyProjectName.jar(5-MyProjectName.jar(this executable jar)) running fine from dist folder. But when i copy MyProjectName.jar somewhere else and try to run, it is not running . It show Message Exception while running the application. But when i put lib folder(1-lib(containing all external jar file)) it is running fine. How can i run it only from MyProjectName.jar???
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/23011913
downvote count: 0
score: 1
tagged with: java
has title: Executable Jar file is not running if it is out of dist folder

http://stackoverflow.com/comment/33542560
score: 0
type: QuestionComment
has text: Its always the third passed argument?
type: Comment
comment on: http://stackoverflow.com/q/22111046

http://stackoverflow.com/comment/33598391
type: QuestionComment
has text: @BlueRidgeTigers I think you simply need to keep one list of visited pages starting with you root page. When you visit a page you check that it's not already in the list, if it's not you add the page to the list then parse it. If you're parsing a lot of pages, you might have to optimise the check - maybe splitting the list by domain, etc.
type: Comment
comment on: http://stackoverflow.com/q/22141880
score: 0

http://stackoverflow.com/comment/87062698
has text: jm0 it did not work for me without fully qualified classname, though it was imported. It did compile successfully though.
type: AnswerComment
comment on: http://stackoverflow.com/a/29020641
type: Comment
score: 3

http://stackoverflow.com/comment/33390627
score: 59
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22026104
has text: It's so that if anyone says "why are you using Eclipse?", you can say "I have NO IDEA".

http://stackoverflow.com/a/22110159
has comment: http://stackoverflow.com/comment/33540868
answers question: http://stackoverflow.com/q/22110106
downvote count: 0
type: Answer
has body: You're trying to call an instance method on a class -- don't do that but instead call it on an instance -- create an object from the class and then call the method. e.g., It's not: MyClass.someMethod(); but rather MyClass myInstance = new MyClass(); myInstance.someMethod(); And regardless, this is not how you use applets. Rather they're supposed to be used in an HTML page or with an applet loader. Instead create a JFrame or JDialog and display it.
score: 2
upvote count: 2

http://stackoverflow.com/q/22157510
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/22164917
upvote count: 5
tagged with: java
score: 4
answer count: 2
favorite count: 0
type: UnansweredQuestion
tagged with: android
has title: Moving sprite from point to point
has answer: http://stackoverflow.com/a/22159433
has body: I want to move a sprite between two points. first point is x=0 and y=0 and the second point is a point where the user touched the screen. To move, I want to use an equation to go through the two points which is y=ax+b. I have attempted this in the method move() but the sprite does not move. Please help. Class Display: package com.example.name; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; public class Display extends SurfaceView { private Bitmap bmp; private SurfaceHolder holder; private GameLoopThread gameLoopThread; private Sprite sprite; private long lastClick; private float x = 0.0F; private float y = 0.0F; public Display(Context context) { super(context); bmp = BitmapFactory.decodeResource(getResources(), R.drawable.gonia); sprite = new Sprite(this, bmp, x, y, x, y); gameLoopThread = new GameLoopThread(this); holder = getHolder(); holder.addCallback(new SurfaceHolder.Callback() { @Override public void surfaceDestroyed(SurfaceHolder holder) { boolean retry = true; gameLoopThread.setRunning(false); while (retry) { try { gameLoopThread.join(); retry = false; } catch (InterruptedException e) { } } } @Override public void surfaceCreated(SurfaceHolder holder) { gameLoopThread.setRunning(true); gameLoopThread.start(); } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } }); } @Override protected void onDraw(Canvas canvas) { canvas.drawColor(Color.BLACK); sprite.onDraw(canvas); } @Override public boolean onTouchEvent(MotionEvent event) { if (System.currentTimeMillis() - lastClick &gt; 500) { lastClick = System.currentTimeMillis(); x = (float) sprite.ostatniaWartoscX(); y = (float) sprite.ostatniaWartoscY(); float gotox = (float) event.getX(); float gotoy = (float) event.getY(); synchronized (getHolder()) {…

http://stackoverflow.com/comment/33545631
has text: *"use the setBounds() method"* ..unless of course, you want a *reliable and robust* GUI. Java GUIs might have to work on a number of platforms, on different screen resolutions & using different PLAFs. As such they are not conducive to exact placement of components. To organize the components for a robust GUI, instead use layout managers, or [combinations of them](http://stackoverflow.com/a/5630271/418556), along with layout padding & borders for [white space](http://stackoverflow.com/q/17874717/418556).
comment on: http://stackoverflow.com/a/22112552
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/comment/33364919
type: Comment
has text: Hey Guys! So I made the alterations and not getting any errors. However, I doesn't print out "name" or even "age" when the main method is executed: if (optionSelected == 2) { System.out.println(zac.displayProfile()); }
comment on: http://stackoverflow.com/q/22011835
score: 0
type: QuestionComment

http://stackoverflow.com/comment/33555982
score: 1
comment on: http://stackoverflow.com/a/22118776
has text: what if the file is called `InPayed_OutPayed.txt` ?
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33593800
type: QuestionComment
has text: Seems some problem with your adapter.. please post the complete code
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22139571

http://stackoverflow.com/q/22141060
has answer: http://stackoverflow.com/a/22203815
has comment: http://stackoverflow.com/comment/33696784
downvote count: 0
answer count: 1
favorite count: 0
linked to: http://stackoverflow.com/q/7993652
has comment: http://stackoverflow.com/comment/34058188
has comment: http://stackoverflow.com/comment/33699065
has comment: http://stackoverflow.com/comment/33793992
has comment: http://stackoverflow.com/comment/33799323
tagged with: android
has comment: http://stackoverflow.com/comment/33701062
has title: Webcam supported picture sizes
accepted answer: http://stackoverflow.com/a/22203815
type: AnsweredQuestion
has body: I am attempting to retrieve the available picture-size resolutions supported by my webcam; using the OpenCV library. I have tried working with similar Android question/answers but to no avail. (e.g. Android camera supported picture sizes). Here is my code: import org.opencv.highgui.VideoCapture; import org.opencv.core.Size; public class MyCameraCaptureClass { public static void main(String[] args) { System.out.println("Hello, OpenCV"); System.out.println("This program will display the webcam's supported sizes"); System.loadLibrary("opencv_java248"); //load .dll for the jar VideoCapture vidCap0 = new VideoCapture(0); if (vidCap0.isOpened()) { System.out.println("Camera found, and it works so far..."); for (Size aSize : vidCap0.getSupportedPreviewSizes()) { System.out.println("Doesn't print this at all"); System.out.println("Height:" + aSize.height + "Width:" + aSize.width); } } vidCap0.release(); } } And the stack trace is: Exception in thread "main" java.lang.Exception: unknown exception at org.opencv.highgui.VideoCapture.getSupportedPreviewSizes_0(Native Method) at org.opencv.highgui.VideoCapture.getSupportedPreviewSizes(VideoCapture.java:478) at webcam.MyCameraCaptureClass.main(MyCameraCaptureClass.java:19) All help will be sincerely appreciated.
tagged with: java
upvote count: 10
type: Question
has comment: http://stackoverflow.com/comment/33690651
tagged with: opencv
has comment: http://stackoverflow.com/comment/33698206
score: 10
has comment: http://stackoverflow.com/comment/33980445

http://stackoverflow.com/comment/100348447
type: Comment
comment on: http://stackoverflow.com/a/22042085
has text: I saw that, but TBH at that point you'd probably be better using ReactNative or something else.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33492736
score: 0
has text: @user3362775 ok, just assumed you may have wanted `uno, dos, tres, ...` Glad it's working the way you want!
comment on: http://stackoverflow.com/a/22083273
type: AnswerComment
type: Comment

http://stackoverflow.com/a/22093356
type: AcceptedAnswer
has body: You are mixing layout with non-layout panels. This is not going to work well, if you do not set the size of the TabLayoutPanel within the DisclosurePanel explicitly.
type: Answer
accepted answer of: http://stackoverflow.com/q/22092949
answers question: http://stackoverflow.com/q/22092949
score: 0
has comment: http://stackoverflow.com/comment/33513616

http://stackoverflow.com/comment/33556636
type: QuestionComment
comment on: http://stackoverflow.com/q/22118846
has text: Same error nothing changed
score: 0
type: Comment

http://stackoverflow.com/comment/33404187
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22034064
has text: @AchintyaJha yes, that is what I'm asking.
score: 0

http://stackoverflow.com/comment/33480827
type: QuestionComment
has text: I've been googling around looking for .dat files containing *control points*, but the only standard format (I didn't knew that exists an standard format of .dat files) I've found is either: *Cambridge .DAT* file format or a type of csv containing waypoints. In what format is your "dichromatic.dat" file ? could you post a sample?
score: 0
comment on: http://stackoverflow.com/q/22073976
type: Comment

long-polling
tags question: http://stackoverflow.com/q/22166256
type: Tag
tag name: long-polling

http://stackoverflow.com/comment/33465055
comment on: http://stackoverflow.com/a/22068537
type: AnswerComment
has text: @WATTOStudios no more comments after your last edit :)
score: 0
type: Comment

http://stackoverflow.com/q/22026995
has body: Is there any property or any code that I can implement to make an icon inside a JLabel resizable. Or is there any other item which can store an image, that I could use to have a resizable image inside a JFrame?
has answer: http://stackoverflow.com/a/22028594
tagged with: image
has comment: http://stackoverflow.com/comment/33392179
score: 0
linked to: http://stackoverflow.com/q/14548808
has answer: http://stackoverflow.com/a/22030589
answer count: 3
tagged with: jlabel
tagged with: imageicon
has answer: http://stackoverflow.com/a/22027598
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33392337
has comment: http://stackoverflow.com/comment/33392525
tagged with: java
tagged with: swing
has title: Can I make resizable the icon inside a jlabel?
type: Question

http://stackoverflow.com/a/22069615
upvote count: 1
has comment: http://stackoverflow.com/comment/33475276
answers question: http://stackoverflow.com/q/22069525
type: Answer
has comment: http://stackoverflow.com/comment/33501406
has comment: http://stackoverflow.com/comment/33471770
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33487604
has body: The standard card manager's AID is defined by GlobalPlatform as follows : A0000001510000

http://stackoverflow.com/comment/33599714
type: Comment
score: 1
has text: Your code style indicates that you're new enough to Java that you *really* shouldn't be attempting reflection yet.
comment on: http://stackoverflow.com/q/22143361
type: QuestionComment

http://stackoverflow.com/a/22030503
downvote count: 1
accepted answer of: http://stackoverflow.com/q/22019291
type: Answer
upvote count: 0
score: -1
has body: I have implemented a custom key generator to solve this. Still I think this can be solved by ehcache without using a custom key generator. But i could not get the answer anywhere. Please see my answer below: @Component public class Home { private Parameter param; @Cacheable(cacheName = "homeCache", keyGenerator = @KeyGenerator(name = "com.myapp.cache.Home.ParamKeyGenerator")) public Result getPerson(Person p) { //Do something with p return result; } public Parameter getParam() { return param; } public void setParam(Parameter param) { this.param = param; } public static class ParamKeyGenerator implements CacheKeyGenerator&lt;Serializable&gt; { public Serializable generateKey(MethodInvocation methodInvocation) { Object[] obj = methodInvocation.getArguments(); Home h = (Home) methodInvocation.getThis(); return this.generateKey(obj[0], h.getParam()); } public Serializable generateKey(Object... data) { String key = ((Person) data[0]).getName() + ((Parameter) data[1]).getName(); System.out.println("generating key: " + key); return key; } } }
answers question: http://stackoverflow.com/q/22019291
type: AcceptedAnswer

http://stackoverflow.com/q/22163687
has comment: http://stackoverflow.com/comment/33637800
type: UnansweredQuestion
upvote count: 1
tagged with: swing
downvote count: 1
linked to: http://stackoverflow.com/q/22143648
tagged with: nimbus
tagged with: jbutton
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/22166047
has body: I have used Nimbus to create rounded corners for buttons in swing referring here: Use Nimbus to give rounded corners for JButton I now want to give a 3d look to the buttons. How should I go about this using nimbus? i had gone through nimbus but coudnt find appropriate info note: I have added image where button1 shows that I have used: generateButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); and second with nimbus effect
has comment: http://stackoverflow.com/comment/33638524
has comment: http://stackoverflow.com/comment/33638037
answer count: 1
has comment: http://stackoverflow.com/comment/33636477
linked to: http://stackoverflow.com/q/12233928
favorite count: 0
has title: 3D Effect to buttons in java swing using nimbus
score: 0
has comment: http://stackoverflow.com/comment/33638720
has comment: http://stackoverflow.com/comment/33638061
has comment: http://stackoverflow.com/comment/33638124

http://stackoverflow.com/q/22107351
has body: I've been trying to get an enemy's coordinates so I can act on where they are. The code I use does not seem to work: double absBearing = e.getBearingRadians() + e.getHeadingRadians(); double ex = getX() + e.getDistance() * Math.sin(absBearing); double ey = getY() + e.getDistance() * Math.cos(absBearing); I seem to be getting odd returns that are giving me values greater than the size of the field and even minus numbers, has anyone any idea on how to ammend this piece of code to get the enemy's X and Y in the same way my X and Y is returned?
upvote count: 6
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/22743501
downvote count: 1
type: Question
tagged with: robocode
has comment: http://stackoverflow.com/comment/33535991
has comment: http://stackoverflow.com/comment/33538345
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/22743501
has title: Robocode how to get the enemies co-ordinates
score: 5

http://stackoverflow.com/q/22144294
has comment: http://stackoverflow.com/comment/33601423
possible better answer: http://stackoverflow.com/a/22145653
score: 0
has answer: http://stackoverflow.com/a/22145653
linked to: http://stackoverflow.com/q/13761639
tagged with: android
has answer: http://stackoverflow.com/a/22145324
has body: You can find my code here: How to correctly build table with data using onPostExecute and ListView I need to do loading data from the server when my ListView is scroll to the bottom. I tried to looking for solution on Stackoverflow, but it is not helpful for me. Also if it's not difficult i like to know how it's work for understand all. Thank's to all
has comment: http://stackoverflow.com/comment/33601394
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/22145324
has title: How i can load new elements when my ListView is scrolled to bottom?
type: Question
linked to: http://stackoverflow.com/q/22048333
answer count: 2

http://stackoverflow.com/comment/33593611
comment on: http://stackoverflow.com/a/22138346
has text: `BufferedReader` is designed for reading text files so yeah !
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33547379
score: 0
type: Comment
has text: Unfortunately I don't have any control over the input at all. Something else weird just happened as well. I submitted my code with the foo() and it used 6.4MB but when I submitted immediately after again it used 20MB. Now I'm thinking it has something to do with codeeval. Thanks everyone. Will still be trying to figure it out
type: QuestionComment
comment on: http://stackoverflow.com/q/22113578

http://stackoverflow.com/q/22029656
has answer: http://stackoverflow.com/a/22030187
has title: Is static method without any parameters thread-safe?
possible better answer: http://stackoverflow.com/a/22029682
has body: I have a counter and multiple threads access the getCount method. The code is like the following: public class ThreadSafeMethod { public static int counter = 0; public static int getCount() { return counter++; } } Is the method thread safe? My understanding is that because counter++ is not atomatic, it is not safe. Then how to make it safe? If we add synchronized keyword, what object will be synchronized?
answer count: 4
accepted answer: http://stackoverflow.com/a/22029684
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22029682
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22029700
score: 0
linked to: http://stackoverflow.com/q/578904
has answer: http://stackoverflow.com/a/22029684
tagged with: multithreading

http://stackoverflow.com/comment/33587996
has text: Thanks, I'll look more into classes and defining variables
type: AnswerComment
comment on: http://stackoverflow.com/a/22108248
score: 0
type: Comment

http://stackoverflow.com/comment/33609179
has text: You're correct, I've read the link and I think the `Home Object` is a Hibernate alternative to the `DAO`, though **We can use a Home directly from a JSF page** suggests extra functionality (since this doesn't correspond with the layer model in my opinion). Maybe the previous developer misinterpreted the meant usage of these type of objects, since he implemented both `Home` and `DAO`?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22148410

http://stackoverflow.com/a/25668640
score: -3
type: Answer
upvote count: 0
answers question: http://stackoverflow.com/q/22063509
has body: Although I don't know what's the issue exactly, but from the log I found it's strange that the plugin reading source.properties from D:\adt-bundle-windows-x86-20130522\sdk\tools\tools\source.properties. I think the right path should be ...\sdk\tools\source.properties. You can try the following places and see if something is wrong: 1.Eclipse: Windows | Preferences | Android | SDK Location 2.Windows Environment variable for ANDROID_HOME
downvote count: 3

http://stackoverflow.com/comment/33498429
has text: you could run and check the behavior :)
type: Comment
type: QuestionComment
score: 2
comment on: http://stackoverflow.com/q/22086709

http://stackoverflow.com/q/22055295
has comment: http://stackoverflow.com/comment/33457556
type: UnansweredQuestion
tagged with: swt
answer count: 0
score: 0
tagged with: java
has title: Java program crashes on eclipse with weird error
type: Question
has body: I have this java project with SWT's GUI in it. I have been working on it for a couple of weeks now, but I ran into some problem I could not solve. I have a MainMenu object that renders the main menu, and it has some buttons on it. public static void main(String[] args) { MainMenu menu=new MainMenu(); menu.run(); } the main menu has an inner class that extends MouseAdapter: private class StartGameListener extends MouseAdapter Its all purpose is to listen to the Start game button and launch up the game according to user selection, one of them offers a custom board game, where the player get to decide the initial position of the draughts on the board. To implement that, I created an object called CustomBoard. So, whenever the user presses the StartGame button and the "Custom Game" option is checked, it fires up the "mouseUp()" method inside the inner class StartGameListener, and instantiates a CustomBoard object and (supposed to) run it. Problem is, whenever the control gets to the constructor line: CustomBoard custom_board_menu=new CustomBoard(display, board_size); I get this nasty error in the console; (SWT:2806): GLib-GObject-CRITICAL **: g_closure_add_invalidate_notifier: assertion 'closure-&gt;n_inotifiers &lt; CLOSURE_MAX_N_INOTIFIERS' failed appearing over and over again in an infinite loop, and the program crushes of course. I should (maybe) mention three things: 1. Every time different code error appears (this time it is (SWT:2806) as you can see). 2. I have another GUI object that runs perfectly fine from the same "mouseUp()" method. 3. And this is the weirdest of all: When I instantiate CustomBoard object independently from the MainMenu, meaning: public static void main(String[] args) { CustomBoard cb=new CustomBoard(new Display(), 8); cb.run(); } it works! I tried to google it, but couldn't find any information regarding this error. Any help would be greatly appreciated!
has comment: http://stackoverflow.com/comment/33443980
has comment: http://stackoverflow.com/comment/33442532
has comment: http://stackoverflow.com/comment/33443098
tagged with: user-interface

http://stackoverflow.com/comment/33525146
comment on: http://stackoverflow.com/q/22101371
has text: Is this a generic question or are you interested in enforcing a lock acquisition ordering?
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33363315
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22011356
has text: `org.codehaus.jackson`? Still using Jackson 1.9.x? ;)
type: Comment

http://stackoverflow.com/a/22163206
has body: You cant call an instance method without an Object reference. But if the method is static you can call it with class. If you want to call a method without making an instance make that method static. Please learn difference between static and instance method
answers question: http://stackoverflow.com/q/22163144
upvote count: 1
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/comment/33512304
type: AnswerComment
comment on: http://stackoverflow.com/a/22087460
has text: @user1613403 I think I answered this already. That's the standard process of doing it with JMS queues. Topics don't support that.
score: 0
type: Comment

selenium-webdriver
tags question: http://stackoverflow.com/q/22018124
tags question: http://stackoverflow.com/q/22034583
tags question: http://stackoverflow.com/q/22168004
tags question: http://stackoverflow.com/q/22070278
tags question: http://stackoverflow.com/q/22021793
tags question: http://stackoverflow.com/q/22055527
tags question: http://stackoverflow.com/q/22110282
tags question: http://stackoverflow.com/q/22021031
tags question: http://stackoverflow.com/q/22008715
tags question: http://stackoverflow.com/q/22095543
tags question: http://stackoverflow.com/q/22091892
tags question: http://stackoverflow.com/q/22139498
tags question: http://stackoverflow.com/q/22143465
tags question: http://stackoverflow.com/q/22058872
tags question: http://stackoverflow.com/q/22099124
tag name: selenium-webdriver
tags question: http://stackoverflow.com/q/22010614
tags question: http://stackoverflow.com/q/22008953
tags question: http://stackoverflow.com/q/22162937
tags question: http://stackoverflow.com/q/22145776
tags question: http://stackoverflow.com/q/22091246
tags question: http://stackoverflow.com/q/22149626
tags question: http://stackoverflow.com/q/22110004
tags question: http://stackoverflow.com/q/22039766
tags question: http://stackoverflow.com/q/22089243
tags question: http://stackoverflow.com/q/22144945
tags question: http://stackoverflow.com/q/22087952
tags question: http://stackoverflow.com/q/22067856
tags question: http://stackoverflow.com/q/22049976
tags question: http://stackoverflow.com/q/22012076
tags question: http://stackoverflow.com/q/22168651
tags question: http://stackoverflow.com/q/22072286
tags question: http://stackoverflow.com/q/22166234
tags question: http://stackoverflow.com/q/22070014
tags question: http://stackoverflow.com/q/22014233
tags question: http://stackoverflow.com/q/22023799
type: Tag
tags question: http://stackoverflow.com/q/22058636
tags question: http://stackoverflow.com/q/22106436
tags question: http://stackoverflow.com/q/22037573

http://stackoverflow.com/comment/33605677
comment on: http://stackoverflow.com/a/22144816
type: AnswerComment
score: 0
type: Comment
has text: This is for reading encrypted sheet..I want to encrypt sheet with a password.

http://stackoverflow.com/comment/33636003
type: QuestionComment
has text: you will need Context to call `findViewById`
score: 0
comment on: http://stackoverflow.com/q/22163457
type: Comment

http://stackoverflow.com/comment/33443966
type: QuestionComment
comment on: http://stackoverflow.com/q/22046896
has text: We have directly displayed the output to the end users and they are really worried as they get this sort of number instead of actual value they get from doing it manually. I overcame the issue after rounding the output in GUI.
score: 0
type: Comment

http://stackoverflow.com/q/22143901
tagged with: java
has answer: http://stackoverflow.com/a/22149209
tagged with: eclipse
type: Question
answer count: 2
tagged with: javascript
has comment: http://stackoverflow.com/comment/33605138
score: 0
tagged with: preferences
type: UnansweredQuestion
has body: When using "File Search" in eclipse with resulting Java file results in the search window. Originally clicking one of these results used to bring up the Java editor. However, I installed and uninstalled a javascript plugin and now clicking on a Java file brings up the javascript editor. Anyone know where these options can be changed or restored?
has answer: http://stackoverflow.com/a/22143936
has title: Eclipse file associations for search

http://stackoverflow.com/q/22060858
possible better answer: http://stackoverflow.com/a/22065171
favorite count: 0
tagged with: wicket
type: AnsweredQuestion
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22098704
upvote count: 1
has body: I am implementing AjaxRequestTarget.IListener. So my application automatically updates FeedbackPanel if there is any messages. And I would like to check if there is any messages my code: getAjaxRequestTargetListeners().add(new AjaxRequestTarget.IListener() { @Override public void onBeforeRespond(Map&lt;String, Component&gt; map, final AjaxRequestTarget target) { WebSession.get().getFeedbackMessages(); // Doesnt work target.getPage().getSession().getFeedbackMessages(); // Doesnt work target.getPage().visitChildren(IFeedback.class, new IVisitor&lt;Component, Void&gt;() { @Override public void component(Component component, IVisit&lt;Void&gt; visit) { if (component.isVisibleInHierarchy()) { target.add(component); } } }); } @Override public void onAfterRespond(Map&lt;String, Component&gt; map, AjaxRequestTarget.IJavaScriptResponse response) { } });
type: Question
tagged with: session
has title: How to get wicket's FeedbackMessages count
has answer: http://stackoverflow.com/a/22065171
answer count: 3
has answer: http://stackoverflow.com/a/22677412
accepted answer: http://stackoverflow.com/a/22098704
downvote count: 0

rpc
tag name: rpc
tags question: http://stackoverflow.com/q/22072398
type: Tag
tags question: http://stackoverflow.com/q/22036850

http://stackoverflow.com/comment/33392071
comment on: http://stackoverflow.com/a/22023495
type: Comment
has text: didn't help me..please someone help me
score: 0
type: AnswerComment

http://stackoverflow.com/q/22130654
answer count: 1
has title: Could not find class 'com.github.sendgrid.Sendgrid' from method com.example.master.SigupActivity.sendEmail
has answer: http://stackoverflow.com/a/22360656
accepted answer: http://stackoverflow.com/a/22360656
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
tagged with: sendgrid
tagged with: eclipse
has body: I have having in issue in Java eclipse IDE, where I access a function called send() from class com.github.sendgrid.Sendgrid. I have included all the required jars in the libs folder and added then added the jars to the calsspath. I get no compile errors, but get Java java.lang.noclassdeffounderror:com.github.sendgrid. I am using sendgrid api for my android application in Eclipse IDE. Thank you.
type: Question
upvote count: 1
has comment: http://stackoverflow.com/comment/33587144
favorite count: 0
tagged with: android

http://stackoverflow.com/comment/33374376
comment on: http://stackoverflow.com/a/22014363
has text: Good answer. But you can get to the Expression object, and its dependencies, using the API in the original question just as well. There are two layers of indirection: XPathExecutable.getUnderlyingExpression().getInternalExpression()
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33558008
comment on: http://stackoverflow.com/a/22119729
type: Comment
has text: That's a really good point! I've added an additional bit of info to my answer
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33559748
type: AnswerComment
type: Comment
has text: http://code.google.com/p/libgdx/wiki/FileModule this page has lots of variations on calling resource files like .mp3s or .txts files for a game. You could try `FileHandle handle = Gdx.files.external("myfile.txt");` or `FileHandle handle = Gdx.files.classpath("myfile.txt");`
comment on: http://stackoverflow.com/a/22120026
score: 0

http://stackoverflow.com/a/22522146
has body: For the original question, I think you are not looking for a load balancer, but just a plain reverse proxy with the twist that it has to be dynamic. Check out Apache httpd mod_proxy with mod_rewrite. For the dynamic part maybe your tomcats can register their connected "refrigerators" in a sqldb, in that case use RewriteMap with dbd.
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/22082865
has comment: http://stackoverflow.com/comment/34330499
downvote count: 0

http://stackoverflow.com/q/22059165
answer count: 2
tagged with: swing
has comment: http://stackoverflow.com/comment/33449162
tagged with: java
has answer: http://stackoverflow.com/a/22059290
possible better answer: http://stackoverflow.com/a/22059424
score: 2
type: AnsweredQuestion
has title: Having two objects move in an SwingBot
has answer: http://stackoverflow.com/a/22059424
downvote count: 0
has comment: http://stackoverflow.com/comment/33449154
has body: I'm trying to make it so that both shapes move when the commands are pressed. My question is: How do I get the blue polygon to move along with the yellow rectangle? I can't seem to figure it out, no matter what I do. Any help is appreciated! thanks! EDIT: Removed Timer Code (it is for something different) import javax.swing.JFrame; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import javax.swing.JComponent; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import java.awt.Color; import java.awt.Polygon; import java.util.Scanner; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Random; import javax.swing.JFrame; import javax.swing.Timer; public class Original { public static void main(String[] args) { // contruction of new JFrame object JFrame frame = new JFrame(); // mutators frame.setSize(400,400); frame.setTitle("SwingBot"); // program ends when window closes frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Robot r = new Robot(); frame.add(r); // voila! frame.setVisible(true); // your Scanner-based command loop goes here int noend = 0; System.out.println("Type a Command:"); while(noend == 0) { Scanner input = new Scanner(System.in); String command = input.next(); if(command.equals("left")) r.moveBot(-10,0); if(command.equals("right")) r.moveBot(10,0); if(command.equals("down")) r.moveBot(0,10); if(command.equals("up")) r.moveBot(0,-10); } // call methods on the Robot instance like w.moveBot(10,10) in response to // user input } public static class Robot extends JComponent { private Rectangle rect = new Rectangle(20,60); private Polygon poly = new Polygon(); public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; // set the color g2.setColor(Color.ORANGE); // draw the shape` g2.fill(rect); int xPoly[] = {75, 125, 170, 170, 200, 105, 60}; int yPoly[] = {75, 50, 88, 111, 125, 180, 150}; poly = new Polygon(xPoly, yPoly, xPoly.length); super.paintComponent(g); g…
favorite count: 0
type: Question
tagged with: paintcomponent
linked to: http://stackoverflow.com/q/21868170
accepted answer: http://stackoverflow.com/a/22059290
has comment: http://stackoverflow.com/comment/33449193
tagged with: timer
upvote count: 2

http://stackoverflow.com/comment/33923964
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/22297926
has text: ill upgrade to new one and check

http://stackoverflow.com/comment/33415513
score: 0
type: Comment
has text: I'm pretty sure that you are looking for the Convex Hull ( http://en.wikipedia.org/wiki/Convex_hull ) of the click positions. There are various algorithms for that (e.g. the "Graham Scan"). You can probably find a Java implementation with these keywords.
type: QuestionComment
comment on: http://stackoverflow.com/q/22035293

http://stackoverflow.com/comment/33619163
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22153980
score: 0
has text: You said you can't use arrays. What can you use?

http://stackoverflow.com/comment/33625011
comment on: http://stackoverflow.com/a/22154115
type: AnswerComment
score: 0
type: Comment
has text: Thank you for your help. I add 'sys' as your advice and divisi2 is read. But it said there is an invaild syntax in one of divisi2's file. I have no idea, so I try another meaning. Would you mind help me have a look at it? Thank you. [link](http://stackoverflow.com/questions/22157108/how-to-send-arguments-to-python-in-java)

http://stackoverflow.com/q/22091083
tagged with: jtree
has title: Cannot add leaf to Jtree
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/33506635
favorite count: 0
has answer: http://stackoverflow.com/a/22092126
tagged with: swing
type: AnsweredQuestion
score: 1
tagged with: defaulttreemodel
tagged with: java
has body: I am tryng to build a Tree, but I cannot add any leaf, only be able to add to the root. Below an example do you have any help? Thanks, Gianluca import java.awt.Dimension; import java.util.ArrayList; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTextField; import javax.swing.JTree; import javax.swing.UIManager; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeSelectionModel; public class ExtendePedigree extends JPanel{ private JTree tree; private static String lineStyle = "Horizontal"; private static boolean useSystemLookAndFeel = false; private JPanel descPanel; private JTextField anelloText; private JTextField varieta; private int toReturn; public ExtendePedigree(String soggetto){ JDialog extPedigreeJDialog = new JDialog(); //Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode(soggetto); createNodes(top,soggetto); //Create a tree that allows one selection at a time. tree = new JTree(top); tree.getSelectionModel().setSelectionMode (TreeSelectionModel.SINGLE_TREE_SELECTION); //Listen for when the selection changes. //tree.addTreeSelectionListener(this); //Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); descPanel = new JPanel(); //descPane.setEditable(false); JLabel anello = new JLabel("Anello"); anelloText = new JTextField(20); JLabel varietaLabel = new JLabel("Descrizione"); varieta = new JTextField(50); descPanel.add(anello); descPanel.add(anelloText); descPanel.add(varietaLabel); descPanel.add(varieta); JScrollPane descView = new JScrollPane(descPanel); //Add the scroll panes to a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(descView); Dimension minimumSize = new Dimension(1024, 768); descView.setMinimumSize(minimumSize); treeView.…
upvote count: 1
accepted answer: http://stackoverflow.com/a/22092126
type: Question
has comment: http://stackoverflow.com/comment/33506372

http://stackoverflow.com/comment/33449161
comment on: http://stackoverflow.com/a/22059038
type: Comment
has text: For sure. Most of the top section should be a single method that gets called twice, then most of the bottom section can be removed completely.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33535920
type: Comment
has text: Code faster with Intellij IDEA [live templates](http://maciejwalkowiak.pl/blog/2014/01/14/code-faster-with-intellij-idea-live-templates/a).
type: QuestionComment
comment on: http://stackoverflow.com/q/22093561
score: 0

http://stackoverflow.com/comment/33566034
has text: i am not asking u guys to do the basic program for me , I just want to study, just want to learn the way of think when program and very appreciate the kind people who helping me ,am I wrong? if u don't like what i did, just don't leave any comments. actually from this post, I learned I can use object to be the parameter, is it specifically?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22123972
score: 2

http://stackoverflow.com/q/22047330
tagged with: multithreading
has answer: http://stackoverflow.com/a/22596295
tagged with: android
upvote count: 1
type: AnsweredQuestion
score: 1
tagged with: java
tagged with: chat
type: Question
accepted answer: http://stackoverflow.com/a/22596295
answer count: 2
tagged with: network-programming
has body: I'm writing an Android chat application and right now I have a problem with organization of server request-response. In my chat messages are represented in JSON format with field TransactionId which is unique for a particular set of request-response pair. For example, request to set message as read: {Type : "READ_MESSAGE", Sender : "Alice", Recievier : "server", Body : "123456", TransactionId : "550e8400-e29b-41d4-a716-446655440000"} and corresponding response : {Type : "READ_MESSAGE", Sender : "server", Recievier : "Alice", Body : "1", TransactionId : "550e8400-e29b-41d4-a716-446655440000"} Id here is used to identificate for which request response has come, for example, in case when I'm waiting for 5 different READ_MESSAGE responses. But here's the problem. My android client consists of one thread, that accepts incoming messages, and a separate thread per outcoming message. So I can't wait for response in the outcoming message thread, and right now I use this code: private void sendJSON(final String JSON) { Thread t = new Thread(new Runnable() { @Override public void run() { runnable.out.println(JSON); JSONMessage json = new JSONMessage(JSON); //After 5 seconds we should check: was message sent successfully? try { Thread.sleep(5000L); } catch (InterruptedException e) { e.printStackTrace(); } sendMessageToUI(json.getTransactionId(), CHECK_IF_SENT); } }); t.start(); } and private void proceeIncoming() { while (!SocketClient.this.toExit) { try { String str = SocketClient.this.in.readLine(); if (str != null) { JSONMessage recievedMsg = new JSONMessage(str); switch (recievedMsg.getType()) { case MESSAGE: SocketService.this.sendJSON(new JSONMessage.Builder(MessageType.RECEIVED_MESSAGE, Global.getUserPref().getString("Username", ""), "server", recievedMsg.getTransactionId()).build().toString()); SocketService.this.sendMessageToUI(str, MSG_SEND_JSON_MESSAGE); History.writeJSON(str); break; case RECEIVED_MESSAGE: SocketService.this.sendMessageToUI(recievedMsg.getTransactio…
has title: Request-Response messaging format and algorithm design
has answer: http://stackoverflow.com/a/22047634
downvote count: 0
favorite count: 0
possible better answer: http://stackoverflow.com/a/22047634

http://stackoverflow.com/q/22137386
has comment: http://stackoverflow.com/comment/33589646
has title: Using printf in java
tagged with: system.out
has comment: http://stackoverflow.com/comment/33589594
has comment: http://stackoverflow.com/comment/33589625
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22137452
has comment: http://stackoverflow.com/comment/33589598
score: 0
tagged with: java
has body: Following the format below.. System.out.printf("%.2f", val); Was wondering how i could get my output to be 2 decimal places to the left side not to the right? I am trying to compute monthly interest rate. My formula in my class method is: Annual Rate is set at 4.5 it cannot be changed so i have it set to: private static in my separate class. Formula for monthlyInterest return (annualInterestRate / 12) * balance; Then when i go back to main and try and print as follows: "\nAnnual Rate:\t" + String.format("%.2f", a.getAnnualRate()) Results ID: 1122 Created: 03/02/14 Owner: Tom H Opening Balance: $100.0 Annual Rate: 4.50 Monthly Interest: 37.5 &lt;-----Would like this to display the monthly interest properly
type: Question
has comment: http://stackoverflow.com/comment/33589576
has comment: http://stackoverflow.com/comment/33589923
has comment: http://stackoverflow.com/comment/33589759
has comment: http://stackoverflow.com/comment/33590021
tagged with: printf
answer count: 1

libgdx
tags question: http://stackoverflow.com/q/22160619
tags question: http://stackoverflow.com/q/22151098
tags question: http://stackoverflow.com/q/22119498
tags question: http://stackoverflow.com/q/22082621
tag name: libgdx
tags question: http://stackoverflow.com/q/22116113
tags question: http://stackoverflow.com/q/22121915
tags question: http://stackoverflow.com/q/22107805
tags question: http://stackoverflow.com/q/22103029
tags question: http://stackoverflow.com/q/22104491
tags question: http://stackoverflow.com/q/22161809
tags question: http://stackoverflow.com/q/22154771
tags question: http://stackoverflow.com/q/22120421
tags question: http://stackoverflow.com/q/22119371
tags question: http://stackoverflow.com/q/22062429
type: Tag
tags question: http://stackoverflow.com/q/22152925
tags question: http://stackoverflow.com/q/22107247
tags question: http://stackoverflow.com/q/22017994
tags question: http://stackoverflow.com/q/22037813
tags question: http://stackoverflow.com/q/22080642
tags question: http://stackoverflow.com/q/22009475
tags question: http://stackoverflow.com/q/22139201
tags question: http://stackoverflow.com/q/22156596
tags question: http://stackoverflow.com/q/22134501
tags question: http://stackoverflow.com/q/22130470
tags question: http://stackoverflow.com/q/22107268
tags question: http://stackoverflow.com/q/22109001
tags question: http://stackoverflow.com/q/22121694
tags question: http://stackoverflow.com/q/22089088
tags question: http://stackoverflow.com/q/22116033
tags question: http://stackoverflow.com/q/22121467
tags question: http://stackoverflow.com/q/22100502
tags question: http://stackoverflow.com/q/22124110
tags question: http://stackoverflow.com/q/22065069

http://stackoverflow.com/comment/33579965
type: QuestionComment
has text: I have a repo at https://github.com/arshadalisoomro/AonawareDictServiceSDK, use this, see if this helps you.
score: 0
comment on: http://stackoverflow.com/q/22131076
type: Comment

http://stackoverflow.com/comment/33553517
type: QuestionComment
has text: I think you get a dead connection. The code looks okay
comment on: http://stackoverflow.com/q/22117210
score: 0
type: Comment

http://stackoverflow.com/a/22141540
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33601691
has body: read it from the classpath, getclass -> getresourceasstream. For validation consider using the xerces lib.
type: Answer
has comment: http://stackoverflow.com/comment/33601833
score: 0
has comment: http://stackoverflow.com/comment/33600723
has comment: http://stackoverflow.com/comment/33601322
accepted answer of: http://stackoverflow.com/q/22141341
answers question: http://stackoverflow.com/q/22141341

http://stackoverflow.com/q/22029677
has title: ImageViews and Intents
has comment: http://stackoverflow.com/comment/33397085
tagged with: android
has comment: http://stackoverflow.com/comment/33396996
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33396980
possible better answer: http://stackoverflow.com/a/22029774
has comment: http://stackoverflow.com/comment/33396914
tagged with: java
has answer: http://stackoverflow.com/a/22029792
accepted answer: http://stackoverflow.com/a/22029792
tagged with: android-intent
type: Question
has comment: http://stackoverflow.com/comment/33397100
tagged with: eclipse
tagged with: listview
has answer: http://stackoverflow.com/a/22029774
score: 0
has body: So I'm trying to start a new activity when an image is clicked that will start a new activity with the image being in full screen. To do this I've written the following code: ImageView defined in XML file: &lt;ImageView android:id="@+id/sun" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/sun_title" android:layout_centerHorizontal="true" android:contentDescription="@string/sun_image" android:src="@drawable/sun" /&gt; Here is where I use an onClickListener to handle the intent when the image is clicked: ImageView imageView; //begin onViewCreated Method ... final Context classContext = null; imageView = (ImageView) getView().findViewById(R.id.sun); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(classContext, Settings.class); startActivity(i); } }); ... //end onViewCreated Method I get no errors with the following code but when I run the application and tap the image, the app crashes with a nullPointerException. Here is the logcat for that: 02-25 16:55:43.201: E/AndroidRuntime(3459): FATAL EXCEPTION: main 02-25 16:55:43.201: E/AndroidRuntime(3459): Process: com.andrewq.planets, PID: 3459 02-25 16:55:43.201: E/AndroidRuntime(3459): java.lang.NullPointerException 02-25 16:55:43.201: E/AndroidRuntime(3459): at android.content.ComponentName.&lt;init&gt;(ComponentName.java:77) 02-25 16:55:43.201: E/AndroidRuntime(3459): at android.content.Intent.&lt;init&gt;(Intent.java:3821) 02-25 16:55:43.201: E/AndroidRuntime(3459): at com.andrewq.planets.FragmentA$2.onClick(FragmentA.java:43) 02-25 16:55:43.201: E/AndroidRuntime(3459): at android.view.View.performClick(View.java:4438) 02-25 16:55:43.201: E/AndroidRuntime(3459): at android.view.View$PerformClick.run(View.java:18422) 02-25 16:55:43.201: E/AndroidRuntime(3459): at android.os.Handler.handleCallback(Handler.java:733) 02-25 16:55:43.201: E/AndroidRuntime(3459): at android.os.Handler.dispatchMessage(Hand…
answer count: 2
has comment: http://stackoverflow.com/comment/33397024

http://stackoverflow.com/comment/33521279
has text: That's a relative path. Which directory are you executing from, and does the path exist from that point? If you're on a non-Windows system, paths and filenames may be case-sensitive; check that too.
comment on: http://stackoverflow.com/q/22099648
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22113899
type: UnansweredQuestion
upvote count: 1
tagged with: swing
type: Question
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33547296
has comment: http://stackoverflow.com/comment/33547444
has answer: http://stackoverflow.com/a/22116449
downvote count: 0
answer count: 1
linked to: http://stackoverflow.com/q/19012691
favorite count: 0
tagged with: jtable
has title: Can we set/adjust size of JTable column as per the size of GUI Component?
has body: In my project,i need to adjust the sizes of columns in JTable as per the sizes of GUI Components such as JComboBox and JTextField. Can we adjust the size of column as per the size of GUI Component ?
has comment: http://stackoverflow.com/comment/33547581

http://stackoverflow.com/a/22103460
has comment: http://stackoverflow.com/comment/33530768
has comment: http://stackoverflow.com/comment/33529432
has comment: http://stackoverflow.com/comment/33530543
accepted answer of: http://stackoverflow.com/q/22103365
has comment: http://stackoverflow.com/comment/33529174
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33531948
has comment: http://stackoverflow.com/comment/33530589
has comment: http://stackoverflow.com/comment/33530310
type: Answer
has comment: http://stackoverflow.com/comment/33529223
has body: Only when there is a native library in use (in your example, SMTP; it's probably implemented in pure Java). The usual way to add a native library is by using the correct flag with the java command line. For example, java -Djava.library.path=%STARTPATH%\lib -jar somefile.jar
has comment: http://stackoverflow.com/comment/33530741
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33530388
answers question: http://stackoverflow.com/q/22103365

http://stackoverflow.com/comment/33643275
has text: add some code to get more quality answers.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22167637
score: 0

http://stackoverflow.com/a/22106577
has comment: http://stackoverflow.com/comment/33556813
downvote count: 0
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/33556862
has body: Instead of a stack trace, notify the user that there was a concurrent update to the data they were working on, and force them to refresh it before saving. Try to preserve whatever they have edited or your users will hate you. Or were you looking for a technical solution?
has comment: http://stackoverflow.com/comment/33556651
score: 2
answers question: http://stackoverflow.com/q/22106409

http://stackoverflow.com/comment/33627455
comment on: http://stackoverflow.com/a/22157105
has text: @user3376275 Add `<mvc:annotation-driven/>` to your servlet context. You'll need to add the corresponding `mvc` namespace declarations as well.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33617691
score: 0
type: QuestionComment
type: Comment
has text: param.split() just splits the String. It doesn't delete anything in it. So there's still a 0 length string which gets added to items, hence 1 as its size.
comment on: http://stackoverflow.com/q/22153206

http://stackoverflow.com/q/22116377
tagged with: java
has comment: http://stackoverflow.com/comment/33552419
type: Question
accepted answer: http://stackoverflow.com/a/22116903
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/33551844
has comment: http://stackoverflow.com/comment/33551963
has body: The error describe in the title of this post is being displayed in the eclipse console for my spring mvc application. I try look for other similars examples here in the stackoverflow, but none of this others have solutions for my problem. Follow below some files from my project: the controller: package com.HorarioLivre.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; import com.HorarioLivre.core.Sessao; import com.HorarioLivre.data.UsuarioDAO; @Controller public class HorarioLivreController { private Sessao sessao; @RequestMapping(value="/login", method=RequestMethod.POST) public ModelAndView usuario_login(@RequestParam("username") String username, @RequestParam("password") String password) { UsuarioDAO usuario = new UsuarioDAO(username, password); if(usuario.getUsuario() != null) { this.setSessao(new Sessao(usuario.getUsuario())); } ModelAndView mav = new ModelAndView(); mav.setViewName("usuario_start"); mav.addObject("usuario", usuario.getUsuario()); return mav; } public Sessao getSessao() { return sessao; } public void setSessao(Sessao sessao) { this.sessao = sessao; } } the web.xml <?xml version="1.0" encoding="UTF-8"?> HorarioLivre index.jsp HorarioLivre org.springframework.web.servlet.DispatcherServlet 1 HorarioLivre / the HorarioLivre-servlet.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" 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.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/sche…
tagged with: spring
has title: No mapping found for HTTP request with URI [/HorarioLivre/login.html] in DispatcherServlet with name 'HorarioLivre'
has answer: http://stackoverflow.com/a/22116903
type: AnsweredQuestion
tagged with: mapping

http://stackoverflow.com/q/22056013
score: 1
tagged with: java
upvote count: 1
type: Question
tagged with: heroku
accepted answer: http://stackoverflow.com/a/22066773
has title: Passing correct JVM arguments to Play 2.2.1 app on Heroku
has answer: http://stackoverflow.com/a/22066773
answer count: 1
downvote count: 0
tagged with: jvm
favorite count: 0
has body: I'm trying to pass correct JVM arguments to my play 2.2.1 application deployed on Heroku but there is a problem. My Procfile looks like this: web: target/universal/stage/bin/myapp -Dhttp.port=${PORT} -Dconfig.file=conf/production.conf -J-javaagent:lib/heroku-javaagent-1.4.jar=stdout=true,lxmem=true -J-javaagent:lib/newrelic.jar -J-Dnewrelic.config.file=lib/newrelic.yml In this article (https://devcenter.heroku.com/articles/play-support) it says that PLAY_OPTS is not needed to be passed because it is read by the generated script. However, in my app, at runtime I read the JVM arguments and they look like this: JVM value: -Djava.rmi.server.useCodebaseOnly=true JVM value: -Xms1024m JVM value: -XX:MaxPermSize=256m JVM value: -XX:ReservedCodeCacheSize=128m JVM value: -Duser.dir=/app/target/universal/stage JVM value: -Dhttp.port=57279 JVM value: -javaagent:lib/heroku-javaagent-1.4.jar=stdout=true,lxmem=true JVM value: -Xmx1024m JVM value: -javaagent:lib/newrelic.jar JVM value: -Dnewrelic.config.file=lib/newrelic.yml JVM value: -Dconfig.file=conf/production.conf So the "JAVA_OPTS: -Xmx384m -Xss512k -XX:+UseCompressedOops" isn't read by the script apparently. I also tried to append -Xmx384m -Xss512k -XX:+UseCompressedOops to Procfile but again, it didn't work. How can I make this work?
tagged with: playframework-2.2
type: AnsweredQuestion

http://stackoverflow.com/comment/33516265
type: AnswerComment
has text: I don't know I start this in a gradle environment. I have no idea where you can find more details in eclipse
type: Comment
comment on: http://stackoverflow.com/a/22094784
score: 0

http://stackoverflow.com/q/22160459
type: Question
has answer: http://stackoverflow.com/a/22170553
tagged with: javascript
tagged with: jsf-2.2
tagged with: jquery
score: 0
answer count: 2
has title: Modal confirmDialog Over a Layout Unit (Everything is blocked)
accepted answer: http://stackoverflow.com/a/22170553
linked to: http://stackoverflow.com/q/14281605
possible better answer: http://stackoverflow.com/a/24582551
has body: Hi evryone i have a problem with ConfirmDialog i ma using Primeface 4 and when i try to use ConfirmDialog doesn't work the small window of confirmation come but it's block and don't work and you can't click on it here is the small code. I am trying to do a confirmation before delete &lt;h:form prependId="false"&gt; &lt;p:contextMenu for="dataTable"&gt; &lt;p:menuitem value="View" update="display" icon="ui-icon-search" oncomplete="utilisateur.show()" /&gt; &lt;p:menuitem value="Delete" icon="ui-icon-close" onclick="confirmation.show()" /&gt; &lt;/p:contextMenu&gt; &lt;p:dataTable id="dataTable" var="user" value="#{usersBean.u}" paginator="true" rows="10" rowKey="#{user.idUtilisateur}" selection="#{usersBean.selectUser}" selectionMode="single" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="3,5,10,15"&gt; &lt;f:facet name="header"&gt; &lt;p:confirmDialog id="confirmDialog" message="Are you sure about about deleting this?" header="Initiating delete process" severity="alert" widgetVar="confirmation"&gt; &lt;p:commandButton id="confirm" value="Yes Sure" update="dataTable" oncomplete="confirmation.hide()" actionListener="#{usersBean.deleteUser}" /&gt; &lt;p:commandButton id="decline" value="Not Yet" onclick="confirmation.hide()" type="button" /&gt; &lt;/p:confirmDialog&gt; &lt;/f:facet&gt;
has answer: http://stackoverflow.com/a/24582551
type: AnsweredQuestion
tagged with: primefaces
tagged with: java
linked to: http://stackoverflow.com/q/8970685

http://stackoverflow.com/q/22027474
has comment: http://stackoverflow.com/comment/33397677
has answer: http://stackoverflow.com/a/22027691
answer count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33398216
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33397732
tagged with: garbage-collection
score: 3
tagged with: linked-list
has title: Sliding Window: Implementation and Performance (Java)
upvote count: 3
tagged with: java
tagged with: sliding-window
has comment: http://stackoverflow.com/comment/33397809
has answer: http://stackoverflow.com/a/22027505
type: Question
has body: I want to implement a very simple sliding window. In other words, I will have some kind of list with objects inserted from the right end of that list and dropped from the left end. In every insertion, the previous objects are left-shifted by one index. When the list get filled with objects, in every insertion from the right end an object will be dropped from the left end (and the previous objects of course will be left-shifted by one index, as usual). I had in mind either a LinkedList or an ArrayDeque - probably the latter is a better choise, since as far as I know both inserting AND removing to/from either end is constant effort O(1) for an ArrayDeque, which is not the case for a LinkedList. Is that right? Moreover, I would like to ask the following: Left-shifting all the previous objects stored in the sliding window when I insert a new object is processing-intensive for a large sliding window with 100,000 or even 1,000,000 objects as in my case. Is there any other data structure which might perform better in my application? NOTE: I use the term "sliding window" for what I want to implement, maybe there is some other term that describes it better, but I think is clear what I want to do from the above description.
tagged with: arraydeque

http://stackoverflow.com/comment/33637261
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22164145
has text: Because of you tagged `ORACLE` i answer the question in oracle, which `DBMS` are you work in?

http://stackoverflow.com/q/22123692
has body: I downloaded a .jar file from JSON lib: http://sourceforge.net/projects/json-lib/files/ Then I went to netbeans and imported the file into my library, now how do I used JSONobject in my program? I think I need to do some sort of import statement, but Im not sure Thanks in advance, Im a noob
type: AnsweredQuestion
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has answer: http://stackoverflow.com/a/22123713
has answer: http://stackoverflow.com/a/22123708
tagged with: import
type: Question
tagged with: jar
possible better answer: http://stackoverflow.com/a/22123708
accepted answer: http://stackoverflow.com/a/22123723
score: 0
answer count: 3
has title: How do I import from a jar file that is already in my library? (Netbeans Java)
linked to: http://stackoverflow.com/q/4879903
has answer: http://stackoverflow.com/a/22123723
tagged with: netbeans

http://stackoverflow.com/comment/33399106
score: 0
comment on: http://stackoverflow.com/q/22007400
type: Comment
type: QuestionComment
has text: These classes are doing some calculation, storing some form data etc. But each of the object has some common form field data which is of my interest to apply additional behavior.

http://stackoverflow.com/comment/33480813
has text: Actually my question is linked to this http://stackoverflow.com/questions/22063249/how-to-make-a-thread-wait-for-a-notify-for-a-specific-time-and-execute-code-acco?noredirect=1#comment33456544_22063249 One of the threads here is just a listen thread, which should notify the other thread if it receives a specific kind of packet... So far I suppose I would have to use a common resource.
type: AnswerComment
comment on: http://stackoverflow.com/a/22066937
score: 0
type: Comment

http://stackoverflow.com/q/22058935
possible better answer: http://stackoverflow.com/a/22059008
score: 0
has body: I am trying to create a program to play rock paper scissors with the computer using switch statements. The problem I am having is that the program is telling me the second switch statement (switch (user){ ) is unreachable. Any tips would help. UPDATE: Unreachable problem fixed! Problem is that switch statement is not reading individual computer choice and outputting all. Example Output: Please enter an integer between 0 and 2 to play ( 0 = Rock 1 = Paper 2 = Scissors): 2 The computer chose Rock! You chose Scissors! You loose! The computer chose Paper! You chose Scissors! You win! The computer chose Scissors! You chose Scissors! It's a draw Program: import java.util.Scanner; public class RockPaperScissors { public static void main(String[] args) { Scanner input = new Scanner(System.in); int comp = (int)Math.random()*3; System.out.print("Please enter an integer between 0 and 2 to play ( 0 = Rock 1 = Paper 2 = Scissors): "); int user = input.nextInt(); while(user &lt; 0) { System.out.print("Invalid integer, please type in a new number above zero and less than two: "); user = input.nextInt(); } switch (comp){ case 0: System.out.println("The computer chose Rock!"); break; switch (user){ case 0: System.out.println("You chose Rock! It's a draw!"); break; case 1: System.out.println("You chose Paper! You win!"); break; case 2: System.out.println("You chose Scissors! You loose!"); break; } case 1: System.out.println("The computer chose Paper!"); break; switch (user){ case 0: System.out.println("You chose Rock! You loose!"); break; case 1: System.out.println("You chose Paper! It's a draw!"); break; case 2: System.out.println("You chose Scissors! You win!"); break; } case 2: System.out.println("The computer chose Scissors!"); break; switch (user){ case 0: System.out.println("You chose Rock! You win!"); break; case 1: System.out.println("You chose Paper! You loose!"); break; case 2: System.out.println("You chose Scissors! It's a draw"); break; } } } }
answer count: 3
has answer: http://stackoverflow.com/a/22059188
has title: Switch Statement within a switch statement
has answer: http://stackoverflow.com/a/22059008
tagged with: input
has comment: http://stackoverflow.com/comment/33448693
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22059009
accepted answer: http://stackoverflow.com/a/22059009
tagged with: java
tagged with: switch-statement
type: Question

http://stackoverflow.com/comment/33485432
type: Comment
comment on: http://stackoverflow.com/q/22079260
score: 0
has text: Lol, I thought someone would say that. What I meant was, if btn1 is pressed, panel1 gets displayed in jframe. When btn2 is pressed, I would.like panel2 to be displayed. Sorry, my bad.
type: QuestionComment

http://stackoverflow.com/a/22064055
accepted answer of: http://stackoverflow.com/q/22063681
score: 3
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: This is quite a disappointing question. After a few tries, I seem to know the reason. It is a bug of some specific version of Android. In fact, I'm not that sure, but I get some support here. I ran exactly the same code on another Android device(Samsung GT-I9220 with Android 4.1.4), it just works fine. And after I change the ByteBuffer.allocateDirect(1024) to ByteBuffer.allocate(1024)(without the direct), it works on the previous device which causes the exception. I really don't know the reason but this is the situation. I'll leave this question open for some more time, just in case someone knows the reason or confirms if this is really a bug of Android(of some version).
answers question: http://stackoverflow.com/q/22063681
upvote count: 3

http://stackoverflow.com/a/22138188
upvote count: 3
has comment: http://stackoverflow.com/comment/33591153
answers question: http://stackoverflow.com/q/22138150
has comment: http://stackoverflow.com/comment/33591052
score: 3
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22138150
downvote count: 0
has comment: http://stackoverflow.com/comment/33590973
type: Answer
has body: Read the section from the Swing tutorial on How to Use Tables The tutorial shows you how to use a combo box as an editor for a column in a table. This is what you should be doing instead of having a separate combo box. To calculate the amount, you need to create a custom TableModel and override the setValueAt() method. Whenever the quantity or rate changes you recalculate the amount.

latitude-longitude
tags question: http://stackoverflow.com/q/22063842
type: Tag
tag name: latitude-longitude

dom
tags question: http://stackoverflow.com/q/22041082
tags question: http://stackoverflow.com/q/22030779
type: Tag
tags question: http://stackoverflow.com/q/22134100
tags question: http://stackoverflow.com/q/22012228
tags question: http://stackoverflow.com/q/22042109
tags question: http://stackoverflow.com/q/22062587
tags question: http://stackoverflow.com/q/22039711
tags question: http://stackoverflow.com/q/22106514
tags question: http://stackoverflow.com/q/22132042
tags question: http://stackoverflow.com/q/22094200
tags question: http://stackoverflow.com/q/22086664
tags question: http://stackoverflow.com/q/22156768
tag name: dom
tags question: http://stackoverflow.com/q/22009732
tags question: http://stackoverflow.com/q/22151653
tags question: http://stackoverflow.com/q/22051344

http://stackoverflow.com/comment/33479609
comment on: http://stackoverflow.com/a/22074406
score: 1
type: AnswerComment
has text: same error..can u explain what u have jst mentioned
type: Comment

http://stackoverflow.com/comment/33576498
comment on: http://stackoverflow.com/q/22129523
has text: Show us real code. V is not a class. `Map<Drug, SideEffect[]>` is a valid declaration (provided Drug and SideEffect are existing classes).
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33456067
has text: But I'm using `javacpp`so I need a way to map it with that, preferably.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22063101
type: AnswerComment

http://stackoverflow.com/a/28065801
type: Answer
has body: Here is the perfect code for finding next prime for a given number. public class NextPrime { int nextPrime(int x) { int num=x,j; for( j=num+1;;j++) { int count=0; for(int i=1;i&lt;=j;i++) { if(j%i==0) { count++; //System.out.println("entered"); } //System.out.println(count); } if(count==2) { System.out.println(" next prime is "); break; } }return j; } public static void main(String args[]) { NextPrime np = new NextPrime(); int nxtprm = np.nextPrime(9); System.out.println(nxtprm); } }
answers question: http://stackoverflow.com/q/22082770
score: 0

http://stackoverflow.com/q/22127102
tagged with: struts2
answer count: 1
has body: i'm trying a simple example about Struts2 ,i encountered an below issue ---------------- Mar 02, 2014 7:16:05 PM org.apache.catalina.core.ApplicationDispatcher invoke SEVERE: Servlet.service() for servlet jsp threw exception ------------------------------------------------------------------------ java.lang.ClassNotFoundException: javax.el.ELContext ---------------------------------------------------- at java.net.URLClassLoader$1.run(URLClassLoader.java:366) 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 java.lang.ClassLoader.loadClass(ClassLoader.java:356) at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2442) at java.lang.Class.privateGetPublicMethods(Class.java:2562) at java.lang.Class.privateGetPublicMethods(Class.java:2578) at java.lang.Class.privateGetPublicMethods(Class.java:2578) at java.lang.Class.getMethods(Class.java:1427) at freemarker.ext.beans.BeansWrapper.discoverAccessibleMethods(BeansWrapper.java:1395) at freemarker.ext.beans.BeansWrapper.discoverAccessibleMethods(BeansWrapper.java:1385) at freemarker.ext.beans.BeansWrapper.populateClassMapWithBeanInfo(BeansWrapper.java:1129) at freemarker.ext.beans.BeansWrapper.populateClassMap(BeansWrapper.java:1072) at freemarker.ext.beans.BeansWrapper.introspectClassInternal(BeansWrapper.java:1010) at freemarker.ext.beans.BeansWrapper.introspectClass(BeansWrapper.java:969) at freemarker.ext.beans.BeanModel.&lt;init&gt;(BeanModel.java:140) at freemarker.ext.beans.StringModel.&lt;init&gt;(StringModel.java:90) at freemarker.ext.beans.StringModel$1.create(StringModel.java:75) at freemarker.ext.beans.BeansModelCache.create(BeansModelCache.java:45) at freemarker.ext.util.ModelCache.getInstance(ModelCache.java:115) at freemarker.ext.beans.BeansWrapper.wrap(BeansWrapper…
has answer: http://stackoverflow.com/a/22129482
favorite count: 0
accepted answer: http://stackoverflow.com/a/22129482
upvote count: 1
type: AnsweredQuestion
has title: java.lang.ClassNotFoundException: javax.el.ELContext
score: 1
tagged with: java
type: Question
downvote count: 0
tagged with: jsp
tagged with: tomcat

http://stackoverflow.com/q/22109913
has answer: http://stackoverflow.com/a/22110224
tagged with: multidimensional-array
type: UnansweredQuestion
has body: This code is to shift a 2D array "arr" to the left completely once it runs through, but for some reason, the elements are shifting over by two. public static void shiftLeft() { for(int i = 0; i&lt;arr.length;i++) { int temp = arr[i][0]; int n = 0; for(n = 0;n&lt;arr.length - 1;n++) { arr[i][n] = arr[i][n+1]; arr[i][n+1] = temp; } } }
tagged with: java
has answer: http://stackoverflow.com/a/22110496
type: Question
tagged with: arrays
has title: Why does this code for shifting left in a 2D array not work and shifts left 2 instead?
has comment: http://stackoverflow.com/comment/33540737
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/33540629

http://stackoverflow.com/comment/33585652
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22134807
type: AnswerComment
has text: @BURNS, Just edited my answer. If the change above also doesn't work, then I think you might want to upload your file somewhere, so we can see the original file. It is difficult to guess what's happening because sometimes invisible characters are lost when you paste into SO.

http://stackoverflow.com/comment/33683072
type: AnswerComment
has text: OK, thanks! One more thing: can you **mix** `<rabbit>` tags with standard `<bean>` (i.e. use both to configure rabbitMQ in a single app) and expect they will work just as all have been defined with the same namespace?
type: Comment
comment on: http://stackoverflow.com/a/22148933
score: 0

http://stackoverflow.com/q/22057232
upvote count: 4
has answer: http://stackoverflow.com/a/77922547
has answer: http://stackoverflow.com/a/22057708
type: AnsweredQuestion
downvote count: 0
accepted answer: http://stackoverflow.com/a/22057708
possible better answer: http://stackoverflow.com/a/77922547
favorite count: 0
type: Question
tagged with: windows
has title: Detecting system sound on Windows using Python
has body: Is there any way to detect system sound instead of microphone sound? I want to be able to detect whenever my system makes a sound instead of when the microphone picks up the actual sound. One way I found to do this use an "audio loop-back in either software or hardware (e.g. connect a lead from the speaker 'out' jack to the microphone 'in' jack)." Capturing speaker output in Java I am building a program that plays an mp3 file whenever a system sound happens but I don't want it to go off if the dog barks. Thanks!
linked to: http://stackoverflow.com/q/6644368
tagged with: python
score: 4
tagged with: detect
answer count: 2
tagged with: audio
tagged with: java

http://stackoverflow.com/q/22065396
has comment: http://stackoverflow.com/comment/33460227
has comment: http://stackoverflow.com/comment/33460033
has body: I am using a java library to parse text to longitude and latitude. Through PIG I send a text in each line and it returns a longitude and latitude (if found), otherwise null. The library works fine but it crashes terribly when it finds very weird characters. The error I get is (I will show your an example of the word character at the end) : # A fatal error has been detected by the Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x02d927da, pid=4880, tid=4151524208 # # JRE version: 7.0_17-b02 # Java VM: Java HotSpot(TM) Server VM (23.7-b01 mixed mode linux-x86 ) # Problematic frame: # C [libPlacemakerJNI.so+0x4f47da] YGEO::TokeniserBase::CaseCollector::add(YGEO::Unicode::UTF8Encoding::Case)+0x46 # # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again # # An error report file with more information is saved as: # /home/grid0/tmp/bz6784883/hs_err_pid4880.log # # If you would like to submit a bug report, please visit: # http://bugreport.sun.com/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. # An example of the weird character (which overlaps other lines) even when you search in google is this one https://www.google.es/#q=++%3B̋̉ͧ̇ I can not even copy and paste it here... Does any one have an idea how can I filter these case before sending the lines to the udf? I will greatly appreciate any help. --- edited : some people asked me to add my code. I am not very sure if it is important since all I want to know is how to filter these characters in Pig, Java or with any other user defined function before passing it to placemaker.... so here it goes: register /homes/ruthgavi/JARS/placemaker_java.jar; register /homes/ruthgavi/JARS/internetlocality-for-placemaker-1.2.0.jar; register /homes/ruthgavi/JARS/placemaker_bootstrap-1.2.0.jar; register /homes/ruthgavi/JARS/PlacemakerUDF-1.2.0.jar; define placema…
has comment: http://stackoverflow.com/comment/33460948
type: Question
has comment: http://stackoverflow.com/comment/33459728
tagged with: java
has answer: http://stackoverflow.com/a/22065793
has comment: http://stackoverflow.com/comment/33459862
score: 0
has comment: http://stackoverflow.com/comment/33459462
answer count: 1
has comment: http://stackoverflow.com/comment/33459696
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33460627
tagged with: utf-8
has title: Using PIG and Java udf : A fatal error has been detected by the Java Runtime Environment: VERY WEIRD CHARACTER Unicode::UTF8Encoding::Case
has comment: http://stackoverflow.com/comment/33460325
has comment: http://stackoverflow.com/comment/33459847
tagged with: apache-pig

http://stackoverflow.com/comment/67149321
type: AnswerComment
comment on: http://stackoverflow.com/a/22110821
score: 3
type: Comment
has text: More details on internal compilation here: http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-3.html#jvms-3.10

http://stackoverflow.com/comment/33567098
comment on: http://stackoverflow.com/a/22122838
score: 0
type: Comment
has text: I'm sorry I cannot find whats wrong, I checked line by line so I guess ill just await some more help. Maybe someone can debug it for me since I have no idea what I'm doing. Thanks for your help
type: AnswerComment

http://stackoverflow.com/comment/33644791
has text: Please provide the desired output.
type: QuestionComment
comment on: http://stackoverflow.com/q/22168592
score: 0
type: Comment

http://stackoverflow.com/a/22042303
type: Answer
has comment: http://stackoverflow.com/comment/33421152
score: 2
has comment: http://stackoverflow.com/comment/33419978
has comment: http://stackoverflow.com/comment/33419731
upvote count: 2
has comment: http://stackoverflow.com/comment/33421873
has comment: http://stackoverflow.com/comment/33421031
has comment: http://stackoverflow.com/comment/33419684
has comment: http://stackoverflow.com/comment/33421459
answers question: http://stackoverflow.com/q/22042243
has comment: http://stackoverflow.com/comment/33422182
has comment: http://stackoverflow.com/comment/33419709
downvote count: 0
has body: Yes, it's quite right. Look at the documentation for InputStreamReader and you won't find a constructor taking a File parameter. Instead, you should construct a FileInputStream to read from the file, and pass that to the constructor of the InputStreamReader. You should also specify the encoding you want to use, otherwise it'll use the platform default encoding. Also note: You should use a try-with-resources statement to close the resource automatically I wouldn't name a File variable is - that sounds more like you'd expect it to be an InputStream. So for example: File file = new File(homedir, "java/in.txt"); try (BufferedReader br = new BufferedReader(new InputStreamReader( new FileInputStream(file), StandardCharsets.UTF_8))) { int value = 0; while ((value = br.read()) != -1) { char c = (char) value; System.out.println(c); } } (Or use the Files API as per fge's answer.)
has comment: http://stackoverflow.com/comment/33421255

http://stackoverflow.com/a/22066403
upvote count: 1
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/22065069
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/22065069
has body: To have a fixed rotation you hav to rotate the ShapeRenderer only once. There are 2 possible ways i can think about: call shapeRenderer.rotate(0, 0, 1, 45); in the constructor or in create() / show() method This call rotates your ShapeRenderer by 45° (last parameter) arround the Z-Axis (The 3rd parameter) call shapeRenderer.rotate(0, 0, 1, 45); in the rendermethod, only if you did not rotate yet. So you have to keep a boolean rotated and only if it is false you call rotate() and set it to true. To answer the question in your comment: You cannot directly set the rotation, you can only rotate (relative to the current rotation). So i would suggest to store a float rotation, and everytime you rotate your ShapeRenderer you set the new value. To set a rotation in degrees you have to rotate like: shapeRenderer.rotate(0, 0, 1, newRotation - rotation); rotation = newRotation; This works only if you always rotate arround the same axis, in your case the Z-axis. Else you would have to store 3 rotations (x,y,z). If you rotate arround a custom axis, defined by for example (0.1, 0.3, 0.6) you would need to calculate the rotation for all axes. But i don't really know how to do that. I think some Vectormath would do that. But i don't think you need that.

http://stackoverflow.com/comment/33586133
type: Comment
comment on: http://stackoverflow.com/a/22135079
score: 0
type: AnswerComment
has text: I just do things the way the professor asks, he is the one that set up the global variable. BF and Search.

http://stackoverflow.com/a/22102065
has comment: http://stackoverflow.com/comment/33534784
type: AcceptedAnswer
downvote count: 0
type: Answer
upvote count: 7
answers question: http://stackoverflow.com/q/22101807
has body: It formats Date. In Date formatting "SSS" pattern means milliseconds from 000 to 999, so you are correct.
score: 7
has comment: http://stackoverflow.com/comment/33566338
accepted answer of: http://stackoverflow.com/q/22101807
has comment: http://stackoverflow.com/comment/33565934

http://stackoverflow.com/q/22064558
answer count: 7
has comment: http://stackoverflow.com/comment/33457972
has answer: http://stackoverflow.com/a/22064824
has answer: http://stackoverflow.com/a/22064837
favorite count: 0
accepted answer: http://stackoverflow.com/a/22064857
has answer: http://stackoverflow.com/a/22064654
has title: Finding the largest number in a column using 2D arrays
possible better answer: http://stackoverflow.com/a/22064837
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22064857
has answer: http://stackoverflow.com/a/23113974
downvote count: 0
has answer: http://stackoverflow.com/a/22064806
tagged with: java
has body: I was trying to write a method that finds the largest number in a column. However, it seems that I am having problem to find a way to return the highest number in a column rather than taking into consideration all numbers combined in the array. I would really appreciate any comments or feedback! This is my code: public static void max1(int[][] score) { for (int i = 0; i &lt; score.length; i++) { int max = score[0][0]; for (int j = 0; j &lt; score[i].length; j++) if (score[i][j] &gt; max) max = score[i][j]; System.out.println(max + " "); } }
type: Question
has answer: http://stackoverflow.com/a/22064657
tagged with: arrays
upvote count: 2

http://stackoverflow.com/comment/33499965
type: AnswerComment
comment on: http://stackoverflow.com/a/22087270
score: 0
type: Comment
has text: so post ur sample input xml file so we can test where the problem lies

http://stackoverflow.com/comment/33375869
has text: Could you paste your code into a pastebin for me? That would help a lot.
comment on: http://stackoverflow.com/a/22018312
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/22154458
has comment: http://stackoverflow.com/comment/33638410
type: Question
has title: OpenSSL analogue for Java
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33624341
has comment: http://stackoverflow.com/comment/33624184
tagged with: java
tagged with: rsa
has comment: http://stackoverflow.com/comment/33619882
upvote count: 2
tagged with: openssl
answer count: 1
tagged with: public-key-encryption
has answer: http://stackoverflow.com/a/22154667
accepted answer: http://stackoverflow.com/a/22154667
favorite count: 0
score: 2
downvote count: 0
has body: Is there any way to do these OpenSSL operation using Java openssl genrsa -out private.pem 2048 openssl pkcs8 -topk8 -in private.pem -outform DER -out private.der -nocrypt openssl rsa -in private.pem -pubout -outform DER -out public.der to generate private.der and public.der

http://stackoverflow.com/comment/33406104
comment on: http://stackoverflow.com/q/22035176
score: 0
type: Comment
type: QuestionComment
has text: Because it's my second year of Java and I'm prone to laziness. Will remember in the future not to use raw types unless there is a specific advantage to doing so. Thanks!

http://stackoverflow.com/a/22053155
answers question: http://stackoverflow.com/q/22052810
score: 0
has body: You could also use: [^\p{Alpha}]\p{Alpha}{2}$ Use Alnum instead if digits count as words. This does, however, fail if the entire string is only two characters long.
type: Answer

proxy
tags question: http://stackoverflow.com/q/22110726
type: Tag
tags question: http://stackoverflow.com/q/22165172
tags question: http://stackoverflow.com/q/22044261
tags question: http://stackoverflow.com/q/22108201
tags question: http://stackoverflow.com/q/22156913
tags question: http://stackoverflow.com/q/22120986
tag name: proxy
tags question: http://stackoverflow.com/q/22142523
tags question: http://stackoverflow.com/q/22160744

http://stackoverflow.com/comment/33408571
comment on: http://stackoverflow.com/q/22034910
score: 0
type: Comment
type: QuestionComment
has text: @DanielSzalay No other entries

http://stackoverflow.com/q/22065482
has body: Is there a way to write data to an OutputStream object which is connected to a channel, and this channel will pass the data to a bytebuffer (preferably, direct bytebuffer)? I have a situation where a third party function can write its output to an outputStream. I want to be able to write this data to a bytebuffer using channels. Is it possible? Thank you
tagged with: java
has comment: http://stackoverflow.com/comment/33460539
has comment: http://stackoverflow.com/comment/33460376
type: Question
tagged with: nio
tagged with: bytebuffer
upvote count: 2
answer count: 1
has comment: http://stackoverflow.com/comment/33460261
has answer: http://stackoverflow.com/a/22066378
accepted answer: http://stackoverflow.com/a/22066378
favorite count: 0
tagged with: channel
score: 2
has title: Using channels to pass data from outputStream to bytebuffer
type: AnsweredQuestion
downvote count: 0

http://stackoverflow.com/q/22088934
has answer: http://stackoverflow.com/a/22089345
has answer: http://stackoverflow.com/a/22089299
has comment: http://stackoverflow.com/comment/33502321
has title: how to find the index of an item in an array java
tagged with: java
has comment: http://stackoverflow.com/comment/33502554
has comment: http://stackoverflow.com/comment/33502388
has comment: http://stackoverflow.com/comment/33502293
has comment: http://stackoverflow.com/comment/33502282
type: Question
tagged with: arrays
has comment: http://stackoverflow.com/comment/33502570
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/33502313
has comment: http://stackoverflow.com/comment/33502183
has comment: http://stackoverflow.com/comment/33502605
has comment: http://stackoverflow.com/comment/33502185
has body: I want to find the index of the start up letter and then show the index of that item in array or array list in java. Example: I have: String[] arr={"apple","at","book","bad","car","cat"}; when I input a: then i will get index =0, b: i will get index=2, c: i will get index=4 Because my array item is over 20,000 , so using linear Search is too slow. and my list is unsorted, so i can't use Binary Search also. I want to get index of the item like the example above, what can i solve with this?
tagged with: hash
has comment: http://stackoverflow.com/comment/33502350
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/1522108
has comment: http://stackoverflow.com/comment/33502821

http://stackoverflow.com/comment/33500040
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22073487
has text: Thx, but I don't believe we've understood each other on the question. I'm gonna edit it a bit :)
score: 0

http://stackoverflow.com/comment/33538875
type: Comment
comment on: http://stackoverflow.com/q/22109001
score: 0
has text: Could you include some of your current code?
type: QuestionComment

http://stackoverflow.com/comment/33548521
has text: you loop over a **collection** not over a **Condition** !
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/22114565
type: Comment

http://stackoverflow.com/comment/33529538
type: Comment
comment on: http://stackoverflow.com/a/22103993
type: AnswerComment
has text: This is going to result in a StackOverflowException with the code you have now. Move Move Move Move Move...
score: 0

http://stackoverflow.com/q/22091714
upvote count: 1
tagged with: android-arrayadapter
score: 1
tagged with: java
linked to: http://stackoverflow.com/q/22093997
tagged with: listview
type: Question
downvote count: 0
favorite count: 0
answer count: 3
has title: android add item to arraylist from arraylist
has answer: http://stackoverflow.com/a/22091906
tagged with: android
has answer: http://stackoverflow.com/a/22094780
has answer: http://stackoverflow.com/a/22092996
type: UnansweredQuestion
has body: I have a gridview that filled using a custom adapter in an activity, and I want you to press a target item in another activity in another gridview. private static class MyAdapter extends BaseAdapter { static List&lt;Item&gt; items = new ArrayList&lt;Item&gt;(); private LayoutInflater inflater; public MyAdapter(Context context) { inflater = LayoutInflater.from(context); items.add(new Item("Restaurante Arsenal", R.drawable.arsenal)); items.add(new Item("Restaurante The Grill", R.drawable.grill)); items.add(new Item("Rte Las Delicias", R.drawable.delicias)); items.add(new Item("Restaurante Europa", R.drawable.logo_restaurante_europa)); items.add(new Item("Restaurante Coconut", R.drawable.coco)); items.add(new Item("Rte GastroXabia", R.drawable.gastroxabia)); } I had planned to use this: MisLocalesFavActivity.MyAdapter.items.add(MyAdapter.items.get(position)); So: public boolean onItemLongClick(AdapterView&lt;?&gt; parent, View v, final int position, long id) { // TODO Auto-generated method stub String[] opc = new String[] { "Añadir a mis locales favoritos", "Copiar", "Eliminar"}; AlertDialog opciones = new AlertDialog.Builder( Restaurantes_Activity.this) .setTitle("Opciones") .setItems(opc, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int selected) { if (selected == 0) { //acciones para editar MisLocalesFavActivity.MyAdapter.items.add(MyAdapter.items.get(position)); Toast.makeText(getApplicationContext(), "Añadido a mis locales favoritos! " , Toast.LENGTH_SHORT).show(); } else if (selected == 1) { //acciones para copiar }else if (selected == 2) { //acciones para eliminar } } }).create(); opciones.show(); return true; } }); But I have an error in .add Specifically this: The method add(MisLocalesFavActivity.MyAdapter.Item) in the type List is not applicable for the arguments (Restaurantes_Activity.MyAdapter.Item) THANKS !!!

http://stackoverflow.com/a/22097726
answers question: http://stackoverflow.com/q/22096909
has body: The simplest solution is to use maven-assembly-plugin like this: [...] <build> [...] <plugins> <plugin> maven-assembly-plugin 2.4 jar-with-dependencies [...]
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33521592
upvote count: 1

http://stackoverflow.com/comment/33491567
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22076135
has text: If you stick with primitive or simple types like Map and List, it's actually not much more complex than PHP or Python. The difference is largely in the tools available to interact with these structures. In Python/PHP/Perl, the focus is more on speed of development and ease of interaction, and their softly typed nature lends well to this approach. Java isn't like that, as you have to pay careful attention to types, and as such the more flexible structure interactions you are used to aren't available in Java. The same data structures are available, and likely are similarly complex under the hood

http://stackoverflow.com/q/22091371
has answer: http://stackoverflow.com/a/22266189
tagged with: android
has comment: http://stackoverflow.com/comment/33782580
type: AnsweredQuestion
has body: I am new to Android and I want to play online radio (example link http://www.bbc.co.uk/radio/listen/live/r1_aaclca.pls) using ParsePls. I have PlsParse code but after this I don't know how to play using the player in Android. PlsParser.java public PlsParser(File file) throws FileNotFoundException { this.reader = new BufferedReader(new FileReader(file), 1024); } @Override public List&lt;String&gt; getUrls() { LinkedList&lt;String&gt; urls = new LinkedList&lt;String&gt;(); while (true) { try { String line = reader.readLine(); if (line == null) { break; } String url = parseLine(line); if (url != null &amp;&amp; !url.equals("")) { urls.add(url); } } catch (IOException e) { e.printStackTrace(); } } return urls; } private String parseLine(String line) { if (line == null) { return null; } String trimmed = line.trim(); if (trimmed.indexOf("http") &gt;= 0) { return trimmed.substring(trimmed.indexOf("http")); } return ""; } } and PlaylistParser.java public interface PlaylistParser { public List&lt;String&gt; getUrls(); } Basically I need to play online fm in Android. How can I do this?
has title: How to play online radio using .pls format in Android?
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/22266189
score: 0
answer count: 1

http://stackoverflow.com/comment/33596801
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22141615
type: Comment
has text: @MohseTaheri you can tell this by the `instanceof` check. See the edited answer.

ssdp
tag name: ssdp
type: Tag
tags question: http://stackoverflow.com/q/22168526

http://stackoverflow.com/q/22157108
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/22159045
type: Question
has comment: http://stackoverflow.com/comment/33624939
has comment: http://stackoverflow.com/comment/33625038
has comment: http://stackoverflow.com/comment/33626184
downvote count: 0
answer count: 1
has title: The solution to send arguments to Python process using Runtime.exec
favorite count: 0
tagged with: exec
has answer: http://stackoverflow.com/a/22159045
has body: I solved this problem finally!! Now, I paste my code and notes here, in order to help others. My example code is to calculate similarity score between two words. In Java, it sends two words to Python where looks up score. Then, Python get two arguments and print their similarity score. At last, it reads the result of Python code in Java. Java: import java.io.*; public class RuntimeTest { public static void main(String[] args) { try { Runtime r = Runtime.getRuntime(); String[] cmd={"/usr/bin/python", "/home/parallels/Desktop/.../src/ConceptNetSimilarity.py", "cat", "dog"}; Process p = r.exec(cmd); #exec(String[] cmd) - cmd[0]:path of python-3.x cmd[1]:path of your python code cmd[2],[3]:arguments #if you only invoke python code without arguments, `Process p = r.exec("python path-of-your-code");` instead. p.waitFor(); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; while ((line = br.readLine()) != null) { System.out.println(line); } p.waitFor(); } catch (Exception e) { e.printStackTrace(); } } } Python: import sys import divisi2 assoc = divisi2.network.conceptnet_assoc('en') U, S, _ = assoc.svd(k=100) spread = divisi2.reconstruct_activation(U, S) print spread.entry_named(sys.argv[1],sys.argv[2]) #argv=['/home/parallels/Desktop/.../src/ConceptNetSimilarity.py', 'cat', 'dog'] Result: 0.819618978389
upvote count: 1
tagged with: python
has comment: http://stackoverflow.com/comment/60886289
type: AnsweredQuestion

http://stackoverflow.com/a/22164061
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/22161809
answers question: http://stackoverflow.com/q/22161809
upvote count: 1
has comment: http://stackoverflow.com/comment/33678047
has comment: http://stackoverflow.com/comment/33681917
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33720540
has body: You missed the most important part here. The given code where you add your new InputListener... is inside your render() method. That's not how it should be. What it basically does is adding a new, anonymous InputListener to your image in every single frame. All those listeners will get notified and they all add 1 to your upcounter. Move the code to your show() method and it should work as you expected.
type: Answer

http://stackoverflow.com/q/22145590
has comment: http://stackoverflow.com/comment/33603405
accepted answer: http://stackoverflow.com/a/22145655
linked to: http://stackoverflow.com/q/3179216
has comment: http://stackoverflow.com/comment/33603517
has comment: http://stackoverflow.com/comment/33603712
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22145655
has comment: http://stackoverflow.com/comment/33603285
tagged with: java
has comment: http://stackoverflow.com/comment/33603594
has title: Underscore in package name in Java - is it bad?
type: Question
has comment: http://stackoverflow.com/comment/33604047
tagged with: naming-conventions
upvote count: 13
has comment: http://stackoverflow.com/comment/33611205
score: 12
tagged with: java-package
answer count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/33603487
has body: Sorry for my English I think that sometimes it is necessary. In my opinion search_result_list, location_provider are easier to read than searchresultlist, locationprovider. What does the documentation say?
duplicate of: http://stackoverflow.com/q/3179216
favorite count: 0

http://stackoverflow.com/comment/33457801
comment on: http://stackoverflow.com/a/22063994
type: Comment
has text: yes I know. the problem is that I have an array of strings. example of 1000 elements. I do not understand the algorithm, how do I make another array, each element of which is equal to 1-20 rows of the first array. the second element of the first array of rows 20-40. etc.
type: AnswerComment
score: 0

http://stackoverflow.com/q/22010704
type: Question
tagged with: jakarta-ee
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/33363097
has answer: http://stackoverflow.com/a/28584875
has body: I am working on a financial application where lots of agents hit the DB (Using UI) very frequently. I am using Oracle UniversalConnectionPool for DB Connection. But soon it creates lots of inactive sessions with DB. I don't have issues with inactive sessions because it puts them in the pool but problem is that after reaching the max limit it give error that Exception occurred while getting connection: oracle.ucp.UniversalConnectionPoolException: All connections in the Universal Connection Pool are in use Here is the code please have a look and help private static PoolDataSource pds = null; static UniversalConnectionPoolManager mgr = null; try{ pds = PoolDataSourceFactory.getPoolDataSource(); pds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource"); pds.setConnectionPoolName("JDBC_UCP"); pds.setInitialPoolSize(2); pds.setMinPoolSize(2); pds.setMaxPoolSize(10); pds.setURL("jdbc:oracle:thin:@192.168.4.5:1521:CDIM"); pds.setUser("baseline"); pds.setPassword("baseline"); mgr = UniversalConnectionPoolManagerImpl.getUniversalConnectionPoolManager(); mgr.createConnectionPool((UniversalConnectionPoolAdapter)pds); mgr.startConnectionPool("JDBC_UCP"); }catch(Exception e){ LogManager.error(DBConnection.class, "getConnection : " + e.getMessage()); } get Connection like this pds.getConnection(); Close Connection like this con.close(); con = null;
has title: Java-Oracle UniversalConnectionPool
type: UnansweredQuestion
tagged with: jdbc
has comment: http://stackoverflow.com/comment/33363416
has comment: http://stackoverflow.com/comment/33363781
tagged with: database-performance
tagged with: java

http://stackoverflow.com/q/22072654
type: UnansweredQuestion
downvote count: 2
has comment: http://stackoverflow.com/comment/33474551
upvote count: 1
has comment: http://stackoverflow.com/comment/33472757
has comment: http://stackoverflow.com/comment/33473232
has answer: http://stackoverflow.com/a/22073504
tagged with: java
tagged with: mutual-exclusion
type: Question
has comment: http://stackoverflow.com/comment/33472766
has title: Understanding critical region
answer count: 1
has comment: http://stackoverflow.com/comment/33472671
has body: I was reading through some examples online regarding about the critical region, entry protocol and exit protocol, and had a hard time figuring out. http://pages.cs.wisc.edu/~dusseau/Classes/CS537-S01/SampleQuizzes/sol2.html class BankAccount { private int turn = 0; private boolean lock = {true, true}; private int balance; private int accountNumber; BankAccount(int acct) { accountNumber = acct; balance = 0; } // tellerID is either 0 or 1 public void deposit(int amount, int tellerID) { lock[tellerID] = true; turn = 1 - tellerID; while (lock[1-tellerID] &amp;&amp; turn == (1 - tellerID)); balance += amount; lock[tellerID] = false; } } What's the entry protocol, exit protocol and critical region for this example? and as for the critical region, is it mutual exclusion, starvation or will it result in a deadlock?
tagged with: deadlock
has comment: http://stackoverflow.com/comment/33473009
score: -1
favorite count: 0
has comment: http://stackoverflow.com/comment/33472837
has comment: http://stackoverflow.com/comment/33472759

http://stackoverflow.com/a/22125568
downvote count: 0
has body: Roughly, a Java application always uses about as much memory as you allocate to it with -Xmx. In production the heap expands to that limit until the garbage collector kicks in. However, that is quite a simplification the rules when the JVM expands or shrinks the heap space are a litte more complex. The JIT will produce more and larger machine code in production. So if you just start your application locally and warm it up with a few clicks, there no more object garbage, which keeps the heap expanding. And there is no need to JIT the methods because nobody uses it frequently.
type: Answer
answers question: http://stackoverflow.com/q/22123810
score: 2
upvote count: 2

http://stackoverflow.com/comment/33495959
type: Comment
has text: I've changed it to System.out.println(line + ": " + myAwesomeTranslator.translate(num));
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/22084990

http://stackoverflow.com/q/22160451
has answer: http://stackoverflow.com/a/22160658
tagged with: android-asynctask
tagged with: android
accepted answer: http://stackoverflow.com/a/22160483
has title: Performance issues in Main thread even with AsyncTasks
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/22160483
tagged with: multithreading
has body: My Main thread seems to be pretty bad with performance. Transitioning between activities results in significant delays. I have pushed all of Web/Bitmap/File work into AsyncTasks and yet this is still happening. I have been doing my head in trying to figure out what is causing the slow-downs. My question is - If the Main thread uses a class (say ImageDownloader) that creates its own little AsyncTasks (say ImageDownloadTask), will Main wait for ImageDownloader to finish it's AsyncTasks (hence delays?) I would love to post code, but it's a very large project. If there is anything specific I should look for, please let me know and I'll be sure to share.
type: Question
possible better answer: http://stackoverflow.com/a/22160658
tagged with: performance
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/33631122

http://stackoverflow.com/comment/33446495
type: Comment
type: QuestionComment
has text: ok, thanks. Didn't know that. I will try to get it out of my code. I am pretty sure though, that its not the reason of the problem.
score: 0
comment on: http://stackoverflow.com/q/22057038

http://stackoverflow.com/q/22099190
has answer: http://stackoverflow.com/a/22107968
favorite count: 0
has comment: http://stackoverflow.com/comment/33534259
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33524400
has comment: http://stackoverflow.com/comment/33525022
has answer: http://stackoverflow.com/a/59410282
score: 1
tagged with: java
tagged with: swt
tagged with: windowbuilder
has comment: http://stackoverflow.com/comment/33535146
has comment: http://stackoverflow.com/comment/33526108
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33524786
type: Question
has comment: http://stackoverflow.com/comment/33536006
answer count: 2
has comment: http://stackoverflow.com/comment/33524900
has comment: http://stackoverflow.com/comment/33534056
has title: How to get Window Builder's SWT designer in 64-bit Eclipse
has body: I am trying to create a SWT WindowBuilder application in 64-bit Eclipse running on Windows 7. I removed both the 32-bit and 64-bit JRE on my computer along with the old Eclipse and old JDK, rebooted, downloaded the latest version yesterday evening, and then installed the latest 32/64 versions of the JRE and the JDK. Yes, I used a "professional" unzip utility, 7-zip, to unzip the "Eclipse IDE for Java Developers" and then copied the contents to the "C:\Program Files\Development\Tools\Eclipse", which I created. I launched Eclipse this morning and tried to create a SWT application and SWT was MIA. I went to the "Menu > Help > Install New Software..." dialog to find that SWT was already installed. Here is an image of of the new project dialog "Menu > File > New > Other". As you can see Eclipse came bundled with SWT, I did read the installation note about the fact that only Eclipse does not support the Windows built-in zip compression tool, and used 7-zip. How do I get SWT to install properly? I am using a freshly downloaded version and did not do anything other than go into Eclipse. Why would SWT not show?
has comment: http://stackoverflow.com/comment/33533931
upvote count: 1
has comment: http://stackoverflow.com/comment/33535966
downvote count: 0

http://stackoverflow.com/q/22060889
type: Question
has title: Easymock mocking inputstream read operation
has answer: http://stackoverflow.com/a/22061049
downvote count: 0
favorite count: 0
answer count: 3
has body: I want to test following code with easymock. I have created mock socket and mock inputstream but I am not able to mock the read method. Can anyone please help me byte[] lenbuf = new byte[2]; sock.getInputStream().read(lenbuf); I am trying following in my unit test InputStream mockInputStream = createMock(InputStream.class); expect(mockInputStream.read(new byte[2])).andReturn(2); replay(mockInputStream); it gives me following error Unexpected method call InputStream.read([0, 0]): InputStream.read([0, 0]): expected: 1, actual: 0 Thanks
possible better answer: http://stackoverflow.com/a/22061335
has comment: http://stackoverflow.com/comment/33458972
accepted answer: http://stackoverflow.com/a/22061049
has answer: http://stackoverflow.com/a/22061335
upvote count: 3
tagged with: unit-testing
type: AnsweredQuestion
score: 3
tagged with: java
tagged with: easymock
has answer: http://stackoverflow.com/a/54088055

http://stackoverflow.com/comment/34186154
score: 0
has text: Done, see: https://issues.apache.org/jira/browse/KARAF-2827
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22034099

http://stackoverflow.com/a/22120462
type: Answer
answers question: http://stackoverflow.com/q/22120122
has comment: http://stackoverflow.com/comment/33560335
has body: Here's a way to do this in Java: import java.io.*; public class WorldSeries { /** * Count the number of lines a string occurs on in a file. */ public static final void main(String[] argv) throws IOException { if(argv.length&lt;2) { showUsage(); System.exit(-1); } int count=0; String term = argv[0]; String filename = argv[1]; LineNumberReader reader = new LineNumberReader( new FileReader(filename) ); for(String line=reader.readLine(); line != null; line=reader.readLine()) { if(line.indexOf(term) &gt; -1) { count++; } } System.out.println(count); } private static final void showUsage() { System.out.println("Search for term in a file."); System.out.println("USAGE: &lt;term&gt; &lt;file-name&gt;"); } } But you can also do this with scripting: grep -c "Boston Red Sox" world-series.txt
downvote count: 1
upvote count: 0
score: -1

http://stackoverflow.com/comment/33561239
type: QuestionComment
comment on: http://stackoverflow.com/q/22121582
has text: http://stackoverflow.com/questions/14308129/case-expressions-must-be-constant-expressions-for-static-final-int
score: 0
type: Comment

http://stackoverflow.com/q/22042836
tagged with: jdbc
has answer: http://stackoverflow.com/a/22043137
has body: I create a Hashmap for some 400 or so objects. I have to store the objects as well as the hash maps in the mysql table. So each record of this table will have a object as well as its corresponding hashmap. How do I go about achieving this as well as retrieving my hashmap back from the sql table. The hashmap contains a histogram and the object that I wish to store is a image.
type: UnansweredQuestion
has title: how to save a Java Hashmap as a attribute in a sql table and load it back
downvote count: 1
tagged with: java
score: -1
tagged with: mysql
type: Question
tagged with: hashmap
upvote count: 0
tagged with: histogram
has comment: http://stackoverflow.com/comment/33419659
has answer: http://stackoverflow.com/a/22043529
has comment: http://stackoverflow.com/comment/33419738
favorite count: 0
has answer: http://stackoverflow.com/a/22043095
linked to: http://stackoverflow.com/q/4602210
answer count: 3

http://stackoverflow.com/a/22041220
has comment: http://stackoverflow.com/comment/33416582
has comment: http://stackoverflow.com/comment/33416703
has comment: http://stackoverflow.com/comment/33416932
score: 0
answers question: http://stackoverflow.com/q/22041082
type: Answer
has body: Split the text content at &lt;break/&gt; and add each split element to an ArrayList.

http://stackoverflow.com/q/22045926
score: 0
answer count: 1
tagged with: soap
tagged with: web-services
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22099863
tagged with: cxf
tagged with: java
tagged with: jax-ws
has title: CXF Webservice Server delegate Request Credentials to inner Webservice Call
type: Question
linked to: http://stackoverflow.com/q/8987232
has body: How can I pass through the credentials (basic auth) from a getting request to a new request to another Webservice ? I didn't find any property bag which can share data between the interceptors in a single request. for clarification: client [with basic auth cred] --> request --> WS-1 ** WS-1 --> request --> WS-2 and pass thru the credentials from the original client ** WS-1 --> request --> WS-3 (with no creds) WS-1 --> response --> client
accepted answer: http://stackoverflow.com/a/22099863

http://stackoverflow.com/comment/33443977
has text: @robermann Conceptually, they aren't. And as far as implementation details are concerned, some 64 bit JVMs use 32 bit references to "compress pointers". The resulting values aren't pointers or addresses as commonly understood, but perfectly match the concept of a reference, which is just "something which identifies an object".
comment on: http://stackoverflow.com/a/22056150
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33609268
comment on: http://stackoverflow.com/q/22147507
type: Comment
type: QuestionComment
has text: Yep, and tried other eclipses too. Now i'm going to try a clean and new eclipse...
score: 0

http://stackoverflow.com/q/22021114
has comment: http://stackoverflow.com/comment/33384886
has answer: http://stackoverflow.com/a/22069650
accepted answer: http://stackoverflow.com/a/22069650
type: Question
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33385146
tagged with: java
tagged with: antlr
answer count: 1
tagged with: compilation
tagged with: ide
has title: Is there any way to include Antlr in the Java compilation process?
score: 0
tagged with: antlr4
has body: I am using Antlr4 to create a Java (Java 7) source transformation tool. I take as an input a Main.java file and transform it to an output newMain.java source file, which corresponds to the same program, but with minor changes. To run my transformation tool I am using the exported generator.jar file as follows: Step1 (I use the generator.jar to create the newMain.java file by using the following command): java -jar generator.jar folderName/Main.java Step2: (I compile the newMain.java file) javac folderName/newMain.java Step3: (I run the newMain.class file) java newMain I was wondering if there is any other way of doing this operation, which would be transparent to the user (through command line or by using an IDE)? I mean that the user should just compile his Main.java class without seeing the generated newMain.java source file neither the newMain.class. Actually, the new generated .class file should replace the initial Main.class file.

http://stackoverflow.com/q/22035054
linked to: http://stackoverflow.com/q/7210269
tagged with: jpa-2.0
type: UnansweredQuestion
has body: How to write a JPA query that make a join between 2 entities EntityA @Id long id String field1 String field2 EntityB @Id String field1 @Id String field2 How can I write a join like This in JPQL select * from entityA,entityB where entityB.field1 = entityA.field1 and entityB.field2 = entityA.field2
score: 0
tagged with: java
tagged with: mysql
type: Question
has answer: http://stackoverflow.com/a/22035241
has answer: http://stackoverflow.com/a/22035347
has title: How to make an inner join , Left join , right join between 2 table using JPA
answer count: 2
tagged with: jpa

currency
tag name: currency
type: Tag
tags question: http://stackoverflow.com/q/22028249

http://stackoverflow.com/q/22122687
tagged with: mockito
has answer: http://stackoverflow.com/a/22123130
has comment: http://stackoverflow.com/comment/33563468
has body: Below is my method which gives me the date of either recent Monday or recent Thursday in the format of YYYYMMDD. Today is Saturday, so it should return date for Thursday in the format of YYYYMMDD so it will be - 2014027 public static String getDate() { Calendar cal = Calendar.getInstance(); try { int dow = cal.get(Calendar.DAY_OF_WEEK); switch (dow) { case Calendar.THURSDAY: case Calendar.FRIDAY: case Calendar.SATURDAY: case Calendar.SUNDAY: while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.THURSDAY) { cal.add(Calendar.DATE, -1); } break; case Calendar.MONDAY: case Calendar.TUESDAY: case Calendar.WEDNESDAY: while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { cal.add(Calendar.DATE, -1); } break; } } catch (Exception ex) { // log error } return toDateFormat.format(cal.getTime()); } So my question is, how do I mock the Calendar getInstance method so that I can easily junit getDate method? I have never mocked it before so I am facing some problem? Can anyone provide a simple example if possible on my example?
answer count: 1
tagged with: junit
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/22123130
tagged with: powermock
has title: How to mock a certain method while doing junit?
linked to: http://stackoverflow.com/q/14456377
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33563337
has comment: http://stackoverflow.com/comment/33563508
has comment: http://stackoverflow.com/comment/33563364
score: 1
tagged with: java
upvote count: 1
has comment: http://stackoverflow.com/comment/33563344
tagged with: unit-testing
type: Question

resolution
tags question: http://stackoverflow.com/q/22108084
type: Tag
tag name: resolution
tags question: http://stackoverflow.com/q/22020385

http://stackoverflow.com/q/22098745
has title: Naive bayes text classification calculation, better to do in MySQL or java
score: 0
answer count: 1
type: UnansweredQuestion
has body: The calculation for class conditional probability in naive bayes is P(t|c) = Log2((n1+1)/(n2+n3)) Where t = token x; c = class x n1 = number of token x in class x n2 = number of all token in class x n3 = number of all token in all class Which one is faster, doing calculation in MySQL or in Java (of course we need to grab data from MySQL to use it in Java)?
has answer: http://stackoverflow.com/a/22098867
tagged with: java
tagged with: mysql
type: Question
has comment: http://stackoverflow.com/comment/33519470

http://stackoverflow.com/comment/33562615
type: Comment
comment on: http://stackoverflow.com/a/22121849
has text: @TedBigham Sorry I copied that value wrong. Yes, it is 128. The `(byte)` cast is used on the literal not on the result of `<<`. So the `int` literal value is cast to a `byte`. The shift operator **requires (the Java Language requires)** that unary numeric promotion happens. So the `byte` value of `-128` is promoted to the `int` value `-128`. And then _that_ value is used in the shift. If you take a look with your favorite IDE, you'll notice that the `println()` method used is the one that accepts an `int`.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33660214
has text: @mkl I debuged the code, and I get the file path not URL, also I have the file in the directory.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22167723

http://stackoverflow.com/a/69780373
answers question: http://stackoverflow.com/q/22039569
type: Answer
has body: ThreadLocal can lead to memory leak if we do not set null manually once its out of scope.
score: 0

http://stackoverflow.com/q/22154785
type: UnansweredQuestion
tagged with: garbage-collection
has comment: http://stackoverflow.com/comment/33620973
score: 2
has comment: http://stackoverflow.com/comment/33621152
tagged with: guava
tagged with: java
has comment: http://stackoverflow.com/comment/33621210
type: Question
has answer: http://stackoverflow.com/a/22167228
has comment: http://stackoverflow.com/comment/33620813
downvote count: 0
has answer: http://stackoverflow.com/a/22155141
has body: I have something like this: private final Cache&lt;Long, BlockingDeque&lt;Peer&gt;&gt; peers = CacheBuilder.newBuilder() .expireAfterAccess(10, TimeUnit.MINUTES) .build(); public class Peer { public void hanleRequest(String request) { ... } //.... } Cache provides only two policies: expiredAfterWrite and expireAfterAccess. Either the first nor the second is suitable for me. I want BlockingDeque&lt;Peer&gt; entity expires in 10 minutes after last invocation of Peer#handleRequest() method on one of Peer objects that belongs to that BlockingDeque. Means Peer#handleRequest() resets the expiration counter. I want Any of other methods of Peer object doesn't reset counter. I want peers.get(key) also doesn't reset counter. Example peers.getIfPresent(key); // doesn't reset counter peers.getIfPresent(key).add(new Peer()); // doesn't reset counter peers.getIfPresent(key).remove(peer); //doesn't reset counter peers.getIfPresent(key).handleRequest(request); // RESET counter! Questions Is that possible with help of Guava Cache, ExpiringMap, MapMaker or any other Guava map? If asnwer to the first question is NO. Can I just customize one of the Guava elements to have no need to implement all from scratch? If answer to the second question is NO. What is the better way to implement that by my own? At the moment I suppose it'll be ConcurrentHashMap with daemon thread in addition. That thread will be iterate throught the whole map each 5-15 seconds and check if any entity is expired Updated: Is that a good solution? As I suppose, handleRequest is a operation which will be performed on each user request, so it performance stays on the first place. Approximate BlockingDeque objects in peers cache is near 10, approximate number of Peer object in one deque is 2. private final Cache&lt;Long, BlockingDeque&lt;Peer&gt;&gt; peers = CacheBuilder.newBuilder() .expireAfterWrite(10, TimeUnit.MINUTES) //CHANGE TO WRITE POLICY .build(); public class Peer { public void hanleRequest(String request) { …
has title: Guava Cache: manual management by removal policy
answer count: 2
favorite count: 0
upvote count: 2
has comment: http://stackoverflow.com/comment/33621206

http://stackoverflow.com/q/22162075
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33634613
has title: NullPointerException when trying to print a Jlabel iconImage
score: 0
has comment: http://stackoverflow.com/comment/33634021
has comment: http://stackoverflow.com/comment/33635149
tagged with: printing
has comment: http://stackoverflow.com/comment/33633775
has comment: http://stackoverflow.com/comment/33634411
favorite count: 0
tagged with: netbeans
tagged with: jlabel
has body: I'm having a NullPointerException when I'm trying to print a JLabel's icon. All I want is to print it on a paper using a button. What seems to be my error? Here's my code: package at; import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.awt.print.PageFormat; import java.awt.print.Paper; import java.awt.print.Printable; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import java.io.File; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JLabel; public class M extends javax.swing.JFrame { /** * Creates new form M */ public M() { initComponents(); } public static void printComponent(JComponent comp, boolean fill) throws PrinterException { PrinterJob pjob = PrinterJob.getPrinterJob(); PageFormat pf = pjob.defaultPage(); pf.setOrientation(PageFormat.LANDSCAPE); PageFormat postformat = pjob.pageDialog(pf); if (pf != postformat) { //Set print component pjob.setPrintable(new ComponentPrinter(comp, fill), postformat); if (pjob.printDialog()) { pjob.print(); } } } public static void printComponentToFile(Component comp, boolean fill) throws PrinterException { Paper paper = new Paper(); paper.setSize(8.3 * 72, 11.7 * 72); paper.setImageableArea(18, 18, 559, 783); PageFormat pf = new PageFormat(); pf.setPaper(paper); pf.setOrientation(PageFormat.LANDSCAPE); BufferedImage img = new BufferedImage( (int) Math.round(pf.getWidth()), (int) Math.round(pf.getHeight()), BufferedImage.TYPE_INT_RGB); Graphics2D g2d = img.createGraphics(); g2d.setColor(Color.WHITE); g2d.fill(new Rectangle(0, 0, img.getWidth(), img.getHeight())); ComponentPrinter cp = new ComponentPrinter(comp, fill); try { cp.print(g2d, pf, 0); } finally { g2d.dispose(); } try { ImageIO.write(img, "…
answer count: 0
type: UnansweredQuestion
upvote count: 1
has comment: http://stackoverflow.com/comment/33633692
downvote count: 1

http://stackoverflow.com/comment/33376802
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22018312
has text: Thank you for doing that. Let me know what happens next.

http://stackoverflow.com/q/22040108
upvote count: 1
type: Question
has title: groovy, string refuses to be a bigInt, is odd instead
accepted answer: http://stackoverflow.com/a/22040309
has body: I am losing my hair with Groovy lang, it has ruined 4 days for me in a row and it is counting. What i need to do is to execete an external process, read stdout, get that value and convert it to big int. What i have def str ='openssl x509 -in "'+ file + '" -serial -noout' def command = "cmd /c " + str; def proc = command.execute(); proc.waitFor(); def response = "${proc.in.text}" def result = response.split('=')[1] log.info result // outputs: 7434F30AEE5F2001530C7F0C4844E9EE log.info result.class.name // outputs: java.lang.String Ok, very cool, lets go on: def big = new BigInteger(result.decodeHex()) No-no, cant be done: java.lang.NumberFormatException: odd number of characters in hex string Meanwhile in another script: def numb = '7434F30AEE5F2001530C7F0C4844E9EE' log.info numb.class.name // outputs : java.lang.String b = new BigInteger(numb.decodeHex()) log.info b // outputs : 154465376439281796222583609645190146542
tagged with: groovy
answer count: 1
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/22040309
type: AnsweredQuestion
score: 1
tagged with: java

http://stackoverflow.com/comment/33488795
type: QuestionComment
has text: I make UI for linux desktop.
score: 0
comment on: http://stackoverflow.com/q/22075820
type: Comment

http://stackoverflow.com/comment/33484745
has text: this not working you are using c = a+a; that is not a valid statement in java.
comment on: http://stackoverflow.com/a/22079073
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/22116744
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33704843
has comment: http://stackoverflow.com/comment/127968753
has comment: http://stackoverflow.com/comment/33701640
answers question: http://stackoverflow.com/q/22114292
type: Answer
has comment: http://stackoverflow.com/comment/127959274
upvote count: 3
has body: The code is indeed rather confusing. For example, it is not clear what the condition for the blinking should be. At the moment, it seems like the condition is that a particular cell displays the current time (as obtained from a calendar instance). However, making this decision in the CellRenderer is highly dubious. Instead, this decision should be made from outside, since it actually depends on the model data. The implementation of the thread that controls the actual blinking is not very elegant. This could more easily be solved with a Swing Timer. (The thread only puts a task on the event queue, anyhow). Additionally, changing the background of a table cell renderer component is fairly independent of the component itself. However, I created a small example of how I would tackle this problem. I tried to mimic your original intention as far as possible: The sample creates a table that contains Strings of time (Calendar instances) that are a few seconds in the future, randomly permuted. It creates a timer that regularly checks whether any time limits has been exceeded. When the time has beed exceeded, the corresponding table cell starts to blink. The blinking itself is handled by a special BlinkCellRenderer. Since this cell renderer only has to switch the background color of a cell, it just uses a delegate cell renderer which provides the actual cell renderer component, and sets the background color of this component according to the current blinking state. It also allows adding and removing cells that should currently be blinking. Of course, this could be extended and implemented in a more sophisticated and versatile way, but maybe it serves as an inspiration, at least. import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Collecti…
score: 3
has comment: http://stackoverflow.com/comment/33705879
accepted answer of: http://stackoverflow.com/q/22114292
has comment: http://stackoverflow.com/comment/33700924

http://stackoverflow.com/comment/33426942
type: QuestionComment
comment on: http://stackoverflow.com/q/22046798
has text: I hope you don't use that password anywhere else...
score: 0
type: Comment

http://stackoverflow.com/q/22044540
tagged with: hashmap
score: -2
has comment: http://stackoverflow.com/comment/33422640
answer count: 3
has title: hashMap<String,AddressBO> in java
has body: I have hashmap &lt;&lt; String, AddressBO &gt;&gt; string key and class as value,where AddressBO is a class that has add1,add2,city,state,zip etc fields,and in map i have just two keys-primary and secondary and there value is object of AddressBO. Now I have to compare whether address are same or different ie values are same for both the object. For this do I have to override equals and hashcode method in AddressBo class or implement comparator interface?
has answer: http://stackoverflow.com/a/22044723
has comment: http://stackoverflow.com/comment/33422890
favorite count: 0
has answer: http://stackoverflow.com/a/22044920
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22044795
upvote count: 0
tagged with: java
downvote count: 2
type: Question

http://stackoverflow.com/a/22152959
type: Answer
has comment: http://stackoverflow.com/comment/33617255
has comment: http://stackoverflow.com/comment/33642598
answers question: http://stackoverflow.com/q/22152858
has comment: http://stackoverflow.com/comment/33617458
has body: Integer.toString(19991).length();
score: 0

http://stackoverflow.com/comment/33553812
has text: The available() test and loop should be *removed.* It is essentially nonsense to read if available() <= 0. It happens to work here because ObjectInputStream.available() must be returning zero, but it's still nonsense code.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22114197

http://stackoverflow.com/comment/33628493
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22133414
has text: The pipe is being closed is the IOException I get when trying to write to the console when the line == null

http://stackoverflow.com/comment/33489229
score: 0
type: Comment
type: QuestionComment
has text: XStream still lives? If not, maybe switch to JAXB with annotations, which is relatively easy. You can use StandardCharsets.UTF_8 which cannot throw an UnsupportedEncodingException. In NetBeans you can easily create an embedded DTD in the XML, to validate the structure. In general "ANSI as UTF-8" is a no-namer I have seen in Notepad++; it is just UTF-8 and is fine. Mind the XML better should be without BOM (special zero-width space at file begin).
comment on: http://stackoverflow.com/q/22081006

http://stackoverflow.com/q/22059540
has body: Hi All I am trying to set up redis server using java. My Redis server is linux server with ulimit unlimited. Here is my spring bean which creates connection public class JedisService implements IJedisService, InitializingBean, DisposableBean{ private JedisPool jedisPool; public JedisService() { } public JedisPool getJedisPool() { return jedisPool; } @Override public void destroy() throws Exception { if(jedisPool != null){ jedisPool.destroy(); } } @Override public void afterPropertiesSet() throws Exception { JedisPoolConfig poolConfig = new JedisPoolConfig(); poolConfig.setMaxActive(1000); poolConfig.setMaxIdle(10); poolConfig.setMinIdle(1); poolConfig.setMaxWait(30000); poolConfig.setNumTestsPerEvictionRun(10); poolConfig.setTestOnBorrow(true); poolConfig.setTestOnReturn(true); poolConfig.setTestWhileIdle(true); poolConfig.setTimeBetweenEvictionRunsMillis(30000); jedisPool = new JedisPool(poolConfig,Config.REDIS_HOST, RestrictionUtils.REDIS_PORT,RestrictionUtils.REDIS_CONNECTION_TIMEOUT); } public boolean validateHitsCount(String hostKey,String urlKey,int hostHitsCount, int urlHitsCount, long timeKey,Map&lt;String, Object&gt; overLimit){ int retryCount = 0; return recursiveRedisConnection(retryCount,hostKey,urlKey,hostHitsCount,urlHitsCount,timeKey,overLimit); } private boolean recursiveRedisConnection(int retryCount,String hostKey,String urlKey,int hostHitsCount, int urlHitsCount, long timeKey,Map&lt;String, Object&gt; overLimit){ Jedis jedis = null; boolean returnObj = true; try { //Connection jedis = getJedisPool().getResource(); jedis.connect(); //Delete previous keys try { deletePreviouskeys(jedis, urlKey, hostKey, timeKey); } catch (Exception e) { } //Validation String value = jedis.get(hostKey+timeKey); if(value != null){ try { int count = Integer.parseInt(value); System.out.println("HostCount: "+hostKey+ " "+count); if(count &lt; hostHitsCount){ jedis.incr(hostKey+timeKey); returnObj = validateURLHits(jedis, urlKey, urlHitsCount, timeKey, overLimit); }else{ …
has title: Could not get a resource from the pool JedisConnectionException
tagged with: java
tagged with: jedis
type: Question
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/22302755
tagged with: redis
type: UnansweredQuestion

http://stackoverflow.com/q/22122882
has body: I'm trying to get a BufferedWriter to print several Strings, each on a different Line in a text file. I'm trying to use out.newLine() to set a new line for the next string, but I'm getting an error message of cannot find symbol - method newLine() This is the code I am trying to use: Writer out = null; try { out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(start+"2"+dest+".txt"), "utf-8")); // create output file from start names out.write(outputOne);//Write Line 1 out.newLine(); out.write(outputTwo); //Write Line 2 out.newLine(); out.write(outputThree); //Write Line 3 out.newLine(); out.write(outputFour); //Write Line 4 out.close(); } catch (IOException ex) { //Handle Errors System.err.println("Error in BufferedWriter, IOException"); } finally { try {out.close();} catch(Exception ex) {} }
type: AnsweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22122890
has title: BufferedWriter newLine method not found
score: 0
accepted answer: http://stackoverflow.com/a/22122890
answer count: 1

http://stackoverflow.com/comment/33609256
comment on: http://stackoverflow.com/q/22148533
has text: This question appears to be off-topic because it is a request for a code review.
score: 0
type: Comment
type: QuestionComment

opencv
type: Tag
tags question: http://stackoverflow.com/q/22141969
tags question: http://stackoverflow.com/q/22089039
tags question: http://stackoverflow.com/q/22131032
tags question: http://stackoverflow.com/q/22117353
tags question: http://stackoverflow.com/q/22085747
tag name: opencv
tags question: http://stackoverflow.com/q/22018946
tags question: http://stackoverflow.com/q/22141060
tags question: http://stackoverflow.com/q/22124783
tags question: http://stackoverflow.com/q/22043430
tags question: http://stackoverflow.com/q/22156887
tags question: http://stackoverflow.com/q/22088826
tags question: http://stackoverflow.com/q/22135253
tags question: http://stackoverflow.com/q/22117579

http://stackoverflow.com/q/22147863
upvote count: 2
has title: creating an object with static type of base class vs subclass?
has body: I cannot figure out the difference between accessing a method of a subclass that is accessed and overwritten using the base class(Object) for the static type of the object versus using the subclass(Point). For example: public class Point { int x, y; ... public boolean equals(Object o){ ... } public boolean equals(Point p){ ... } } Object o = new Object(); Point p = new Point(3,4); Object op = new Point(3,4); // here the static type is Point and the dynamic type is point, in this case // the equals() method that we choose and gets overwrriten depends on the // parameter type that is passed. p.equals(o); p.equals(p); p.equals(op); // here however the static type is Object so we initially look at the equals() // method in our Object class during compile time and check its parameter type // which is Object, thus if we overwrite // the equals() method we will pick the one that has a type Object parameter. // Since the dynamic type of our object is Point, when we are at run time // we will look for the equals() method in Point that matches with the // method type Object parameter. op.equals(o); op.equals(op); op.equals(p); What i am not seeing is why would i want to use the later rather than the former to specify what method i would like to overwrite? The former depends on the type parameter while the later depends on the type parameter of the static type of our object. I just dont see the benefit of using Basetype obj = new Subclasstype() to access and overwritten method in my subclass. It looks more complicated and the object can only be used to access instances of methods in the subclass that were in the base class, not any other methods in the subclass.
possible better answer: http://stackoverflow.com/a/22148106
tagged with: extend
type: Question
tagged with: object
has answer: http://stackoverflow.com/a/22147964
tagged with: java
accepted answer: http://stackoverflow.com/a/22147964
has comment: http://stackoverflow.com/comment/33608336
answer count: 2
downvote count: 0
tagged with: polymorphism
favorite count: 0
has answer: http://stackoverflow.com/a/22148106
score: 2
type: AnsweredQuestion

http://stackoverflow.com/comment/33784934
has text: Workshift is serialized but not inside visit. Visit is a child of Workshift, so there's no need to serialize it again inside Visit. Visit only holds reference to workshift. This example is just a structural representation of problem I'm having. Otherwise my actual data structure is far more complex than this.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22238249
type: AnswerComment

http://stackoverflow.com/q/22148533
type: AnsweredQuestion
has body: My task is to classify sentences with rappoort its weight. I would have to regroup three types of data. I registered each type of data in a table, then I put it in an other table in order to have a table like this: Sentence Weight Class sentence1 0.342 classe1 sentence2 0.231 classe2 sentence3 0.535678 classe3 I made the following program: String table1[]={"sentenc1","sentenc2","sentenc3"}; double table2[]={0.342,0.231,0.535678}; String table3[]={"classe1","classe2","classe3"}; Object [][] table= new Object[10][10]; int i=0; for(int j=0; j&lt;3;j++) { table[j][i]=table1[j]; } i=1; for(int j=0; j&lt;3;j++) { table[j][i]=table2[j]; } i=2; for(int j=0; j&lt;3;j++) { table[j][i]=table3[j]; } for(int k=0; k&lt;3;k++) { for(int j=0; j&lt;3;j++) { System.out.println("table["+k+"]["+j+"]="+table[k][j]); } } Is it a good way or It has problems? Are there other method?
tagged with: java
downvote count: 2
accepted answer: http://stackoverflow.com/a/22148719
has comment: http://stackoverflow.com/comment/33609256
has comment: http://stackoverflow.com/comment/33609483
type: Question
has title: Register different types of data
score: -2
upvote count: 0
answer count: 1
has answer: http://stackoverflow.com/a/22148719
favorite count: 0
has comment: http://stackoverflow.com/comment/33608924

http://stackoverflow.com/q/22122935
score: 0
has answer: http://stackoverflow.com/a/22123002
linked to: http://stackoverflow.com/q/21868170
favorite count: 0
type: UnansweredQuestion
has title: Live counting in GUI
upvote count: 1
linked to: http://stackoverflow.com/q/21618830
tagged with: swing
downvote count: 1
has body: I am trying to display a real-time counting in a simple java gui, I have used optionPane but there is a built-in button. So every time to display the next number, the user will have to press the button. Is there a way to let the numbers run by itself in a simple gui? example: for(int i = 0; i &lt; 100; i++) { JOptionPane.showMessageDialog(null, i); }
has answer: http://stackoverflow.com/a/22123181
linked to: http://stackoverflow.com/q/21532761
has comment: http://stackoverflow.com/comment/33563996
linked to: http://stackoverflow.com/q/21800466
tagged with: java
type: Question
answer count: 2
linked to: http://stackoverflow.com/q/21587972
has comment: http://stackoverflow.com/comment/33563838

http://stackoverflow.com/comment/64988641
comment on: http://stackoverflow.com/a/23820460
score: 1
type: AnswerComment
has text: Your article contains nothing whatsoever to do with asynchronous I/O. 'Non-blocking' means that the operation completes or fails immediately. 'Asynchronous' means that the operation continues in the background while the actual async I/O method you called returns to your code. They are not even slightly related. Java NIO has a whole raft of asynchronous channels since I think 1.7, in addition to non-blocking and multiplexing.
type: Comment

http://stackoverflow.com/q/22020533
answer count: 1
score: 47
tagged with: java
has answer: http://stackoverflow.com/a/22021656
tagged with: jakarta-mail
upvote count: 47
has body: I am trying to upgrade to latest Java Mail utility. From javax.mail mail 1.4.7 to (my Intention) javax.mail mail 1.5.1 But I don't find 1.5.1 for mail artifact, but I can see com.sun.mail javax.mail 1.5.1 My Question is why group id changed and if I change the group id for 1.5.1 do I need to change all my mail implementation that is already present (package name change and any other stuff) and what is the difference between com.sun.mail vs javax.mail?
type: AnsweredQuestion
has title: JavaMail API from Maven
downvote count: 0
favorite count: 0
type: Question
accepted answer: http://stackoverflow.com/a/22021656
tagged with: maven

http://stackoverflow.com/q/22036935
tagged with: gui-builder
type: UnansweredQuestion
tagged with: swing
has title: How to add/design a modal configuration pop up window to main JFrame in WindowBuilder?
answer count: 0
score: 0
tagged with: java
tagged with: windowbuilder
has comment: http://stackoverflow.com/comment/33409805
tagged with: eclipse
type: Question
has comment: http://stackoverflow.com/comment/33409055
has body: All I want to do is have a JOptionPane pop up when the user clicks on a certain menu item. The JOptionPane will show some basic configuration and then when the user clicks ok, the appropriate command will be run. What I can't work out is how to do this in WindowBuilder. The only way I can see is to create a separate class file but that seems like overkill. How do I 'add' the JOptionPane so that I can see it and edit its design in WindowBuilder?
has comment: http://stackoverflow.com/comment/33639713

http://stackoverflow.com/comment/33542077
score: 1
type: AnswerComment
has text: If main() is not public, it doesn't meet the requirements for being the program entry point. No matter what the file name is.
type: Comment
comment on: http://stackoverflow.com/a/22110840

http://stackoverflow.com/a/22108805
accepted answer of: http://stackoverflow.com/q/22108644
has body: From your code findControl method is returing null which is causing this nullpointer exception as it makes control null. Just wild wild wild guess and please ignore this if its not correct. Are you expecting to pass "console" in findControl method or it should be same as "console-popup". Sometimes we do type error and look into different direction. Anyway Just to complete the answer you can add this line just after calling find Control method. final ConsoleControl control = (ConsoleControl)this.nifty.createPopup("console-popup").findControl("console", ConsoleControl.class); if(control == null){ //log error message if want return; }
answers question: http://stackoverflow.com/q/22108644
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33538516
upvote count: 1
type: AcceptedAnswer

http://stackoverflow.com/comment/33373142
score: 0
type: AnswerComment
type: Comment
has text: I didn't understand your sentence, I am sorry.
comment on: http://stackoverflow.com/a/22016868

http://stackoverflow.com/comment/34954676
comment on: http://stackoverflow.com/a/22902806
score: 0
type: AnswerComment
has text: @fge It doesn't seem like it applies to all character sets though. For example, [UTF-8 clearly defines](http://en.wikipedia.org/wiki/UTF-8) what is invalid, but says nothing (as far as I can see) about unmappable character. I would assume that they are all mappable, just some sequences are invalid, ie. malformed.
type: Comment

http://stackoverflow.com/q/22140006
linked to: http://stackoverflow.com/q/4585867
linked to: http://stackoverflow.com/q/423950
tagged with: border
answer count: 1
downvote count: 0
favorite count: 0
linked to: http://stackoverflow.com/q/778222
linked to: http://stackoverflow.com/q/5120116
has answer: http://stackoverflow.com/a/22140057
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33594311
tagged with: swing
linked to: http://stackoverflow.com/q/32155070
tagged with: jbutton
score: 4
has title: Rounded corners for Swing JButton Swing without features of actual JButton
tagged with: java
type: Question
upvote count: 4
has body: 1 I have gone through the code on Java documentation for Swing look and feel, but I could not find much about how to modify the default look of JButtons. I want to have rounded/curved corners for JButtons in Swing. Is there a way to achieve this? What functions and values should I use? I have used the statement below: generateButton.setBorder(new RoundedBorder(20)); The code for RoundedBorder I found in Stack Overflow question Rounded Swing JButton using Java: I do get a black rounded border outline around the original button. MY button has orange background. But it doesn't remove the orange area outside the rounded corners. Also I do not want the black border. How should I go about this?

http://stackoverflow.com/q/22163246
linked to: http://stackoverflow.com/q/3436398
type: AnsweredQuestion
tagged with: java
has body: The question sound dumb but it's like that I had a binary string which contains a series of "0" and "1". If I store its as textfile it'll be huge since each character take about 8 bytes. But actually it should be much lesser since "0" or "1" is just actually 1 bit (1 byte/8). My question is how could to do that in Java? Edited to avoid confuse I've used an algorithm to encode all the data down to "0" and "1" sequence string. So 1 chunk of data could become quite big ... a few A4 paper of 1 string contains "0" and "1". I'm stuck at the step to write down that string (which just "0" and "1") to an actual binary data file ... and it should be much lesser than just store down the text file which contains "0" and "1" as I assumed
type: Question
score: 0
answer count: 3
possible better answer: http://stackoverflow.com/a/22163338
tagged with: converters
has answer: http://stackoverflow.com/a/22163338
has answer: http://stackoverflow.com/a/22188490
tagged with: binary
accepted answer: http://stackoverflow.com/a/22188490
has answer: http://stackoverflow.com/a/22163494
has title: convert a binary string contains "0101010101001" for instance to actual binary file
linked to: http://stackoverflow.com/q/6658388

syntax
tags question: http://stackoverflow.com/q/22097269
type: Tag
tags question: http://stackoverflow.com/q/22124731
tags question: http://stackoverflow.com/q/22016586
tags question: http://stackoverflow.com/q/22158432
tags question: http://stackoverflow.com/q/22029382
tag name: syntax
tags question: http://stackoverflow.com/q/22061764

http://stackoverflow.com/comment/33534497
comment on: http://stackoverflow.com/a/22105831
has text: Hmm... So are you the person who assigned this task to this student? Why did you delete your other copy of this comment and post it again? You say "Methods should be as simple as possible." Note that it is simpler to check whether each character results in a match than to check whether there is valid input and then check whether each character results in a match. Also, your repeat post resulted in some repetition in your statements.
type: AnswerComment
type: Comment
score: 0

http://stackoverflow.com/a/22017420
has comment: http://stackoverflow.com/comment/33388566
answers question: http://stackoverflow.com/q/22016572
has comment: http://stackoverflow.com/comment/33388924
score: 0
has body: Here is an approach: use an ExecutorService to handle DB requests; use Futures for your map values; use a ConcurrentHashMap as a map implementation. The Future should get from the DB; it will use the ExecutorService. When you need to make manipulations on one object, synchronize on this future's .get() which will be the object. Also, google for "Java concurrency in practice", and buy the book ;)
type: Answer

http://stackoverflow.com/comment/33452758
type: Comment
type: QuestionComment
has text: Could you please post the complete xml configuration file, because Amudhan and Dave Syer are rigth, you need to add `<task:annotation-driven />`. On the other hand you wrote (in Amudhan's comment) that this lead to an exception. So something must be very wrong with your xml file, therefore please post the COMPLETE xml file, including the "header".
score: 0
comment on: http://stackoverflow.com/q/22060996

http://stackoverflow.com/comment/33506702
type: QuestionComment
type: Comment
score: 1
has text: Would it have anything to do with the path you're providing the web service at? If you've listed your app as being at `myapp/`, what happens if you change that to `myapp`?
comment on: http://stackoverflow.com/q/22091551

http://stackoverflow.com/comment/33444677
has text: it wont allow me to post the rest
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22056553

http://stackoverflow.com/q/22050978
type: Question
has answer: http://stackoverflow.com/a/22051094
score: 0
tagged with: http://stackoverflow.com/tag/csv
answer count: 1
has comment: http://stackoverflow.com/comment/33434396
type: UnansweredQuestion
has title: Coverting a string into timestamp java mysql
linked to: http://stackoverflow.com/q/5201383
tagged with: timestamp
tagged with: java
tagged with: mysql
has body: My csv file has the following format 26/02/2014 17:20:17. I've stored it in a string array in my program as value[0]. How would I go about converting it into a timestamp that can be stored into a DATETIME column in mysql e.g. 2014-02-26 17:20:17

http://stackoverflow.com/comment/33491645
type: AnswerComment
comment on: http://stackoverflow.com/a/22082674
type: Comment
score: 1
has text: Another thought : declare a property if you want to use many libs in the same version, and use it in each dependency tag related to this framework.

http://stackoverflow.com/comment/33464980
type: AnswerComment
comment on: http://stackoverflow.com/a/22042572
type: Comment
has text: @russell1911dev I've made them package-protected (with no access modifier), so you don't need getters and setters. Please note, that you cannot use System.out on Android, use Log class instead (http://developer.android.com/reference/android/util/Log.html)
score: 0

http://stackoverflow.com/a/23171141
downvote count: 0
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/22166472
score: 1
has body: You have to assign a server to your project. Right click on project and select Properties (last one) Select on left panel "Targeted Runtimes" and select your server. Click on and re-import the classes if it's needed with Ctrl + Shift + O

http://stackoverflow.com/comment/33377449
type: AnswerComment
comment on: http://stackoverflow.com/a/22017602
type: Comment
has text: Sorry but I mean to mark my own as that's the solution to the problem, I can only tomorrow, thanks again for your help.
score: 0

http://stackoverflow.com/q/22117096
score: 0
tagged with: sql
answer count: 1
has body: I have 2 tables Customers &amp; Accounts in my Oracle Database. I have sequence numbers for generating surrogate key values for both tables. CREATE SEQUENCE customers_seq NOCACHE; CREATE SEQUENCE accounts_seq NOCACHE; CREATE TABLE customers ( customer_surrogate_id NUMBER(10), customer_id VARCHAR2(8) UNIQUE NOT NULL, customer_password VARCHAR2(20), customer_name VARCHAR2(20), customer_pan VARCHAR2(10) UNIQUE, customer_email_id VARCHAR2(20) UNIQUE, CONSTRAINT customer_pk PRIMARY KEY (customer_surrogate_id) ); CREATE TABLE accounts ( accounts_surrogate_id NUMBER(10), account_id VARCHAR2(10) UNIQUE NOT NULL, customer_surrogate_id NUMBER(10), account_type VARCHAR2(10), account_currency VARCHAR2(20), account_balance NUMBER(20, 2), CONSTRAINT accounts_pk PRIMARY KEY (accounts_surrogate_id), CONSTRAINT accounts_fk FOREIGN KEY (customer_surrogate_id) REFERENCES customers(customer_surrogate_id) ); I know how to use sequence_name.NEXTVAL &amp; sequence_name.CURRVAL in insert statements to perform the reference The problem is with using NEXTVAL &amp; CURRVAL is that it assumes that inserts to both tables occur sequentially like insert into Customers(// use NEXTVAL here) insert into Accounts(// use CURRVAL here to reference the above row in Customers) But in my java application, the multiple inserts for the Customers table can occur before even one insert occurs in Accounts table. CURRVAL will return the value of the last inserted row of the Customers table. When inserting a row into Accounts table, I can get customers_id values in my application. Should the customer_id be used to query the Customers table to get the customer_surrogate_id as shown below? insert into Customers(// use NEXTVAL here) ... insert into Accounts(// use the customer_id to query and find customer_surrogate_id) Is there better way to reference the Customers table in this situation? Edit: I am using JDBC to access the database.
type: UnansweredQuestion
tagged with: oracle-database
has answer: http://stackoverflow.com/a/22117184
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33552932
has comment: http://stackoverflow.com/comment/33556727
has title: Referencing Surrogate keys

http://stackoverflow.com/q/22081505
answer count: 9
has comment: http://stackoverflow.com/comment/33769050
has comment: http://stackoverflow.com/comment/33735065
has comment: http://stackoverflow.com/comment/33778101
upvote count: 9
has comment: http://stackoverflow.com/comment/33680331
has comment: http://stackoverflow.com/comment/33771105
has body: I am having a really weird issue with a Java application. Essentially it is a web page that uses magnolia (a cms system), there are 4 instances available on production environment. Sometimes the CPU goes to 100% in a java process. So, first approach was to make a thread dump, and check the offending thread, what I found was weird: "GC task thread#0 (ParallelGC)" prio=10 tid=0x000000000ce37800 nid=0x7dcb runnable "GC task thread#1 (ParallelGC)" prio=10 tid=0x000000000ce39000 nid=0x7dcc runnable Ok, that is pretty weird, I have never had a problem with the garbage collector like that, so the next thing we did was to activate JMX and using jvisualvm inspect the machine: the heap memory usage was really high (95%). Naive approach: Increase memory, so the problem takes more time to appear, result, on the restarted server with increased memory (6 GB!) the problem appeared 20 hours after restart while on other servers with less memory (4GB!) that had been running for 10 days, the problem took still a few more days to reappear. Also, I tried to use the apache access log from the server failing and use JMeter to replay the requests into a local server in an attemp to reproduce the error... it did not work either. Then I investigated the logs a little bit more to find this errors info.magnolia.module.data.importer.ImportException: Error while importing with handler [brightcoveplaylist]:GC overhead limit exceeded at info.magnolia.module.data.importer.ImportHandler.execute(ImportHandler.java:464) at info.magnolia.module.data.commands.ImportCommand.execute(ImportCommand.java:83) at info.magnolia.commands.MgnlCommand.executePooledOrSynchronized(MgnlCommand.java:174) at info.magnolia.commands.MgnlCommand.execute(MgnlCommand.java:161) at info.magnolia.module.scheduler.CommandJob.execute(CommandJob.java:91) at org.quartz.core.JobRunShell.run(JobRunShell.java:216) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549) Caused by: java.lang.OutOfMemoryError: G…
possible better answer: http://stackoverflow.com/a/22156946
downvote count: 0
has answer: http://stackoverflow.com/a/22156946
has comment: http://stackoverflow.com/comment/33639211
tagged with: garbage-collection
has answer: http://stackoverflow.com/a/22280138
has comment: http://stackoverflow.com/comment/33489818
accepted answer: http://stackoverflow.com/a/22169096
type: AnsweredQuestion
tagged with: java
tagged with: memory
linked to: http://stackoverflow.com/q/40119
has answer: http://stackoverflow.com/a/22239504
type: Question
has answer: http://stackoverflow.com/a/22169096
score: 9
tagged with: magnolia
has title: Problems with Java garbage collector and memory
has answer: http://stackoverflow.com/a/22155433
linked to: http://stackoverflow.com/q/1393486
has answer: http://stackoverflow.com/a/22289287
has answer: http://stackoverflow.com/a/22081862
has answer: http://stackoverflow.com/a/22238048
favorite count: 0
has answer: http://stackoverflow.com/a/22282606

http://stackoverflow.com/comment/33465254
type: Comment
has text: I'd love a version which didn't involve splitting the string. I was really looking for a regex which would work out of curiosity. I could absolutely split on sat and then just regex the text which comes after, but I'd learn less :)
type: QuestionComment
comment on: http://stackoverflow.com/q/22051862
score: 0

http://stackoverflow.com/comment/33621322
type: QuestionComment
comment on: http://stackoverflow.com/q/22152018
has text: It's unclear what you're asking here. If you don't want to serialize certain fields in your serializer you just ... wouldn't add them to the JsonElement you're returning.
score: 0
type: Comment

jdbc
tags question: http://stackoverflow.com/q/22166019
tags question: http://stackoverflow.com/q/22085970
tags question: http://stackoverflow.com/q/22027417
tags question: http://stackoverflow.com/q/22066316
tags question: http://stackoverflow.com/q/22042741
tags question: http://stackoverflow.com/q/22105896
tags question: http://stackoverflow.com/q/22127945
tags question: http://stackoverflow.com/q/22033556
tags question: http://stackoverflow.com/q/22076879
tags question: http://stackoverflow.com/q/22160068
tags question: http://stackoverflow.com/q/22058416
tags question: http://stackoverflow.com/q/22010704
tags question: http://stackoverflow.com/q/22077589
tags question: http://stackoverflow.com/q/22065654
tags question: http://stackoverflow.com/q/22095216
tags question: http://stackoverflow.com/q/22060426
tags question: http://stackoverflow.com/q/22149962
tags question: http://stackoverflow.com/q/22015281
tags question: http://stackoverflow.com/q/22096398
type: Tag
tags question: http://stackoverflow.com/q/22060686
tags question: http://stackoverflow.com/q/22122567
tags question: http://stackoverflow.com/q/22024153
tags question: http://stackoverflow.com/q/22133571
tags question: http://stackoverflow.com/q/22020500
tags question: http://stackoverflow.com/q/22100380
tags question: http://stackoverflow.com/q/22165225
tags question: http://stackoverflow.com/q/22058760
tags question: http://stackoverflow.com/q/22074866
tags question: http://stackoverflow.com/q/22033660
tags question: http://stackoverflow.com/q/22010666
tags question: http://stackoverflow.com/q/22061923
tags question: http://stackoverflow.com/q/22110759
tags question: http://stackoverflow.com/q/22021865
tags question: http://stackoverflow.com/q/22066644
tags question: http://stackoverflow.com/q/22074570
tags question: http://stackoverflow.com/q/22069819
tags question: http://stackoverflow.com/q/22105318
tags question: http://stackoverflow.com/q/22092704
tags question: http://stackoverflow.com/q/22061488
tags question: http://stackoverflow.com/q/22034044
tags question: http://stackoverflow.com/q/22074230
tags question: http://stackoverflow.com/q/22082706
tags question: http://stackoverflow.com/q/22025831
tags question: http://stackoverflow.com/q/22136168
tags question: http://stackoverflow.com/q/22094547
tags question: http://stackoverflow.com/q/22018225
tag name: jdbc
tags question: http://stackoverflow.com/q/22005680
tags question: http://stackoverflow.com/q/22104531
tags question: http://stackoverflow.com/q/22028487
tags question: http://stackoverflow.com/q/22144231
tags question: http://stackoverflow.com/q/22141776
tags question: http://stackoverflow.com/q/22090056
tags question: http://stackoverflow.com/q/22042836
tags question: http://stackoverflow.com/q/22043277
tags question: http://stackoverflow.com/q/22097665
tags question: http://stackoverflow.com/q/22158006
tags question: http://stackoverflow.com/q/22021069
tags question: http://stackoverflow.com/q/22059626
tags question: http://stackoverflow.com/q/22064613

http://stackoverflow.com/comment/33389786
type: Comment
has text: did you try writing getactivity() instead of context in all of your Toast statements?
comment on: http://stackoverflow.com/a/22025502
score: 0
type: AnswerComment

http://stackoverflow.com/q/22037395
score: 1
tagged with: java
upvote count: 1
type: Question
tagged with: java-web-start
answer count: 1
downvote count: 0
has answer: http://stackoverflow.com/a/22037505
favorite count: 0
has body: I would like to know if when I launch my Java Web Start application, I'm using my browser or the connection is directly from the Java sandbox against the server through Http/Https protocol. I want ot know, wether once the JAR has been downloaded and stored locally, next time when the applciation is launched, it will use my browser?
type: UnansweredQuestion
has title: Is java Web Start Application using my browser each time I run the application?

http://stackoverflow.com/comment/33604403
type: Comment
has text: Yes you can use it, and its better later to take to appropriate part of code and use it in your eclipse project
comment on: http://stackoverflow.com/a/22143941
type: AnswerComment
score: 0

http://stackoverflow.com/a/22302787
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/22121918
downvote count: 0
has body: To create a runnable JAR with Spring Boot, use the spring-boot-maven-plugin in your pom.xml org.springframework.boot spring-boot-maven-plugin Maybe you want to have a look at my example application http://info.michael-simons.eu/2014/02/20/developing-a-web-application-with-spring-boot-angularjs-and-java-8/ (Source is on GitHub, App is live and runs from a JAR). One thing that you should note: JSP from JAR doesn't work due to some embedded Tomcat problems. I'm using Thymeleaf. If you need JSP, stay with the WAR deployment.
type: Answer

http://stackoverflow.com/comment/33590553
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22132364
has text: Thx for ur reply, I have 100+ other beans (controllers, services, dao) getting initialized at the same time. can you explain a bit more on "make every bean in some object graph be lazily initialized.".
score: 0

http://stackoverflow.com/comment/33568923
comment on: http://stackoverflow.com/a/22112629
score: 0
type: Comment
has text: @user3367768 `javac -classpath <PATH TO jfxrt.jar> <YOUR CLASS>`
type: AnswerComment

http://stackoverflow.com/comment/33590620
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22130722
has text: @rjohnb4 then you should mark as answer, see left side of the answer for right tick.

http://stackoverflow.com/q/22134138
tagged with: swing
type: Question
type: AnsweredQuestion
tagged with: jcheckbox
has body: I've got a 3 column JTable. Column 2 is a checkbox which I want to enable/disable the JSpinner for that row. I've got working how I want except for one thing -- The JSpinner doesn't actually look like its disabled (text and spinner buttons greyed out). I'm not quite sure how to attain this. I've tried forcibly calling setEnabled(false) on the JSpinner, but the table doesn't seem to redraw correctly. Here is some code I've gotten working through other StackOverflow examples: import java.awt.Component; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.EventObject; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSpinner; import javax.swing.JTable; import javax.swing.WindowConstants; import javax.swing.event.CellEditorListener; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; public class SpinnerTable { public JComponent makeUI() { String[] columnNames = { "Name", "Spinner Enable", "Spinner" }; final Object[][] data = { { "aaa", true, 1 }, { "bbb", true, 10 }, { "ccc", true, 10 } }; final DefaultTableModel model = new DefaultTableModel(data, columnNames) { @Override public Class&lt;?&gt; getColumnClass(int column) { return getValueAt(0, column).getClass(); } }; JTable table = new JTable(model) { @Override public void setValueAt(Object aValue, int row, int column) { super.setValueAt(aValue, row, column); } @Override public boolean isCellEditable(int row, int column) { if (column == 2) return (Boolean) model.getValueAt(row, 1); return super.isCellEditable(row, column); } }; table.setRowHeight(36); table.setAutoCreateRowSorter(true); TableColumn column = table.getColumnModel().getColumn(2); column.set…
tagged with: jtable
has answer: http://stackoverflow.com/a/22134415
linked to: http://stackoverflow.com/q/15089824
has title: JTable with JSpinner Enable/Disable
score: 3
answer count: 1
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/22134415
upvote count: 3
tagged with: jspinner
tagged with: java

http://stackoverflow.com/comment/33475418
comment on: http://stackoverflow.com/a/22061695
type: Comment
has text: Matcher would be great but split also is accounting for `"12-123-12345"` without the letter in this case I want it to return just ["12-123-12345"]
score: 0
type: AnswerComment

http://stackoverflow.com/q/22117181
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22117252
score: 0
tagged with: file
type: Question
tagged with: audio
has body: I have an audio file that I am converting into a byte array, but then you cannot tell when that byte value is actually played in the song. So I am trying to stretch it out over the length of the song. So while the song is playing, it outputs the byte value. How is this possible? Here is my code so far: public class Main { private static final String FILENAME = "assets/pf.wav"; private static double[] endResult = null; public static void convert() throws IOException{ ByteArrayOutputStream out = new ByteArrayOutputStream(); BufferedInputStream in = new BufferedInputStream(new FileInputStream(FILENAME)); int read; byte[] buff = new byte[1024]; while ((read = in.read(buff)) &gt; 0) { out.write(buff, 0, read); } out.flush(); byte[] audioBytes = out.toByteArray(); endResult = calculateFFT(audioBytes); } public static double[] calculateFFT(byte[] signal) { final int mNumberOfFFTPoints =1024; double mMaxFFTSample; double temp; Complex[] y; Complex[] complexSignal = new Complex[mNumberOfFFTPoints]; double[] absSignal = new double[mNumberOfFFTPoints/2]; for(int i = 0; i &lt; mNumberOfFFTPoints; i++){ temp = (double)((signal[2*i] &amp; 0xFF) | (signal[2*i+1] &lt;&lt; 8)) / 32768.0F; complexSignal[i] = new Complex(temp,0.0); } y = FFT.fft(complexSignal); mMaxFFTSample = 0.0; int mPeakPos = 0; for(int i = 0; i &lt; (mNumberOfFFTPoints/2); i++) { absSignal[i] = Math.sqrt(Math.pow(y[i].re(), 2) + Math.pow(y[i].im(), 2)); if(absSignal[i] &gt; mMaxFFTSample) { mMaxFFTSample = absSignal[i]; mPeakPos = i; } } return absSignal; } public static void main(String[] args) throws UnsupportedAudioFileException, IOException { File file = new File(FILENAME); AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(file); AudioFormat format = audioInputStream.getFormat(); long frames = audioInputStream.getFrameLength(); final double durationInSeconds = (frames+0.0) / format.getFrameRate(); try { convert(); for(int i = 0; i &lt; endResult.length; i++) { System.out.println(endResult[i]…
tagged with: java
has answer: http://stackoverflow.com/a/22117252
tagged with: arrays
answer count: 1
tagged with: byte
has title: Java output values over time

http://stackoverflow.com/comment/33464083
has text: @rgreso See my answer, it probably fixes your problem.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22067696

http://stackoverflow.com/a/22059685
answers question: http://stackoverflow.com/q/22059386
score: 0
type: Answer
has body: When you are using recursion, you should remember the base case, reduced problem, and general solution. The base case here is: if node == null, stop recursion. Reduced Problem is: Should be able to visit any single left/parent/right node General Solution is: Visit Left, Visit Node, Visit Right. So, your code should be: public void lnrTraverse(Node node) { //if (node == null) return; //This is not needed. Valid only if it an empty tree if (node.left != null) { lnrTraversal(node.left); } System.out.println(node); if (node.right != null) { lnrTraversal(node.right); } }

http://stackoverflow.com/a/22059703
answers question: http://stackoverflow.com/q/22059626
score: 0
type: Answer
has body: Class is not accessible to JVM java.lang.ClassNotFoundException, please make sure driver jar file is added in your build path.

http://stackoverflow.com/a/22055384
has body: The builder pattern is about to crate a new instance of class and initialize it as much as required to do. In the way you are going you tend to finish with a partial setter of some properties and create a possible fake relation because two object has the same attributes. To support this in example everything has an name attribute but you do not create a super interface to called Nameable and implements its in every possible place. If those attribute are shared across your classes you should think to create a class for them. class Code { int number; String name; } class Race { Code code; //other attributes; } Then you have a one builder for code and another for race. Note also that the good design is a balance of trade offs. If two fields are common for 5 classes is the a purpose to make the code complex and create a dedicated mechanize that will only pack the initialization and will not do anything productive.
answers question: http://stackoverflow.com/q/22054989
score: 0
type: Answer

alpha-transparency
type: Tag
tags question: http://stackoverflow.com/q/22069051
tag name: alpha-transparency

http://stackoverflow.com/q/22056287
score: 1
tagged with: java
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/22056441
has body: I want to compare people who post lots of questions vs lots of answers in a Web Forum. I need to print out the top 10 users who ask questions and also who answer the questions. I have written a script that generates the list. But it takes too long and uses too much memory and is inefficient. The code which I have written is using HashMap. The .xml file of the users and the posts is very big. The actual data is around 5-6 gigabytes. I need to know the best way by which I can improve the time, efficiency and performance.
has answer: http://stackoverflow.com/a/22210957
answer count: 3
tagged with: distributed-system
favorite count: 0
type: UnansweredQuestion
tagged with: bigdata
upvote count: 1
has title: Print top 10 users who post lots of questions and lots of answers of a Web Forum
tagged with: parallel-processing
tagged with: performance
has answer: http://stackoverflow.com/a/22083159

http://stackoverflow.com/q/22153339
tagged with: java
tagged with: authentication
has answer: http://stackoverflow.com/a/22170501
type: Question
score: 3
has body: I am trying to enable token based authentication for a HTTP api with spring security. Looking around i see answers about implementing the filters and the handlers like Spring Security authentication via token Spring Security 3.2 Token Authentication There is a pretty interesting KeyBasedPersistenceTokenService class. Is there no filter or the rest of the elements needed to build up the authentication mechanism in spring security?
linked to: http://stackoverflow.com/q/17126201
linked to: http://stackoverflow.com/q/18131669
upvote count: 3
has title: Token authentication based with spring security
answer count: 1
tagged with: spring-security
favorite count: 0
tagged with: spring
accepted answer: http://stackoverflow.com/a/22170501
type: AnsweredQuestion
downvote count: 0

http://stackoverflow.com/q/22044911
tagged with: junit
downvote count: 0
possible better answer: http://stackoverflow.com/a/22045041
has answer: http://stackoverflow.com/a/22045041
favorite count: 0
has answer: http://stackoverflow.com/a/22045123
accepted answer: http://stackoverflow.com/a/22045279
type: AnsweredQuestion
has title: carrying out JUnit Testing with complex code
has comment: http://stackoverflow.com/comment/33423539
score: 1
tagged with: java
upvote count: 1
has comment: http://stackoverflow.com/comment/33423438
has body: Can someone guide me on how to carry out JUnit testing in java. I have watched youtube videos but I am finding it hard to understand the concept of getting more complext code unit tested. http://www.youtube.com/watch?v=lYnMyi81hrs http://www.youtube.com/watch?v=KX6CgjHciXU For example, how can I test this code? text = "I was chosen"; JButton button1 = new Jbutton(""); JButton button2 = new Jbutton(""); JButton button3 = new Jbutton(""); List&lt;JButton&gt; buttons = Arrays.asList(button1, button2, button3); Random r = new Random(); buttons.get(r.nextInt(buttons.size())).setText(text); and also test large pieces of code that are in methods and being called elsewhere. edited: package testing; import javax.swing.JOptionPane; public class test { String sign = "!"; String notSign = "-"; public test(){ String test = JOptionPane.showInputDialog("Please write a sign: "); if (test.equals("!")){ sign1(); } else if (test.equals("-")){ sign2(); } } public void sign1(){ sign = "*"; } public void sign2(){ notSign = "/"; } public static void main(String args[]){ new test(); } } edited 2: The reason, I wanted to know how Junit test works is because, I am working on this project for my collage and after finishing my code, it is producing bugs and I have read the code over and over again and have no clue where the bugs are coming from. Is there is better way of finding bugs and fixing them?
type: Question
has comment: http://stackoverflow.com/comment/33423556
has answer: http://stackoverflow.com/a/22045279
has comment: http://stackoverflow.com/comment/33423796
answer count: 3

http://stackoverflow.com/comment/33554743
comment on: http://stackoverflow.com/q/22117899
score: 0
type: Comment
type: QuestionComment
has text: @GeorgeTomlinson: Ah, I had interpreted "combination array" as the *output* (given that each element will be a combination of elements from the input). But now that I look back at the code, I see that the *input* variable is called `combination`, somewhat confusingly (and contrary to the later `com[0]` etc, too). Definitely still a poorly worded question, but I think I see what it means now. Thanks :)

web-services
type: Tag
tags question: http://stackoverflow.com/q/22029420
tags question: http://stackoverflow.com/q/22037793
tags question: http://stackoverflow.com/q/22005328
tags question: http://stackoverflow.com/q/22062411
tags question: http://stackoverflow.com/q/22076657
tags question: http://stackoverflow.com/q/22054482
tags question: http://stackoverflow.com/q/22167012
tags question: http://stackoverflow.com/q/22113598
tags question: http://stackoverflow.com/q/22070340
tags question: http://stackoverflow.com/q/22037077
tags question: http://stackoverflow.com/q/22101510
tags question: http://stackoverflow.com/q/22112414
tags question: http://stackoverflow.com/q/22092538
tags question: http://stackoverflow.com/q/22070744
tags question: http://stackoverflow.com/q/22159596
tags question: http://stackoverflow.com/q/22144402
tags question: http://stackoverflow.com/q/22045926
tags question: http://stackoverflow.com/q/22140095
tags question: http://stackoverflow.com/q/22084867
tags question: http://stackoverflow.com/q/22061135
tags question: http://stackoverflow.com/q/22022387
tags question: http://stackoverflow.com/q/22014507
tags question: http://stackoverflow.com/q/22022000
tags question: http://stackoverflow.com/q/22081314
tags question: http://stackoverflow.com/q/22113707
tags question: http://stackoverflow.com/q/22016605
tags question: http://stackoverflow.com/q/22168170
tags question: http://stackoverflow.com/q/22159454
tags question: http://stackoverflow.com/q/22104584
tags question: http://stackoverflow.com/q/22076188
tags question: http://stackoverflow.com/q/22147457
tags question: http://stackoverflow.com/q/22115195
tag name: web-services
tags question: http://stackoverflow.com/q/22089940
tags question: http://stackoverflow.com/q/22127090
tags question: http://stackoverflow.com/q/22110326
tags question: http://stackoverflow.com/q/22076654
tags question: http://stackoverflow.com/q/22068864
tags question: http://stackoverflow.com/q/22070627
tags question: http://stackoverflow.com/q/22078568
tags question: http://stackoverflow.com/q/22117512
tags question: http://stackoverflow.com/q/22006092
tags question: http://stackoverflow.com/q/22157589

do-while
tags question: http://stackoverflow.com/q/22134735
tags question: http://stackoverflow.com/q/22036264
type: Tag
tag name: do-while
tags question: http://stackoverflow.com/q/22058895

http://stackoverflow.com/comment/54999071
score: 0
has text: @flaschenpost: that’s actually a problem that lacks a real use case. If you know the class of an `enum`, you can simply call `TypeOfEnum.valueOf(name)` anyway. And it’s not that anything was preventing you from putting this stuff into a `static` utility method accepting a `Class` parameter. Making it inherited instance methods was a premise of the question…
type: Comment
comment on: http://stackoverflow.com/a/22102121
type: AnswerComment

http://stackoverflow.com/comment/33630937
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22160245
has text: @user2932450 This is a lot of code. Can you please post your stack trace as well as clearly indicate the line that is causing the exception?
score: 0

http://stackoverflow.com/q/22085016
has body: So I am having problems with a recursive program. What the program does it takes a text file as an input that has a list of unsorted numbers. It then asks the user for a number to find in the array using a recursive binary search. If the number is found the index of that number is returned if not -1 is returned. Now this program here returns -1 for any input even if it is in the array. The part I don't understand is the the return mid statement gets called and then the return -1 gets called a couple times. So I am very confused on how my program runs into a return statement but ignores it and then returns -1. Here is the numbers in the text file I used. 31 70 5 71 140 187 162 98 153 8 109 103 145 157 27 23 136 54 19 168 114 25 139 129 94 And here is the program itself. import java.io.*; import java.util.*; public class Lab2 { public static void main (String[] args) throws Exception { if (args.length &lt; 1) { System.out.println( "Fatal Error. Enter a filename on the command line!\n"); System.exit(0); } int[] arr = new int[30]; // don't do the resizing thing. Leave that to Project#1 int cnt=0; Scanner file1 = new Scanner( new FileReader(args[0]) ); while ( file1.hasNextInt() ) arr[cnt++]= file1.nextInt(); file1.close(); // print the array as it came from the file printArray( "original array: ", arr, cnt ); // sort using Arrays.sort (see utils API) Arrays.sort( arr, 0, cnt ); // 2nd index non inclusive - i.e. cnt-1 // re-print it - should come out sorted printArray( "sorted array: ", arr, cnt ); // now search the sorted array using YOUR bSearch Scanner kbd = new Scanner( System.in ); do { System.out.print("Enter number to search for: "); int key = kbd.nextInt(); if ( key &lt;= 0) break; // ENTER ZERO OR NEGATIVE TO QUIT LOOP int index=bSearch( arr, 0, cnt-1, key ); if ( index &lt; 0 ) System.out.println( key + " not found at index: " + index); else System.out.println( key + " found at index: " + index); } while ( true ); // infinite loop. Must break to get out } // EN…
tagged with: recursion
score: 0
tagged with: java
has title: Recursive Java Program ignores if else statement return and returns 3 times
accepted answer: http://stackoverflow.com/a/22085053
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22085109
type: Question
possible better answer: http://stackoverflow.com/a/22085109
tagged with: return
tagged with: return-value
has answer: http://stackoverflow.com/a/22085053
answer count: 2

http://stackoverflow.com/q/22095854
has title: Convert Postgresql query to Hibernate
has comment: http://stackoverflow.com/comment/33516818
tagged with: java
tagged with: hibernate
has body: In my Java Web application I use Postgresql and some data tables are filled automatically in server. In the database I have a STATUS table like below: I want to select the data related to a vehicle between selected dates and where the vehicle stayed connected. Simply I want to select the data which are green in the above table which means I exactly want the data when firstly io1=true and the data when io1=false after the last io1=true. I have postgresql query statement which exactly gives me the desired data; however, I have to convert it to HQL because of my application logic. working postgresql query: WITH cte AS ( SELECT iostatusid, mtstrackid, io1,io2,io3, gpsdate, (io1 &lt;&gt; LAG(io1) OVER (PARTITION BY mtstrackid ORDER BY gpsdate) ) AS status_changed FROM iostatus WHERE mtstrackid = 'redcar' AND gpsdate between '2014-02-28 00:00:00' and '2014-02-28 23:59:59' ) SELECT iostatusId, mtstrackid, io1, io2, io3,gpsdate FROM cte WHERE status_changed OR io1 AND status_changed IS NULL ORDER BY gpsdate ; How should I convert the above query to HQL or how could I retrieve the desired data with HQL?
answer count: 1
downvote count: 0
favorite count: 0
tagged with: postgresql
has comment: http://stackoverflow.com/comment/33518099
has comment: http://stackoverflow.com/comment/33514192
has comment: http://stackoverflow.com/comment/33516728
has answer: http://stackoverflow.com/a/22096077
type: UnansweredQuestion
score: 1
upvote count: 1
type: Question

http://stackoverflow.com/comment/33559995
comment on: http://stackoverflow.com/a/22120824
has text: Maybe you have to implement another comparison function
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33523618
has text: What does it mean? Are you now using the absolute path of the mp3?
comment on: http://stackoverflow.com/a/22100855
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33536221
score: 0
has text: *"The Java format of 180000 = 6am"* Huh? Never seen such format, sorry.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22107323

http://stackoverflow.com/q/22121467
tagged with: flappy-bird-clone
favorite count: 0
has body: I use LibGDX and move only the camera in my game. Yesterday I founded a way to draw the ground in my game. I'm trying to make a clone of Flappy Bird, but I have problems with drawing the ground which is moving on the screen. In every render call I add a new Actor to the Stage, but after a few times the drawing is no more flowing. The frames per second sink very fast. Is there another way to draw ground in games?
has answer: http://stackoverflow.com/a/22130598
upvote count: 17
type: AnsweredQuestion
tagged with: java
score: 17
tagged with: draw
type: Question
accepted answer: http://stackoverflow.com/a/22130598
possible better answer: http://stackoverflow.com/a/32038903
tagged with: libgdx
has title: Remove Actors from Stage?
tagged with: game-engine
downvote count: 0
has answer: http://stackoverflow.com/a/32038903
has comment: http://stackoverflow.com/comment/33561330
answer count: 3
has answer: http://stackoverflow.com/a/27807302

http://stackoverflow.com/q/22060404
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/22060850
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33451213
linked to: http://stackoverflow.com/q/843972
has comment: http://stackoverflow.com/comment/33451439
tagged with: java
has comment: http://stackoverflow.com/comment/33451478
upvote count: 1
downvote count: 1
has body: I have extracted features such as sift,surf,edge,color and texture;and then I made a hash code using MD5. I have tried to compare and rank the bulk of images with query image with binary level hamming distance of feature hash code and direct hash code hamming distance with each feature in each time.Unfortunately these two hamming distances are giving me worst result in the case of every feature hash codes. I just wanna solution for hash code based image search in java.And want to know how can i generate bitwise weight for each hash code.
has title: I am looking for a solution for image comparison with hash code. And my tries are below
type: Question
has answer: http://stackoverflow.com/a/22112673

http://stackoverflow.com/comment/33649485
comment on: http://stackoverflow.com/a/22169350
type: AnswerComment
has text: In JFreeChart, chart is updated automatically when dataset values changed. So, this solution works for now. But i have to study about EDT either.
score: 0
type: Comment

http://stackoverflow.com/comment/33639314
has text: @MadProgrammer Yea your right, `TableModel` just applying the `MVC` pattern concepts into `JTable`.
comment on: http://stackoverflow.com/a/22165297
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/a/22125580
answers question: http://stackoverflow.com/q/22116226
type: Answer
upvote count: 1
score: 1
has body: you can use the intval() method in php $v1 = 334420379; $v2 = 1825406976; $res = intval($v1+$v2); it will return you the desired result -2135139941
downvote count: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22116226

http://stackoverflow.com/comment/33657137
type: QuestionComment
comment on: http://stackoverflow.com/q/22126432
has text: Ok I'll look at the code more. But for now I see one questionable statement: finder.fork()); returns ForkJoinTask<V>. Perhaps you should add(finder); and then do finder.fork() in another statement. You many not be joining on a finder but the return from a fork(). Will look at this more closely shortly.
score: 0
type: Comment

http://stackoverflow.com/comment/33522580
score: 0
has text: Make member variables of your text fields in Frame1. Then give Frame1 either a set method for each of the fields that will call `field.setText(text)` or give the frame one big `setData` method with a composite object containing all the values as members.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22097768

http://stackoverflow.com/comment/33553551
type: Comment
comment on: http://stackoverflow.com/a/22107581
type: AnswerComment
score: 0
has text: Here there will be no intervention on other applications.

http://stackoverflow.com/a/22100585
accepted answer of: http://stackoverflow.com/q/22064297
score: 0
answers question: http://stackoverflow.com/q/22064297
type: AcceptedAnswer
type: Answer
has body: Use JavaMail as the transport for Amazon SES SMTP. Instructions and sample code for using the SMTP endpoint are also provided in the Amazon SES documentation. Use the SDK if you intend to send email via the Amazon SES API.

http://stackoverflow.com/comment/33569522
type: Comment
comment on: http://stackoverflow.com/q/22125881
type: QuestionComment
has text: @DjDexter5GHz I add some code with exception output to explain it
score: 0

http://stackoverflow.com/comment/33476508
type: AnswerComment
has text: Are you sure, that json does have `data`?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22074360

http://stackoverflow.com/comment/33552853
type: QuestionComment
has text: Please post the full code.
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22117072

http://stackoverflow.com/q/22071427
has body: I apparently doing something wrong in the configuration of a jdbcRealm. But I don't know what exactly. This is my configuration: What else is needed to help me? @Entity @Table(name = "gebruiker") public class User implements Serializable { @Id @Column(name="User_NAME") private String name; @ManyToOne @JoinTable(name = "groep_gebruiker") private Role rol; @Entity @Table(name = "groep") public class Role implements Serializable { @Id private String rol; @OneToMany(mappedBy = "rol") private Collection&lt;User&gt; gebruikers = new ArrayList();
tagged with: jdbcrealm
tagged with: glassfish
tagged with: security
answer count: 1
tagged with: jpa
has comment: http://stackoverflow.com/comment/33485549
has title: SEC1111: Cannot load group for JDBC realm user
linked to: http://stackoverflow.com/q/10483132
type: UnansweredQuestion
score: 0
tagged with: java
has answer: http://stackoverflow.com/a/22071538
type: Question

http://stackoverflow.com/comment/33474218
comment on: http://stackoverflow.com/q/22072872
type: Comment
score: 0
has text: am able to parse your xml successfully ..no exception..check the xml again
type: QuestionComment

http://stackoverflow.com/q/22137454
has body: I'm pretty new to JPA, having used JDO (DataNucleus) and Hibernate. I get how to set up persistence.xml for the JPA configuration, but I need to make one tweak. Instead of specifying the DataSource in the XML, I want to provide the actual DataSource object to the EntityManagerFactory. I need to do this because I create and manage my own DataSource objects and do not rely on the container to do so, thus I cannot (and do not want to) look up the DataSource via a JNDI name in persistence.xml. So, how to I provide a DataSource object to the EntityManagerFactory rather than specifying it in persistence.xml? I can't imagine it's hard to do but I can't seem to find it, and I've looked all over the place. If it helps at all, I'm using Hibernate 4 as the JPA provider (actually, I'm transitioning from 3.6 to 4, where the Ejb3Configuration class is gone). Hopefully I can do it in a non-Hibernate specific way, but it's not a huge deal if I have to use Hibernate specific APIs. Thank you!!! -Ryan
score: 2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33606775
upvote count: 2
has answer: http://stackoverflow.com/a/22225373
possible better answer: http://stackoverflow.com/a/43791190
has comment: http://stackoverflow.com/comment/33592655
type: Question
tagged with: java
tagged with: hibernate
answer count: 2
accepted answer: http://stackoverflow.com/a/22225373
tagged with: jpa
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/33591290
has title: How to set a DataSource on a JPA EntityMangerFactory that is not from JNDI
has answer: http://stackoverflow.com/a/43791190

http://stackoverflow.com/comment/33635185
has text: you mean there is no way to do it without creating images?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22162873

http://stackoverflow.com/comment/33641925
type: Comment
type: QuestionComment
score: 1
has text: The answer is "a mistake in the code"
comment on: http://stackoverflow.com/q/22166774

http://stackoverflow.com/comment/33637110
type: Comment
score: 2
comment on: http://stackoverflow.com/a/22164092
has text: @eatSleepCode Well, `t2 instanceof Test` will return `true`, but that doesn't mean `new Test() { }` creates an object of `Test`. No it doesn't. A subclass object is always an `instanceof` all it's super classes.
type: AnswerComment

http://stackoverflow.com/comment/33573740
type: Comment
comment on: http://stackoverflow.com/a/22127891
has text: As you may know, the `.` means current location, so do you have another JAR in your current directory?
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33558140
has text: The last example, `foo.<YourType>doStuff()`, shows that it's futile to even have `T` at all. It's a valid answer to a question that doesn't make sense.
score: 1
comment on: http://stackoverflow.com/a/22119569
type: AnswerComment
type: Comment

http://stackoverflow.com/a/22157056
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/33625806
downvote count: 0
has comment: http://stackoverflow.com/comment/33625839
has comment: http://stackoverflow.com/comment/33624903
has body: well ... somehow the encryption should output a byte array... the decryption should convert it back to a byte Array, which has to be interpreted as UTF-8 - encodes String using Snew String( UTF_encoded string then you do some string magic here: encMsg = stringToHex(new String(cipherData)); Why??? You dont need that! Also in decryption: msg = new String(decryptedData); you need to give the same encoding as in encryption: msg = new String(decryptedData, "UTF-8"); A try to clean up and fix your code: import java.io.UnsupportedEncodingException; import javax.crypto.*; import java.security.*; import java.util.Arrays; import javax.crypto.spec.*; public class AESCrypto2 { private Cipher AEScipher; private KeyGenerator AESgen; private SecretKeySpec AESkey; private SecretKeySpec decodeKey; private byte[] cipherData; private String msg; public static void main(String[] args) { try { AESCrypto2 a = new AESCrypto2(); a.encrypt("Hello!"); a.decrypt(a.getCipherData(), a.getKey()); } catch (NoSuchAlgorithmException ex) { ex.printStackTrace(); } catch (NoSuchPaddingException ex) { ex.printStackTrace(); } catch (InvalidKeyException ex) { ex.printStackTrace(); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } catch (IllegalBlockSizeException ex) { ex.printStackTrace(); } catch (BadPaddingException ex) { ex.printStackTrace(); } } public AESCrypto2() throws NoSuchAlgorithmException, NoSuchPaddingException, UnsupportedEncodingException { AESgen = KeyGenerator.getInstance("AES"); AESgen.init(128); AESkey = (SecretKeySpec) AESgen.generateKey(); decodeKey = new SecretKeySpec(AESkey.getEncoded(), "AES"); AEScipher = Cipher.getInstance("AES/ECB/NoPadding"); } public AESCrypto2(String msg) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, UnsupportedEncodingException, IllegalBlockSizeException, BadPaddingException { this(); encrypt(msg); } public byte[] encrypt(String msg) throws NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingEx…
upvote count: 2
answers question: http://stackoverflow.com/q/22156779
has comment: http://stackoverflow.com/comment/33625057
has comment: http://stackoverflow.com/comment/33625350
has comment: http://stackoverflow.com/comment/33625602

http://stackoverflow.com/comment/33432292
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22049586
has text: @Niks would try that.
type: AnswerComment

http://stackoverflow.com/q/22047860
score: 96
has answer: http://stackoverflow.com/a/25110179
has body: Is it possible to run a web application using Tomcat Server in Intellij Idea Community Edition? I tried to find some information about it but haven't achived any success.
accepted answer: http://stackoverflow.com/a/25110179
answer count: 17
has answer: http://stackoverflow.com/a/27691548
favorite count: 0
has answer: http://stackoverflow.com/a/45259706
has answer: http://stackoverflow.com/a/38266010
downvote count: 0
has answer: http://stackoverflow.com/a/43769274
has answer: http://stackoverflow.com/a/41086974
has answer: http://stackoverflow.com/a/69784985
type: AnsweredQuestion
upvote count: 96
has answer: http://stackoverflow.com/a/62723913
tagged with: java
has title: Tomcat in Intellij Idea Community Edition
linked to: http://stackoverflow.com/q/26570378
has answer: http://stackoverflow.com/a/42536202
type: Question
possible better answer: http://stackoverflow.com/a/38266010
has answer: http://stackoverflow.com/a/34535331
has answer: http://stackoverflow.com/a/59488729
tagged with: intellij-idea
tagged with: apache
has answer: http://stackoverflow.com/a/35066290
has answer: http://stackoverflow.com/a/36809902
has answer: http://stackoverflow.com/a/55805653
has answer: http://stackoverflow.com/a/22048716
has answer: http://stackoverflow.com/a/64088649
tagged with: tomcat
has answer: http://stackoverflow.com/a/43767474

http://stackoverflow.com/comment/33584724
type: QuestionComment
has text: @BoristheSpider Then every number would be composite if he started at 1. And then 8 would be prime if it only tested odd numbers.
comment on: http://stackoverflow.com/q/22134211
score: 0
type: Comment

http://stackoverflow.com/comment/33434250
type: QuestionComment
type: Comment
has text: Your regex is anchored both at the beginning and end of input, it will therefore only match once...
comment on: http://stackoverflow.com/q/22050907
score: 4

http://stackoverflow.com/q/22104097
has body: From the docs: The Interrupt Status Flag The interrupt mechanism is implemented using an internal flag known as the interrupt status. Invoking Thread.interrupt sets this flag. When a thread checks for an interrupt by invoking the static method Thread.interrupted, interrupt status is cleared. The non-static isInterrupted method, which is used by one thread to query the interrupt status of another, does not change the interrupt status flag. By convention, any method that exits by throwing an InterruptedException clears interrupt status when it does so. However, it's always possible that interrupt status will immediately be set again, by another thread invoking interrupt. I read these SO posts. But I don't think I have understood this correctly. so I tested this on a sample code below. I have two threads running in this. one is main and other Thread-0 which is labeled t. I call t.interrupt() and I call Thread.currentThread().isInterrupted() in the run method. Where exactly is the flag set? Does Thread Class maintains a static list of all the Threads that is currently running and by calling Thread.currentThread() I get the currentThread Object and check if it is interrupted? If the Thread class itself has the boolean flag interrupted, how does it differentiate between two threads; example main and Thread-0 here. Is the static flag same to both the Threads? what exact sequences of steps are happening, set flag, where is the look up and unset flag etc? when I uncomment the block of code below (which is currently commented out), the program never stops. I do not understand why? import java.util.Random; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; public class ThreadInterrupt { public static void main(String[] args) throws InterruptedException { System.out.println("Starting."); Thread t = new Thread(new Runnable(){ @Override …
downvote count: 1
has answer: http://stackoverflow.com/a/22104149
type: AnsweredQuestion
has title: how does thread.interrupt() sets the flag?
has answer: http://stackoverflow.com/a/22104201
tagged with: java
score: -1
type: Question
answer count: 2
possible better answer: http://stackoverflow.com/a/22104201
upvote count: 0
has comment: http://stackoverflow.com/comment/33955148
tagged with: runnable
accepted answer: http://stackoverflow.com/a/22104149
tagged with: interrupt
linked to: http://stackoverflow.com/q/3590000
favorite count: 0
tagged with: multithreading

http://stackoverflow.com/q/22134456
has comment: http://stackoverflow.com/comment/33586719
upvote count: 1
has comment: http://stackoverflow.com/comment/33586688
type: Question
has comment: http://stackoverflow.com/comment/33586188
has comment: http://stackoverflow.com/comment/33586129
has comment: http://stackoverflow.com/comment/33585480
has comment: http://stackoverflow.com/comment/33586970
has comment: http://stackoverflow.com/comment/33585973
tagged with: udpclient
has body: I'm developing a simple UDP communication software to communicate with my robot. I've been able to use this code to send the first packet but when I try to send the second it does not send neither does it give me errors, what did I do wrong? EDIT : The problem is I can't use the send void twice. Code : Send Void: public static void Send(String Message) { Client Clt = new Client(); Clt.Message = Message; Clt.start(); } Client : public class Client extends Thread { public String Message; public void run() { PrintStream myPS = null; try { myPS = new PrintStream(Start.CltSkt.getOutputStream()); } catch (IOException e) { e.printStackTrace(); } myPS.println(Message); try { finalize(); } catch (Throwable e) { e.printStackTrace(); } } } EDIT 2 (Problem Solved) : thanks to everyone that answered/commented the questions especially to EJP. The problem was : I was not using a DatagramSocket so I ended up with this : public static void Send(String Message) { InetAddress Ip = null; DatagramSocket datagramSocket = null; try { datagramSocket = new DatagramSocket(); } catch (SocketException ex) { Logger.getLogger(Start.class.getName()).log(Level.SEVERE, null, ex); } byte[] buffer = Message.getBytes(); DatagramPacket packet; try { Ip = InetAddress.getByName(CltIp); } catch (UnknownHostException ex) { Logger.getLogger(Start.class.getName()).log(Level.SEVERE, null, ex); } packet = new DatagramPacket(buffer, buffer.length, Ip, Integer.parseInt(CltPort)); try { datagramSocket.send(packet); } catch (IOException ex) { Logger.getLogger(Start.class.getName()).log(Level.SEVERE, null, ex); } } I was not awere of the the use with datagram sockets! Now I'm :)
has title: Udp client thread not reusable
downvote count: 0
has comment: http://stackoverflow.com/comment/33585601
favorite count: 0
has comment: http://stackoverflow.com/comment/33587019
type: UnansweredQuestion
answer count: 0
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33586337
tagged with: multithreading

http://stackoverflow.com/comment/33420008
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22042925
has text: This might actually be the slowest of all of the answers. Inside of a string, Im not completely sure how it does it's memory allocations, but at worst it will do a memory allocation (often considered one of the heaviest taxing burdens in a program) for each non-zero element you add!!! I wont down-vote, because it is technically correct, but it also uses more memory (n-1) semicolons.
score: 3

http://stackoverflow.com/comment/33420943
has text: @injecteer: define 'possible'. Runtime exceptions are nasty.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22043564

snappy
type: Tag
tags question: http://stackoverflow.com/q/22150417
tag name: snappy

http://stackoverflow.com/q/22087039
has title: Java. File processing. For loop Error
has answer: http://stackoverflow.com/a/22087132
tagged with: java
answer count: 3
tagged with: file
tagged with: loops
upvote count: 1
tagged with: processing
tagged with: for-loop
possible better answer: http://stackoverflow.com/a/22087070
has answer: http://stackoverflow.com/a/22087070
accepted answer: http://stackoverflow.com/a/22087132
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/22087672
score: 1
favorite count: 0
has body: So I have this loop that will take a line of text and set it to a string to be processed by a method. while (input.hasNextLine()){ String text = input.nextLine(); processLine(text); } The processLine method is. public static void processLine(String text) { Scanner data = new Scanner(text); while (data.hasNext()){ String str = "hi"; int tabCount = 0; str = data.next(); System.out.print(str + " "); if (str.equals("{")) { tabCount++; System.out.println(); for (int i = 0; i &lt; TAB_SIZE * tabCount; i++){ System.out.print(" "); } } } What is happening is that my tabCount isn't being increased but it is still doing a println. How can this be? This is the output. public class Test1 { public static void main( String[] args ) { System.out.println( "This is Test 1." ); } } Any help is appreciated.
type: Question
has comment: http://stackoverflow.com/comment/33499329

http://stackoverflow.com/comment/33416981
type: Comment
comment on: http://stackoverflow.com/a/22041005
type: AnswerComment
has text: You may want to inverse the check; e.g.: MyOwnClass.class.isAssignableFrom(t), allowing MyOwnClass to be checked for an implementation of t
score: 0

http://stackoverflow.com/comment/33543751
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22068229
has text: @AlexK asked in same day!!

http://stackoverflow.com/q/22048210
has title: how to understand NetworkInterface and InetAddress concept?
type: UnansweredQuestion
type: Question
has answer: http://stackoverflow.com/a/22054128
tagged with: network-programming
tagged with: java
score: 0
answer count: 1
has body: I think in java, NetworkInterface is abstraction of network card . If this is right , why one NetworkInterface contains more than one InetAddress ? for example this code in my macbook : NetworkInterface en0 = NetworkInterface.getByName("en0"); Enumeration&lt;InetAddress&gt; adrs = en0.getInetAddresses() ; while(adrs.hasMoreElements()){ InetAddress adr = adrs.nextElement(); System.out.println(adr.getHostAddress()); } Output: fe80:0:0:0:7a31:c1ff:feb7:a3a2%4 192.168.1.100 There are two address, but I didn't use IPv6. My question is that, how to understand this two concepts? What's their relationship?

http://stackoverflow.com/a/51387102
type: Answer
answers question: http://stackoverflow.com/q/22150527
upvote count: 6
has body: If you're using IntelliJ go to Code>Reformat code
score: 6
downvote count: 0

http://stackoverflow.com/comment/33376387
type: QuestionComment
comment on: http://stackoverflow.com/q/22008769
has text: What did you try so far? And how it is related with JavaScript?
score: 0
type: Comment

http://stackoverflow.com/a/57406410
upvote count: 2
downvote count: 1
has body: Add a default Controller such as FallbackController with an empty RequestMapping path method to handle all Exception requests: @Controller public class FallbackController { @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}) @ResponseBody public String fallback(HttpServletRequest request, HttpServletResponse response) { return "Anything you want"; } @ExceptionHandler(InvalidTokenException.class) public @ResponseBody Response handleInvalidTokenException(InvalidTokenException e) { Log.p.debug(e.getMessage()); Response rs = new Response(); rs.setErrorCode(ErrorCode.INVALID_TOKEN); return rs; } } Hope it helps.
type: Answer
score: 1
answers question: http://stackoverflow.com/q/22062311

http://stackoverflow.com/q/22009203
score: 1
tagged with: java
type: Question
tagged with: jersey
has body: This question is for Jersey 2.x. Let's say I have a GET method. The client request contains an Accept header for either XML or JSON. Is it possible for the method to return a POJO in the representation the client requested? Currently, my GET method returns JSON using Jackson. But I don't know how to make it return XML when the client requests it. All the examples I see here expect the POJO to be JAXB annotated. The POJO being returned doesn't have JAXB annotations and I'm not allowed to add them. But the object does fulfill the JavaBean contract, so it's a real POJO. Since Jackson can serialize a POJO (with no annotations) to JSON , I hope there's an existing MessageBodyWriter that does the same for XML. If this is possible: - How do I annotate the GET method? Currently, I use the line below. Is this enough? @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML }) I'm configuring Jersey through web.xml and Maven. I've got JSON serialization working, but I haven't figured out how to configure for XML output. What config is needed to make XML work? Thanks for your help.
tagged with: http://stackoverflow.com/tag/json
has answer: http://stackoverflow.com/a/22010866
accepted answer: http://stackoverflow.com/a/22010866
upvote count: 1
answer count: 1
has title: Can Jersey convert a GET returned POJO to XML or JSON depending on the request's Accept header?
favorite count: 0
has comment: http://stackoverflow.com/comment/33362061
tagged with: rest
tagged with: http://stackoverflow.com/tag/xml
type: AnsweredQuestion
downvote count: 0

http://stackoverflow.com/a/22085038
type: Answer
answers question: http://stackoverflow.com/q/22084968
accepted answer of: http://stackoverflow.com/q/22084968
score: 3
downvote count: 0
has body: Source: https://stackoverflow.com/a/2887161/546060 NaN is triggered by the following occurrences: results that are complex values √x where x is negative log(x) where x is negative tan(x) where x mod 180 is 90 asin(x) or acos(x) where x is outside [-1..1] 0/0 ∞/∞ ∞/−∞ −∞/∞ −∞/−∞ 0×∞ 0×−∞ 1∞ ∞ + (−∞) (−∞) + ∞
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33495680
upvote count: 3

http://stackoverflow.com/comment/33507167
type: QuestionComment
type: Comment
has text: It does work or not ?
comment on: http://stackoverflow.com/q/22091689
score: 0

http://stackoverflow.com/comment/33556350
comment on: http://stackoverflow.com/a/22118955
score: 0
type: AnswerComment
type: Comment
has text: @nikopol86 Not with this implementation, no. It always returns the value from the String literal. This can't be changed.

http://stackoverflow.com/q/22143807
tagged with: java
tagged with: apache-camel
type: Question
has comment: http://stackoverflow.com/comment/33601446
answer count: 1
has answer: http://stackoverflow.com/a/22144523
upvote count: 3
has comment: http://stackoverflow.com/comment/33603184
favorite count: 0
has title: Extract Route Statistics in Camel
has comment: http://stackoverflow.com/comment/33601290
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33606205
has comment: http://stackoverflow.com/comment/33600828
score: 3
has body: On JConsole, We can see following route Statistics. Minimum / Maximum / Mean Processing Time First / last Message completion Time Number of messages failed or re-delivered. Total number of transaction processed Requirement: I need to show above data on web page. Below is my code: public void process(Exchange exchange) throws Exception { CamelContext context = exchange.getContext(); List&lt;Route&gt; routeObj = context.getRoutes(); for (Route routeId : routeObj) { boolean started = context.getRouteStatus(strRouteId).isStarted(); boolean stopped = context.getRouteStatus(strRouteId).isStopped(); boolean suspended = context.getRouteStatus(strRouteId).isSuspended(); // TODO: find min/max/mean processing time, first/last message // completion time, etc. } } Thanks in advance. Please suggest me how to get min/max/mean processing time, first/last message completion time, etc.
downvote count: 0

http://stackoverflow.com/comment/33557218
type: Comment
comment on: http://stackoverflow.com/a/22105983
type: AnswerComment
has text: @MarkRotteveel right, if you have a need for multiple connections and all the nice things a pool brings. sometimes it's only necessary to havea single connection, and a manager object (enum or singleton) would suffice).
score: 0

oop
tags question: http://stackoverflow.com/q/22022921
tags question: http://stackoverflow.com/q/22166067
tags question: http://stackoverflow.com/q/22117984
tags question: http://stackoverflow.com/q/22007128
tags question: http://stackoverflow.com/q/22039675
tag name: oop
tags question: http://stackoverflow.com/q/22038782
tags question: http://stackoverflow.com/q/22152060
tags question: http://stackoverflow.com/q/22158275
tags question: http://stackoverflow.com/q/22047074
tags question: http://stackoverflow.com/q/22037263
tags question: http://stackoverflow.com/q/22162052
tags question: http://stackoverflow.com/q/22159564
tags question: http://stackoverflow.com/q/22120021
tags question: http://stackoverflow.com/q/22134781
tags question: http://stackoverflow.com/q/22051019
tags question: http://stackoverflow.com/q/22161758
tags question: http://stackoverflow.com/q/22046222
tags question: http://stackoverflow.com/q/22131430
tags question: http://stackoverflow.com/q/22156079
tags question: http://stackoverflow.com/q/22023867
tags question: http://stackoverflow.com/q/22050848
tags question: http://stackoverflow.com/q/22097768
tags question: http://stackoverflow.com/q/22064530
tags question: http://stackoverflow.com/q/22121210
tags question: http://stackoverflow.com/q/22052330
tags question: http://stackoverflow.com/q/22158432
tags question: http://stackoverflow.com/q/22155853
tags question: http://stackoverflow.com/q/22021205
tags question: http://stackoverflow.com/q/22053172
tags question: http://stackoverflow.com/q/22093994
tags question: http://stackoverflow.com/q/22163702
tags question: http://stackoverflow.com/q/22107482
tags question: http://stackoverflow.com/q/22093842
type: Tag
tags question: http://stackoverflow.com/q/22014980
tags question: http://stackoverflow.com/q/22058831
tags question: http://stackoverflow.com/q/22008060

http://stackoverflow.com/comment/33526517
has text: Uh, your second code could (should?) be converted to a singleton, really
type: QuestionComment
comment on: http://stackoverflow.com/q/22102248
score: 0
type: Comment

calculator
tags question: http://stackoverflow.com/q/22024864
tags question: http://stackoverflow.com/q/22031810
type: Tag
tag name: calculator
tags question: http://stackoverflow.com/q/22100533

http://stackoverflow.com/comment/33421143
has text: Your answer isn't very helpful.Just like the comment you made in my [other](http://stackoverflow.com/questions/22009499/modeling-relationships-jpa-between-entities-in-google-app-engine-datastore) question.If i knew the cause of the "pretty clear" error i wouldn't be asking this question.Besides,am wondering why the example works in the book and gives an error in my code.
type: Comment
comment on: http://stackoverflow.com/a/22043342
score: 0
type: AnswerComment

http://stackoverflow.com/q/22120747
has comment: http://stackoverflow.com/comment/33560627
has comment: http://stackoverflow.com/comment/33559986
tagged with: java
has comment: http://stackoverflow.com/comment/33565616
has comment: http://stackoverflow.com/comment/33566996
has answer: http://stackoverflow.com/a/22120899
upvote count: 10
type: Question
has comment: http://stackoverflow.com/comment/33565822
has comment: http://stackoverflow.com/comment/33565553
has comment: http://stackoverflow.com/comment/33559880
tagged with: algorithm
has answer: http://stackoverflow.com/a/22123350
has comment: http://stackoverflow.com/comment/33566978
score: 10
linked to: http://stackoverflow.com/q/10529915
has comment: http://stackoverflow.com/comment/33560709
has answer: http://stackoverflow.com/a/22122002
has title: Would Java indexOf (brute force method) be more practical for me or some other substring algorithm?
has comment: http://stackoverflow.com/comment/33559767
tagged with: substring
has answer: http://stackoverflow.com/a/22121827
downvote count: 0
answer count: 7
has comment: http://stackoverflow.com/comment/33560462
linked to: http://stackoverflow.com/q/1765579
has answer: http://stackoverflow.com/a/22121066
tagged with: string
has comment: http://stackoverflow.com/comment/33566872
favorite count: 0
has body: I'm looking at finding very short substrings (pattern, needle) in many short lines of text (haystack). However, I'm not quite sure which method to use outside the naive, brute force method. Background: I'm doing a side project for fun where I receive text messaging chat logs of multiple users (anywhere from 2000-15000 lines of text and 2-50 users), and I want to find all the various pattern matches in the chat logs based on predetermined words that I've come up with. So far I have about 1600 patterns that I'm looking for, but I may look for more. So for example, I want to find the number of food related words that are used in an average text message log such as "hamburger", "pizza", "coke", "lunch", "dinner", "restaurant", "McDonalds". While I gave out English examples, I will actually be using Korean for my program. Each of these designated words will have their own respective score, which I put in a hashmap as key and value separately. I then show the top scorers for food related words as well as the most frequent words used by those users for food words. My current method is to eliminate each line of text by whitespaces, and process each individual word from the haystack by using contains method (which uses the indexOf method and the naive substring search algorithm) of the haystack contains the pattern. wordFromInput.contains(wordFromPattern); To give an example, with 17 users in chat, 13000 lines of text, and the 1600 patterns, I've found that this whole program took 12-13 seconds with this method. And on the Android app that I'm developing, it took 2 minutes and 30 seconds to process, which is far too slow. Originally, I tried to use a hash map and to merely get the pattern instead of searching for it in the ArrayList, but I then realized that is... not possible with hash table for what I am trying to do with a substring. I've looked around through Stackoverflow and found a lot of helpful and related questions, such as these two: 1 and 2. I'm somewhat more fam…
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33561139
has answer: http://stackoverflow.com/a/22122947
linked to: http://stackoverflow.com/q/9741188
has comment: http://stackoverflow.com/comment/33566326
has comment: http://stackoverflow.com/comment/33559812
has answer: http://stackoverflow.com/a/22120904
linked to: http://stackoverflow.com/q/3183582
has comment: http://stackoverflow.com/comment/33560210

http://stackoverflow.com/comment/48950403
score: 0
type: AnswerComment
has text: use latest library . if you don't @Erum
comment on: http://stackoverflow.com/a/22297926
type: Comment

http://stackoverflow.com/a/22030824
has comment: http://stackoverflow.com/comment/33398772
type: Answer
score: 0
answers question: http://stackoverflow.com/q/22030766
has body: You can redirect eclipse console output to a file (like this : How can we redirect a Java program console output to multiple files?) and, in another console window, from outside eclipse, you can (linux/cygwin) do something like tail -f on this file. Notice that this does not mean eclipse will listen to what you type in your external console window.

http://stackoverflow.com/q/22150415
has title: How to delete the key/value pair when the Value is of type "Null" (on update)
linked to: http://stackoverflow.com/q/12636938
has body: I'm practicing with the database mongoDB inside a Java project. I have a Collection "Object" wich holds all documents with information about "objects". These "objects" are represented bij a Class in Java called "LoanboardObject". An Object can be made/changed with an web application that sends the data with a Post message to the Server. The Object is created and the parameters are stored in the object. LoanBoardObject public class LoanboardObject implements ILoanBoardEntity { private ObjectId id; private String objectName; private String objectCode; private String category; private Boolean lent = false; private String description = ""; private Boolean enabled = false; public BasicDBObject toDBObject() { BasicDBObject object = new BasicDBObject(); object.put("_id", id); object.put("object_name", objectName); object.put("object_code", objectCode); object.put("category", category); object.put("lent", lent); object.put("description", description); object.put("enabled", enabled); return object; } ... } To save this object to the database I do the following: NewObjectServlet //Create the object LoanboardObject object = new LoanboardObject(objectId, etc...); //Create the database MongoDataTx tx = new MongoDataTx(DATABASE); tx.save(object.toDBObject(), "object"); MongoDataTX private DB db; public MongoDataTx(String dbName) { db = Mongo.getMongoDB().getMongoClient().getDB(dbName); } public void save(final DBObject object, String collection) { DBCollection coll = db.getCollection(collection); coll.save(object); } Mongo private static final String HOST = "localhost"; private static final int PORT = 27017; private static Mongo mongoDB; private static MongoClient mongo; public Mongo() { try { mongo = new MongoClient(HOST, PORT); } catch (UnknownHostException e) { e.printStackTrace(); } } public static Mongo getMongoDB() { if (mongoDB == null) { mongoDB = new Mongo(); } return mongoDB; } public MongoClient getMongoClient() { return mongo; } The problem with this is when a value i…
has answer: http://stackoverflow.com/a/23408700
type: AnsweredQuestion
tagged with: java
type: Question
tagged with: mongodb
accepted answer: http://stackoverflow.com/a/23408700
tagged with: null
tagged with: key-value-store
answer count: 1
score: 0
linked to: http://stackoverflow.com/q/17213965

http://stackoverflow.com/comment/34312522
type: AnswerComment
comment on: http://stackoverflow.com/a/22147888
has text: So you mean something like String[] question = {question1, question2....} that is the first point. And the second one, I should go by simply typing Collections.shuffle(question); Though I did not understand 3 and 4 (am I even correct with the two first ones??) Sorry for the late answer, as I have been very busy
type: Comment
score: 0

http://stackoverflow.com/a/22082932
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/22076654
has body: JSON works well using the Jackson library. GSON may be an option but I haven't tried it myself. SOAP is pretty much out of the question as you mention yourself, but XML binding over REST can be done reasonably well using the SimpleXML framework instead of JAXB. For complex object architectures this can be quite slow however. If you have the choice I'd say go for JSON. Have a look at http://en.wikipedia.org/wiki/Comparison_of_data_serialization_formats for additional options.
type: Answer
upvote count: 1

http://stackoverflow.com/comment/33648030
type: AnswerComment
type: Comment
has text: Sure binding error will still work as per Spring doc. Sorry using @Valid annotation is out of scope from your question, please find another thread, I'm sure it has been asked many times before.
comment on: http://stackoverflow.com/a/22159595
score: 0

http://stackoverflow.com/a/22011739
upvote count: 2
answers question: http://stackoverflow.com/q/22011133
type: Answer
score: 2
has body: Taking cues from your earlier query, when I try and combine the 3 tds through a valid Selector syntax, I get the result you are expecting. doc.select("td[class=css-sched-table-title], td[class=css-sched-waypoints], td[class=css-sched-times]") Note, you can combine multiple conditions within your selector syntax like this Elements row = doc.select("td[class=css-sched-table-title], td[class=css-sched-waypoints], td[class=css-sched-times]"); which effectively becomes your OR operator. Elements row = doc.select("td[class=css-sched-table-title], td[class=css-sched-waypoints], td[class=css-sched-times]"); System.out.println("::Total Count::" + row.size()); Iterator&lt;Element&gt; iterator = row.listIterator(); while (iterator.hasNext()) { Element element = iterator.next(); String id = element.attr("id"); String classes = element.attr("class"); String value = element.text(); System.out.println("Id : " + id + ", classes : " + classes + ", value : " + value); } Gives, ::Total Count::25 Id : , classes : css-sched-table-title, value : Saturday - Afternoon Id : , classes : css-sched-waypoints, value : Townline and Southern Id : , classes : css-sched-waypoints, value : Clearbrook and Blueridge Id : , classes : css-sched-waypoints, value : Clearbrook and South Fraser Id : , classes : css-sched-waypoints, value : Ar. Bourquin Exchange Id : , classes : css-sched-waypoints, value : Lv. Bourquin Exchange Id : , classes : css-sched-waypoints, value : Downtown Abbotsford Id : , classes : css-sched-waypoints, value : McMillan and Old Yale Id : , classes : css-sched-waypoints, value : Sandy Hill and Old Clayburn Id : , classes : css-sched-times, value : Id : , classes : css-sched-times, value : 6:15 Id : , classes : css-sched-times, value : Id : , classes : css-sched-times, value : 6:20 Id : , classes : css-sched-times, value : Id : , classes : css-sched-times, value : 6:24 Id : , classes : css-sched-times, value : Id : , classes : css-sched-times, value : 6:34 Id : , classes : css-sched…
accepted answer of: http://stackoverflow.com/q/22011133
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/22151131
favorite count: 0
linked to: http://stackoverflow.com/q/2091465
linked to: http://stackoverflow.com/q/3624280
upvote count: 2
tagged with: android
has body: I have a basic understanding of java and android but am still new and am struggling to find the correct way to save a variable and be able to access it/read it from other classes/activities. I have seen singletons but I am confused if it is the right way and how it would look, also do I need to make sure its thread safe? Is there a better way that I am unaware of? Basically I have a login that gets a username and some info about that user. How can I save that to a class/singleton and access it later? EDIT after some more searching I found this example: public class Drivers { private static Array drivers; public static void setDrivers(Array c){ drivers = c; } public static Array getDrivers(){ return drivers; } } and get and set like this: public class AnyClass { { int clicks = ActionClass.getDrivers(); ActionClass.setDrivers(0); } Would this work/be correct?
has answer: http://stackoverflow.com/a/22151379
score: 2
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/22151379
has answer: http://stackoverflow.com/a/22151703
type: Question
has comment: http://stackoverflow.com/comment/33614589
accepted answer: http://stackoverflow.com/a/22151703
has title: Saving variables on android til the app closes
has answer: http://stackoverflow.com/a/22151743
linked to: http://stackoverflow.com/q/21697172
answer count: 3
downvote count: 0

http://stackoverflow.com/q/22035424
downvote count: 2
has answer: http://stackoverflow.com/a/22035675
upvote count: 1
has comment: http://stackoverflow.com/comment/33406598
has comment: http://stackoverflow.com/comment/33406529
tagged with: java
score: -1
has body: I am trying to send random numbers inside a UDP socket using this code below but the command sendData = number.getBytes(); is not working. Is it because I have to replace getBytes with something else? public class UDPServer { public void run() throws IOException { DatagramSocket serverSocket = new DatagramSocket(5555); byte[] receiveData = new byte[1024]; byte[] sendData = new byte[1024]; while (true) { DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); serverSocket.receive(receivePacket); String sentence = new String(receivePacket.getData()); InetAddress IPAddress = receivePacket.getAddress(); int port = receivePacket.getPort(); Random dice = new Random(); int number; for (int counter = 1; counter &lt;= 10; counter++) { number = dice.nextInt(6); } sendData = number.getBytes(); DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, port); serverSocket.send(sendPacket); }
type: Question
answer count: 1
has comment: http://stackoverflow.com/comment/33406611
has comment: http://stackoverflow.com/comment/33406585
favorite count: 0
has title: send numbers in UDP socket in java
type: UnansweredQuestion

http://stackoverflow.com/q/22114510
has comment: http://stackoverflow.com/comment/33548338
type: UnansweredQuestion
tagged with: sockets
has title: Further problems with ObjectInputStreams with Sockets
has comment: http://stackoverflow.com/comment/33550674
has answer: http://stackoverflow.com/a/22127128
tagged with: java
has comment: http://stackoverflow.com/comment/33571056
tagged with: stream
has body: In another thread I asked for help with a problem of sockets and ObjectInputStreams. swapnil7 answered and gave me help: My Code said: while(!line.equalsIgnoreCase("exit")){ while(in.available() &lt;= 0){} line = in.readObject().toString(); System.out.println("&gt;&gt;&gt; recieved: " + line); } I thought, that in.available() requests, how much bytes are ready to recieve. So I did a loop, that did nothing, until in.available() said, that there are more bytes to recieve. Then swapnil7 said, that I have to do it like this: while(!line.equalsIgnoreCase("exit")){ while(in.available() &lt;= 0){ line = in.readObject().toString(); System.out.println("&gt;&gt;&gt; recieved: " + line); } } I worked. But that was only the test application. My real application, that uses the ObjectStreams not only for text, looks like this: while(true){ try{ while(in.available() &lt;= 0) { Object obj = in.readObject(); if(obj instanceof ArrayList){ Main.info("recieved package: " + obj.getClass()); app.sendClientUpdate(this, obj); }else{ Main.info("recieved unexpected package: " + obj.toString()); } } }catch(Exception ex){ Main.error("Error while reading: " + ex.getMessage()); } } This should be the exact same thing, but it throws an exception: Error while reading: invalid type code: 42 Thrown here in code: Main.error("Error while reading: " + ex.getMessage()); This is what I expected, when I thought, that in.available() returns the amount of recievable bytes. I thought, that this exception means, that the inputStream blocks the reading, because the buffer is empty. Now, I am confused, because on one hand, I had to do it like swapnil7 said, on the other hand, my big application throws an exception. Can anyone explain these two different behaviors to me? P.S. English is still not my mother language :) So I'm sorry about mistakes. EDIT: So, here is the writing part. It writes to the sockets more than one time per second (I think 6 times, or so): public void sendPackets() throws IOException{ out.w…
type: Question
answer count: 2
tagged with: network-programming
has answer: http://stackoverflow.com/a/22115245
has comment: http://stackoverflow.com/comment/33548434
score: 0
has comment: http://stackoverflow.com/comment/33548518

http://stackoverflow.com/a/22069564
answers question: http://stackoverflow.com/q/22069400
downvote count: 0
type: Answer
score: 1
upvote count: 1
has body: An interface is a way of providing a public contract to users of the class implementing the interface. How the class is implemented doesn't matter, as long as they are adhering to the contract. Therefore, it doesn't make sense to have private methods in an interface.

http://stackoverflow.com/comment/33579172
has text: 25 is last position alphabet[25]
comment on: http://stackoverflow.com/q/22131154
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22080789
has comment: http://stackoverflow.com/comment/33488353
type: AcceptedAnswer
has body: You can request that the user types in his commands and then check using the method from the String class equalsIgnoreCase() and compare it and see if it is the same as add, remove, etc. (whatever commands you need). Use if-else statements to implement the logic. For example if user input resolves to add, then you add an element. If user input is not any of the common functions, then print message that there was an error and so on. I cannot type out the answer in code as this is an assignment. import java.util.*; import java.util.Scanner; public class assignment216{ public static void main (String args[]){ ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;(); Scanner e = new Scanner(System.in); System.out.println("Enter command, or type 'quit' to exit \n"); while (!e.nextLine().equalsIgnoreCase("quit")) { // As long as input not equal to quit if (e.nextLine().equalsIgnoreCase("add") { System.out.println("Enter name to add:\n"); String name = e.nextLine(); names.add(name); } if (e.nextLine().equalsIgnoreCase("remove") { System.out.println("Enter name to remove:\n"); String name = e.nextLine(); names.remove(name); } } if(e.nextLine().equalsIgnoreCase("quit"){ scanner.close(); System.exit(); } } }
answers question: http://stackoverflow.com/q/22080660
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/33488564
accepted answer of: http://stackoverflow.com/q/22080660
upvote count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/33488262

http://stackoverflow.com/comment/33603184
type: Comment
score: 0
comment on: http://stackoverflow.com/q/22143807
has text: JMX tutorial says about defining creating a custom MBean and Notification related. In one of the link, they just say how to configure JMX such that it will gather all statistics at route level. In my requirement, Camel is running. It has some routes which are started. In above code, I have to find statistics for each route. Through context I can get MBeanServer. But after that there is no way to get statistics for the specific route. Please help me out.
type: QuestionComment

http://stackoverflow.com/q/22116370
type: Question
has title: Update data error using sqlite
tagged with: java
score: 0
tagged with: sql-update
has comment: http://stackoverflow.com/comment/33559745
tagged with: sqlite
answer count: 1
has answer: http://stackoverflow.com/a/22116383
has comment: http://stackoverflow.com/comment/33551722
has body: I want to update some data in a database, and I keep on getting the following error: Java.sql.SQLException: unrecognized tokens:"Hello" My question is, how do I solve the issue I'm having? You can find my code below: private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { String value1= jTextField1.getText(); try{ String sql = "Update KKKB1 set Pangkat='"+value1+"' where Pangkat='"+value1+" "; pst=conn.prepareStatement(sql); pst.executeUpdate(); JOptionPane.showMessageDialog(null,"Updated"); Main ad=new Main(); ad.setVisible (true); dispose(); }
type: UnansweredQuestion

http://stackoverflow.com/comment/33617802
comment on: http://stackoverflow.com/q/22152657
has text: No, I want to remove old menu and add a new one.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33487257
score: 0
type: QuestionComment
type: Comment
has text: I'm doing it in java. It's kinda urgent
comment on: http://stackoverflow.com/q/22080344

http://stackoverflow.com/q/22162359
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33634205
upvote count: 3
tagged with: bit-manipulation
accepted answer: http://stackoverflow.com/a/22162453
type: Question
tagged with: java
has title: Why would you use a BitSet in java as opposed to an array of booleans (in Java)?
has comment: http://stackoverflow.com/comment/33634093
has body: Other than the difference in methods available, why would someone use a BitSet as opposed to an array of booleans? Is performance better for some operations?
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/22162604
favorite count: 0
has answer: http://stackoverflow.com/a/22162453
score: 3
possible better answer: http://stackoverflow.com/a/22162604
has comment: http://stackoverflow.com/comment/33634661
tagged with: bitset
has comment: http://stackoverflow.com/comment/33634035

http://stackoverflow.com/comment/100301083
has text: Updated it, didn't even cross my mind this question would still be of interest in 2019 ;)
comment on: http://stackoverflow.com/a/22042085
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/25380114
downvote count: 0
has comment: http://stackoverflow.com/comment/40056147
type: Answer
has comment: http://stackoverflow.com/comment/40103119
answers question: http://stackoverflow.com/q/22135002
score: 4
upvote count: 4
has body: Or you can add this to user ApplicationContext &lt;mvc:annotation-driven&gt; &lt;mvc:argument-resolvers&gt; &lt;bean class="org.springframework.data.web.PageableHandlerMethodArgumentResolver" /&gt; &lt;/mvc:argument-resolvers&gt; &lt;/mvc:annotation-driven&gt; it will work with Spring 4

http://stackoverflow.com/q/22125142
has body: I am currently writing Asteroids for extra credit in my computer science class, following a very loose guide that provided some starter code. I have a ship and I can use key presses to change its position. The starter code provided a method of drawing the ship based on a Point position. I was then given this public void accelerate(double acceleration) { pull.x += (acceleration * Math.cos(Math.toRadians(rotation))); pull.y += (acceleration * Math.cos(Math.toRadians(rotation))); } How am I supposed to implement this with position? I can increase both position.x and position.y, but how exactly am I supposed to use this method? Also, can I implement acceleration for turning? There is a variable rotation that is supposed to go from 0 to 360.
answer count: 1
has answer: http://stackoverflow.com/a/22125677
accepted answer: http://stackoverflow.com/a/22125677
has title: Java - Asteroids - acceleration in two dimensions
type: AnsweredQuestion
tagged with: java
type: Question
tagged with: game-physics
tagged with: rotation
score: 0

http://stackoverflow.com/a/38431584
score: 1
has body: You can add a delay in the Observable returned in the retryWhen Operator /** * Here we can see how onErrorResumeNext works and emit an item in case that an error occur in the pipeline and an exception is propagated */ @Test public void observableOnErrorResumeNext() { Subscription subscription = Observable.just(null) .map(Object::toString) .doOnError(failure -&gt; System.out.println("Error:" + failure.getCause())) .retryWhen(errors -&gt; errors.doOnNext(o -&gt; count++) .flatMap(t -&gt; count &gt; 3 ? Observable.error(t) : Observable.just(null).delay(100, TimeUnit.MILLISECONDS)), Schedulers.newThread()) .onErrorResumeNext(t -&gt; { System.out.println("Error after all retries:" + t.getCause()); return Observable.just("I save the world for extinction!"); }) .subscribe(s -&gt; System.out.println(s)); new TestSubscriber((Observer) subscription).awaitTerminalEvent(500, TimeUnit.MILLISECONDS); } You can see more examples here. https://github.com/politrons/reactive
answers question: http://stackoverflow.com/q/22066481
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/comment/33671566
has text: I am unable to use a direct ping since i am accessing it through a proxy
comment on: http://stackoverflow.com/q/22147457
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22157312
linked to: http://stackoverflow.com/q/15420968
type: Question
tagged with: nosuchfileexception
has answer: http://stackoverflow.com/a/22157884
tagged with: class
answer count: 3
accepted answer: http://stackoverflow.com/a/22157524
upvote count: 1
downvote count: 0
has title: NoSuchFieldException when trying to retrieve the value of field
possible better answer: http://stackoverflow.com/a/22157651
favorite count: 0
has answer: http://stackoverflow.com/a/22157524
tagged with: field
has answer: http://stackoverflow.com/a/22157651
type: AnsweredQuestion
has body: I read this post and followed the guidelines there. but that did not help; I get NoSuchFieldException when the field exists. The sample code is below: Here is my code: class A{ private String name="sairam"; private int number=100; } public class Testing { public static void main(String[] args) throws Exception { Class cls = Class.forName("A"); Field testnum=cls.getDeclaredField("number"); testnum.setAccessible(true); int y = testnum.getInt(testnum); System.out.println(y); } } EDIT: per answer below, I tried this: Class cls = Class.forName("A"); Field testnum=cls.getDeclaredField("number"); testnum.setAccessible(true); A a = new A(); int y = testnum.getInt(a); System.out.println(y); but the error is same
tagged with: reflection
score: 1
tagged with: java

http://stackoverflow.com/comment/33514429
comment on: http://stackoverflow.com/a/22094616
score: 0
type: AnswerComment
has text: It tries to find substring in the big string. If the name is part of the big merged string the chanr index returned by LOCATE >0
type: Comment

http://stackoverflow.com/a/22039501
answers question: http://stackoverflow.com/q/22039458
accepted answer of: http://stackoverflow.com/q/22039458
upvote count: 2
has body: cause you comparing "繁體中文" with "繁體中文[br]" s.equalsIgnoreCase(s1) will give you true
type: AcceptedAnswer
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/comment/58587353
type: AnswerComment
score: 0
type: Comment
has text: How do you know which JRE version is installed? I used `java -version`, but the numbers were very far from 7: `java version "1.7.0_95" OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-0ubuntu0.14.04.1) OpenJDK Zero VM (build 24.95-b01, mixed mode)`. According to neo4j, it requires JRE 7 now. I am confused, should I update, or is the problem with the environment variables?
comment on: http://stackoverflow.com/a/22113522

http://stackoverflow.com/comment/33448825
has text: Try this: http://stackoverflow.com/q/3872063/1397117
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22058421

http://stackoverflow.com/comment/33482065
score: 0
comment on: http://stackoverflow.com/q/22077535
type: Comment
type: QuestionComment
has text: I second the "narrow things as much as possible" case - developers tend to do stupid stuff with variables they can access and it's always a pleasure fixing a bug with all necessary variables in one place without looking at too much places. :-)

http://stackoverflow.com/comment/33395702
score: 0
has text: output of program `Drive found C:\ Java Result: 1 BUILD SUCCESSFUL (total time: 11 seconds)`
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22028171

http://stackoverflow.com/comment/33526430
type: Comment
type: QuestionComment
has text: "Keep getting reached end of file while parsing error." What file? What parsing? You have nothing remotely file-related in the code you've posted.
comment on: http://stackoverflow.com/q/22102324
score: 0

http://stackoverflow.com/q/22031701
type: Question
tagged with: javasound
has comment: http://stackoverflow.com/comment/33541107
tagged with: jmf
tagged with: java
upvote count: 1
accepted answer: http://stackoverflow.com/a/22032338
tagged with: audio-player
type: AnsweredQuestion
downvote count: 0
answer count: 1
has title: Sun, Audio-player and Sound I/O
score: 1
favorite count: 0
has answer: http://stackoverflow.com/a/22032338
tagged with: sun
has body: I have a few questions related to Sun, Audio-player and Sound Input/Output Why is the sun.audio.AudioPlayer package not part of the Java API? Some info is here instead: http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6b14/sun/audio/AudioPlayer.java Yet it is still part of the default JDK build I am using. I have tried using JMF and spent half the day screw balling around with it, to no real avail. I managed to import the jmf.jar into Eclipse I tried a demo script and it still spat out errors like nobody business. Considering its abandoned now?!? Java does however provide a link for a relatively new version: http://www.oracle.com/technetwork/java/javase/download-142937.html I am a little concerned however how at the bottom of the page the following is written "false,,,,,,,"? Whats the best package to use for audio I/O and manipulation in your opinion? I just want to work on a project and I though an MP3 player would be a nice place to start as I can do a little swing. However it seems to be rather difficult as from what I have read Java is not really very keen on making mp3 and audio manipulation packages.

http://stackoverflow.com/q/22039990
has body: I found an unexpected deadlock while running tasks in a ThreadPoolExecutor. The idea is a main task that launches a secondary task that changes a flag. The main task halts until the secondary task updates the flag. If corePoolSize >=2 the main task completes as expected. If corePoolSize &lt;2 it seems that the secondary task is enquenqued but never launched. Using a SynchronousQueue instead, the main task completes even for corePoolSize=0. I'd like to know: what's the cause of the deadlock?. It seems no obvious from the documentation. why using a SynchronousQueue instead of a LinkedBlockingQueue prevents the deadlock? Is corePoolSize =2 a safe value to prevent this kind of deadlocks? import java.util.concurrent.*; class ExecutorDeadlock { /*------ FIELDS -------------*/ boolean halted = true; ExecutorService executor; Runnable secondaryTask = new Runnable() { public void run() { System.out.println("secondaryTask started"); halted = false; System.out.println("secondaryTask completed"); } }; Runnable primaryTask = new Runnable() { public void run() { System.out.println("primaryTask started"); executor.execute(secondaryTask); while (halted) { try { Thread.sleep(500); } catch (Throwable e) { e.printStackTrace(); } } System.out.println("primaryTask completed"); } }; /*-------- EXECUTE -----------*/ void execute(){ executor.execute(primaryTask); } /*-------- CTOR -----------*/ ExecutorDeadlock(int corePoolSize,BlockingQueue&lt;Runnable&gt; workQueue) { this.executor = new ThreadPoolExecutor(corePoolSize, 4,0L, TimeUnit.MILLISECONDS, workQueue); } /*-------- TEST -----------*/ public static void main(String[] args) { new ExecutorDeadlock(2,new LinkedBlockingQueue&lt;&gt;()).execute(); //new ExecutorDeadlock(1,new LinkedBlockingQueue&lt;&gt;()).execute(); //new ExecutorDeadlock(0,new SynchronousQueue&lt;&gt;()).execute(); } }
tagged with: threadpool
type: UnansweredQuestion
tagged with: concurrency
tagged with: deadlock
score: 2
downvote count: 0
favorite count: 0
type: Question
upvote count: 2
has title: Unexpected deadlock in Executor
tagged with: executorservice
has answer: http://stackoverflow.com/a/22040222
tagged with: java
answer count: 1

http://stackoverflow.com/a/22082512
accepted answer of: http://stackoverflow.com/q/22082451
upvote count: 2
has comment: http://stackoverflow.com/comment/33491293
type: Answer
answers question: http://stackoverflow.com/q/22082451
downvote count: 1
has comment: http://stackoverflow.com/comment/33491337
has comment: http://stackoverflow.com/comment/33491246
score: 1
has comment: http://stackoverflow.com/comment/33491297
has comment: http://stackoverflow.com/comment/33491598
has comment: http://stackoverflow.com/comment/33491312
has body: Array variance allows you to treat a String[] as an Object[] with no problems, and you can then cast back with no problems: Object[] x = new String[] { "x", "y", "z" }; System.out.println(x.getClass()); // Prints class [Ljava.lang.String; String[] y = (String[]) x; // No exception This corresponds with your serialization case - serialization is merely preserving the type of the array (as I'd expect it to - it would be very broken otherwise). Serialization is really a red herring here - it's easy to demonstrate the same issue without using serialization at all. The problem with the cast at the start of your code is due to your array initialization, which is creating an Object[] instance, not a String[] instance: Object[] x = { "x", "y", "z" }; System.out.println(x.getClass()); // Prints class [Ljava.lang.Object; String[] y = (String[]) x; // ClassCastException That first line is equivalent to: Object[] x = new Object[] { "x", "y", "z" }; The type of array to create is inferred not from the elements of the array, but from the type of the variable which is being declared. (Unfortunately that's not terribly clearly specified in the JLS, as far as I can tell... but it's definitely the way it works.) If you change the declaration of the variable your using for serialization to: Object[] arrV={new String("Car"), new String("Bike")}; ... then you'll see the same exception when you cast the deserialized result. (Also note that there's no need to call the String(String) constructor all over the place - just { "Car", "Bike" } would be fine.) One point to note about array variance: this is checked at execution time. For example: Object[] x = { "x", "y", "z" }; x[0] = new Object(); // This is fine, because the array really is an Object[] Object[] y = new String[] { "x", "y", "z" }; y[0] = new Object(); // This compiles, but throws an ArrayStoreException // because the array is really a String[]
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33491833

http://stackoverflow.com/comment/33375977
score: 2
has text: @NickRippe do you think this is the case? In any case, Swing GUIs must be able to work with different L&F which implies for instance different font sizes which may cause issues as illustrated [here](http://stackoverflow.com/questions/12529200/non-resizable-window-border-and-positioning/12532237#12532237). So fixed locations/sizes through `setBounds()` is a way to shoot oneself in the foot.
comment on: http://stackoverflow.com/q/22017592
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22081858
answers question: http://stackoverflow.com/q/22081817
upvote count: 7
has comment: http://stackoverflow.com/comment/33490049
type: AcceptedAnswer
downvote count: 0
score: 7
has body: 49, 52, and 10 are the ASCII character codes for the characters you typed, 14Enter. You may continue to use System.in.read(), and process each character as it arrives. You would do something like the following: collect the characters that are typed look for digits typed followed by Enter convert the ASCII codes of the digits to a decimal number This is, of course, exactly what Scanner.nextInt() does for you.
type: Answer
has comment: http://stackoverflow.com/comment/33490086
has comment: http://stackoverflow.com/comment/33490487
accepted answer of: http://stackoverflow.com/q/22081817
has comment: http://stackoverflow.com/comment/33490343

http://stackoverflow.com/comment/33354571
comment on: http://stackoverflow.com/q/22005734
has text: -pls find the DDls of both tables
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22101510
has answer: http://stackoverflow.com/a/22108409
accepted answer: http://stackoverflow.com/a/22108409
has title: how to make database access quicker in a java web app with jax-rs and mongo
type: AnsweredQuestion
tagged with: java
tagged with: web-services
type: Question
tagged with: jakarta-ee
tagged with: mongodb
has body: I have a jax-rs running on glassfish. I have some EJB stateless session beans as endpoints for the service and my database is mongoDB. I have a singleton that returns the connection from mongo. (Is this ok by the way?). Which is faster in the business logic: a) have a singleton as a UserService for example that adds and retrieves users from the database or b) have the add/retrive functions in the EJBs because they are threaded? when is a "service" bean like that needed?
score: 0
answer count: 1

http://stackoverflow.com/comment/33431731
has text: It isn't strange at all. A `ListView` recycles its rows so you need to make sure you're resetting the state of the views in the `getView()` method of the adapter. The state(the color) needs to be saved outside of the row view itself.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22049108

http://stackoverflow.com/q/22167650
tagged with: file
type: Question
tagged with: beanshell
tagged with: java
has answer: http://stackoverflow.com/a/22176428
answer count: 1
downvote count: 0
tagged with: symmetricds
tagged with: synchronization
favorite count: 0
has title: Symmetricds change source base dir for file sync dynamically
has body: We have a corp node and many store nodes for file sync. We have sync files from each store nodes to corp node. The source directory be different in different stores. Can we change the base dir of a file trigger dynamic using something like bean shell script or any extension. i.e. the source base directory of a file trigger will be different in different stores.
accepted answer: http://stackoverflow.com/a/22176428
score: 2
type: AnsweredQuestion
upvote count: 2

http://stackoverflow.com/comment/33396515
score: 0
type: Comment
type: QuestionComment
has text: userCharArray must be empty
comment on: http://stackoverflow.com/q/22029382

http://stackoverflow.com/comment/33576571
comment on: http://stackoverflow.com/q/22129523
has text: I have deleted the source code... it didn't work on my implementation (it must have been faulty).
type: Comment
type: QuestionComment
score: 0

dialog
tag name: dialog
tags question: http://stackoverflow.com/q/22154389
type: Tag
tags question: http://stackoverflow.com/q/22090316
tags question: http://stackoverflow.com/q/22088861
tags question: http://stackoverflow.com/q/22157049
tags question: http://stackoverflow.com/q/22105203

http://stackoverflow.com/q/22053412
tagged with: arraylist
answer count: 5
has answer: http://stackoverflow.com/a/22053872
has answer: http://stackoverflow.com/a/22053470
type: AnsweredQuestion
tagged with: list
has comment: http://stackoverflow.com/comment/33438874
accepted answer: http://stackoverflow.com/a/22053470
type: Question
has title: Java acess the first list in a list of list
has comment: http://stackoverflow.com/comment/33438888
tagged with: java
has answer: http://stackoverflow.com/a/22053465
score: 0
has answer: http://stackoverflow.com/a/22053653
tagged with: nested
has answer: http://stackoverflow.com/a/22053507
possible better answer: http://stackoverflow.com/a/22053465
has body: Here is my program ArrayList&lt;ArrayList&lt;?&gt;&gt; matrix = new ArrayList(); // nested list so as to have each matrix.add(new ArrayList()); matrix.add(new ArrayList()); matrix.add(new ArrayList()); I know I can access each item of the list by using matrix.get(0) but what if I want to access the first item of the first nested list (I hope it is clear) That is what I would like to do. It would even be better if I could turn each of the nested list or even the entire list into a proper array with nested arrays inside but that may be a tall order. I am sorry my programming skills are really poor.

http://stackoverflow.com/q/22030677
type: Question
tagged with: java
tagged with: hibernate
tagged with: eclipse
answer count: 2
has answer: http://stackoverflow.com/a/22482618
has answer: http://stackoverflow.com/a/51901447
downvote count: 0
favorite count: 0
has body: I have hibernate and I would like to decrease the logging that happens in console everytime it runs. I do not have log4j in my application nor do I want to add it in. Here is an example of the logs I get everytime I run my app Feb 25, 2014 6:36:41 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit> INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final} Feb 25, 2014 6:36:41 PM org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.3.1.Final} Feb 25, 2014 6:36:41 PM org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found Feb 25, 2014 6:36:41 PM org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist Feb 25, 2014 6:36:41 PM org.hibernate.cfg.Configuration configure INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml Feb 25, 2014 6:36:41 PM org.hibernate.cfg.Configuration getConfigurationInputStream INFO: HHH000040: Configuration resource: /hibernate.cfg.xml Feb 25, 2014 6:36:42 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide! Feb 25, 2014 6:36:42 PM org.hibernate.cfg.Configuration doConfigure INFO: HHH000041: Configured SessionFactory: null Feb 25, 2014 6:36:42 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!) Feb 25, 2014 6:36:42 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH000401: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://localhost:5432/hibernatedb] Feb 25, 2014 6:36:42 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH000046: Connection properties: {user=Sidney…
score: 2
upvote count: 2
type: UnansweredQuestion
has title: Hibernate: Disable logging to console WITHOUT log4j

http://stackoverflow.com/a/22030765
downvote count: 0
upvote count: 2
has body: You can use a mock framework like Mockito and parameterize your test using JUnitParams. Assuming you have a class that validates Searcher and if search returns 'valid' it will pass. The code and test would look like below, with 2 test cases, 1 for valid and one for invalid search result. public class SomeClass { public boolean isValid(Searcher searcher) { return searcher.search().equals("valid"); } } @RunWith(JUnitParamsRunner.class) public class SomeClassTest { public Object[] provideIsValid() { return new Object[]{ new Object[]{ "invalid", false }, new Object[]{ "valid", true } }; } @Test @Parameters(method = "provideIsValid") public void testIsValid(String output, String expected) { SomeClass someClass = new SomeClass(); Searcher mock = mock(Searcher.class); when(mock.search()).thenReturn(output); String actual = someClass.isValid(mock); assertEquals(expected, actual); }
type: Answer
has comment: http://stackoverflow.com/comment/33436150
answers question: http://stackoverflow.com/q/22028580
score: 2

http://stackoverflow.com/q/22133214
has answer: http://stackoverflow.com/a/22133320
has title: ReentrantLock.lock() doesn't block other threads
tagged with: multithreading
accepted answer: http://stackoverflow.com/a/22133320
tagged with: reentrantlock
has answer: http://stackoverflow.com/a/22133321
type: Question
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/22133321
tagged with: concurrency
upvote count: 4
answer count: 3
has answer: http://stackoverflow.com/a/22133466
downvote count: 0
score: 4
favorite count: 0
has body: I'm having a hard time understanding the behavior of ReentrantLock.lock() I have the following class import java.util.concurrent.locks.*; class BlockingClass { private Lock lock = new ReentrantLock(); private Condition condition = lock.newCondition(); public void a() { lock.lock(); System.out.println("called in method a(): lock()"); try { System.out.println("called in method a(): await()"); condition.await(); } catch (InterruptedException e) {} finally { lock.unlock(); System.out.println("called in method a(): unlock() "); } } public void b() { lock.lock(); System.out.println("called in method b(): lock()"); System.out.println("called in method b(): signalAll()"); condition.signalAll(); lock.unlock(); System.out.println("called in method b(): unlock() "); } } which I run with the following test: class BlockingClassTest { public static void main(String[] args) throws InterruptedException { final BlockingClass blockingClass = new BlockingClass(); new Thread() { public void run() { System.out.println("Thread1 calling a()"); blockingClass.a(); } }.start(); Thread.sleep(1000); new Thread() { public void run() { System.out.println("Thread2 calling b()"); blockingClass.b(); } }.start(); } } I would have expected a deadlock. Once the a() method calls lock.lock(), I would expect that anyone calling the b() method would have to wait at b's lock.lock() until the thread calling a() had called lock.unlock(). But since a() is waiting for b() to call condition.signalAll(), both methods should have stayed blocked forever. Instead, this is the output I get in the console: Thread1 calling a() called in method a(): lock() called in method a(): await() Thread2 calling b() called in method b(): lock() called in method b(): signalAll() called in method a(): unlock() called in method b(): unlock() What am I misunderstanding about the proper use and functioning of lock() and unlock()?

http://stackoverflow.com/comment/33558536
comment on: http://stackoverflow.com/q/22113578
score: 0
type: QuestionComment
type: Comment
has text: see my edit for some more code

generics
tags question: http://stackoverflow.com/q/22014129
tags question: http://stackoverflow.com/q/22143148
tags question: http://stackoverflow.com/q/22047926
tags question: http://stackoverflow.com/q/22151968
tags question: http://stackoverflow.com/q/22054873
tags question: http://stackoverflow.com/q/22063667
tags question: http://stackoverflow.com/q/22051930
tags question: http://stackoverflow.com/q/22163520
tags question: http://stackoverflow.com/q/22135566
tags question: http://stackoverflow.com/q/22123606
tags question: http://stackoverflow.com/q/22049042
tags question: http://stackoverflow.com/q/22135623
tags question: http://stackoverflow.com/q/22129536
tags question: http://stackoverflow.com/q/22138475
tags question: http://stackoverflow.com/q/22095401
tags question: http://stackoverflow.com/q/22059271
tags question: http://stackoverflow.com/q/22150580
tags question: http://stackoverflow.com/q/22070863
tags question: http://stackoverflow.com/q/22147407
tags question: http://stackoverflow.com/q/22096247
tags question: http://stackoverflow.com/q/22009630
tags question: http://stackoverflow.com/q/22163978
type: Tag
tags question: http://stackoverflow.com/q/22061701
tags question: http://stackoverflow.com/q/22082260
tags question: http://stackoverflow.com/q/22046474
tags question: http://stackoverflow.com/q/22028199
tags question: http://stackoverflow.com/q/22159564
tags question: http://stackoverflow.com/q/22025924
tags question: http://stackoverflow.com/q/22144671
tags question: http://stackoverflow.com/q/22156690
tags question: http://stackoverflow.com/q/22159427
tags question: http://stackoverflow.com/q/22071967
tags question: http://stackoverflow.com/q/22152982
tags question: http://stackoverflow.com/q/22120353
tags question: http://stackoverflow.com/q/22056218
tags question: http://stackoverflow.com/q/22009578
tags question: http://stackoverflow.com/q/22141521
tags question: http://stackoverflow.com/q/22026635
tags question: http://stackoverflow.com/q/22140684
tags question: http://stackoverflow.com/q/22156877
tags question: http://stackoverflow.com/q/22024056
tags question: http://stackoverflow.com/q/22079570
tags question: http://stackoverflow.com/q/22096824
tags question: http://stackoverflow.com/q/22010976
tags question: http://stackoverflow.com/q/22041519
tags question: http://stackoverflow.com/q/22116010
tags question: http://stackoverflow.com/q/22123106
tags question: http://stackoverflow.com/q/22121210
tags question: http://stackoverflow.com/q/22045686
tags question: http://stackoverflow.com/q/22054989
tag name: generics
tags question: http://stackoverflow.com/q/22119470
tags question: http://stackoverflow.com/q/22162832

http://stackoverflow.com/comment/33602901
type: Comment
score: 5
has text: The problem is not exactly that the called can store anything: the real problem is, if it would be allowed, the caller would not be sure of having a String instance, so would have to handle it as in pre-generics days (instanceof operator).
type: AnswerComment
comment on: http://stackoverflow.com/a/22144722

http://stackoverflow.com/comment/33436255
score: 0
type: AnswerComment
has text: (I assume that your solution is working; please confirm that this is the case so that I know the edit is good.) Mod: Please disregard pre-edit flag.
type: Comment
comment on: http://stackoverflow.com/a/22051941

http://stackoverflow.com/q/22119513
tagged with: android
score: 0
tagged with: java
has title: Eclipse android Error setting focus to : org.eclipse.e4.ui.model.application.ui.basic.impl.PartImpl Manager.java
tagged with: eclipse
has answer: http://stackoverflow.com/a/27937886
has body: i keep getting this error when i try to run my application, problem is i deleted my manager class, so i don't know where the error is coming from. I suspect my try, catch exception in my main activity, but tried removing it and my app still wasn't opening, this is the code... protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button logbtn = (Button)findViewById(R.id.logbutton); Button regbtn = (Button)findViewById(R.id.regbutton); logbtn.setOnClickListener(this); regbtn.setOnClickListener(this); } @Override public void onClick(View args) { // TODO Auto-generated method stub switch(args.getId()){ case R.id.logbutton: String email = em.getText().toString(); String pword = pw.getText().toString(); boolean didItWork = true; MySqlDB details = new MySqlDB(this); try { details.open(); boolean data = details.checkData(email, pword); details.close(); if (data == true) { Intent i = new Intent(MainActivity.this, MainHomepage.class); startActivity(i); } } catch(Exception e) { didItWork = false; String error = e.toString(); Dialog d = new Dialog(this); d.setTitle("oops!"); TextView tv = new TextView(this); tv.setText(error); d.setContentView(tv); d.show(); } finally { if (didItWork) { Dialog d = new Dialog(this); d.setTitle("Yay!!"); TextView tv = new TextView(this); tv.setText("Successful!"); d.setContentView(tv); d.show(); } } break; case R.id.regbutton: Intent i = new Intent(MainActivity.this, MainRegister.class); startActivity(i); break; } } below is the logcat 03-03 12:58:47.354: W/GAV2(29238): Thread[GAThread,5,main]: Service unavailable (code=1), will retry. 03-03 12:58:47.354: D/chromium(16048): Unknown chromium error: -2 03-03 12:58:47.354: I/GAV2(29238): Thread[GAThread,5,main]: No campaign data found. 03-03 12:58:47.354: W/ActivityManager(690): Unable to start service Intent { act=com.google.android.gms.analytics.service.START cmp=com.google.android.gms/.analytics.service.AnalyticsService (…
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22119749
type: Question
answer count: 2

http://stackoverflow.com/a/22085109
upvote count: 1
answers question: http://stackoverflow.com/q/22085016
score: 1
downvote count: 0
type: Answer
has body: You're calling bsearch, but you're not returning the answer. Both lines that say bsearch(... should say return bsearch(....

http://stackoverflow.com/comment/33479465
has text: @PeterHamilton, have you tried my solution in Java? I don't see any reason why it wouldn't work. It does not require a split and returns all matches. I might even be able to adapt it to also work in Ruby now that I just checked a reference that shows lookbehinds not working in Ruby but lookaheads working in Ruby and most RegEx engines.
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22051862
type: QuestionComment

http://stackoverflow.com/comment/33577894
type: Comment
comment on: http://stackoverflow.com/a/22130395
has text: How to I let the class throw the exception? I know I have to write "... throws myException" somewhere, but I don't remember where it goes
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33576649
type: AnswerComment
comment on: http://stackoverflow.com/a/22128355
has text: peeskillet: Yes, the tableChanged method can be used to notify the listeners when data is changed, but it is also called even if the data is not changed. if you move into the cell of the column with the JCheckBox and move out without changing the value of the cell the tableChanged method is still called and the expression if (checked) will still be evaluated even though it has not been changed. This is why I ended up using setvalueAt as mKorbel suggested. I will post it below when I can.
score: 0
type: Comment

http://stackoverflow.com/q/22110376
has body: Trying to learn to use stacks. What is wrong with my push method? input = kbd.next(); // pushes individual characters onto the stack for (int i = 0; i &lt; input.length(); i++) { Character ch = input.charAt(i); stack.push(ch); public void push (T element) { //System.out.print("\n"); // System.out.print(element); if (size() == stack.length) { expandCapacity();} stack[top] = element; top++; My push method in the Stack use generics so I am wondering why the Characters do not go in. Also tested with strings. I am thinking that this is something specific about Java rather than me not coding the push() method correctly.
answer count: 1
has title: Implementing a Stack: Pushed Characters are null in stack
has comment: http://stackoverflow.com/comment/33541234
has comment: http://stackoverflow.com/comment/33541160
has comment: http://stackoverflow.com/comment/33541782
has answer: http://stackoverflow.com/a/22110451
has comment: http://stackoverflow.com/comment/33541621
has comment: http://stackoverflow.com/comment/33541324
has comment: http://stackoverflow.com/comment/33541187
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33541700
has comment: http://stackoverflow.com/comment/33541189
type: Question
has comment: http://stackoverflow.com/comment/33541263
has comment: http://stackoverflow.com/comment/33541275
has comment: http://stackoverflow.com/comment/33541193
tagged with: stack
tagged with: java
has comment: http://stackoverflow.com/comment/33541227
score: 0
has comment: http://stackoverflow.com/comment/33541678

http://stackoverflow.com/comment/33580259
score: 3
has text: Have you provided run time arguments to your program?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22131816

http://stackoverflow.com/a/22098949
has comment: http://stackoverflow.com/comment/33522628
type: Answer
score: 2
downvote count: 0
has body: You can use ViewTreeObserver: final ViewTreeObserver observer = surface.getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { observer.removeOnPreDrawListener(this); // do what you need to do, getWidth() is now valid surface.getWidth(); return false; // will not draw this initial frame } }); Note that it is not sufficient to inflate the view. Your view needs to pass the inflate-measure-layout life cycle before getWidth() becomes valid. Read more about how android draws views.
has comment: http://stackoverflow.com/comment/33599386
upvote count: 2
answers question: http://stackoverflow.com/q/22098714

http://stackoverflow.com/a/22108776
downvote count: 0
has body: Java keeps all literals (strings placed in code) in special part of JVM memory. If there are two or more identical literals JVM just pointer to the same object instead of creating few strings with the same content. So: "ab" == "ab" // true - because they are the same objects but: "ab" == new String("ab") // false - because new String(...) is new String not literal You can get or move your String to the special memory by invoking intern() method. String ab1 = "ab"; String ab2 = new String("ab"); // ab1 == ab2 is false as described above ab2 = ab2.intern(); // ab1 == ab2 but now it's true because ab2 pointers to "ab" in special part of memory.
upvote count: 2
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22108641
answers question: http://stackoverflow.com/q/22108641
type: Answer
score: 2

http://stackoverflow.com/q/22076107
has answer: http://stackoverflow.com/a/22076165
has answer: http://stackoverflow.com/a/22076178
linked to: http://stackoverflow.com/q/15357366
tagged with: java
answer count: 5
possible better answer: http://stackoverflow.com/a/22076165
has body: This might be a very basic question but I'm not used to work with Java and I would like to create an array / list like this: 6546:{ "Ram":{ 24M, 4M, 64M, ... }, "Cpu":{ 2%, 4%, 6%, ... }, ... } I've been trying it with LinkedList and so on but end up creating lists of lists and it starts looking very ugly. This is a very common array in JSON, PHP or even Javascript, what would be the best way to create it by using Java?
has title: Create multi array in Java
has comment: http://stackoverflow.com/comment/33503638
has comment: http://stackoverflow.com/comment/33478975
has comment: http://stackoverflow.com/comment/33478988
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22076298
accepted answer: http://stackoverflow.com/a/22076135
type: Question
has comment: http://stackoverflow.com/comment/33479109
has comment: http://stackoverflow.com/comment/33479106
has comment: http://stackoverflow.com/comment/33478944
score: 0
has answer: http://stackoverflow.com/a/22076399
has answer: http://stackoverflow.com/a/22076135

http://stackoverflow.com/comment/33439930
has text: Agree with @DSquare. Your UI (at least the piece we can see) is not laid out in a "border" style. So avoid using `BorderLayout`. Most of the layout managers in Swing were meant to solve specific, common UI layouts. (`FlowLayout` for button bars, `BorderLayout` for UI's with a main content area, etc.) `GridBagLayout` is the catch all, most flexible one to solve requirements that don't fit neatly into the other layouts.
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/22053820
type: Comment

http://stackoverflow.com/q/22022001
downvote count: 0
has comment: http://stackoverflow.com/comment/37695198
has answer: http://stackoverflow.com/a/24384401
tagged with: java
has body: unfortunately, I have some problems with android's bluetooth. For my test environment I use a Nexus 4 with Android 4.4.2. I have a Java Application on my PC, which uses bluecove in order to make a SPP connection as client. The programme is looking for a special service name and connects with my android phone. Afterwards it sends 72 bytes to my android phone and waits for an answer. When getting that answer the programme sleeps for 3 seconds and than starts again. On my android phone I have an application with background bluetooth listener which starts at boot. This application is based on BluetoothChat sample demo. When receiving bluetooth data I check incoming data and send back an answer. All that is working fine. But after 489 bluetooth connections the android app fails with following error snippet while PC-java-app is going on: getBluetoothService() called with no BluetoothManagerCallback Shutting down VM threadid=1: thread exiting with uncaught exception (group=0x41b34ba8) FATAL EXCEPTION: main Process: de.tum.lme.diamantum:remote_blue, PID: 21567 java.lang.NullPointerException: FileDescriptor must not be null at android.os.ParcelFileDescriptor.&lt;init&gt;(ParcelFileDescriptor.java:174) at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:905) at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:897) at android.bluetooth.IBluetooth$Stub$Proxy.createSocketChannel(IBluetooth.java:1355) at android.bluetooth.BluetoothSocket.bindListen(BluetoothSocket.java:349) at android.bluetooth.BluetoothAdapter.createNewRfcommSocketAndRecord(BluetoothAdapter.java:1055) at android.bluetooth.BluetoothAdapter.listenUsingRfcommWithServiceRecord(BluetoothAdapter.java:976) at com.test.btconn.BluetoothHandling$AcceptThread.&lt;init&gt;(BluetoothHandling.java:449) at com.test.btconn.BluetoothHandling.start(BluetoothHandling.java:216) at com.test.btconn.BluetoothListenerService.setupBtSockets(BluetoothListenerService.java:330) at com…
linked to: http://stackoverflow.com/q/21166222
type: Question
tagged with: spp
tagged with: bluetooth
has comment: http://stackoverflow.com/comment/33383814
score: 9
linked to: http://stackoverflow.com/q/13262339
has comment: http://stackoverflow.com/comment/36182200
has title: android bluetooth connection fails after 489 successful connections
has answer: http://stackoverflow.com/a/27873675
favorite count: 0
has comment: http://stackoverflow.com/comment/37664436
upvote count: 9
type: UnansweredQuestion
tagged with: android
has answer: http://stackoverflow.com/a/27164043
has comment: http://stackoverflow.com/comment/37694645
has answer: http://stackoverflow.com/a/34799084
has comment: http://stackoverflow.com/comment/37613781
answer count: 4
has comment: http://stackoverflow.com/comment/37510830

http://stackoverflow.com/comment/33542906
type: AnswerComment
type: Comment
has text: why did you use while loop?
comment on: http://stackoverflow.com/a/22111207
score: 0

http://stackoverflow.com/comment/33488516
type: QuestionComment
comment on: http://stackoverflow.com/q/22080851
has text: @Rperryng error 139, That is what happen D:
score: 0
type: Comment

http://stackoverflow.com/comment/33443033
has text: oh right, i changed them over to test something, forgot to put them back! thanks for that!
comment on: http://stackoverflow.com/q/22054311
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/q/22158700
upvote count: 2
downvote count: 2
has comment: http://stackoverflow.com/comment/33628317
has body: I'm trying to write a program that reads grades from a .txt file and then outputs the grades in reverse order of the array index. import java.io.* import java.util.* public class GradePrint { public static void main(String[] args) throws IOException { Scanner in = new Scanner(new FileReader("data.txt")); int[] grades = new int[30]; for (int i = 0; i &lt; 30, i++){ int grade = in.nextInt(); How do I take those grades and put them in an array and then print them out in reverse order?
has title: Java: How to store values from .txt into array
has answer: http://stackoverflow.com/a/22158790
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33627943
tagged with: java
has comment: http://stackoverflow.com/comment/33627986
type: Question
has answer: http://stackoverflow.com/a/22158749
accepted answer: http://stackoverflow.com/a/22158749
tagged with: arrays
has comment: http://stackoverflow.com/comment/33627806
possible better answer: http://stackoverflow.com/a/22158790
has comment: http://stackoverflow.com/comment/33627912
score: 0
answer count: 2
favorite count: 0

http://stackoverflow.com/comment/33672378
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22155832
has text: @SotiriosDelimanolis I have confirmed that this does indeed work with Spring 4. Please feel free to submit an Answer and I'll be happy to accept it.
score: 0

http://stackoverflow.com/comment/33530882
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22104643
has text: What part don't you understand exactly?

http://stackoverflow.com/comment/33595663
type: AnswerComment
comment on: http://stackoverflow.com/a/22072144
score: 0
type: Comment
has text: Thank you so much i will try it ASAP and vote as accepted answer if it works.

http://stackoverflow.com/comment/33391488
has text: You know from the exception traceback where the exception originates. Add System.out.println calls just ahead of the failing operation to dump the array indices and the array .length values. Something will surprise you.
comment on: http://stackoverflow.com/q/22026683
score: 2
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33379857
has text: remove the package stackdemo; in both coding.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22020504

http://stackoverflow.com/a/22033548
accepted answer of: http://stackoverflow.com/q/22033487
answers question: http://stackoverflow.com/q/22033487
type: Answer
score: 12
upvote count: 12
has body: Per the Javadoc of the parse method: Parses text from the beginning of the given string to produce a date. The method may not use the entire text of the given string. (emphases mine). Contrary to the implication of comments above, this has nothing to do with lenient parsing; rather, it's just that this method is not intended to consume the whole string. If you wish to validate that it consumed the whole string, I suppose you could set up a ParsePosition object and use the two-arg overload, and then examine the ParsePosition afterward to see if it parsed to the end of the string.
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/22022921
has title: Why is a interface data member public and static?
has comment: http://stackoverflow.com/comment/33385811
has comment: http://stackoverflow.com/comment/33384313
has comment: http://stackoverflow.com/comment/33384911
score: 2
upvote count: 3
type: UnansweredQuestion
downvote count: 1
has answer: http://stackoverflow.com/a/22023579
tagged with: oop
has body: Why does java make a interface data member public &amp; static implicitly?
tagged with: java
has comment: http://stackoverflow.com/comment/33384452
type: Question
has answer: http://stackoverflow.com/a/22023158
has comment: http://stackoverflow.com/comment/33385117
has comment: http://stackoverflow.com/comment/33384940
has comment: http://stackoverflow.com/comment/33384537
has comment: http://stackoverflow.com/comment/33384533
answer count: 2
has comment: http://stackoverflow.com/comment/33384483
linked to: http://stackoverflow.com/q/2430756
duplicate of: http://stackoverflow.com/q/8027394
favorite count: 0

http://stackoverflow.com/comment/33559410
type: Comment
comment on: http://stackoverflow.com/a/22120026
score: 0
has text: Can you put the .mp3 in some other directory and see if the compiler or JRE can find it? You could leave the FileHandle as is but do this for the File object. I do not think it would matter since both objects are calling the same thing just in different places on the file system. Maybe the File object cannot see inside the game engine's code for some reason.
type: AnswerComment

http://stackoverflow.com/comment/33665857
comment on: http://stackoverflow.com/a/22072161
score: 0
type: Comment
has text: Sorry, I was talking about the second sentence in your answer where you suggested calling Thread.yield(). That effectively is the same as lowering the priority of the main thread (i.e., it allows the other threads to run.) The main Thread in the example is grabbing resources (native threads), and the other Threads are releasing them. Giving the other Threads priority over the main Thread prevents the resource from being depleted.
type: AnswerComment

http://stackoverflow.com/q/22064355
has comment: http://stackoverflow.com/comment/33457980
has title: How to find error occuring place in jsp
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/22105863
tagged with: servlets
has comment: http://stackoverflow.com/comment/33458373
type: Question
score: 0
accepted answer: http://stackoverflow.com/a/22105863
has comment: http://stackoverflow.com/comment/33458055
linked to: http://stackoverflow.com/q/8701699
has comment: http://stackoverflow.com/comment/33459028
answer count: 1
tagged with: jsp
has comment: http://stackoverflow.com/comment/33458544
has body: I'm working with a Google app engine app and when i testing my app following error has occurred. at org.apache.jsp.eCommersViews.media_jsp._jspService(media_jsp.java:92) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)..... But i have no idea how to find the place that error happen in Media.jsp. Can someone please tell me how to find the error.
tagged with: google-app-engine

http://stackoverflow.com/comment/33545287
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/22112688
has text: Did you define User level variables or System level? Did you add JAVA_HOME and JRE_HOME to your PATH? What is the output of `java -version`?
type: Comment

http://stackoverflow.com/q/22058712
has comment: http://stackoverflow.com/comment/33448338
has answer: http://stackoverflow.com/a/22059245
has comment: http://stackoverflow.com/comment/33464586
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/22059245
tagged with: selenium
type: Question
has body: In this div contains load more, and i want to click in this div. Load More 92 main url of this page.
has title: how to click the div in css using selenium webdriver
score: 0
answer count: 1

http://stackoverflow.com/comment/33612671
type: QuestionComment
has text: I currently only override id "pk" with hash equals. Other than my id, there is just name in the class. Very simple lookup table.
score: 0
comment on: http://stackoverflow.com/q/22150190
type: Comment

http://stackoverflow.com/comment/33481135
type: QuestionComment
has text: Sounds like more of a question for math.stackexchange.com than a Java question.
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22077089

http://stackoverflow.com/q/22098950
has body: I'm working on a small SWT java program. When I export it to runnable .jar file, all libraries are included, of course. But the size of the .jar file is big (~2.5 MB) compared to the code (~37KB). The biggest library is the SWT lib, which is ~2.4 MB. Can I export .jar file without the SWT lib or other libraries? if not, what is the best solution to have smaller .jar file size?
tagged with: java
type: UnansweredQuestion
tagged with: user-interface
downvote count: 0
tagged with: jar
answer count: 0
score: 1
favorite count: 0
type: Question
has title: How to Export .JAR File Without All Included Libraries (Especially SWT lib)
tagged with: swt
upvote count: 1

http://stackoverflow.com/q/22148242
type: UnansweredQuestion
tagged with: android
has answer: http://stackoverflow.com/a/22148368
linked to: http://stackoverflow.com/q/3669325
score: 1
upvote count: 1
type: Question
has title: multiselection listView contains checkBoxes
has answer: http://stackoverflow.com/a/22148574
tagged with: java
answer count: 2
downvote count: 0
has body: I have ListView with check boxes the app delete the checked items ;; and should delet teh items that have the same id with the checked items : here's my code private class CAdapter extends BaseAdapter { private LayoutInflater mInflater; private ArrayList&lt;Entity&gt; list; private Context context; String Status; CAdapter(Context context, ArrayList&lt;Entity&gt; getC) { this.context = context; this.list = getC; Status=""; mInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); } class ViewHolder { TextView Name; TextView Desc; Button deleteBtn; CheckBox CBox; } public int getCount() { return list.size(); } public Object getItem(int position) { return list.get(position); } public long getItemId(int position) { return position; } @SuppressLint("NewApi") public View getView(final int position, View convertView, ViewGroup parent) { final ViewHolder holder; final CEntity CObj = list.get(position); if (convertView == null) { convertView = mInflater.inflate( R.layout.custom_list_view_confirmed, parent, false); holder = new ViewHolder(); holder.Name = (TextView) convertView .findViewById(R.id.Name); holder.Desc = (TextView) convertView .findViewById(R.id.activity1); holder.deleteBtn = (Button) convertView .findViewById(R.id.deleteBtn); holder.CBox=(CheckBox) convertView.findViewById(R.id.isCheck); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } if (CObj.getMystatus().equals( context.getResources().getString(R.string.course_status_delete))) { holder.status.setTextColor(Color.RED); } else if (attemptedCourseObj.getMystatus().equals( context.getResources().getString(R.string.course_status_pending))) { holder.status.setTextColor(Color.GREEN); } else if (attemptedCourseObj.getMystatus().equals( context.getResources().getString(R.string.course_status_update))) { holder.status.setTextColor(Color.BLUE); } holder.Name.setText(attemptedCourseObj.getCourseName()); holder.CBox.setOnClickListener(new OnClickListener(){ …
favorite count: 0

http://stackoverflow.com/a/22124479
upvote count: 2
has body: String string = "Simple Java Word Count Program"; String[] words = string.split("\\s+"); System.out.println("Words Count: " + words.length); Good thing is now you can even use words by indexes. First word in the string would be words[0], second word would be words[1] and so on. Other method is to count the number of spaces instead, and then number of words would be 1 more than the number of spaces (in an ideal world): String string = "Simple Java Word Count Program"; string = string.trim(); int spaceCount = 0; for(int i = string.length() - 1; i &gt;= 0; i--) { if(string.charAt(i) == ' ') { spaceCount++; } } System.out.println("Words Count: " + (spaceCount + 1)); If there are multiple spaces between two words, then the above spaceCount method will fail. To prevent that from happening, use this simple technique: String string = " Simple Java Word Count Program "; string = string.trim(); int spaceCount = 0; boolean isLastCharSpace = false; for(int i = string.length() - 1; i &gt;= 0; i--) { if(string.charAt(i) == ' ') { if(!isLastCharSpace) { spaceCount++; isLastCharSpace = true; } } else { isLastCharSpace = false; } } System.out.println("Words Count: " + (spaceCount + 1)); Now this will print the correct word count, without using any extra memory, unlike the first method, and without falling in any pitfall of multiple consecutive spaces between words, unlike the second method. If you have series of special characters included in your string and if they are attached with words, then there will be no issue. If they are not attached with words, and are independently existing in your string, then there will be some discrepancy in the answers of program and real answer. One can even write code similarly to prevent such situation from happening, and to provide exactly correct answer. Here's how such method would look like: String string = " Simple Java - Word, {Count Program} "; string = string.trim(); string = removeAllSpecialCharacters(string); int spaceCount = 0; boolean …
answers question: http://stackoverflow.com/q/22124429
downvote count: 0
type: Answer
score: 2

http://stackoverflow.com/q/22154295
type: UnansweredQuestion
tagged with: java
tagged with: slick2d
tagged with: lwjgl
type: Question
has answer: http://stackoverflow.com/a/23370962
has title: LWJGL load image from jar with slick-util
tagged with: image
score: 0
has body: I'm creating a game with LWJGL, and I want to display the LWJGL logo when the game starts. For that, I need to load the image from the jar file. You can see how I set up my resources here: https://i.sstatic.net/PVo52.jpg I have been searching, and it appears that you have to use a '/' in front of the path. That didn't work for me, also without the '/' in front. I also tried putting 'jar:' before resources, but it doesn't work either.
answer count: 1

http://stackoverflow.com/a/22022100
has comment: http://stackoverflow.com/comment/33383400
type: Answer
has comment: http://stackoverflow.com/comment/33383788
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/33384136
has comment: http://stackoverflow.com/comment/33383455
has comment: http://stackoverflow.com/comment/33385941
has comment: http://stackoverflow.com/comment/33384538
has comment: http://stackoverflow.com/comment/33384030
accepted answer of: http://stackoverflow.com/q/22021940
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33383700
downvote count: 0
answers question: http://stackoverflow.com/q/22021940
has body: In Java, you cannot use the value of a String object to reference an actual variable name. Java will think you're attempting to to call add on the String object, which doesn't exist and gives you the compiler error you're seeing. To avoid the repetition, you need to add your Lists to two master lists that you can index. In your question, you mention arrays, but you call add, so I'm assuming that you're really referring to Lists of some sort. List&lt;List&lt;Integer&gt;&gt; numbers = new ArrayList&lt;List&lt;Integer&gt;&gt;(20); List&lt;List&lt;Integer&gt;&gt; numbersy = new ArrayList&lt;List&lt;Integer&gt;&gt;(20); // Add 20 ArrayList&lt;Integer&gt;s to each of the above lists in a loop here. Then you can bounds-check ant.getAntNumber() and use it as an index into your master lists. int antNumber = ant.getAntNumber(); // Make sure it's within range here. numbers.get(antNumber).add(ant.getCol()); numbersy.get(antNumber).add(ant.getRow());

http://stackoverflow.com/q/22119730
tagged with: maven
possible better answer: http://stackoverflow.com/a/22212507
type: Question
has title: Bad request error when generating services
tagged with: java
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/22218818
accepted answer: http://stackoverflow.com/a/22218818
has answer: http://stackoverflow.com/a/22212507
tagged with: rest
tagged with: google-app-engine
type: AnsweredQuestion
has body: I´m building a REST api using googles endpoints. When I build using maven I get the following error. Google App Engine Java SDK - get endpoints discovery doc... Using Class Name:se.deverything.webapi.endpoints.BloodPressureReadingEndpoint Using Class Name:se.deverything.webapi.endpoints.EventEndpoint Executing endpoints Command=[get-discovery-doc, -cp, C:\Git\monium\webapi\webapi-war\target\webapi-war-0-snapshot\WEB-INF\classes;C:\Git\monium\webapi\webapi-war\target/classes;C:\Git\monium\webapi\services\target\services-0-snapshot.jar;C:\Git\monium\webapi\model\target\model-0-snapshot.jar;C:\Users\Marthin\.m2\repository\jstl\jstl\1.2\jstl-1.2.jar;C:\Users\Marthin\.m2\repository\com\google\appengine\appengine-endpoints\1.8.7\appengine-endpoints-1.8.7.jar;C:\Users\Marthin\.m2\repository\javax\jdo\jdo-api\3.0.1\jdo-api-3.0.1.jar;C:\Users\Marthin\.m2\repository\javax\transaction\jta\1.1\jta-1.1.jar;C:\Users\Marthin\.m2\repository\org\eclipse\persistence\javax.persistence\2.1.0\javax.persistence-2.1.0.jar;C:\Users\Marthin\.m2\repository\org\datanucleus\datanucleus-core\3.2.12\datanucleus-core-3.2.12.jar;C:\Users\Marthin\.m2\repository\org\datanucleus\datanucleus-api-jpa\3.3.7\datanucleus-api-jpa-3.3.7.jar;C:\Users\Marthin\.m2\repository\org\datanucleus\datanucleus-rdbms\3.2.11\datanucleus-rdbms-3.2.11.jar;C:\Users\Marthin\.m2\repository\org\datanucleus\datanucleus-api-jdo\3.1.3\datanucleus-api-jdo-3.1.3.jar;C:\Users\Marthin\.m2\repository\com\google\appengine\appengine-api-1.0-sdk\1.8.7\appengine-api-1.0-sdk-1.8.7.jar, -o, C:\Git\monium\webapi\webapi-war\target/generated-sources/appengine-endpoints/WEB-INF, -w, C:\Git\monium\webapi\webapi-war\target/generated-sources/appengine-endpoints, -f, rest, se.deverything.webapi.endpoints.BloodPressureReadingEndpoint, se.deverything.webapi.endpoints.EventEndpoint] mar 01, 2014 9:05:28 EM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml INFO: Successfully processed C:\Git\monium\webapi\webapi-war\target/g…

http://stackoverflow.com/comment/33441498
type: QuestionComment
has text: You have read this post: http://stackoverflow.com/questions/6415728/junit-testing-with-simulated-user-input
comment on: http://stackoverflow.com/q/22054655
score: 0
type: Comment

http://stackoverflow.com/a/22042012
answers question: http://stackoverflow.com/q/22041921
upvote count: 5
score: 4
has body: You're asking whether the type is final, not the parameter - and java.util.Date isn't a final class. Looking at the API, I can't immediately see any way of determining that a parameter is final - but that's really an implementation detail anyway. It makes no difference to the caller at all.
type: Answer
downvote count: 1

http://stackoverflow.com/a/22147233
type: Answer
has comment: http://stackoverflow.com/comment/33784861
has body: Your first question, When main method is called by default one main thread is created. And main thread is a non-dameon thread. When threads created by the main method it inherits it's parant's property. That means they are all non-daemon threads. As you know JVM waits until all non-daemon threads to complete. So it will executes even after the main thread completes. See here : daemon vs non-daemon Java Stack for each thread creation and your second question: join method joins the currently running thread at the end of the thread which is calling the join method. That means the current thread will be stopped and it start after the thread referenced by the join method. Synchronization stops two threads executing the same code at the same time.
has comment: http://stackoverflow.com/comment/33607575
score: 4
upvote count: 4
answers question: http://stackoverflow.com/q/22146899
downvote count: 0

http://stackoverflow.com/q/22006824
favorite count: 0
upvote count: 8
type: Question
has title: Maven parallel test output
has answer: http://stackoverflow.com/a/22007100
has comment: http://stackoverflow.com/comment/33355752
tagged with: maven
has comment: http://stackoverflow.com/comment/33355602
answer count: 1
has comment: http://stackoverflow.com/comment/72216180
has body: When I set my Maven build to run my integration tests in parallel, I see: 01:31:47 ------------------------------------------------------- 01:31:47 T E S T S 01:31:47 ------------------------------------------------------- 01:31:48 Concurrency config is parallel='classes', perCoreThreadCount=true, threadCount=20, useUnlimitedThreads=false But then I don't see the progress of any of my tests. Eventually, they all finish and the output gets dumped out all at once. 01:41:42 Running com.my.test.TestClass 01:41:42 Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 69.706 sec .... That test class finished after a minute yet it wasn't output until all the tests finished 10 minutes later. How can I get the results of each class as it finishes to get output? It's hard to understand the progress of the build otherwise.
tagged with: java
type: UnansweredQuestion
score: 8
downvote count: 0

http://stackoverflow.com/a/22014425
has body: bMainMenu = true; List&lt;StudentInfo&gt; students = new ArrayList&lt;StudentInfo&gt;(); while(bMainMenu){ boolean bList = false; boolean bSearch = false; [all the code prompting choices] -if input is "create" then bList = true; -if input is "search" then bSearch = true; -if input is "exit" then bMainMenu = false; while(bList){ [all the code that creates the array and prompts for student info where the array is as long as the user chooses] // Build this student info object based on user parameters StudentInfo studentInfo = new StudentInfo(name, class); students.add(studentInfo); } while(bSearch){ /* Play with "students" arraylist. It is accessible here and contains all studentinfo details added before. */ } }
type: Answer
score: 1
upvote count: 1
accepted answer of: http://stackoverflow.com/q/22007078
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/22007078

http://stackoverflow.com/comment/33507471
score: 0
has text: Clean and rebuild your project.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22091689

http://stackoverflow.com/comment/33562378
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22121707
has text: So, I'd been using user.dir instead of user.home because I'm not sure how to locate the files I need using user.home. Is there a different way to find the current directory of the application?
score: 0

http://stackoverflow.com/comment/33464252
score: 0
type: QuestionComment
has text: Just as a warning: `finally` is meant for cleaning up resources and not for control flow. See http://stackoverflow.com/questions/48088/returning-from-a-finally-block-in-java and the topics linked from there for more details.
type: Comment
comment on: http://stackoverflow.com/q/22068289

http://stackoverflow.com/q/22031992
score: 1
linked to: http://stackoverflow.com/q/3119607
possible better answer: http://stackoverflow.com/a/22032112
tagged with: java
has answer: http://stackoverflow.com/a/22032089
type: Question
has body: I have an app in which I need to detect users Wifi connection and based on that, the user can see some data. The point is that I want to get notified when the user was on some other network while starting the app and moves to some other network while the app was running. Let me make a scenario: Suppose I have 2 wifi, one inside my house and other outside. When starting the app, I was inside the house and accordingly the data shown to me was "ABC". Now when I move outside the house, my app should give a notification and kill the activity and hence I should not be able to see the same data "ABC" when I am outside the house.
has title: How to get notified when the users Wifi changes from one network to other
has comment: http://stackoverflow.com/comment/33401300
answer count: 3
has answer: http://stackoverflow.com/a/22032112
upvote count: 1
tagged with: wifi
linked to: http://stackoverflow.com/q/5888502
favorite count: 0
has answer: http://stackoverflow.com/a/22032381
accepted answer: http://stackoverflow.com/a/22032381
tagged with: android
has comment: http://stackoverflow.com/comment/33400815
type: AnsweredQuestion
downvote count: 0

http://stackoverflow.com/comment/33487724
type: QuestionComment
score: 1
has text: So, what happens if `firstName` and `lastName` are both `null`? @Dan Well, there are a lot of typos in his code, I doubt it even compiles.
comment on: http://stackoverflow.com/q/22080613
type: Comment

http://stackoverflow.com/q/22079260
tagged with: java
has title: External JPanels called from a JFrame
type: Question
has comment: http://stackoverflow.com/comment/33485923
tagged with: jpanel
score: 0
has comment: http://stackoverflow.com/comment/33486045
answer count: 1
has answer: http://stackoverflow.com/a/22080104
has comment: http://stackoverflow.com/comment/33485313
has comment: http://stackoverflow.com/comment/33485198
has comment: http://stackoverflow.com/comment/33485317
tagged with: jframe
type: UnansweredQuestion
has body: A while back I started a project that soon built up a shed load of code, most of the code was made up of components and their properties. All was going well until I hit an error. Off the top of head, the error was something on the line of exceeding the code limit of a constructor, roughly 65000 bytes. This error has literally bought me and my project to halt. At the same time I have also found major problems in my understanding of SWING. What I tried was to break my game code into logical sections, putting each section into a different class. For example, a jpanel which dealt with buying and selling would be its own .java file. Another jpanel that dealt with shipping would be in another .java file. What I hoped to achieve was a JFrame that called each of these jpanels when the user requested it at the press of a jbutton. However, this didn't quite work as I wished, putting me in a position where I need help. What I have done is simplified my problem by creating an example framework, hoping that somebody could point out what I need to be looking at, possibly even a solution. I have created a JFrame which holds a panel called bg, which itself holds 2 JButtons (btn1 and btn2). In a different class file I have created a JPanel called panel1, and in another class again I have created another JPanel called panel2. When the user opens the application they are presented with a frame and the option of two buttons, when any of these buttons are pressed I would like for either panel1 or panel2 to open. How would this be done? Any help would be greatly appreciated. Thanks in advance. ////////////// frame package panel; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class Frame implements ActionListener { public JPanel bg; public static JButton btn1, btn2; public Frame(){ JFrame f = new JFrame(); f.setSize(308, 205); f.setLayout(null); f.setLo…
tagged with: addition
has comment: http://stackoverflow.com/comment/33486787
tagged with: swing
has comment: http://stackoverflow.com/comment/33485432
has comment: http://stackoverflow.com/comment/33486662

http://stackoverflow.com/a/22126067
upvote count: 1
answers question: http://stackoverflow.com/q/22125277
score: 1
downvote count: 0
type: Answer
has body: Here's a tutorial with examples for programming with Java bytecode that I wrote. Unfortunately I stopped due to lack of interest, but if you find it useful I can finish it.

http://stackoverflow.com/q/22108641
has comment: http://stackoverflow.com/comment/33538282
type: Question
has comment: http://stackoverflow.com/comment/33538303
tagged with: string-interning
has comment: http://stackoverflow.com/comment/33538230
accepted answer: http://stackoverflow.com/a/22108776
possible better answer: http://stackoverflow.com/a/22108678
has title: The == operator in Java
score: 0
has answer: http://stackoverflow.com/a/22108665
tagged with: java
answer count: 3
tagged with: object-identity
linked to: http://stackoverflow.com/q/18172310
has comment: http://stackoverflow.com/comment/33538250
has answer: http://stackoverflow.com/a/22108776
upvote count: 4
has body: the following is true in Java "abc"=="abc" Why? The two Strings are two different objects, they should not have the same object identity?
downvote count: 4
linked to: http://stackoverflow.com/q/513832
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22108678
favorite count: 0
duplicate of: http://stackoverflow.com/q/513832

http://stackoverflow.com/comment/125252375
comment on: http://stackoverflow.com/a/22014164
type: AnswerComment
has text: Also, the problem can be in classpath order for regular JUnit tests. I faced with such order issue and was managed to solve it with this suggestion https://stackoverflow.com/a/23507579/902217
score: 0
type: Comment

http://stackoverflow.com/a/22046685
score: 0
has body: A regular expression is the easier way, but probably on big files, the more efficient way in Java is going with a binary search, that is reading byte-per-byte with a RandomAccessFile - http://docs.oracle.com/javase/6/docs/api/java/io/RandomAccessFile.html.
type: Answer
answers question: http://stackoverflow.com/q/22046475

http://stackoverflow.com/a/22061857
has comment: http://stackoverflow.com/comment/33454163
score: 0
has body: for splitting string with particular format you need to specify regular expression so in your case regular expression will be ("\r\n") Look Here
type: Answer
answers question: http://stackoverflow.com/q/22061774
upvote count: 1
downvote count: 1

http://stackoverflow.com/comment/33491358
comment on: http://stackoverflow.com/q/22082658
type: Comment
has text: Yes you can override and throw UnsopportedOperationException but if you do that cause you can't do anymore then write it explicity in javadoc, but think about relationship between Foo and FooExtension is not as you think(inheritance `IS A` relationship).. You sure if you do that breaks liskov substitution principle
score: 1
type: QuestionComment

http://stackoverflow.com/q/22166695
has comment: http://stackoverflow.com/comment/33730082
upvote count: 6
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33641824
has body: In right click menu have Source-&gt; generate Getters and Setters.On selecting the option, the user can select the variables for which getter and setter need to be generated. I want something similar. Source-&gt; generate increment code. User can select the variable names from a list populated from his class attributes. the generated method will look like private Integer abc; public void incrementAbc(){ abc++; } I was thinking of extending the popupmenu plugin to create the options in the menus. But how do I make the code to be autogenerated on selection by user. Is using fast code template the answer. I new to plugins and I am confused. PLease do help.
tagged with: java
has comment: http://stackoverflow.com/comment/33729319
accepted answer: http://stackoverflow.com/a/22166934
type: Question
has comment: http://stackoverflow.com/comment/33736376
has title: Auto generating methods for variables in eclipse
tagged with: eclipse
has answer: http://stackoverflow.com/a/22166934
downvote count: 0
answer count: 1
has comment: http://stackoverflow.com/comment/33736610
favorite count: 0
has comment: http://stackoverflow.com/comment/33641709
score: 6
has comment: http://stackoverflow.com/comment/33641936
linked to: http://stackoverflow.com/q/2512916

http://stackoverflow.com/a/34324781
score: 0
has body: Firstly you could get all the rows of the table like this: List&lt;WebElement&gt; rows = we.findElements(By.xpath(".//tbody/tr")); then you could iterate over all the rows and then get all the columns of a row like this: List&lt;WebElement&gt; cols = rows.get(rowID).findElements(By.xpath(".//td")); To check the "BIGNAME", iterate over the cols and do this : cols.get(index).getText().equals("BIGNAME")
type: Answer
answers question: http://stackoverflow.com/q/22144945

sockets
tags question: http://stackoverflow.com/q/22120986
tags question: http://stackoverflow.com/q/22028115
tags question: http://stackoverflow.com/q/22028552
tags question: http://stackoverflow.com/q/22162344
tags question: http://stackoverflow.com/q/22150866
tags question: http://stackoverflow.com/q/22089666
tags question: http://stackoverflow.com/q/22123608
tags question: http://stackoverflow.com/q/22159682
tags question: http://stackoverflow.com/q/22015412
tags question: http://stackoverflow.com/q/22036788
tags question: http://stackoverflow.com/q/22110726
tags question: http://stackoverflow.com/q/22162871
tags question: http://stackoverflow.com/q/22049724
tags question: http://stackoverflow.com/q/22086206
tags question: http://stackoverflow.com/q/22013287
tags question: http://stackoverflow.com/q/22095777
tags question: http://stackoverflow.com/q/22090558
tags question: http://stackoverflow.com/q/22090203
tags question: http://stackoverflow.com/q/22099699
tags question: http://stackoverflow.com/q/22086113
tags question: http://stackoverflow.com/q/22032666
tags question: http://stackoverflow.com/q/22113669
tags question: http://stackoverflow.com/q/22108269
type: Tag
tags question: http://stackoverflow.com/q/22140023
tags question: http://stackoverflow.com/q/22163250
tags question: http://stackoverflow.com/q/22047097
tags question: http://stackoverflow.com/q/22132483
tags question: http://stackoverflow.com/q/22065050
tags question: http://stackoverflow.com/q/22116236
tags question: http://stackoverflow.com/q/22089456
tags question: http://stackoverflow.com/q/22114510
tags question: http://stackoverflow.com/q/22104803
tags question: http://stackoverflow.com/q/22120663
tags question: http://stackoverflow.com/q/22108569
tags question: http://stackoverflow.com/q/22057169
tags question: http://stackoverflow.com/q/22080443
tags question: http://stackoverflow.com/q/22042022
tag name: sockets
tags question: http://stackoverflow.com/q/22010360
tags question: http://stackoverflow.com/q/22126187
tags question: http://stackoverflow.com/q/22067928
tags question: http://stackoverflow.com/q/22113962
tags question: http://stackoverflow.com/q/22031628
tags question: http://stackoverflow.com/q/22061628
tags question: http://stackoverflow.com/q/22060300
tags question: http://stackoverflow.com/q/22131915
tags question: http://stackoverflow.com/q/22121799
tags question: http://stackoverflow.com/q/22128994
tags question: http://stackoverflow.com/q/22107380
tags question: http://stackoverflow.com/q/22127429
tags question: http://stackoverflow.com/q/22110205
tags question: http://stackoverflow.com/q/22008803

http://stackoverflow.com/q/22018531
score: 2
answer count: 0
tagged with: java
tagged with: http://stackoverflow.com/tag/json
tagged with: fasterxml
type: Question
has title: JsonSerializable: call standard serialization from serialize method
has body: The problem is in serialize method (see code section of my question). All looks well till my ComplexGraph class swell to twenty ot thirty fields. When ComplexGraph become a real complex graph, than it's very ugly to serialize each field via jsonGenerator.writeNumberField("id", id). Question: How can I invoke standard serialization in serialize method? Like: public class ComplexGraph implements JsonSerializable { public void serialize(JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException { if (isPrivate) return; //HERE IS THE QUESTION else jsonGenerator.standardSerialization(this); } } Code: public class ComplexGraph implements JsonSerializable { private int id; private String text; private boolean isPrivate; // getters and setters @Override public void serialize(JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException { if (isPrivate) return; jsonGenerator.writeStartObject(); //IT'S VERY UGLY WHEN complexGraph HAS MANY DEPENDENCIES! jsonGenerator.writeNumberField("id", id); jsonGenerator.writeStringField("text", text); jsonGenerator.writeEndObject(); } @Override public void serializeWithType(JsonGenerator jsonGenerator, SerializerProvider serializerProvider, TypeSerializer typeSerializer) throws IOException, JsonProcessingException { serialize(jsonGenerator, serializerProvider); } }
downvote count: 0
favorite count: 0
tagged with: serialization
upvote count: 2
type: UnansweredQuestion

http://stackoverflow.com/comment/33432060
score: 0
type: QuestionComment
has text: Also to make it better formated, put common denominators outside in new if statements e.g. if(choose == 3){ if(dicetotal == 7){} else{}}... Makes it much more readable.
type: Comment
comment on: http://stackoverflow.com/q/22049467

http://stackoverflow.com/comment/33560019
score: 0
type: Comment
has text: I have been pretty afraid of using regex simply because I'm not well versed in it. Additionally, I'm a bit concerned that the performance might not improve all that significantly.
comment on: http://stackoverflow.com/a/22120899
type: AnswerComment

http://stackoverflow.com/q/22040487
favorite count: 0
has answer: http://stackoverflow.com/a/22043209
type: UnansweredQuestion
downvote count: 2
upvote count: 1
has comment: http://stackoverflow.com/comment/33425212
type: Question
has title: grabbing information off answer sites
tagged with: java
score: -1
has comment: http://stackoverflow.com/comment/33415331
has body: First off let me say language of preference is Java but any language is acceptable for the answer since I know most languages. Question: Say I have a link, http://ca.answers.yahoo.com/question/index?qid=20140218053709AAM0WfI (random link for this example). Is there any possible way to get the title of the question and store it in a string, then get what he typed as the description for the question(aka this section here) and store it in a separate string? I know how to grab strings from a site but the problem I run into is that I keep grabbing answers aswell as the question. Additional details. I will not know the specific yahoo answer ahead of time, so the code needs to be able to work with all basic questions (aka ones without picture or other complications). Code needs to work with all question/answer forum kinda sites not just yahoo. Not asking anyone to write entire code or anything, I know that is not how site works. Just is there any specific functions that can easily obtain this information?
answer count: 1
tagged with: web
tagged with: string

http://stackoverflow.com/a/78662174
type: Answer
answers question: http://stackoverflow.com/q/22129568
has body: You need to remove the line with setting the content type. I had the same issue and this fixed it.
score: 0

http://stackoverflow.com/comment/33638127
type: QuestionComment
has text: Okay @Neha..Sounds right but how do I correct this?
comment on: http://stackoverflow.com/q/22164575
score: 0
type: Comment

http://stackoverflow.com/comment/33449529
type: AnswerComment
comment on: http://stackoverflow.com/a/22058871
type: Comment
has text: ^^ Did you read my comment about the localized error message from the toast? What's wrong with my path ?? I made a few changes and now getting "ENOENT: No such file or directory"
score: 0

http://stackoverflow.com/comment/33497885
comment on: http://stackoverflow.com/q/22086082
score: 0
type: Comment
type: QuestionComment
has text: Why is the many to many mapping wrong. It works perfectly, I actually implemented that solution last night and it does the same exact thing as my solution. Can you please tell me the benefits of that solution vs mine. Also, you are correct, cascade should have not been set to all.

http://stackoverflow.com/a/22019014
type: Answer
has body: It is because of Java's autoboxing which will convert 1 into an Integer instead of a Double. Double a = Double.valueOf(1); should work
has comment: http://stackoverflow.com/comment/33378110
score: 0
answers question: http://stackoverflow.com/q/22018921

http://stackoverflow.com/comment/33487325
score: 0
has text: @user3298846 All questions on SO are urgent. Try to help us help you. Describe specific problem you are facing (examples would be nice), your attempts to solve it and how did it fail.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22080344

http://stackoverflow.com/a/22122437
has comment: http://stackoverflow.com/comment/33562924
answers question: http://stackoverflow.com/q/22122365
score: 0
has body: How is this working exactly? It looks like the javascript is designed to be a mock server; i.e. to respond to requests sent by client-side library code under test. The unit tests you have added seems to be doing that. Why don't they have to include a dependency in their POM file? The intention is that you should set up the test server by hand in order to run those tests. Besides, it doesn't make sense to declare a Maven dependency on a piece of (non-Java) software that has to be installed and launched for unit testing. (You might be able to get Maven to do that kind of thing, but I'm not sure it is a good idea. And clearly, the project developers haven't done this ...) This theory is supported by the Makefile. Do I have to have node.js installed to be able to run the tests? I suggest that you try it and see ... and / or read and understand the Makefile and its significance. But seriously, you should probably be asking these questions of the authors. The README file says: "You can contact us if you have questions using the standard communication channels described in the developer's site" and there is a link to the site. Once you have figured it out, send them a pull request that improves their developer documentation by documenting the test procedures.
type: Answer

http://stackoverflow.com/comment/33392477
score: 0
type: QuestionComment
has text: possible duplicate of [Find if a number is a power of two without math function or log function](http://stackoverflow.com/questions/19383248/find-if-a-number-is-a-power-of-two-without-math-function-or-log-function)
type: Comment
comment on: http://stackoverflow.com/q/22026924

http://stackoverflow.com/a/22075254
downvote count: 0
score: 1
upvote count: 1
has body: If you're trying to use Military codes (i.e. Z for GMT see: http://www.timeanddate.com/library/abbreviations/timezones/military/z.html) you could so something like this: import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.TimeZone; import java.util.Date; public class CalendarExample { static final String MILITARY_OFFSETS = "YXWVUTSRQPONZABCDEFGHIKLM"; static final int MILLIS_IN_HOUR = 1000*60*60; public static void main(String[] args) { System.out.println(formatDate(new Date(), "yyyy-MM-dd", "GMT")); // 2014-02-27Z System.out.println(formatDate(new Date(), "HH:mm:ss", "GMT")); System.out.println(formatDate(new Date(), "yyyy-MM-dd", "EST")); System.out.println(formatDate(new Date(), "HH:mm:ss", "EST")); } static String formatDate(Date date, String dateTimeFormat, String timezoneCode) { Calendar calendar = new GregorianCalendar(); TimeZone tz = TimeZone.getTimeZone(timezoneCode); calendar.setTimeZone(tz); int offset = calendar.get(Calendar.ZONE_OFFSET)/MILLIS_IN_HOUR; // System.out.println(timezoneCode + " Offset is " + offset + " hours"); String timeZoneCode = MILITARY_OFFSETS.substring(offset + 12, offset + 13); SimpleDateFormat dateFmt = new SimpleDateFormat(dateTimeFormat + "'" + timeZoneCode + "'"); return dateFmt.format(date); } } output: 2014-02-27Z 11:57:44Z 2014-02-27R 11:57:44R
type: Answer
answers question: http://stackoverflow.com/q/22072631

http://stackoverflow.com/comment/33570139
comment on: http://stackoverflow.com/a/22126120
type: AnswerComment
has text: I think I can't apply this method on my codes. Can you help me how can I apply the same approach on my codes? I update my codes on the question.
type: Comment
score: 0

http://stackoverflow.com/q/22148487
tagged with: io
has comment: http://stackoverflow.com/comment/33618458
tagged with: design-patterns
answer count: 0
score: 1
tagged with: java
upvote count: 1
has comment: http://stackoverflow.com/comment/33609728
tagged with: memory
has body: I am making a class to handle Errors, called ErrorHandler Please correct me if this is not the best practice. However, considering just about every method is going to use a BufferedWriter, should I simply initialize it as a field? private BufferedWriter output = new BufferedWriter(new FileWriter(errorFile)); I am concerned with memory leaks and resource usage, should I simply make it private BufferedWriter output; and initialize it/close it within every method, or is initializing it once okay?
type: Question
has comment: http://stackoverflow.com/comment/33618503
has comment: http://stackoverflow.com/comment/33608577
has comment: http://stackoverflow.com/comment/33620950
has comment: http://stackoverflow.com/comment/33610697
has title: Using a BufferedWriter in a static class
downvote count: 0
favorite count: 0
type: UnansweredQuestion

http://stackoverflow.com/a/47205692
has comment: http://stackoverflow.com/comment/99640452
answers question: http://stackoverflow.com/q/22142920
type: Answer
upvote count: 1
score: 1
downvote count: 0
has body: Use load: If you are sure about the object availability that you are retrieving from DB. Else you will end up catching ObjectNotFoundException. When you have heavy object to be loaded (Since it loads lazily whenever you use it) Use get: If you are not sure about the object availability in the DB. You get luxury to check for null, when there is not object available in DB. When you have light object to be loaded (since it loads eagerly).

http://stackoverflow.com/comment/33600135
has text: I was looking at the wrong place! Issue was not comming from the runner but from SONAR itself. I had to change de sonar config file '/opt/sonar' and restart it. In the setting page I now can see that sonar is running on mysql. I'm facing a other issue with the runner, but it is not related to the issue above. So basicaly make sure both SONAR and SONAR-RUNNER are configured to work with mysql.
score: 1
comment on: http://stackoverflow.com/q/22127945
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33461205
score: 0
comment on: http://stackoverflow.com/q/22066013
type: Comment
type: QuestionComment
has text: you cannot copy java.util.iterator, so you should do this with the way that you've shown in your question.

http://stackoverflow.com/a/22161239
has comment: http://stackoverflow.com/comment/33636030
has body: I actually think I see what your for loop is supposed to do, it's a little pow function. But as some others have pointed out, d starts out as 0 so it always ends up 0. Just changing d to 1 will stop your infinite loop: for (d = 1; d &lt; n; d *= 10); But the answer is still wrong since it looks like you're trying to sum the digits. (e.g. 1 + 2 + 3 = 6, but instead the answer returned is 3.53) Since you are dealing with the individual digits, using float is bad here because you don't want fractional values. You want the digits to round. So you need to change your temp variables to int. There's one last thing which is the last digit is skipped. At this point I get 3 as the answer. After changing while(n &gt; 10) to while(n &gt; 0), the right answer is returned. So the code would be this: public static int sumDigits(int n) { int retVar = 0; while (n &gt; 0) { int d; for (d = 1; d &lt; n; d *= 10); d /= 10; retVar += n / d; n %= d; } return retVar; } As a tip, there's a simpler way to solve this same problem which is to start with the smallest digit instead of the largest: while(n &gt; 0) { retVar += n % 10; n /= 10; } Final Note If I'm right about the for loop, the important thing to take home is that if you write stuff like this almost nobody will think it's intentional. Syntax like this might actually work correctly but it's obscure and more like a novelty. The loop can be replaced like this which is much more clear and just as compact: int d = 0; while(d &lt; n) { d *= 10; } Or if you really want: int d = 0; while(d &lt; n) d *= 10; // not recommended but clearly has a body
has comment: http://stackoverflow.com/comment/33636000
upvote count: 2
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33723438
has comment: http://stackoverflow.com/comment/33722782
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/33723091
downvote count: 0
has comment: http://stackoverflow.com/comment/33722661
accepted answer of: http://stackoverflow.com/q/22160970
answers question: http://stackoverflow.com/q/22160970

http://stackoverflow.com/comment/33395096
type: Comment
type: QuestionComment
has text: Nevermind the HTTP part, it was simply used for illustrating variance
comment on: http://stackoverflow.com/q/22028580
score: 0

http://stackoverflow.com/comment/33375862
score: 0
type: AnswerComment
has text: Interesting idea. One issue would be that `Matcher` bounces around the string-being-searched (with backtracking and such) when attempting to find the match, which implies that multiple buffers may *have* to be entirely in memory.
type: Comment
comment on: http://stackoverflow.com/a/22018249

http://stackoverflow.com/comment/37947461
score: 1
has text: +1 for this great answer that saved my day. (sad that apparently it is way too hard to vaadin people to write a decent manual... )
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22081025

http://stackoverflow.com/comment/33373022
has text: I cut down the code a lot because it was just really long. I'm not sure if it is just a case of a missing bracket because everything was fine until I put the last bit of code in. (case 82024 and 82020)
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22016586

http://stackoverflow.com/comment/33603344
has text: @Mena I see. Thanks. Please edit your question with a summary of why this wouldn't work and i'll accept it.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/22144968
score: 0

http://stackoverflow.com/comment/33517063
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22097391
has text: Ur code shows that the result from the method could be a Boolean output. A switch statement would be an option for this. I do not see a problem with my solution. However it does not state the language used so this might not be ok for what you are looking for, but could be helpful to someone else

http://stackoverflow.com/q/22068610
accepted answer: http://stackoverflow.com/a/22068774
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/33464875
has title: Replace with empty space
has answer: http://stackoverflow.com/a/22068863
has body: I have done this before, but now I encounter a different problem. I want to extract just the digits at the end "Homework 1: 89", which is in a .txt file. As said I usually used ".replaceAll("[\D]", "")"* . But if I do it ths time, the number before the colon (1 in example) stays... I cannot see of any solution. it Should look like this: while (dataSc.hasNextLine()) { String data = dataSc.nextLine(); ArrayData.add(i, data); if (data.contains("Homework ")) { idData.add(a, data); idData.set(a, (idData.get(a).replaceAll("[\\D]", ""))); Output being, A new string with Just "89"...
has comment: http://stackoverflow.com/comment/33466356
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22068863
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22068774

http://stackoverflow.com/comment/33542378
type: AnswerComment
comment on: http://stackoverflow.com/a/22111097
type: Comment
has text: I just made an edit to my question to inform that nothing is constant in the string, so we can't assume string will start with p043366329446409.Sorry for that.
score: 0

http://stackoverflow.com/comment/33640056
score: 0
comment on: http://stackoverflow.com/a/22160828
type: Comment
type: AnswerComment
has text: @Remy Thanks for the suggestion; I actually had something lying around using HttpUrlConnection that worked but I'm not sure if I'm allowed to use it, since this is an assignment for learning purposes. It did mention I should use Java Socket library only.. I should add that url.getPort() gave me an IllegalArgumentException: port out of range: -1.

http://stackoverflow.com/a/22167490
has body: The problem is solved! :) The problem was in pom.xml. PersistenceUnit is not required. Enough following configuration entityManagerFactory: ${jdbc.dialect} false com.kuzmenko.homeproject.domain End dependencies, that need: org.springframework spring-tx ${spring.version} org.springframework.data spring-data-jpa 1.4.1.RELEASE org.springframework spring-orm ${spring.version} org.hibernate hibernate-core 4.2.5.Final org.hibernate hibernate-entitymanager 4.2.5.Final org.hibernate.javax.persistence hibernate-jpa-2.1-api 1.0.0.Final
score: 0
answers question: http://stackoverflow.com/q/22150678
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22150678
type: Answer

http://stackoverflow.com/a/22092532
has comment: http://stackoverflow.com/comment/33508287
has body: TreeMultimap uses Comparable rather than equals and hashCode. From the JavaDoc: Implementation of Multimap whose keys and values are ordered by their natural ordering or by supplied comparators. In all cases, this implementation uses Comparable.compareTo(T) or Comparator.compare(T, T) instead of Object.equals(java.lang.Object) to determine equivalence of instances.
score: 4
accepted answer of: http://stackoverflow.com/q/22092237
upvote count: 4
answers question: http://stackoverflow.com/q/22092237
type: AcceptedAnswer
downvote count: 0
type: Answer

http://stackoverflow.com/a/22070792
accepted answer of: http://stackoverflow.com/q/22058636
type: Answer
answers question: http://stackoverflow.com/q/22058636
score: 1
upvote count: 1
has body: You have to add testNG.jar to the classpath. The following links might be helpful :- Java command line with external .jar How to include jar files with java file and compile in command prompt You would have to download testNG jar and add it as well as selenium jar files to your class path. I suggest you to use a build and dependency tools such as maven or ant
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/133410283
score: 0
type: Comment
has text: why the code or dependency is not available on maven? cannot find the classes while using the lastes gson dependency
type: AnswerComment
comment on: http://stackoverflow.com/a/22271096

http://stackoverflow.com/q/22131286
tagged with: swing
tagged with: uimanager
type: AnsweredQuestion
tagged with: custom-component
tagged with: jspinner
tagged with: java
linked to: http://stackoverflow.com/q/22127833
type: Question
score: 0
has title: Swing change foreground color of BasicArrowButton
answer count: 1
has body: In JSpinner class, how would I change the foreground color of two BasicArrowButton(up and down) components? the component.setForeground(&lt;&lt;a_color&gt;&gt;) doesn't work. Thanks in advance. EDIT private void set_colors(JSpinner spinner){ int n = spinner.getComponentCount(); for (int i=0; i&lt;n; i++) { Component c = spinner.getComponent(i); System.out.println(c); if (c instanceof BasicArrowButton) { c.setForeground(ds_conn_text.getForeground());//doesn't work, doesn't change arrow color c.setBackground(ds_conn_text.getBackground()); BasicArrowButton c0=(BasicArrowButton) c;c0.setBorder(ok_button.getBorder()); } } }
accepted answer: http://stackoverflow.com/a/22132789
has answer: http://stackoverflow.com/a/22132789

http://stackoverflow.com/a/22631209
accepted answer of: http://stackoverflow.com/q/22116128
answers question: http://stackoverflow.com/q/22116128
upvote count: 2
type: AcceptedAnswer
type: Answer
has body: In Jboss, session timeout can be increased in two ways, Either for all applications by specifying it in jboss's web.xml or application specific by specifying it in application's web.xml 60 jboss's web.xml location will be different depending on jboss version. in jboss4 it is jboss/server/default/deploy/jbossweb-tomcat55.sar/conf/web.xml in jboss5 it is deployers/jbossweb.deployer/web.xml No idea about later version's
score: 2
downvote count: 0

http://stackoverflow.com/a/22079522
type: AcceptedAnswer
has body: myMap.put("preload_buffer_size", 1024L);
upvote count: 1
type: Answer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22079429
answers question: http://stackoverflow.com/q/22079429
score: 1

http://stackoverflow.com/comment/33496027
comment on: http://stackoverflow.com/q/22085186
type: Comment
type: QuestionComment
has text: If you're looking for a way to ship data with you app you can include a prepopulated db in the apk, which is a much better experience for the users: http://stackoverflow.com/questions/513084/how-to-ship-an-android-application-with-a-database
score: 1

http://stackoverflow.com/comment/33547156
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22113779
has text: for that I will need if statements, however, for an if statement i need to read first and store in a variable and then check. The problem here is that i dont know which type of variable to use to store in.

junit
type: Tag
tags question: http://stackoverflow.com/q/22063167
tags question: http://stackoverflow.com/q/22122687
tags question: http://stackoverflow.com/q/22165356
tags question: http://stackoverflow.com/q/22122269
tags question: http://stackoverflow.com/q/22103769
tags question: http://stackoverflow.com/q/22130701
tags question: http://stackoverflow.com/q/22135694
tags question: http://stackoverflow.com/q/22141123
tags question: http://stackoverflow.com/q/22044872
tags question: http://stackoverflow.com/q/22080304
tags question: http://stackoverflow.com/q/22078501
tags question: http://stackoverflow.com/q/22126312
tags question: http://stackoverflow.com/q/22167592
tags question: http://stackoverflow.com/q/22140213
tags question: http://stackoverflow.com/q/22087355
tag name: junit
tags question: http://stackoverflow.com/q/22086371
tags question: http://stackoverflow.com/q/22034512
tags question: http://stackoverflow.com/q/22044911
tags question: http://stackoverflow.com/q/22099634
tags question: http://stackoverflow.com/q/22054655
tags question: http://stackoverflow.com/q/22168076
tags question: http://stackoverflow.com/q/22128766
tags question: http://stackoverflow.com/q/22069638
tags question: http://stackoverflow.com/q/22130521
tags question: http://stackoverflow.com/q/22028580
tags question: http://stackoverflow.com/q/22080557
tags question: http://stackoverflow.com/q/22017002
tags question: http://stackoverflow.com/q/22151755
tags question: http://stackoverflow.com/q/22082449
tags question: http://stackoverflow.com/q/22026612
tags question: http://stackoverflow.com/q/22094644
tags question: http://stackoverflow.com/q/22067916
tags question: http://stackoverflow.com/q/22164787
tags question: http://stackoverflow.com/q/22126973
tags question: http://stackoverflow.com/q/22024701
tags question: http://stackoverflow.com/q/22015820

http://stackoverflow.com/comment/33594413
type: Comment
has text: Thank you for your input, it is very helpful. I have implemented your suggestions, and I had a question about when I am actually inputting the values at the part that reads "String[] elementsToAdd2 = {}". I tried putting this into a loop like this: "for (int i = 0; i <= 30; i++){String[] elementsToAdd2 = randomString(int 1000); }", but I am getting an error about a class being expected. Since 'randomString(int 1000)' should return a string, I figured this was a legal move. Could you explain to me what I am doing wrong?
type: AnswerComment
comment on: http://stackoverflow.com/a/22139452
score: 0

http://stackoverflow.com/comment/33555604
type: Comment
type: QuestionComment
has text: I thing it might do that, but at my device it doesn't and I don't know how is it possible.
comment on: http://stackoverflow.com/q/22117919
score: 0

http://stackoverflow.com/q/22102703
has comment: http://stackoverflow.com/comment/33528474
favorite count: 0
has comment: http://stackoverflow.com/comment/33528675
has title: Java thread does not get to execute - low CPU usage but high IO-wait
tagged with: linux
has comment: http://stackoverflow.com/comment/33528590
has comment: http://stackoverflow.com/comment/33527152
has comment: http://stackoverflow.com/comment/33527357
has comment: http://stackoverflow.com/comment/33704049
has body: Ubuntu 12.04 LTS java -version java version "1.6.0_38" Java(TM) SE Runtime Environment (build 1.6.0_38-b05) Java HotSpot(TM) 64-Bit Server VM (build 20.13-b02, mixed mode) 4 core CPU - some Dell server hardware 10 threads from time to time run a "heavy" job over several minutes. At other periods they are doing nothing. 1 thread is supposed to wake up every 5 (or so) secs and send a quick ping over the network to another process. This works nicely as long as the other 10 threads do nothing, but when the other 10 threads are running a "heavy" job it never (or very rarely) get to run and send its ping. I could understand this if this "heavy" job was CPU intensive. But during such a "heavy" job top says something like 50-100% IO-wait but around 1% CPU usage. Profiling shows that by far most of the time spent by the 10 threads are spent in (waiting I guess) in some NIO call. It all adds up, and is kinda expected because a lot of the heaviness about the job is to read files from disk. What I do not understand is that during such a "heavy" job, the 1 thread doing pings do not get to run. How can that be explained when top shows 1% CPU usage and it seems (profiling and top) that the 10 threads are spending most of their time waiting for IO. Isnt the 1 ping-thread supposed to get execution-time when the other threads are waiting for IO? Java thread priority is equal on all 11 threads. Spreading a few yields here and there in the 10 threads seem to solve (or lower) the problem, but I simply do not understand why the ping thread does not get to run without the yields, when the other threads do not do much but wait for IO. ADDITIONAL INFO 05.03.2014 I have reproduced the problem in a simpler setup - even though not very simple yet (you will have to find out how to install a Apache Zookeeper server, but it is fairly simple - I can provide info later) Find Eclipse Kepler project here (maven - build by "mvn package"): https://dl.dropboxusercontent.com/u/25718039/io-test.zip Find b…
has comment: http://stackoverflow.com/comment/33529396
has comment: http://stackoverflow.com/comment/33527708
has comment: http://stackoverflow.com/comment/33528897
answer count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33527337
tagged with: multithreading
downvote count: 1
has comment: http://stackoverflow.com/comment/33528451
score: 3
has comment: http://stackoverflow.com/comment/33572053
has comment: http://stackoverflow.com/comment/33527778
tagged with: java
tagged with: preemptive
has comment: http://stackoverflow.com/comment/33533420
has comment: http://stackoverflow.com/comment/33527329
type: Question
upvote count: 4
has comment: http://stackoverflow.com/comment/33528658

http://stackoverflow.com/a/59846741
type: Answer
has body: If you are using the idea version 2019.2 or above, you have to select the checkbox named as Show Dialog which you can see it in front of On Update action. as you can see it in the below image. after selecting this checkbox, every time you press update icon, it will open the pop up and you can decide what you want to do.
score: 1
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/22111603

http://stackoverflow.com/comment/33612809
type: AnswerComment
has text: I tried changing the while statement to an if statement, but it returns a nullpointer exception, even though the line of code itself checks to see if the title will be null.
type: Comment
comment on: http://stackoverflow.com/a/22150503
score: 0

http://stackoverflow.com/comment/33505430
comment on: http://stackoverflow.com/q/22088654
score: 0
has text: @khmarbaise thanks for noticing my problem, I've added the pom file on my post
type: Comment
type: QuestionComment

http://stackoverflow.com/a/23373269
upvote count: 3
answers question: http://stackoverflow.com/q/22006984
downvote count: 0
has body: If you are using spring security, then you should try setting disable-url-rewriting attribute of &lt;http&gt; element to true. Regards,
type: Answer
score: 3

class
tags question: http://stackoverflow.com/q/22140353
tags question: http://stackoverflow.com/q/22056226
tags question: http://stackoverflow.com/q/22086605
tags question: http://stackoverflow.com/q/22103226
tags question: http://stackoverflow.com/q/22060217
tags question: http://stackoverflow.com/q/22080610
tags question: http://stackoverflow.com/q/22051665
tags question: http://stackoverflow.com/q/22106899
tags question: http://stackoverflow.com/q/22030937
tags question: http://stackoverflow.com/q/22021872
tags question: http://stackoverflow.com/q/22076672
tags question: http://stackoverflow.com/q/22090935
tags question: http://stackoverflow.com/q/22009237
tags question: http://stackoverflow.com/q/22093617
tags question: http://stackoverflow.com/q/22085985
tags question: http://stackoverflow.com/q/22101439
tags question: http://stackoverflow.com/q/22031047
tags question: http://stackoverflow.com/q/22049256
tags question: http://stackoverflow.com/q/22135640
tags question: http://stackoverflow.com/q/22078231
tags question: http://stackoverflow.com/q/22162062
tags question: http://stackoverflow.com/q/22010727
tags question: http://stackoverflow.com/q/22012919
type: Tag
tags question: http://stackoverflow.com/q/22157312
tags question: http://stackoverflow.com/q/22083452
tags question: http://stackoverflow.com/q/22079046
tags question: http://stackoverflow.com/q/22038782
tags question: http://stackoverflow.com/q/22081218
tags question: http://stackoverflow.com/q/22049634
tags question: http://stackoverflow.com/q/22106171
tags question: http://stackoverflow.com/q/22049667
tag name: class
tags question: http://stackoverflow.com/q/22075378
tags question: http://stackoverflow.com/q/22141582
tags question: http://stackoverflow.com/q/22099485
tags question: http://stackoverflow.com/q/22131518
tags question: http://stackoverflow.com/q/22148159
tags question: http://stackoverflow.com/q/22026020
tags question: http://stackoverflow.com/q/22098660
tags question: http://stackoverflow.com/q/22031207
tags question: http://stackoverflow.com/q/22073777
tags question: http://stackoverflow.com/q/22069254
tags question: http://stackoverflow.com/q/22159699
tags question: http://stackoverflow.com/q/22156079
tags question: http://stackoverflow.com/q/22158168

http://stackoverflow.com/a/22104202
answers question: http://stackoverflow.com/q/22103781
upvote count: 1
score: 1
downvote count: 0
has body: Initialize your speech engine in onCreate(), not in onClick(), so move this line: tts = new TextToSpeach(this, this); to onCreate() It takes some time until the engine initializes, and because you're calling speakOut() in onInit(), just wait few seconds when you start the app, if initialization is successful, you should hear the sound.
type: Answer

node.js
tags question: http://stackoverflow.com/q/22122365
tags question: http://stackoverflow.com/q/22078644
tags question: http://stackoverflow.com/q/22015412
tags question: http://stackoverflow.com/q/22109454
tags question: http://stackoverflow.com/q/22098959
type: Tag
tag name: node.js

http://stackoverflow.com/comment/33372292
type: Comment
comment on: http://stackoverflow.com/q/22016401
has text: @fge it has one input string, but the pattern searched appears several times within that string, and I want those parts. This loop will give me all the groups found if I print them,
score: 0
type: QuestionComment

http://stackoverflow.com/q/22141178
downvote count: 0
has answer: http://stackoverflow.com/a/22141219
has title: Appropriate collection class in Java for duplicate key, value pairs
answer count: 3
has answer: http://stackoverflow.com/a/22141362
favorite count: 0
has comment: http://stackoverflow.com/comment/33596207
type: UnansweredQuestion
has body: Which collection class should i use for the following data (key1, value1) (key1, value2) (key2, value3) (key3, value3) keys and values are not distinct
tagged with: collections
score: 3
has answer: http://stackoverflow.com/a/22141294
upvote count: 3
linked to: http://stackoverflow.com/q/2889777
tagged with: java
type: Question

http://stackoverflow.com/q/22070535
possible better answer: http://stackoverflow.com/a/22070772
tagged with: java.util.scanner
upvote count: 3
has comment: http://stackoverflow.com/comment/33468572
downvote count: 1
score: 2
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22070751
tagged with: java
has comment: http://stackoverflow.com/comment/33468621
type: Question
tagged with: try-catch
favorite count: 0
has answer: http://stackoverflow.com/a/22070772
tagged with: exception
answer count: 3
has answer: http://stackoverflow.com/a/22070746
has title: Java Try-Catch Exception Calculator
has answer: http://stackoverflow.com/a/22070751
has body: So I'm trying to make a user input calculator using try-catch and exception. The program keeps on repeating and couldn't get the actual input for the numbers and it also includes the statement Wrong input. Please try again. Any idea on how to fix this? import java.util.*; public class Calculator { public static void main(String[] args) { int x=1; do { try { System.out.println("Menu"); System.out.println("1-Addition"); System.out.println("2-Subtraction"); System.out.println("3-Multiplication"); System.out.println("4-Divison"); System.out.println("5-Modulos"); System.out.println("6-Exit"); System.out.println("Choose option: "); Scanner scan = new Scanner(System.in); int choice = scan.nextInt(); switch (choice) { case 1: System.out.print("Input two numbers:"); String dimension = scan.nextLine(); String[] parts = dimension.split(" "); int a = Integer.parseInt(parts[0]); int b = Integer.parseInt(parts[1]); int c=a+b; System.out.println("Sum = " +c); break; case 2: System.out.print("Input two numbers:"); String dif = scan.nextLine(); String[] difference = dif.split(" "); int num1 = Integer.parseInt(difference[0]); int num2 = Integer.parseInt(difference[1]); int d=num1-num2; System.out.println("Difference = " +d); break; case 3: System.out.print("Input two numbers:"); String multi = scan.nextLine(); String[] product = multi.split(" "); int num3 = Integer.parseInt(product[0]); int num4 = Integer.parseInt(product[1]); int p=num3*num4; System.out.println("Product = " +p); break; case 4: System.out.print("Input two numbers:"); String div = scan.nextLine(); String[] quotient = div.split(" "); int num5 = Integer.parseInt(quotient[0]); int num6 = Integer.parseInt(quotient[1]); int q=num5/num6; System.out.println("Quotient = " +q); break; case 5: System.out.print("Input two numbers:"); String mod = scan.nextLine(); String[] modulo = mod.split(" "); int num7 = Integer.parseInt(modulo[0]); int num8 = Integer.parseInt(modulo[1]); int m=num7%num8; System.out.println("Modulos = " +m); …

http://stackoverflow.com/q/22162863
has answer: http://stackoverflow.com/a/22165725
answer count: 1
downvote count: 0
favorite count: 0
type: UnansweredQuestion
score: 1
tagged with: stack
tagged with: java
upvote count: 1
has body: So I'm working on just 1 case right now so I can move onto the bigger picture. I understand there's genius, much better ways to do what I am trying to do, but I'm a student in his first year Java so I don't know mapping, linked lists, anything more than your basic Stack which I wrote the code for rather than used Java's code. You'll see in my code that I push the Fraction object if it is not the multiplication operand and pop the two once the operator is found (I'm not assuming any errors as of right now.) My issue comes where I need to then multiply the two together. They are and must be Objects in the push(object x) When I put them into the stack they are Fractions but pop them as Object objects and cannot use my Fraction.times(Fraction x) method. Any help would be appreciated. public void run() throws java.io.IOException { String readIn; Object op1, op2; boolean valid = true; Stack myStack = new Stack(MAX_TOKEN); Fraction myFract; stdin = new Scanner(System.in); while(stdin.hasNext() &amp;&amp; valid == true) { readIn = stdin.next(); myFract = new Fraction(readIn); if(!readIn.equals("*")) { myStack.push(myFract); } if(readIn.equals("*")) { op1 = myStack.pop(); // ****THIS IS WHERE I NEED ADVICE/HELP op2 = myStack.pop(); } System.out.println(myFract.toString()); } } public Fraction(String fractString) { StringTokenizer str = new StringTokenizer(fractString, "(/)"); numerator = Integer.parseInt(str.nextToken()); denominator = Integer.parseInt(str.nextToken()); reduce(); } public Fraction times(Fraction z) { int myNumer = this.numerator * z.numerator; int myDenom = this.denominator * z.denominator; Fraction newFract = new Fraction("(" + myNumer + "/" + myDenom + ")"); newFract.reduce(); return newFract; }
type: Question
tagged with: object
has title: RPN Program, Object vs Fraction objects: How to solve. JAVA

http://stackoverflow.com/comment/33382971
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22022145
has text: anything outside the ascii charset, like `ü`.
score: 0

custom-exceptions
type: Tag
tags question: http://stackoverflow.com/q/22026301
tag name: custom-exceptions

http://stackoverflow.com/a/22016573
downvote count: 0
has comment: http://stackoverflow.com/comment/33372727
has comment: http://stackoverflow.com/comment/33372789
accepted answer of: http://stackoverflow.com/q/22016405
answers question: http://stackoverflow.com/q/22016405
has comment: http://stackoverflow.com/comment/33372495
score: 5
has comment: http://stackoverflow.com/comment/33373690
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33372600
has comment: http://stackoverflow.com/comment/33373069
has comment: http://stackoverflow.com/comment/33373509
upvote count: 5
type: Answer
has comment: http://stackoverflow.com/comment/33373046
has comment: http://stackoverflow.com/comment/33372867
has body: There is absolutely no difference between this: public void methodA(){ MHandle mh = getMHandle(); mh.toString(); } and this public void methodA(){ this.toString(); } and this public void methodA(){ toString(); } and this public void methodA(){ this.getMHandle().getMHandle().getMHandle().getMHandle(). getMHandle().getMHandle().toString(); } This non-difference is true in any context. Internally to the MHandle class or its concrete sub-classes (such as House), and also to classes that do-or-don't have access to the MHandle class. I don't see the point of having getMHandle() at all, if all it does is return a self-reference without doing anything useful.

http://stackoverflow.com/comment/33627983
has text: Using indexed file formats, insertion may be much more efficient, but text files are not a form of indexed file. As several other people have suggested, another potentially more efficient option is to skip the temporary file and read the original file into memory inserting the new text at the point it is required and then finish adding the original file contents to the end of the buffer before writing all of it back over the original file. However, that depends very much on the size of the files being updated and may not be any more efficient than the relatively simple method I suggested.
comment on: http://stackoverflow.com/a/22156354
type: AnswerComment
type: Comment
score: 0

http://stackoverflow.com/q/22045492
upvote count: 1
has title: Fail to start application debugging - combined C/java android application in Eclipse
has body: NDK_LOCATION is set correctly. The ndk-build command finishes fine and I can see the library in /libs/areabi-v7a - I tried also building all platforms but the message remains. The app doesn't start with this message in eclipse console: [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] Android [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] NDK: [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] Could [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] not [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] find [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] platform [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] files [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] (headers [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] and [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] libraries) [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] Android [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] NDK: [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] Please [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient] run [2014-02-26 15:56:16 - fgeclient] Unknown Application ABI: [2014-02-26 15:56:16 - fgeclient]…
tagged with: android-ndk
type: Question
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33522773
answer count: 1
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/33525217
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22100694
tagged with: c++
score: 1
tagged with: java

http://stackoverflow.com/q/22105859
tagged with: swing
downvote count: 1
tagged with: keyevent
tagged with: java
score: -1
has title: how can I trigger a JList when press @ in a JTable's row in swing?
type: Question
has answer: http://stackoverflow.com/a/22106021
answer count: 2
upvote count: 0
has answer: http://stackoverflow.com/a/22106002
tagged with: jtable
tagged with: jlist
has comment: http://stackoverflow.com/comment/33533741
favorite count: 0
has body: I need to trigger a JList with items when I press @ in a JTable's row in Swing, when the user selects an item the JList should disappear, anyone know how I can achieve this?
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33533604

http://stackoverflow.com/a/22096773
answers question: http://stackoverflow.com/q/22017075
score: 0
has body: After days of messing around with the persistence.xml I fortunately have found an oracle tutorial which guides to create a new JDBC connection pool and resource for glassfish server, to link the derby database. Having done it, all I needed to put inside the persistence.xml was the JTA data source. Here's a video where I have done it from the scratch, this time choosing a ClientDriver - http://www.youtube.com/watch?v=xBNB8L49ZQ4
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/22017075

http://stackoverflow.com/q/22164784
tagged with: java
type: Question
has title: NoClassDefFoundError - could not initialize class ...?
has answer: http://stackoverflow.com/a/48658456
has comment: http://stackoverflow.com/comment/33638357
tagged with: jar
has comment: http://stackoverflow.com/comment/33638149
answer count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33638383
has answer: http://stackoverflow.com/a/22165132
favorite count: 0
type: UnansweredQuestion
tagged with: maven
score: 2
has comment: http://stackoverflow.com/comment/33638175
upvote count: 2
has body: I am getting an error while writing my simple test program: package Xbee; import com.rapplogic.xbee.api.XBee; import com.rapplogic.xbee.api.XBeeException; public class XbeeTest { public static void main(String[] args) { // TODO Auto-generated method stub XBee xbee = new XBee(); try { xbee.open("COM22", 9600); } catch (XBeeException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } I am getting the following: java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class gnu.io.RXTXVersion at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:123) at com.rapplogic.xbee.RxTxSerialComm.openSerialPort(RxTxSerialComm.java:71) at com.rapplogic.xbee.RxTxSerialComm.openSerialPort(RxTxSerialComm.java:61) at com.rapplogic.xbee.api.XBee.open(XBee.java:140) at Xbee.XbeeTest.main(XbeeTest.java:14) The whole problem is that it cannot initialize the class gnu.io.RXTXversion, which is a prt of rtxtcomm.jar, which I have included in my Maven dependency: org.bidib.jbidib.org.qbang.rxtx rxtxcomm 2.2 Any ideas? Thanks.

http://stackoverflow.com/q/22104767
favorite count: 0
has title: Weird code collapse points in eclipse
upvote count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22104972
score: 1
tagged with: java
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33531303
type: Question
downvote count: 0
has body: Can only collapse seemingly random methods, bit annoying why is this?
accepted answer: http://stackoverflow.com/a/22104972
answer count: 1

http://stackoverflow.com/comment/33625092
score: 0
type: Comment
has text: It will work for this string, which is mixed case: `aBcDeDcBa`
comment on: http://stackoverflow.com/a/22157021
type: AnswerComment

http://stackoverflow.com/comment/33496662
has text: You may try to work this by using `Handler` and `Marker.showInfoWindow()`.
comment on: http://stackoverflow.com/q/22082278
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/22112789
answers question: http://stackoverflow.com/q/22112724
type: Answer
downvote count: 0
score: 1
has body: i don't believe its possible to get APKs via google play store on the emulator; hacking concerns... The google play app is only available to certain licensed manufacturers. See similar question here
upvote count: 1

http://stackoverflow.com/q/22142089
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22142110
has answer: http://stackoverflow.com/a/22142151
has answer: http://stackoverflow.com/a/22142110
score: 1
tagged with: java
upvote count: 1
has title: best practice for getting Map value from arguments in a method in java?
type: Question
has answer: http://stackoverflow.com/a/22142277
downvote count: 0
has comment: http://stackoverflow.com/comment/33598154
favorite count: 0
accepted answer: http://stackoverflow.com/a/22142277
answer count: 5
has answer: http://stackoverflow.com/a/22142132
has body: I want to pass a Map that contains key and value that is Listview, which of this 2 method is a good practice in getting the map from arguments Map&lt;String, List&lt;String&gt;&gt; mMap; public static void add(Map&lt;String, List&lt;String&gt; map) { mMap = map; // direct get and assign to map object } public static void add(Map&lt;String, List&lt;String&gt; map) { try { //Copies all of the mappings from the specified map to this map mMap.putAll(map); } catch (Exception e) { } } in the 2 method which is the right way in assigning the value of map argument to our new Map object?
tagged with: dictionary
has answer: http://stackoverflow.com/a/22142134
has comment: http://stackoverflow.com/comment/33597518

http://stackoverflow.com/a/22025275
accepted answer of: http://stackoverflow.com/q/22025161
downvote count: 0
has body: What is captured variable,what is its use and why is that needed? A captured variable is one that has been copied so it can be used in a nested class. The reason it has to be copied is the object may out live the current context. It has to be final (or effectively final in Java 8) so there is no confusion about whether changes to the variable will be seen (because they won't) Note: Groovy does have this rule and a change to the local variable can mean a change to the value in the enclosing class which is especially confusing if multiple threads are involved. An example of capture variable. public void writeToDataBase(final Object toWrite) { executor.submit(new Runnable() { public void run() { writeToDBNow(toWrite); } }); // if toWrite were mutable and you changed it now, what would happen !? } // after the method returns toWrite no longer exists for the this thread...
has comment: http://stackoverflow.com/comment/33389749
has comment: http://stackoverflow.com/comment/81556101
has comment: http://stackoverflow.com/comment/81539282
has comment: http://stackoverflow.com/comment/116347848
type: Answer
has comment: http://stackoverflow.com/comment/33389889
upvote count: 26
has comment: http://stackoverflow.com/comment/33389419
score: 26
has comment: http://stackoverflow.com/comment/33389706
has comment: http://stackoverflow.com/comment/33390644
answers question: http://stackoverflow.com/q/22025161
has comment: http://stackoverflow.com/comment/33388912
has comment: http://stackoverflow.com/comment/33389024
type: AcceptedAnswer

http://stackoverflow.com/a/22068594
score: 2
downvote count: 0
upvote count: 2
has body: I don't think the Metro JAXB RI extensions will let you do that. From the 2.2.7 documentation: 3.1.3. Extending a Common Super Class The &lt;xjc:superClass&gt; customization allows you to specify the fully qualified name of the Java class that is to be used as the super class of all the generated implementation classes. The &lt;xjc:superClass&gt; customization can only occur within your &lt;jaxb:globalBindings&gt; customization on the &lt;xs:schema&gt; element That said, the answer to XJC superinterface and superclass only for all classes? suggests that you may be able to do it with 3rd party extensions. There are some details about plugins in the documentation.
type: Answer
answers question: http://stackoverflow.com/q/22067129

http://stackoverflow.com/q/22041138
answer count: 1
has answer: http://stackoverflow.com/a/22041394
has body: I want to set the cache control header in Jersy response object. I tried similar to it but didnot work. The cache control still shows no cache in response. CacheControl cc = new CacheControl(); cc.setNoStore(true); cc.setNoCache(true); cc.setMustRevalidate(true); return Response.ok(pdf).cacheControl(cc).header("Pragma", "no-cache").build() ; Resposne still shows cache control Cache-Control no-cache Can some one tell how do we do that.
type: UnansweredQuestion
tagged with: java
type: Question
tagged with: jersey
has title: How to set cache control header in Jersy response
tagged with: http-headers
score: 0
tagged with: rest

http://stackoverflow.com/comment/33498039
type: QuestionComment
has text: Try looking up "kiosk mode"
comment on: http://stackoverflow.com/q/22086453
score: 0
type: Comment

http://stackoverflow.com/comment/72996109
has text: No need of throwing exception. Throwing exception leads to performance issue. Return a value based on condition and set response.setStatus() or modify response object as required. Finally 'return false' will ensure response is sent back to the client.
type: Comment
comment on: http://stackoverflow.com/a/22089742
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33543516
has text: Is JNA actually supported on RPI? It would also be useful to know if the native library can be loaded via System.loadLibrary().
comment on: http://stackoverflow.com/q/22103110
type: Comment
type: QuestionComment
score: 1

fractions
type: Tag
tags question: http://stackoverflow.com/q/22124892
tag name: fractions
tags question: http://stackoverflow.com/q/22124710

http://stackoverflow.com/comment/33936032
type: QuestionComment
type: Comment
has text: @user3366312 recalculating the data is not a problem, but I was afraid that the representation of your network might not fit into the main memory and that is something you cannot simply recalculate. However, big cartesian products should not pose a problem, because then you just need a node representing the catesian product, which caches the inputs and calculates the necessary values when required.
comment on: http://stackoverflow.com/q/22106121
score: 0

http://stackoverflow.com/q/22023222
possible better answer: http://stackoverflow.com/a/22023308
type: AnsweredQuestion
downvote count: 0
score: 1
has title: Java Android: BufferedInputStream to byte Array
favorite count: 0
has body: Has anyone an idea how to get a BufferedInputStream to a byte[] so that I can make a Bitmap of it? That's my Stream: BufferedInputStream stream = new BufferedInputStream(socket.getInputStream()); And that's my byte[]: byte[] bytes;
type: Question
answer count: 2
tagged with: android
linked to: http://stackoverflow.com/q/9994129
has answer: http://stackoverflow.com/a/22023272
tagged with: java
tagged with: stream
upvote count: 1
has answer: http://stackoverflow.com/a/22023308
tagged with: arrays
tagged with: bufferedinputstream
accepted answer: http://stackoverflow.com/a/22023272

http://stackoverflow.com/q/22012975
has answer: http://stackoverflow.com/a/22013033
accepted answer: http://stackoverflow.com/a/22013033
possible better answer: http://stackoverflow.com/a/22031324
downvote count: 0
has title: Unparseable date: "2014-02-24T00:54:12.417-06:00" in java
favorite count: 0
answer count: 4
type: AnsweredQuestion
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22031324
has answer: http://stackoverflow.com/a/22013360
has answer: http://stackoverflow.com/a/22013183
upvote count: 1
type: Question
tagged with: jakarta-ee
has body: I want to convert date: 2014-02-24T00:54:12.417-06:00 into IST format. Till far I did: String s = "2014-02-24T00:54:12.417-06:00"; DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"); Date d = formatter.parse(s); TimeZone tx=TimeZone.getTimeZone("Asia/Calcutta"); formatter.setTimeZone(tx); System.out.println("Formatted date in IST = " + formatter.format(d)); String istDateFormat = formatter.format(d); //Date da=formatter.format(d); return istDateFormat; But I am getting error: Unparseable date: "2014-02-24T00:54:12.417-06:00"

http://stackoverflow.com/comment/33403312
type: QuestionComment
comment on: http://stackoverflow.com/q/22033002
has text: Looks like buildBottomPanel() initializes method-local variables, while listener compares action source with object fields. You should review your actual code and if it looks exactly like the example, you should change buildBottomPanel() method to initialize object fields (by removing JRadioButton type declaration from greenButton, blueButton and cyanButton variables).
score: 0
type: Comment

http://stackoverflow.com/comment/33664999
score: 0
has text: If `x` was private then `t2` would legitimately not be able to see it?
type: Comment
comment on: http://stackoverflow.com/a/22164078
type: AnswerComment

http://stackoverflow.com/comment/33527780
score: 0
comment on: http://stackoverflow.com/q/22102881
type: QuestionComment
type: Comment
has text: So are you encrypting with your Python script then decrypting with your Java script always, or do encrypt/decrypt with both sometimes, etc.?

http://stackoverflow.com/a/22021856
type: Answer
answers question: http://stackoverflow.com/q/22021483
score: 0
has body: Answering your 1st question: What is the proper way to represent an array in xml? Please refere to: http://www.w3.org/2005/07/xml-schema-patterns.html#Vector

http://stackoverflow.com/comment/52401965
has text: You forgot to implement `equals()` and `hashcode()` in Person. Only consider field `id` when implementing it. That should solve your problem.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22031128
score: 0

http://stackoverflow.com/comment/33560462
has text: So let me reiterate. You have a set of patterns (a considerable amount of them, say `p`) that are of similar size (say `m`) and don't change often. You want to optimize the time to find occurences of any of those patterns in a given string of size `n`. Is that about correct? If yes, http://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_algorithm is exactly what you need. Basically you need an augmented DFA that remembers in its end states which patterns the end state corresponds to. With `O(p*m)` preprocessing you get `O(n)` search time per haystack string, which is optimal.
score: 0
comment on: http://stackoverflow.com/q/22120747
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22005681
answer count: 2
downvote count: 0
tagged with: jsp
accepted answer: http://stackoverflow.com/a/22372315
favorite count: 0
has body: we have a web application which now needs to call methods from jsp files. We previously used Tomcat6, so we took the following steps migrate to Tomcat 7 declare Servlet version 3 in web.xml expose the bean in our servlet.xml Now, accessing objects with getters and setters via {$bean.object} works fine, but method invocation via {$bean.method} throws the following error org.apache.jasper.JasperException: /WEB-INF/jsp/home.jspx (line: 15, column: 52) "${bean.method()}" contains invalid expression(s): de.odysseus.el.tree.TreeBuilderException: Error parsing '${bean.method()}': syntax error at position 29, encountered '(', expected '}' I read about other people having similiar issues (for example here). While the project depends on a multitude of external libraries, none of the metnioned servletcontainer-specific ones is in the /WEB-INF/lib folder. My questions are: How can I determine if a library is specific to an older version of Tomcat? Is there any other possible source for this error?
tagged with: tomcat7
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
has title: Tomcat 7 method invocation from JSPs
has answer: http://stackoverflow.com/a/22372315
type: Question
possible better answer: http://stackoverflow.com/a/22365553
tagged with: jstl
linked to: http://stackoverflow.com/q/4076601
has answer: http://stackoverflow.com/a/22365553

http://stackoverflow.com/q/22032483
type: AnsweredQuestion
tagged with: performance
upvote count: 5
tagged with: java
has comment: http://stackoverflow.com/comment/35043017
has answer: http://stackoverflow.com/a/42590374
type: Question
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/23071879
possible better answer: http://stackoverflow.com/a/42590374
has comment: http://stackoverflow.com/comment/35043021
has comment: http://stackoverflow.com/comment/35064400
has comment: http://stackoverflow.com/comment/35043007
has title: Arbitrary pre-set precision decimals (Almost like BigDecimal)
favorite count: 0
has body: I'm looking to have a java class that will hold a decimal value with an arbitrary pre-set precision. The class BigDecimal looks to be a good candidate as a starting point, but I want to able to limit the size of the decimal to whatever an end user decides. Literally speaking, the end user would specify a range in base 10 and I would allocate enough bytes to represent any number in that range. I was thinking of having a class that extends BigDecimal. In this class I would add the functions necessary to mimic a decimal within a pre-set range. My questions to the community are: Are there any libraries that already do this? Would extending BigDecimal be a reasonable thing to do?
accepted answer: http://stackoverflow.com/a/23071879
score: 5

http://stackoverflow.com/a/29020641
has comment: http://stackoverflow.com/comment/133827783
downvote count: 3
has comment: http://stackoverflow.com/comment/112519925
has comment: http://stackoverflow.com/comment/101473970
has comment: http://stackoverflow.com/comment/106362172
has body: I don't like the syntax particularly (it looks a little bit hacky...) but this is the most elegant solution I was able to find (it uses a custom JPQL query in the JPA repository class): @Query("select new com.foo.bar.entity.Document(d.docId, d.filename) from Document d where d.filterCol = ?1") List&lt;Document&gt; findDocumentsForListing(String filterValue); Then of course, you just have to provide a constructor for Document that accepts docId &amp; filename as constructor args.
has comment: http://stackoverflow.com/comment/64446568
has comment: http://stackoverflow.com/comment/87812616
type: Answer
has comment: http://stackoverflow.com/comment/47779738
has comment: http://stackoverflow.com/comment/138926143
has comment: http://stackoverflow.com/comment/68659960
score: 214
has comment: http://stackoverflow.com/comment/132101427
answers question: http://stackoverflow.com/q/22007341
has comment: http://stackoverflow.com/comment/68673633
has comment: http://stackoverflow.com/comment/87062698
upvote count: 217
has comment: http://stackoverflow.com/comment/136703133

ksoap2
type: Tag
tags question: http://stackoverflow.com/q/22148120
tags question: http://stackoverflow.com/q/22159596
tag name: ksoap2
tags question: http://stackoverflow.com/q/22137469

http://stackoverflow.com/comment/48609819
type: AnswerComment
has text: Yes, compareAndSwapLong to be exact. Take a look at the allocate method in MappedBusWriter.java
type: Comment
score: 0
comment on: http://stackoverflow.com/a/30141019

http://stackoverflow.com/a/22013955
answers question: http://stackoverflow.com/q/22013647
upvote count: 8
type: Answer
has body: Quoting from Lexical Translations: The longest possible translation is used at each step, even if the result does not ultimately make a correct program while another lexical translation would. Thus, the input characters a--b are tokenized (§3.5) as a, --, b, which is not part of any grammatically correct program, even though the tokenization a, -, -, b could be part of a grammatically correct program. This would explain why x=a+++b is parsed as x=(a++)+b On the other hand, a++++b is tokenized as a++, ++, b which causes an error.
score: 7
downvote count: 1
has comment: http://stackoverflow.com/comment/33375566
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22013647

http://stackoverflow.com/q/22009861
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22010010
accepted answer: http://stackoverflow.com/a/22010010
has comment: http://stackoverflow.com/comment/33360794
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/22010356
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/33360798
has title: How I can write to particular tag in XML?
tagged with: http://stackoverflow.com/tag/xml
favorite count: 0
possible better answer: http://stackoverflow.com/a/22010356
has comment: http://stackoverflow.com/comment/33361000
has body: I have such structure: <?xml version="1.0"?> Check title (Total posts,Total topics,Total members,Our newest member) -// I need to write here something//- Check login I need to write value in the first result tag, how can i do it?
type: AnsweredQuestion

http://stackoverflow.com/comment/33568352
has text: @Asher how much time did it take for you to have a solution and code it :). Just a curiosity nothing much
comment on: http://stackoverflow.com/q/22125086
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33608102
comment on: http://stackoverflow.com/q/22148184
type: Comment
has text: Post your logcat error message.
type: QuestionComment
score: 0

http://stackoverflow.com/a/22097006
answers question: http://stackoverflow.com/q/22095719
has body: The SERIALIZABLE transaction isolation certainly is the most certain way to achieve your goal but it could mean that performance will suffer. There is one option you have not considered and that is to build your own semaphore. You could create a static ConcurrentHashMap of items currently being processed and (at the start of each insert process - put a record and when done delete it. Then each Thread process could consult this semaphore before starting inserts.
accepted answer of: http://stackoverflow.com/q/22095719
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33720219
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/33574387

http://stackoverflow.com/q/22085552
has comment: http://stackoverflow.com/comment/33521710
score: 2
tagged with: beagleboneblack
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/31215670
tagged with: java
tagged with: unsatisfiedlinkerror
has comment: http://stackoverflow.com/comment/33707020
type: Question
has body: We are creating a runnable java jar to run on a beagle bone black(running ubuntu). We have created a runnable jar which runs fine on our mac and pc(windows) but will not run on the ubuntu system. We keep getting the following error when running: Exception in thread "main" java.lang.reflect.InvocationTargetException 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 org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58) Caused by: java.lang.UnsatisfiedLinkError: /home/ubuntu/.jssc/linux/libjSSC-2.6_armhf.so: /home/ubuntu/.jssc/linux/libjSSC-2.6_armhf.so: cannot open shared object file: No such file or directory at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1851) at java.lang.Runtime.load0(Runtime.java:795) at java.lang.System.load(System.java:1062) at jssc.SerialNativeInterface.&lt;clinit&gt;(SerialNativeInterface.java:172) at jssc.SerialPort.&lt;init&gt;(SerialPort.java:118) at InputBoard.&lt;init&gt;(InputBoard.java:33) at InputBoard.main(InputBoard.java:22) ... 5 more Any information would be greatly appreciated. As I said this runs fine through terminal on a mac which is unix based so it seems it should work on Ubuntu. We have no idea why it is referencing the /home/ubuntu directory. Please let us know if you need any code information on the project but I would not think it would be related.
has title: unsatisfied link error runnable jar referencing jssc library
tagged with: jar
tagged with: ubuntu
accepted answer: http://stackoverflow.com/a/31215670
answer count: 3
downvote count: 0
linked to: http://stackoverflow.com/q/661320
possible better answer: http://stackoverflow.com/a/23386412
has answer: http://stackoverflow.com/a/34958087
favorite count: 0
has answer: http://stackoverflow.com/a/23386412
has comment: http://stackoverflow.com/comment/33762253
upvote count: 2

http://stackoverflow.com/comment/33596212
comment on: http://stackoverflow.com/a/22141194
type: AnswerComment
score: 0
type: Comment
has text: the code for the conversions is or was ok before started messing with the testing. I can fix any of that it is the @test stuff that I am stumped with

http://stackoverflow.com/q/22019057
has answer: http://stackoverflow.com/a/22019277
has comment: http://stackoverflow.com/comment/33377189
score: 0
answer count: 3
has body: I need to execute a shell script in a java program. I figured out that i can use processbuilder and runtime.exec.. but my webserver times out every 180 sec but my script execution takes more than that..i do not want to use process for this approach.. is there any other way where i can use thread for this execution. thanks.
has answer: http://stackoverflow.com/a/22020946
tagged with: shell
favorite count: 0
has comment: http://stackoverflow.com/comment/33377017
upvote count: 1
type: AnsweredQuestion
has title: Executing a shell script in java as a thread
accepted answer: http://stackoverflow.com/a/22020946
tagged with: java
downvote count: 1
type: Question
possible better answer: http://stackoverflow.com/a/22019277
has answer: http://stackoverflow.com/a/22019343

http://stackoverflow.com/a/25781380
answers question: http://stackoverflow.com/q/22034583
upvote count: 1
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22034583
has body: Below is Qlickview Data validation code used under selenium using Java Step 1. Locate the qlikview frame. driver.switchTo().frame(driver.findElement(By.className("report_iframe_test"))); Step 2. Go to html element present under qlikview frame which is displayed after inspecting element using the IE developer tool driver.findElement(By.id("PageContainer_test")); driver.findElement(By.id("MainContainer_test")); after locating the element present on qlikview, ex. from highlights section String id = driver.findElement(By.id("32_test")).getText(); System.out.println("after frame--"+id); sysout will print report element value which we can compare against database so as to do data validation.
type: Answer
score: 1

http://stackoverflow.com/a/22121066
answers question: http://stackoverflow.com/q/22120747
has comment: http://stackoverflow.com/comment/33560270
type: Answer
score: 1
has body: I don't know Korean so I imagine the same strategies used to tinker with Strings in Korean isn't necessarily possible in the way it is with English, but perhaps this strategy in pseudocode can be applied with your knowledge of Korean to make it work. (Java is of course still the same, but for example, in Korean is it still highly likely for the letters "ough" to be in succession? Are there even letters for "ough"? But with that being said, hopefully the principle can be applied I would use String.toCharArray to create a two-dimensional array (or ArrayList if variable size needed). The if (first letter of word matches keyword's first letter)//we have a candidate skip to last letter of the current word //see comment below if(last letter of word matches keyword's last letter)//strong candidate iterate backwards to start+1 checking remainder of letters The reason I suggest to skip to the last letter is because statistically a "consonant, vowel" for the first two letters of a word is significantly high, especially nouns, which will consist of alot of your keywords since any food is a noun (almost all the keyword examples you gave were matched that structure of consonant, vowel). And since there are only 5 vowels(plus y), the likelihood of the second letter "i" showing up in the keyword "pizza" is inherently highly likely, yet after that point there is still a good chance that the word may turn out to not be a match. However if you know that the first letter and the last letter match, then you probably have a much stronger candidate and can then iterate in reverse. I think over larger sets of data, this would eliminate candidates much faster than checking letters in order. Basically you'd be letting too many fake candidates past the second iteration, thus increasing your overall conditional operations. It might sound like something small, but in a project like this there's lots of reiterating, so micro-optimizations will accumulate very quickly. If this approach can be ap…
upvote count: 1
downvote count: 0

http://stackoverflow.com/q/22083547
has comment: http://stackoverflow.com/comment/36641656
tagged with: android
answer count: 0
tagged with: java
downvote count: 1
has comment: http://stackoverflow.com/comment/36796558
type: Question
has comment: http://stackoverflow.com/comment/73135252
has comment: http://stackoverflow.com/comment/56358641
score: 7
tagged with: ssl
has comment: http://stackoverflow.com/comment/36791286
linked to: http://stackoverflow.com/q/16719959
tagged with: self-signed
has body: EDITTED: "The code below works fine, no errors, no exceptions" I'm aware of the grand amount of questions in regards to this topic, as well as the many blogs that google conjures up. I have read through them and have managed to come up with what I'm about to explain. My doubt lies in "is my approach correct? Does it have any side-effects?" and another question that is better asked as I explain my method. I based this approach following this Android.Developres tutorial. System.setProperty("jsse.enableSNIExtension", "false"); //Java 7 introduced SNI (enabled by default). The server I use is // misconfigured I suppose and // it sends an "Unrecognized Name" warning in the SSL handshake // which breaks my web service. // Load CA from an InputStream (CA would be saved in Raw file, // and loaded as a raw resource) CertificateFactory cf = CertificateFactory.getInstance("X.509"); InputStream caInput = new BufferedInputStream(new FileInputStream("PATH_TO_CERT.crt")); Certificate ca; try { ca = cf.generateCertificate(caInput); } finally { caInput.close(); } // Create a KeyStore containing our trusted CAs String keyStoreType = KeyStore.getDefaultType(); KeyStore keyStore = KeyStore.getInstance(keyStoreType); keyStore.load(null, null); keyStore.setCertificateEntry("ca", ca); // Create a TrustManager that trusts the CAs in our KeyStore String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm(); TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm); tmf.init(keyStore); // Create an SSLContext that uses our TrustManager SSLContext context = SSLContext.getInstance("TLS"); context.init(null, tmf.getTrustManagers(), null); // Create all-trusting host name verifier // to avoid the following : // java.security.cert.CertificateException: No name matching // This is because Java by default verifies that the certificate CN (Common Name) is // the same as host name in the URL. If they are not, the web service client fails. HostnameVerifier allHostsValid = new Hostname…
favorite count: 0
has comment: http://stackoverflow.com/comment/33524812
has comment: http://stackoverflow.com/comment/36815743
has title: Android connect to server with selfsigned certificate
upvote count: 8
has comment: http://stackoverflow.com/comment/33536535
type: UnansweredQuestion

http://stackoverflow.com/q/22089954
tagged with: string
has answer: http://stackoverflow.com/a/22090070
favorite count: 0
has answer: http://stackoverflow.com/a/22089994
upvote count: 1
has body: How do I convert the following String to a Person object ? String content: String testString = "John|23;Ron|22;Don|32" Person class: public class Person{ private String name; private String age; //getters and setters for name and age } Is there any utility class to convert the testString to Person objects based on the delimiters ";" and "|"
answer count: 4
accepted answer: http://stackoverflow.com/a/22090070
has comment: http://stackoverflow.com/comment/33503978
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22089972
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33503991
has answer: http://stackoverflow.com/a/22090170
possible better answer: http://stackoverflow.com/a/22089972
type: Question
downvote count: 0
has title: String to Java object

http://stackoverflow.com/q/22020915
favorite count: 0
tagged with: multithreading
upvote count: 1
answer count: 1
has title: using semaphores for a traffic synchronization
tagged with: semaphore
tagged with: java
has answer: http://stackoverflow.com/a/22061644
has comment: http://stackoverflow.com/comment/33380842
downvote count: 0
type: UnansweredQuestion
score: 1
type: Question
has comment: http://stackoverflow.com/comment/33381583
tagged with: java-7
has body: I am trying to code for a traffic synchronization problem. My approach is : i am dividing the square for the traffic into 4 quadrants and I have implemented 4 threads for east-west-north-south directions from which a vehicle might approach the square. Any vehicle approaching the square will get an exclusive lock on the quadrant and others will wait till this vehicle passes the square. I am using semaphores for the solution. Pasting my code here : This is my main class : public class MainClass { public static void main(String[] args) { MyThreadClass t1 = new MyThreadClass(); Thread east = new Thread(t1, "east"); Thread west = new Thread(t1, "west"); Thread north = new Thread(t1, "north"); Thread south = new Thread(t1, "south"); east.start(); west.start(); north.start(); south.start(); }} and other file which implements semaphore is : import java.util.concurrent.Semaphore; public class MyThreadClass implements Runnable { Semaphore s = new Semaphore(1, true); String direction[] = {"left", "straight", "right"}; @Override public void run() { // TODO Auto-generated method stub int dirNo = generateRamdomNumberForDirection(); String directionSelected = direction[dirNo]; try { s.acquire(); getLock(directionSelected , Thread.currentThread().getName()); s.release(); } catch(Exception e){ } //getLock(directionSelected); } private int generateRamdomNumberForDirection() { int Min = 0; int Max = direction.length; return Min + (int)(Math.random() * ((Max - Min) )); } private synchronized void getLock(String dir , String threadName) { switch(Thread.currentThread().getName()) { case "east": if (dir.equals(direction[0])) { System.out.println("lock on north east, north west and south west quadrant by east thread"); } break; //TO BE IMPLEMENTED case "west":break; case "north":break; case "south":break; } } } Now my problem is I am getting a lock on all the 4 quadrants. I cannot find a solution if the vehicle wants to go straight. In that case only 2 quadrants will need a lock and a thre…

http://stackoverflow.com/a/22016821
type: Answer
answers question: http://stackoverflow.com/q/22016766
score: 1
accepted answer of: http://stackoverflow.com/q/22016766
upvote count: 1
has body: Try this if (askForOperation.equals("+")) { sum = num1 + num2; JOptionPane.showMessageDialog(null, "The result of the Addition is " + sum); } To avoid any Nullpointer exception, in any case do this, final String plus = "+"; if (plus.equals(askForOperation)) { sum = num1 + num2; JOptionPane.showMessageDialog(null, "The result of the Addition is " + sum); }
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/33644657
type: Comment
score: 0
type: AnswerComment
has text: @T.J.Crowder Hmmm My fault. Sorry then :) I will not delete the question for if its helpful to someone in the future.
comment on: http://stackoverflow.com/a/22168367

http://stackoverflow.com/q/22168275
score: 0
has comment: http://stackoverflow.com/comment/33644567
has body: Let's say I'm using a transformation method that takes a Collection and a Function object, such as the one in Guava's Collections2. I pass an anonymous Function implementation defined inline in the parameter list. Is there any justifiable reason for caching the Function instance if this transformation is used a large amount of times? Would it make a sufficiently significant difference to outweigh the reduced readability from separating definition and use of the Function?
has title: Should Function objects be cached?
has comment: http://stackoverflow.com/comment/33644322
answer count: 0
type: UnansweredQuestion
type: Question
tagged with: instantiation
tagged with: performance
tagged with: java

http://stackoverflow.com/comment/33528205
has text: You need to show us how you're defining `compareTo` in `DateAD`.
score: 0
comment on: http://stackoverflow.com/q/22103223
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22112344
has comment: http://stackoverflow.com/comment/33545452
type: Answer
has comment: http://stackoverflow.com/comment/33545418
has comment: http://stackoverflow.com/comment/33545385
has body: You can only modify files located on SDCard type, public storage. Whether real or emulated. Are you trying to modify files from the Internal storage? You need root permissions for changing anything outside your app's default data directories on the Internal Storage. Since I now know that you are attempting to delete directories I assume that you are trying to delete directories that contain files. You should recursively delete the directory's contents before deleting the directory itself. See this question for how to go about that: https://stackoverflow.com/a/4026761/1590950
has comment: http://stackoverflow.com/comment/33544570
upvote count: 3
score: 3
has comment: http://stackoverflow.com/comment/33544858
has comment: http://stackoverflow.com/comment/33544541
has comment: http://stackoverflow.com/comment/33545016
has comment: http://stackoverflow.com/comment/33544613
has comment: http://stackoverflow.com/comment/33544928
has comment: http://stackoverflow.com/comment/33544752
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22112308
has comment: http://stackoverflow.com/comment/33545469
answers question: http://stackoverflow.com/q/22112308

http://stackoverflow.com/comment/91852819
score: 0
type: Comment
has text: Works like a charm for a Spring boot application though. No need to install any tomcat plugins with this approach. In fact, none of the tomcat plugins mentioned in other answers worked for me for a spring boot app.
type: AnswerComment
comment on: http://stackoverflow.com/a/41086974

http://stackoverflow.com/a/22054317
has comment: http://stackoverflow.com/comment/33440573
score: 1
accepted answer of: http://stackoverflow.com/q/22054028
has comment: http://stackoverflow.com/comment/33440760
upvote count: 2
answers question: http://stackoverflow.com/q/22054028
type: AcceptedAnswer
downvote count: 1
has body: Ok, time to learn Regular Expression or RegEx. So that the you if statement would be: if (userInput.matches(".*[bcdfghjklmnpqrstvwxyz].*")) results += "The input contains consonants"; else results += "The input contains no consonants"; For more read the this tutorial Java Regex - Tutorial
type: Answer

http://stackoverflow.com/comment/33628891
score: 0
type: AnswerComment
type: Comment
has text: Thanks! I replaced setName() with setText(), ScrollPane with JScrollPane and revalidate() since it was no longer needed. However, I still have no idea how to make JLabel hold all selected countries in the list. I have tried: `countryLabel.setText(countryLabel.getText()+" "+countries[indices[i]]);` but obviously it didn't work.
comment on: http://stackoverflow.com/a/22159116

http://stackoverflow.com/comment/33473408
type: Comment
comment on: http://stackoverflow.com/a/22069987
type: AnswerComment
score: 1
has text: Yes. Both ways work, it's up to you; you could also avoid having all that variables, pointing directly to the list of entities, or to a list of DTO.

http://stackoverflow.com/a/22096392
accepted answer of: http://stackoverflow.com/q/22096307
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/33515499
has body: The argument you need to pass to KnowledgeBaseHelper constructor is a Context. An Activity is-a Context so you can use this in an activity. A Fragment isn't a Context so you cannot use this in a fragment. You can use getActivity() in a fragment to get a reference to the hosting activity (which is -a Context).
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22096307
downvote count: 0
has comment: http://stackoverflow.com/comment/33515189
type: Answer

mergesort
tags question: http://stackoverflow.com/q/22079031
tags question: http://stackoverflow.com/q/22052457
tag name: mergesort
type: Tag
tags question: http://stackoverflow.com/q/22049705
tags question: http://stackoverflow.com/q/22109506

http://stackoverflow.com/a/22140411
score: 0
has comment: http://stackoverflow.com/comment/33594873
type: Answer
answers question: http://stackoverflow.com/q/22140023
has comment: http://stackoverflow.com/comment/33594966
has body: What you need is flushing your output stream after sending message by: output.flush(); or use auto flush by passing true while creating Output Stream like this: PrintWriter output = new PrintWriter(out, true); Hope this helps
has comment: http://stackoverflow.com/comment/33594848
has comment: http://stackoverflow.com/comment/33595792

http://stackoverflow.com/comment/33548201
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22114102
type: AnswerComment
has text: @user1282256 I don't see you extending `Comparator<Shoe>` anywhere in your code.

http://stackoverflow.com/q/22076597
answer count: 2
tagged with: layout
score: 0
has answer: http://stackoverflow.com/a/22076935
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22076834
tagged with: panels
has body: I am trying to design an interface with 4 different panels in 1 single frame. I have included 2 of the panel descriptions in the code I included below. Below is part of my code: public class finalFrame extends JFrame { PanelA a = new PanelA() PanelB b = new PanelB() // ... public finalFrame() { super(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //... //... //... add(a); add(b); } } class PanelA extends JPanel { JButton bt = new JButton(); add(bt); //... } class PanelB extends JPanel { // ... //... } class Program { public static void main(String [] args) { finalFrame fr = new finalFrame(); } } This code doesn't seem to work (it only displays the last panel at an odd size (Not what I wanted)). Yet, when I set up the different panels WITHIN the frame class (and not individual panel classes), it works perfectly. Why can't I use different panel classes and then just add them all to the final Frame class afterwards? Furthermore (sorry for all the questions), if I include the panel set up within the frame class and include a frame layout, then it works (as I just mentioned). However, if I include the panel set up within the frame class but I DON'T include a frame layout, then it only displays the last panel using the frame layout. Why isn't it portraying any of the other panels?? Thank you!!
tagged with: java
has title: Four Panel in Frame with Different Layout
type: Question

http://stackoverflow.com/comment/33530372
type: Comment
type: QuestionComment
has text: Excuse my nascent/verbose sentences. Ideally, I am hoping that if the user enters a char, string, double, etc., the program will not crash, but instead alert the user that he/she has inputted an invalid response, and then ask them to try again.
score: 0
comment on: http://stackoverflow.com/q/22104364

drawing
tags question: http://stackoverflow.com/q/22091499
type: Tag
tag name: drawing
tags question: http://stackoverflow.com/q/22120843
tags question: http://stackoverflow.com/q/22133993

http://stackoverflow.com/comment/33589796
type: AnswerComment
comment on: http://stackoverflow.com/a/22135915
score: 0
type: Comment
has text: Is there a way to so this while keeping the original signature on the method?

http://stackoverflow.com/q/22104759
score: 0
has title: LoggerFactory ArrayUtils Random
tagged with: encode
has body: this one does not fly for me: http://pastebin.com/Mctnidng It was elaborated in this forum under a different thread. I've divided it into two files AlphabetHelper.java AlphabetHelperTest.java java -version java version "1.6.0_18" Java(TM) SE Runtime Environment (build 1.6.0_18-b07) Java HotSpot(TM) Server VM (build 16.0-b13, mixed mode) javac -version javac 1.6.0_18 on attempt to compile I included some import java.util.Random; import java.util.logging.Logger; import java.util.List; import java.math.BigInteger; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; But it does not take of. I assume there must be some other Java distribution out there, apache or android. The code however looks quite good, how can I get to run on my Java 1.6? Most oder Java sourcode works fine on my machine. javac -Xlint AlphabetHelper.java AlphabetHelper.java:41: cannot find symbol symbol : variable ArrayUtils location: class AlphabetHelper ArrayUtils.toObject( ^ javac -Xlint AlphabetHelperTest.java AlphabetHelperTest.java:5: cannot find symbol symbol : class Random location: class AlphabetHelperTest private Random random; ^ AlphabetHelperTest.java:8: cannot find symbol symbol : class Logger location: class AlphabetHelperTest private static final Logger LOG = LoggerFactory.getLogger(AlphabetHelperTest.class); ^ it is all about this file http://pastebin.com/Mctnidng to be compiled tested and deployed on Java 1.6 Sincerely,
answer count: 0
type: UnansweredQuestion
tagged with: utf
linked to: http://stackoverflow.com/q/2863954
has comment: http://stackoverflow.com/comment/33531722
has comment: http://stackoverflow.com/comment/33532264
tagged with: java
tagged with: alphabet
type: Question
has comment: http://stackoverflow.com/comment/33579507
tagged with: string

http://stackoverflow.com/comment/33618426
type: QuestionComment
type: Comment
has text: What is `j` and why do you need `j==0`?
score: 1
comment on: http://stackoverflow.com/q/22153647

http://stackoverflow.com/comment/33389006
comment on: http://stackoverflow.com/a/22025375
score: 0
type: AnswerComment
type: Comment
has text: I already tried that and it does not work. What error are you getting?

http://stackoverflow.com/comment/33926329
type: Comment
has text: No, this is substituted by the actual company name :)
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22166762

http://stackoverflow.com/comment/33616155
comment on: http://stackoverflow.com/a/22124239
type: Comment
has text: I have just tu run the code and it work well with <p:menuBar/> but not with <p:panelMenu/> the first item named "accueil" shows in menubar but not shows in panelmenu. Any suggestion?? It's a bug in panelMenu?
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33510550
has text: You don't need jRebel for *Hot Swap*. The fact that an application is running on server is irrelevant.
type: Comment
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/22093619

http://stackoverflow.com/q/22057438
has comment: http://stackoverflow.com/comment/33448994
tagged with: string
favorite count: 0
downvote count: 2
upvote count: 1
has comment: http://stackoverflow.com/comment/33446088
type: AnsweredQuestion
has title: pairing the data in two seperate strings in Java
has answer: http://stackoverflow.com/a/22058736
tagged with: java
type: Question
has body: In this class I have two Strings. I want to pair the ordered int with the planet associated with it. the moons and each planet are in order with each other. Am I pairing them correctly? If not please show me how this would be done. public class Planet { int moons; String planets; Planet(int moons, String planets) { this.moons = moons; this.planets = planets; } private String planets ( String s ) { String[] planets = {"Mercury moons = ", "Venus moons = ", "Earth moons = ", "Mars moons = ", "Jupiter moons = ", "Saturn moons = ", "Uranus moons = ", "Neptune moons = ", "Pluto moons = " }; return s; } private int moons ( int i ) { int[] moons = {0, 0, 1, 2, 67, 62, 27, 14, 5}; return i; } }
answer count: 1
has comment: http://stackoverflow.com/comment/33446083
score: -1
accepted answer: http://stackoverflow.com/a/22058736

http://stackoverflow.com/a/22066547
type: Answer
has comment: http://stackoverflow.com/comment/33477607
has comment: http://stackoverflow.com/comment/33472054
score: 0
answers question: http://stackoverflow.com/q/22062429
has body: You're not showing any code, so it's hard to know what you are actually doing. Based on your description, it sounds like you are placing the payload at where the cursor is rather than moving it the same offset as the cursor moved since you started dragging. Assuming you're using an ActorGestureListener, this is what I do in my app. float touchX, touchY; public void touchDown(InputEvent ev, float x, float y, int pointer, int button) { touchX = x; touchY = y; ... } public void pan(InputEvent ev, float x, float y, float dx, float dy) { moveBy(x - touchX, y - touchY); ... } This way you are moving your actor by the same amount as the mouse cursor moved, so it's like the pointer "glued" itself to whereever you touched your actor. Also, I believe the events in libgdx makes it so that you will not receive the pan events until the cursor has moved a bit inside your actor, so be aware of that when testing (moving the cursor a few pixels only will not trigger the pan events).

http://stackoverflow.com/comment/33383753
type: Comment
has text: It has some calculations over the differents attributes It only reads information, though.
comment on: http://stackoverflow.com/a/22022165
score: 0
type: AnswerComment

http://stackoverflow.com/q/22080851
has comment: http://stackoverflow.com/comment/33488367
type: AnsweredQuestion
score: 3
possible better answer: http://stackoverflow.com/a/31138626
has comment: http://stackoverflow.com/comment/33488439
tagged with: java
has answer: http://stackoverflow.com/a/31138626
has comment: http://stackoverflow.com/comment/33488187
type: Question
tagged with: r.java-file
answer count: 2
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/33488516
has comment: http://stackoverflow.com/comment/33488331
has answer: http://stackoverflow.com/a/22081187
has comment: http://stackoverflow.com/comment/33488208
has comment: http://stackoverflow.com/comment/33488101
tagged with: android
has comment: http://stackoverflow.com/comment/33488242
has comment: http://stackoverflow.com/comment/33488198
has title: Why when I create a new activity, "setContentView" not recognize my layout?
has body: I just created a new activity (project-> new-> android activity) and I get an error where the R file, which does not recognize the layout created by the activity. I use Ubuntu 13.10 (64 bits) public class OrderKaraokeActivity extends SherlockActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_order_karaoke); } } activity_order_karaoke: &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: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=".OrderKaraokeActivity" &gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /&gt; &lt;/RelativeLayout&gt; Console: Description Resource Path Location Type activity_order_karaoke cannot be resolved or is not a field OrderKaraokeActivity.java /src/com/example/adicionalesprueba line 18 Java Problem Import: Console problem:
upvote count: 3
has comment: http://stackoverflow.com/comment/33488409
accepted answer: http://stackoverflow.com/a/22081187

http://stackoverflow.com/comment/33374110
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/22017232
has text: yeah just now tried by placing it first...Same problem

http://stackoverflow.com/comment/33529764
score: 0
type: Comment
has text: Yes. To be clear for a novice, the loop will need to call Department's copy constructor.
comment on: http://stackoverflow.com/a/22103897
type: AnswerComment

http://stackoverflow.com/q/22091656
upvote count: 2
has title: Contents in a new page while creating PDF using xmlworker
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22093406
tagged with: java
tagged with: itext
tagged with: xmlworker
type: Question
score: 2
answer count: 1
downvote count: 0
accepted answer: http://stackoverflow.com/a/22093406
has body: I am creating PDF using Itext and xmlworker. My problem is I want to create the contents in new pages. Below is my code. File file = new File("D:/PDFFiles/Sathesh.pdf"); FileOutputStream fos=new FileOutputStream(file); Document doc=new Document(PageSize.A4, 50, 50, 70, 70); PdfWriter pdfWriter=PdfWriter.getInstance(doc, fos); doc.open(); XMLWorkerHelper worker=XMLWorkerHelper.getInstance(); String firstString=" First Page " ; String secondString=" Second Page " ; String final=firstString+secondString; ByteArrayInputStream is = new ByteArrayInputStream(final.getBytes()); worker.parseXHtml(pdfWriter, doc, is); doc.close(); fos.close(); I want the firstString in first page and secondString in page. Waiting for your answer.
tagged with: http://stackoverflow.com/tag/pdf
favorite count: 0

http://stackoverflow.com/comment/33385240
type: Comment
comment on: http://stackoverflow.com/a/22023272
has text: So just; byte[] bytes = BitmapFactory.decodeStream(stream);?
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33504211
type: Comment
score: 0
has text: i am using testNG framework . and above code is just to verify if the data in the text box is same as what it is in excel sheet . my question is if it is same it will show data verification pass . if its's not same i want the test case to stop there itself and show the test is failed so that i can see where it is failing ... if i use the above code .the testNG report it is showing the test case is passed
comment on: http://stackoverflow.com/a/22089334
type: AnswerComment

http://stackoverflow.com/comment/33515728
type: Comment
type: AnswerComment
has text: For example http://hortonworks.com/products/hortonworks-sandbox/#tutorial_gallery and http://hortonworks.com/hadoop-tutorial/loading-data-into-the-hortonworks-sandbox/
comment on: http://stackoverflow.com/a/22096469
score: 0

onclicklistener
tag name: onclicklistener
tags question: http://stackoverflow.com/q/22156214
tags question: http://stackoverflow.com/q/22164674
tags question: http://stackoverflow.com/q/22053113
tags question: http://stackoverflow.com/q/22156845
type: Tag

http://stackoverflow.com/comment/33557170
comment on: http://stackoverflow.com/q/22119237
has text: I see no difference between these implementations. The static fields are initialized at the same time as static blocks are executed (on class load).
type: Comment
type: QuestionComment
score: 2

http://stackoverflow.com/comment/33518943
comment on: http://stackoverflow.com/a/22090555
type: AnswerComment
has text: When declaring my class, I need to write `extends org.apache.tomcat.websocket.server.DefaultServerEndpointConfigurator`, if I want to use its methods via `super()` - therefore it _is_ container dependent.
score: 0
type: Comment

http://stackoverflow.com/comment/33449120
type: AnswerComment
comment on: http://stackoverflow.com/a/22059038
type: Comment
has text: Honestly I think he just needs to redo some of this code and break it up into some methods.
score: 1

http://stackoverflow.com/a/22087759
answers question: http://stackoverflow.com/q/22017592
score: 1
upvote count: 1
has body: I think setting a background image in JLabel and then adding buttons even after adding containers is a very complex issue. Believe me tried it and it was a very complex task. you can do it by directly drawing as Hovercraft suggested, but remember you would get not so much good image quality with that method. :-|
downvote count: 0
type: Answer

http://stackoverflow.com/comment/33722661
type: AnswerComment
type: Comment
has text: This is actually EXACTLY what I needed. I should have specified what that `for()` loop did. I did try setting d=1 soon after I posted this, although didn't update it. It would be nice if I didn't use silly web compilers (iPad), because it still never returned a result.
comment on: http://stackoverflow.com/a/22161239
score: 0

http://stackoverflow.com/comment/33503436
type: Comment
comment on: http://stackoverflow.com/a/22089519
has text: You were right, but now I'm puzzled why this is a feature. What is the value in rendering Build Path order in the Package Explorer? Is there some subtle use besides seeing the files in my Package Explorer that I'm missing?
score: 0
type: AnswerComment

http://stackoverflow.com/a/22158712
score: 0
answers question: http://stackoverflow.com/q/22158613
has body: You need to define .toString() method in your Dog class and make it override the default .toString() method of Object class. public class Dog { String name; String age; String race; @Override public String toString() { return String.format("Name: %s, Age: %s, Race: %s", name, age, race); } } Then you can simply call System.out.println(dog) for each element of the array and your custom text defined in dog's .toString() method will be displayed.
type: Answer

http://stackoverflow.com/a/22021403
upvote count: 1
accepted answer of: http://stackoverflow.com/q/22020758
downvote count: 0
has comment: http://stackoverflow.com/comment/33437999
answers question: http://stackoverflow.com/q/22020758
type: Answer
has comment: http://stackoverflow.com/comment/33532695
score: 1
has comment: http://stackoverflow.com/comment/33455965
type: AcceptedAnswer
has body: I think that the behavior you see is how it should be. Sessions should not be kept open for a long time (so closing after getting the property would be correct in your test case) and if so, a session refresh is the correct way. Especially when targeting oak, see http://jackrabbit.apache.org/oak/docs/differences.html.

http://stackoverflow.com/q/22133073
score: 0
tagged with: java
tagged with: hibernate
has answer: http://stackoverflow.com/a/22152194
type: Question
tagged with: hibernate-search
tagged with: lucene
answer count: 1
accepted answer: http://stackoverflow.com/a/22152194
has body: I am using Hibernate Search to search for titles of tv shows on my web app. I can use the method fuzzy() on keyword() in order to perfom fuzzy searches on keywords, but I need to take into account the whole title, so I am using phrase() instead of keyword(). The method fuzzy() is not defined for phrase(), so I was wondering if there is an easy way to achieve fuzzy searches on phrases using Hibernate Search.
has title: Fuzzy search on a phrase using Hibernate Search
type: AnsweredQuestion

http://stackoverflow.com/a/22045469
has comment: http://stackoverflow.com/comment/33425325
accepted answer of: http://stackoverflow.com/q/22041915
downvote count: 0
answers question: http://stackoverflow.com/q/22041915
score: 4
has comment: http://stackoverflow.com/comment/33424834
has body: My problem is that the textfields are too long and go out of bounds. I wasn't able to reproduce the issue based on the code you've posted. Maybe there's something else I'm not seeing that causes this behaviour. I actually wanted to align the FREIGHT DETAILS &amp; SALES DETAILS in parallel, separated using a vertical line. Even when working with third-party layout managers such as DesignGridLayout you can follow a Nested Layout approach using JPanel's to group Freight details and Sales detail components. About the vertical separator, don't think it's possible with DesignGridLayout. While you can have components spanning several rows it doesn't work with JSeparator. Please help me with code to do all this, so that my form looks neat and is fully visible. StackOverflow is not a code factory so in most cases people won't do your job for you but they can provide useful examples. However as I've had to copy all your code to test it and I've made some changes using nested layouts approach, I'll make an exception here. Hope it be helpful: import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSeparator; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.table.DefaultTableModel; import net.java.dev.designgridlayout.DesignGridLayout; public class Demo { private void createAndShowGUI() { JLabel i5l1 = new JLabel("FREIGHT DETAILS"); JLabel i5l2 = new JLabel("Date : "); JLabel i5l3 = new JLabel("Vehicle No. : "); JLabel i5l4 = new JLabel("From : "); JLabel i5l5 = new JLabel("Item : "); JLabel i5l6 = new JLabel("Quantity : "); JLabel i5l7 = new JLabel("Kg."); JLabel i5l8 = new JLabel("Rate : Rs."); JLabel i5l15 = new JLabel("SALE DETAILS"); JLabel i5l16 = new JLabel("Cash Sales : Rs. "); JLabel i5l17 = new JLabel("Credit : Rs. "); JLabel i5l18 = new JL…
type: AcceptedAnswer
type: Answer
upvote count: 4

http://stackoverflow.com/comment/33630218
type: Comment
has text: So could you make something like this: `int [][] derparray = new int [][4];`
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22160025

http://stackoverflow.com/comment/33539516
type: Comment
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/22109357
has text: Where's the lock in your code? A vector is not a concurrent structure.

http://stackoverflow.com/q/22115419
tagged with: visible
answer count: 0
score: 1
tagged with: java
has title: how to get a jTable focused that is inside a jWindow?
upvote count: 1
has body: Here's my code... private void cdescKeyReleased(java.awt.event.KeyEvent evt) { if (evt.getKeyCode() == 40 | evt.getKeyCode() == 38) { jWindow2.requestFocusInWindow(); selectitemstable.requestFocusInWindow(); selectitemstable.requestFocus(true); } } What I wanna do is that when I press Up or down arrow keys, I want jWindow2 that has the jTable inside to be visible and to focus to the jTable so I can navigate it using the keyboard? my jTable is inside the Other Components and jWindow1 is an object that I created manually. My JFrame has a Free Design layout....
has comment: http://stackoverflow.com/comment/33550545
type: Question
has comment: http://stackoverflow.com/comment/33550281
tagged with: jwindow
has comment: http://stackoverflow.com/comment/33550126
tagged with: jtable
has comment: http://stackoverflow.com/comment/33550945
downvote count: 0
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33550020

http://stackoverflow.com/comment/33428226
has text: I added the RegisterAction.
comment on: http://stackoverflow.com/q/22045493
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33373438
comment on: http://stackoverflow.com/q/22016026
type: QuestionComment
type: Comment
has text: You still didn't provide any neo4j code. We don't just write code for you.
score: 0

http://stackoverflow.com/comment/33442019
has text: Sorry, I should have included that. I set the endpoint before executing the code. After some more testing, I found setEndPoint to not be consistent. I shuffled my code around a bit and it started working. Now, I'm fighting this delay between the API and AWS Console. After creating an instance, even though I see it on the console, API returns that instance doesn't exist. I have to stick in a 90 sec thread pause before it will detect it.
type: Comment
comment on: http://stackoverflow.com/a/22054742
score: 0
type: AnswerComment

http://stackoverflow.com/q/22052797
linked to: http://stackoverflow.com/q/383947
type: Question
score: 3
possible better answer: http://stackoverflow.com/a/22052977
has answer: http://stackoverflow.com/a/22052977
has body: Okay, so let's say I have a class called Pancake. Pancake.java would look something like this: public class Pancake { public boolean shouldEat() { return false; } } Now, I don't want to edit Pancake.java at all. All I want to do is to change what shouldEat() returns to from a different class, such as "NotPancake.java". I know if I had something like public boolean eat = false; I could easily just change that by doing something like Pancake.eat = true, but is there any way of changing what shouldEat() returns to without editing the class in a similar way? Thanks.
upvote count: 3
answer count: 2
has answer: http://stackoverflow.com/a/22052958
accepted answer: http://stackoverflow.com/a/22052958
has comment: http://stackoverflow.com/comment/33437721
favorite count: 0
linked to: http://stackoverflow.com/q/599978
type: AnsweredQuestion
downvote count: 0
tagged with: java
has title: Edit return value in a class without modifying the class itself?

cubic
tags question: http://stackoverflow.com/q/22078922
tag name: cubic
type: Tag

http://stackoverflow.com/q/22033213
score: 2
type: AnsweredQuestion
tagged with: rhino
tagged with: java
type: Question
has body: I am try use array list of integer and check var exist in it. It work on array of string but not work on array of integers. public static void main(String[] args) throws ScriptException { List&lt;Object&gt; list = new ArrayList&lt;Object&gt;(); list.add(1); list.add(2); List&lt;String&gt; lists = new ArrayList&lt;String&gt;(); lists.add("1"); lists.add("2"); ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("JavaScript"); engine.put("list", list); System.out.println(engine.eval("list.indexOf(1)")); //print -1 , Why ? engine.put("lists", lists); System.out.println(engine.eval("lists.indexOf('1')")); //print 0 } What wrong with code?
answer count: 2
has comment: http://stackoverflow.com/comment/33404672
tagged with: arrays
downvote count: 0
has comment: http://stackoverflow.com/comment/33402802
has answer: http://stackoverflow.com/a/22033683
tagged with: jsr223
has comment: http://stackoverflow.com/comment/33402880
has comment: http://stackoverflow.com/comment/33402965
has answer: http://stackoverflow.com/a/22033338
accepted answer: http://stackoverflow.com/a/22033338
favorite count: 0
has title: indexOf function on ArrayList<Integer> not work in JSR 223 (Rhino scripting engine)
upvote count: 2
linked to: http://stackoverflow.com/q/15528573
possible better answer: http://stackoverflow.com/a/22033683

http://stackoverflow.com/q/22112449
favorite count: 0
answer count: 3
tagged with: android
has title: Loading Bitmaps and Storing them Statically Alternatives?
score: -1
accepted answer: http://stackoverflow.com/a/22112597
tagged with: garbage-collection
possible better answer: http://stackoverflow.com/a/22112569
tagged with: bitmap
downvote count: 1
has answer: http://stackoverflow.com/a/22112569
type: AnsweredQuestion
tagged with: java
type: Question
has body: I have created a small applicaiton (a game), that reuses the same set of images several times. SO i thought i should create a class that is responsible for loading all of the different images once, from which i can then access them statically from other classes. However, i believe this may have caused an issue with the Garbage Collector, which causes my App to lag whenever the GC is run. Here is What the ImgLoader class looks like: public class ImgLoader extends View { public static Bitmap tree1; public ImgLoader(Context context) { super(context); loadImgs(); } public void loadImgs() { System.gc(); // Manually Call GC // TREES tree1 = BitmapFactory.decodeResource(getResources(), R.drawable.tree); tree1 = getResizedBitmap(tree1, MainActivity.height / 2, MainActivity.width / 10); } public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) { int width = bm.getWidth(); int height = bm.getHeight(); float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // CREATE A MATRIX FOR THE MANIPULATION Matrix matrix = new Matrix(); // RESIZE THE BIT MAP matrix.postScale(scaleWidth, scaleHeight); // "RECREATE" THE NEW BITMAP Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false); return resizedBitmap; } public static Bitmap RotateBitmap(Bitmap source, float angle) { Matrix matrix = new Matrix(); matrix.postRotate(angle); return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); } } Note, i only use one Bitmap for the question. Essentially, when i want to use an image in my application, i say: object.image = ImgLoader.tree1; What is an alternative to doing this, that is not so memory intensive? Thank you!
upvote count: 0
has answer: http://stackoverflow.com/a/22112570
has answer: http://stackoverflow.com/a/22112597

http://stackoverflow.com/q/22015807
score: 0
has answer: http://stackoverflow.com/a/22017870
type: AnsweredQuestion
tagged with: performance
accepted answer: http://stackoverflow.com/a/22017870
tagged with: java
has comment: http://stackoverflow.com/comment/33371167
has body: I just were thinking about if it would give you performance if you make your own class e.g. public class Coordinate{ private int x; private int y; public Coordinate(int x, int y){ this.x = x; this.y = y; } /* Getters &amp; Setter */ /* etc. */ } Would that be more performance than if you would use Point2D or would that be somewhat equal in performance? I know it is a naive question but I found nothing when searching the Internet.
type: Question
tagged with: benchmarking
answer count: 1
has comment: http://stackoverflow.com/comment/33371888
has comment: http://stackoverflow.com/comment/33372134
has comment: http://stackoverflow.com/comment/33371275
has comment: http://stackoverflow.com/comment/33371801
has comment: http://stackoverflow.com/comment/33371204
has title: Improving performance by making own Coordinate class instead of using Point2D

http://stackoverflow.com/q/22097251
tagged with: spring
has title: Redirect to a JSP file from controller action in Spring MVC
tagged with: spring-mvc
score: 2
type: AnsweredQuestion
upvote count: 2
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/22097339
has body: In my spring mvc application, I have the following login form: &lt;!--LOGIN FORM--&gt; &lt;form name="login-form" class="login-form" action="usuario_login.html" method="post"&gt; &lt;!--HEADER--&gt; &lt;div class="header"&gt; &lt;!--TITLE--&gt;&lt;h1&gt;Login Form&lt;/h1&gt;&lt;!--END TITLE--&gt; &lt;!--DESCRIPTION--&gt;&lt;span&gt;Fill out the form below to login to my super awesome imaginary control panel.&lt;/span&gt;&lt;!--END DESCRIPTION--&gt; &lt;/div&gt; &lt;!--END HEADER--&gt; &lt;!--CONTENT--&gt; &lt;div class="content"&gt; &lt;!--USERNAME--&gt;&lt;input name="username" type="text" class="input username" value="Username" onfocus="this.value=''" /&gt;&lt;!--END USERNAME--&gt; &lt;!--PASSWORD--&gt;&lt;input name="password" type="password" class="input password" value="Password" onfocus="this.value=''" /&gt;&lt;!--END PASSWORD--&gt; &lt;/div&gt; &lt;!--END CONTENT--&gt; &lt;!--FOOTER--&gt; &lt;div class="footer"&gt; &lt;!--LOGIN BUTTON--&gt;&lt;input type="submit" name="submit" value="Login" class="button" /&gt;&lt;!--END LOGIN BUTTON--&gt; &lt;/div&gt; &lt;!--END FOOTER--&gt; &lt;/form&gt; the page usuario_login.html is configured in the DispatcherServlet in this way: @RequestMapping(value="/usuario_login", method=RequestMethod.POST) public ModelAndView usuario_login(@RequestParam("username") String username, @RequestParam("password") String password) { UsuarioDAO usuario = new UsuarioDAO(username, password); if(usuario.getUsuario() == null) { String message = "oops! n&amp;atilde;o foi possivel efetuar o login. Confira seu login e senha e tente novamente."; return new ModelAndView("","message",message); } else { this.sessao = new Sessao(usuario.getUsuario()); return new ModelAndView("usuario_start","usuario",usuario.getUsuario()); } } My question is: In case of login fail (the condition usuario.getUsuario() == null how i can redirect to my file index.jsp, where the login form is placed? I want send a message explaining the situation, to be displayed in this p…
answer count: 1
downvote count: 0
tagged with: jsp
favorite count: 0
has answer: http://stackoverflow.com/a/22097339

http://stackoverflow.com/q/22081681
has answer: http://stackoverflow.com/a/22081897
has comment: http://stackoverflow.com/comment/33489774
accepted answer: http://stackoverflow.com/a/22081770
type: AnsweredQuestion
tagged with: recursion
has answer: http://stackoverflow.com/a/22081865
tagged with: java
has title: Recursively counting character occurrences in a string
has answer: http://stackoverflow.com/a/51916271
score: 4
type: Question
has answer: http://stackoverflow.com/a/22081770
answer count: 8
tagged with: string
has answer: http://stackoverflow.com/a/22081808
favorite count: 0
has comment: http://stackoverflow.com/comment/33489663
has answer: http://stackoverflow.com/a/22081979
has answer: http://stackoverflow.com/a/69061572
possible better answer: http://stackoverflow.com/a/22081808
tagged with: count
upvote count: 4
has comment: http://stackoverflow.com/comment/33489882
has body: Im making a program to count the number of times a character is found in a string. This is what my method looks like: public static int count (String line, char c) { int charOccurences = 0; //= 0; for (int x = 0 ; x &lt; line.length () ; x++) { if (line.charAt (x) == c) { charOccurences++; line = line.substring (0, x) + line.substring (x + 1); return count (line, c); } else return charOccurences; } return charOccurences; } It always returns 0, due to the fact that once the method calls itself it sets charOccurences back to 0. But i need to declare that variable for the method to work. I cant figure any way around this. Any help would be appreciated.
tagged with: character
has comment: http://stackoverflow.com/comment/33489751
downvote count: 0
has answer: http://stackoverflow.com/a/22081787

http://stackoverflow.com/a/22151960
downvote count: 0
upvote count: 2
has body: You cannot use primitives directly in a collection in Java. This is a deliberate design-decision in Java (though some think it is a mistake). Generics in Java were bolted on after the fact, which is why their application is not uniform across the language. Containers basically want Object types and primitive types aren't derived from Object (i.e., Object is not their superclass unlike every other object in Java). From a code-writing point of view, it certainly looks like there are no wrappers: list.add(6); //list is of type List&lt;Integer&gt; int num = list.get(i); This is because the boxing and unboxing is done automatically for you. At the bytecode level, what you actually have is: list.add(new Integer(6)); int num = ((Integer) list.get(i)).intValue(); So the second option you have is the right way in Java. If you want a less memory-hungry option, you can opt for a straight double[]. However, this means that you are going to have to write code to manage add, retrieve, update, and delete operations. If that is too much extra work, you can try using Apache Commons Primitives. Also, I suspect you meant List&lt;Double&gt; list = new ArrayList&lt;&gt;(); (or some other implementation), right? This is because what you have won't compile.
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/22151932
answers question: http://stackoverflow.com/q/22151932
score: 2

http://stackoverflow.com/comment/33632518
has text: It si not that I have an specific problem, I am just struggling to learn coding and figure people here would help me understand it better.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22161372
type: Comment

linechart
tag name: linechart
type: Tag
tags question: http://stackoverflow.com/q/22096104

http://stackoverflow.com/a/22040966
has comment: http://stackoverflow.com/comment/33416083
type: Answer
answers question: http://stackoverflow.com/q/22040877
upvote count: 1
has comment: http://stackoverflow.com/comment/33416183
has comment: http://stackoverflow.com/comment/33416110
score: 1
has body: This is not concatenating arrays, because that would look more like: Array3[] = {3,3,3,3,2,1} What you want to do is to concatenate each element inside the array, which is a different process entirely, and one you could accomplish with a simple for loop. if(array1 is the same size as array2) { define array3 = new array[array1.length]; for(int x = 0 to array1.length) { array3[x] = array1[x] + array2[x]. } } This is pseudocode, which I provide when the question doesn't contain any code. It's up to you to figure out how to turn this into Java code, although that isn't too difficult. You'll also notice I'm using the + operator for concatenation. I'm assuming your values are String type. If they're not, then get creative, using the Integer.parseInt method.
downvote count: 0

http://stackoverflow.com/a/22031150
has body: You are evoking Thread.sleep inside the EvokeLater which means that it is running on another thread than your for loop. i.e., your for loop is completing instantaneously (well, however long it takes to loop from 1 to 100, which is almost instantaneously). Move Thread.sleep outside of EvokeLater and it should work as you intend. int max = 10; for (int i = 0; i &lt;= max; i++) { final int progress = (int)Math.round( 100.0 * ((double)i / (double)max) ); EventQueue.invokeLater(new Runnable() { @Override public void run() { jProgressBar2.setValue(progress); } }); try { Thread.sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(BandListGenerator.class.getName()).log(Level.SEVERE, null, ex); } } Edit: agree with @MadProgrammer. It appears this is just an illustrative question, but you should make sure whatever you're trying to accomplish here you use a SwingWorker for.
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/22031086
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33554110

http://stackoverflow.com/comment/33544358
type: Comment
has text: with .png is ok, but with .3gp or .mp4 does not worked : Elements pngs = doc.select("a[href$=.3gp]"); for (Element png :pngs) System.out.println(png.attr("href"));
type: AnswerComment
comment on: http://stackoverflow.com/a/22112079
score: 0

http://stackoverflow.com/a/22005495
answers question: http://stackoverflow.com/q/22005370
downvote count: 0
has comment: http://stackoverflow.com/comment/33353743
upvote count: 1
has body: If we create an String like this... String str1 = "abc"; object str1 created in String-Pool, and if we create String str2 = new String("abc"); then, it created in heap, means another new Object. this is the reason that your condition if(str1==str2) returns false, because these both are different objects. But there hashcode is equal because both are "abc", so equals method returns true.
type: Answer
score: 1

http://stackoverflow.com/comment/33394062
has text: @TejaswiRana Java has rules in place for figuring that out.
score: 1
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22027984

http://stackoverflow.com/q/22117654
has body: The JAX-RS annotations Path, GET, POST, PUT and DELETE do not have @Documented on them, so they do not appear in javadocs. It would be extremely useful for these annotations to appear in javadocs, because they would tell you the path and HTTP method for the call. Anybody know how to get this information to appear in javadocs?
has answer: http://stackoverflow.com/a/22117821
type: AnsweredQuestion
score: 1
tagged with: java
tagged with: javadoc
type: Question
upvote count: 1
answer count: 1
favorite count: 0
has title: Javadocs for JAX-RS services
tagged with: jax-rs
accepted answer: http://stackoverflow.com/a/22117821
downvote count: 0

http://stackoverflow.com/q/22100973
answer count: 6
favorite count: 0
tagged with: slf4j
has answer: http://stackoverflow.com/a/34549559
has answer: http://stackoverflow.com/a/78686934
linked to: http://stackoverflow.com/q/10345109
has answer: http://stackoverflow.com/a/22101103
tagged with: buildpath
upvote count: 3
has answer: http://stackoverflow.com/a/44262339
has comment: http://stackoverflow.com/comment/33531533
has comment: http://stackoverflow.com/comment/33529290
tagged with: logging
has answer: http://stackoverflow.com/a/24185095
type: AnsweredQuestion
score: 3
has body: I setup a basic Java program. I am following this tutorial and have this exact code: import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class HelloWorld { public static void main(String[] args) { Logger logger = LoggerFactory.getLogger(HelloWorld.class); logger.info("Hello World"); } } I have the jars slf4j-api-1.7.5.jar and slf4j-log4j12-1.7.5 jar on my build path. I do not understand what gives, the getLogger method exists in the LoggerFactory class which I can F3 (source code look-up) to. I Googled about this and appear to be the only dope with this problem. Any ideas? Here is my .classpath for Eclipse: <xml version="1.0" encoding="UTF-8"?> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdit..../> <classpathentry kind="lib" path="/home/Desktop/slf4j-api-1.7.5.jar" sourcepath="/home/Desktop/slf4j-api-1.7.5.jar"/> <classpathentry kind="lib" path="slf4j-log4j12-1.7.5.jar"/> <classpathentry kind="lib" path="log4j-1.2.17.jar"/> <classpathentry kind="output" path="bin"/>
tagged with: java
has answer: http://stackoverflow.com/a/53808201
has title: LoggerFactory.getLogger cannot be resolved to a type
tagged with: eclipse
accepted answer: http://stackoverflow.com/a/22101103
possible better answer: http://stackoverflow.com/a/24185095
type: Question
has comment: http://stackoverflow.com/comment/33528917
downvote count: 0

http://stackoverflow.com/comment/33527338
has text: is coz I'm using add ? not put?
comment on: http://stackoverflow.com/q/22102837
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22044812
answer count: 1
has comment: http://stackoverflow.com/comment/33423397
has comment: http://stackoverflow.com/comment/33423252
has comment: http://stackoverflow.com/comment/33423322
favorite count: 0
has title: Java - Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.7.2 (or 2.12.4 or 2.16):test
has comment: http://stackoverflow.com/comment/33423379
has comment: http://stackoverflow.com/comment/33424157
type: UnansweredQuestion
tagged with: maven
downvote count: 1
has body: I am trying to build an application using Maven-3.0.4 and jdk 1.6.0_45. In order to successfully build the application, I need to perform six tasks out of which three are success but the fourth one is failing repeatedly. The tasks (along with the status) are:- [INFO] Eureka! Clinical Analytics ........................ SUCCESS [15.788s] [INFO] Eureka Common ..................................... SUCCESS [4:45.548s] [INFO] Eureka WebApp ..................................... SUCCESS [6:46.893s] [INFO] Eureka Services ................................... FAILURE [8:59.532s] [INFO] Eureka Protempa ETL ............................... SKIPPED [INFO] Eureka EAR ........................................ SKIPPED It requires 'maven-surefire-pluginin order to succeed at theEureka Services` task as certain tests are to be done. I've tried using maven-surefire-plugin:2.7.2\2.12.4\2.16 versions of the plugin but the error is always the same and is as follows:- [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.7.2 (or 2.12.4 or 2.16):test (default-test) on project eureka-services: There are test failures. [ERROR] [ERROR] Please refer to /home/user/eureka-1.8.2/eureka-services/target/surefire-reports for the individual test results. [ERROR] -&gt; [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command I am not able to understand what to do now. Please advice. Note:- I am doing it on terminal as I don't have much knowledge about Eclipse.
tagged with: java
score: -1
type: Question
has answer: http://stackoverflow.com/a/22044933
upvote count: 0

http://stackoverflow.com/comment/33742931
type: Comment
comment on: http://stackoverflow.com/a/22171723
has text: Well, i can't use TestNG, i have to use JUnit4.
score: 0
type: AnswerComment

http://stackoverflow.com/a/22096314
answers question: http://stackoverflow.com/q/22088796
upvote count: 2
type: AcceptedAnswer
type: Answer
has body: Why my head id is not displaying the next automatic id from the database in the swing form? This is because you update the text field just when you press save button. The code to get the last id and update the database record is all together within actionPerformed method here: i1b1.addActionListener(new ActionListener() { @Override // always use Override annotation public void actionPerformed(ActionEvent ae) { // all is done here } }; You need to perform a database call to set the next id to i1t1 text field prior to show the internal frame. How to code mandatory fields? It depends on the case. One approach could be have a method that validates all mandatory fields are filled. For instance: private boolean validateMandatoryFields() { return !i1t1.getText().isEmpty() &amp;&amp; selectedOption != null; } Where selectedOption should be some variable or class member that holds the type selected on radio buttons groups. Then modify i1b1 button's action listener to perform the update based on the result of this validation: if true perform the update otherwise show some warning to the user. Note if you provide a default value to your components then you could get rid of validation. In this particular case if you make a radio button (lets say i1r4) selected by default then you wouldn't need any validation because i1t1 will have the next id from the database as per my previous suggestion. Off-topic I know you're running out of time to deliver your project but next time you must consider perform database calls and Swing components updates using a SwingWorker. This is because Swing components creation/update must be handled in the Event Dispatch Thread which is a single thread and time consuming tasks such as database calls or IO operations may block this thread, causing your GUI becomes unresponsive. You can read more about concurrency in Swing in this official document: Lesson: Concurrency in Swing
score: 2
accepted answer of: http://stackoverflow.com/q/22088796
downvote count: 0

http://stackoverflow.com/comment/33426866
type: Comment
has text: Autogenerated *when* ? When called by the JSP ?
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22045493

http://stackoverflow.com/comment/33617340
type: QuestionComment
comment on: http://stackoverflow.com/q/22153033
has text: Yes, there is a way without try/catch. `break` will remove yourself from the `while` loop, so you are correct there. Try doing a simple `if` statement that checks the value of `price`, and if you need to `break` or not.
score: 0
type: Comment

http://stackoverflow.com/a/22030589
type: Answer
answers question: http://stackoverflow.com/q/22026995
has body: Check out Darryl's Stretch Icon which will dynamically scale the icon to fill the label.
score: 0

http://stackoverflow.com/comment/33498706
has text: @ksun: Also, using classical binary search you can not only find the position of an element in a sorted sequence but also its successor/predecessor if the element is not in the sequence. You lose that ability if you create one big, merged sequence because then there can be `ω(log n)` elements between the point where your binary search brings you and the results of the search for some of the lists.
comment on: http://stackoverflow.com/q/22085267
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33539889
type: Comment
type: QuestionComment
has text: Well I'm not asking for anyone to do my homework for me. As you can see, I've already done most of the work. I guess my question is: do you see anything glaringly wrong with my code? Does it seem to conform to the instruction? I guess I'm just asking for someone to check my work. Also thank you below for helping me call my methods into the main class.
score: 0
comment on: http://stackoverflow.com/q/22109197

http://stackoverflow.com/comment/33411439
comment on: http://stackoverflow.com/q/22038359
type: Comment
type: QuestionComment
score: 2
has text: Don't use the intermediate `MSG1` strings and just call `Translator.get(locale, "MSG1");` in your code.

http://stackoverflow.com/q/22164527
answer count: 1
has comment: http://stackoverflow.com/comment/33637829
linked to: http://stackoverflow.com/q/3544919
tagged with: java
has answer: http://stackoverflow.com/a/22164655
has title: java eclipse, boolean value goes wrong
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33637751
tagged with: boolean
accepted answer: http://stackoverflow.com/a/22164655
has comment: http://stackoverflow.com/comment/33637627
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33684974
type: Question
score: 0
has body: I got two threads running on Main.java and a boolean field Main.bool which is false in the beginning. The first thread will set Main.bool to true. After that, The second thread will print out Main.bool. And the result is FALSE. More interesting, I tried to print out a random text before printing Main.bool, then the result turned out to be correct(true). Anyone have an idea what is going on here? I'm using eclipse Kepler. Main.bool = false; thread1.setBool(true); // then wait for some seconds // case 1 thread2.printBool(); --&gt; false // case 2 System.out.println("blah blah"); thread2.printBool(); --&gt; true

http://stackoverflow.com/comment/33650705
comment on: http://stackoverflow.com/a/22139802
type: AnswerComment
score: 0
type: Comment
has text: ya sure...,just post your code..,i see

http://stackoverflow.com/comment/33476014
comment on: http://stackoverflow.com/q/22074585
score: 1
type: Comment
type: QuestionComment
has text: There is a way, but why do you want to do this? You will experience nightmare of runtime exceptions. What's the reason?

http://stackoverflow.com/a/22064549
type: Answer
score: 3
accepted answer of: http://stackoverflow.com/q/22064409
upvote count: 3
answers question: http://stackoverflow.com/q/22064409
has body: Do not parse CSV using regex. Use libraries that know to do this well. For example OpenCSV or Apache commons CSV
has comment: http://stackoverflow.com/comment/33458509
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/33499480
type: QuestionComment
has text: I just started looking at Jersey after spending the last couple years working with RestEasy. Any reason why you are 'forcing' Tomcat into the situation? Reason I ask is that I started with the Jersey User's Guide and followed their steps, which uses Maven for builds and Grizzly for the web server and it everything ran. I believe the initial sample uses Jersey 2.6.
comment on: http://stackoverflow.com/q/22083164
score: 0
type: Comment

apache
tag name: apache
tags question: http://stackoverflow.com/q/22047860
tags question: http://stackoverflow.com/q/22110326
tags question: http://stackoverflow.com/q/22121173
tags question: http://stackoverflow.com/q/22005680
tags question: http://stackoverflow.com/q/22092446
tags question: http://stackoverflow.com/q/22138642
tags question: http://stackoverflow.com/q/22132736
tags question: http://stackoverflow.com/q/22034294
tags question: http://stackoverflow.com/q/22114187
tags question: http://stackoverflow.com/q/22015660
tags question: http://stackoverflow.com/q/22111500
type: Tag
tags question: http://stackoverflow.com/q/22020231
tags question: http://stackoverflow.com/q/22101935

http://stackoverflow.com/a/22116383
answers question: http://stackoverflow.com/q/22116370
score: 1
downvote count: 0
upvote count: 1
type: Answer
has body: PreparedStatement escapes String and Date variables for you. String sql = "Update KKKB1 set Pangkat= ? where Pangkat=? "; pst=conn.prepareStatement(sql); pst.setString(1, p1); pst.setString(2, p2); http://docs.oracle.com/javase/tutorial/jdbc/basics/prepared.html I think this code is a very bad idea. You should be closing your Connection &amp; PreparedStatement in method scope. You should not be mingling UI and persistence code this way. You don't commit or rollback if the INSERT fails.

http://stackoverflow.com/q/22085993
favorite count: 0
has comment: http://stackoverflow.com/comment/33497247
has title: How to run a maven Project?
has answer: http://stackoverflow.com/a/22086048
has comment: http://stackoverflow.com/comment/33497176
upvote count: 3
tagged with: selenium
has body: I have created java project called OneReports. How can i shift the entire project to Maven. Once i shifted to maven how can run in command prompt. Currently i have the problem of dependency. So i plan to move the project. Could anyone help me to step by step process. C:\Jars&gt;javac -cp "C:\Program Files\Java\selenium\*.jar";"OneReports.jar";"testng.jar" test\TestngTestSuiteUsingXML.java C:\Jars&gt;java -cp "C:\Program Files\Java\selenium\*.jar";"OneReports.jar";"testng.jar" test.TestngTestSuiteUsingXML TestNGClassFinder Unable to read methods on class test.LoginOneReports - unable to resolve class reference org/openqa/selenium/WebDriver Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Unknown Source) at java.lang.Class.privateGetPublicMethods(Unknown Source) at java.lang.Class.getMethods(Unknown Source) at org.testng.internal.TestNGClassFinder.&lt;init&gt;(TestNGClassFinder.java:59) at org.testng.TestRunner.initMethods(TestRunner.java:409) at org.testng.TestRunner.init(TestRunner.java:235) at org.testng.TestRunner.init(TestRunner.java:205) at org.testng.TestRunner.&lt;init&gt;(TestRunner.java:153) at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:522) at org.testng.SuiteRunner.init(SuiteRunner.java:157) at org.testng.SuiteRunner.&lt;init&gt;(SuiteRunner.java:111) at org.testng.TestNG.createSuiteRunner(TestNG.java:1299) at org.testng.TestNG.createSuiteRunners(TestNG.java:1286) at org.testng.TestNG.createSuiteRunners(TestNG.java:1289) at org.testng.TestNG.runSuitesLocally(TestNG.java:1140) at org.testng.TestNG.run(TestNG.java:1057) at test.TestngTestSuiteUsingXML.main(TestngTestSuiteUsingXML.java:20) Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriver at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessC…
tagged with: maven
has comment: http://stackoverflow.com/comment/33497332
type: AnsweredQuestion
score: 3
has comment: http://stackoverflow.com/comment/33497231
accepted answer: http://stackoverflow.com/a/22086048
has answer: http://stackoverflow.com/a/22086060
tagged with: java
type: Question
answer count: 2
possible better answer: http://stackoverflow.com/a/22086060
downvote count: 0

http://stackoverflow.com/a/22091992
has comment: http://stackoverflow.com/comment/33508316
type: Answer
answers question: http://stackoverflow.com/q/22091318
score: 0
has body: I think you should try Opengl... Since you mention that you use java i suggest that you should use JOGL, a wrapper for the opengl libraries in java... Here is a quite extensive tutorial. http://www3.ntu.edu.sg/home/ehchua/programming/opengl/JOGL2.0.html As a starting demo you could possibly draw a rectangle and a cube in 3d space and move the cube using the data you extract from the wiimote

http://stackoverflow.com/a/22093155
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33509728
has comment: http://stackoverflow.com/comment/33509634
upvote count: 2
has comment: http://stackoverflow.com/comment/33509744
has comment: http://stackoverflow.com/comment/33509515
type: Answer
answers question: http://stackoverflow.com/q/22093045
has body: Have a look at the forever project. If you have npm installed you can use that to install the forever package with the -g (for global install) parameter: npm install forever -g Then use the start argument to start the script. In your case this could be a bash file (.sh) with the required java commands. forever start name-of-script-here If the script would fail (system.exit in java or any fatal error) it will be restarted by forever. You can also get a list of all the running scripts managed by forever with: forever list

http://stackoverflow.com/q/22021140
has answer: http://stackoverflow.com/a/22021323
tagged with: byte
type: Question
score: 4
has answer: http://stackoverflow.com/a/22021277
tagged with: java
tagged with: stream
has comment: http://stackoverflow.com/comment/33381171
possible better answer: http://stackoverflow.com/a/22021387
accepted answer: http://stackoverflow.com/a/22021323
has answer: http://stackoverflow.com/a/22021387
upvote count: 4
has answer: http://stackoverflow.com/a/22021199
answer count: 4
has title: Consequences of not closing byte streams
downvote count: 0
has comment: http://stackoverflow.com/comment/33380905
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33381048
favorite count: 0
has body: The question says it all. What are the consequences of not closing the various byte streams? It is very much emphasized to always do so, but there is no mention of how it causes problems. Can someone please explain what actually happens?

http://stackoverflow.com/comment/33534295
type: AnswerComment
score: 0
type: Comment
has text: The program should not call perfectMatches() unless the user inputs a valid number. Methods should be as simple as possible. Checking to see if the number is valid and checking to see if the number is a perfect match are two separate functions and should be represented as such. Otherwise, the program checks anything for a perfect match. If the user enters a word, the program checks to see if it is a perfect match. This is a flaw in design. Also, the isValidNumber should be used to check the user's input not just the generated number.
comment on: http://stackoverflow.com/a/22105831

http://stackoverflow.com/comment/33575091
has text: How can I give a limit to the nodes I get from 'rel.getEndNode()'. The function hasLabes() can do a favor...But if I have 1000 friends, it'll take too much time to make a judgement...
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22115924

http://stackoverflow.com/a/22138824
score: 1
has body: You just try like this you can achieve the Date format conversion easily... String inputPattern = "yyyy-MM-dd hh:mm:ss"; String outputPattern = "dd-MMM-yyyy hh:mm a"; SimpleDateFormat inFormat = new SimpleDateFormat(inputPattern); SimpleDateFormat outputFormat = new SimpleDateFormat(outputPattern); Date date1 = null; if (date != null) { try { date1 = inFormat.parse(date); str = outputFormat.format(date1); Log.d(null, str); } catch (ParseException e) { e.printStackTrace(); } } else { str = " "; }
has comment: http://stackoverflow.com/comment/33635007
answers question: http://stackoverflow.com/q/22128134
has comment: http://stackoverflow.com/comment/33635031
has comment: http://stackoverflow.com/comment/33598656
accepted answer of: http://stackoverflow.com/q/22128134
type: AcceptedAnswer
downvote count: 0
type: Answer
upvote count: 1

http://stackoverflow.com/q/22092620
tagged with: servlets
has answer: http://stackoverflow.com/a/22094316
type: Question
downvote count: 0
accepted answer: http://stackoverflow.com/a/22094316
answer count: 1
has title: HstResponse::addHeadElement has no effect
favorite count: 0
upvote count: 1
type: AnsweredQuestion
score: 1
tagged with: java
has body: I'm using Hippo CMS. After unsuccessfully using HST SEO support plugin, I realised that HstResponse::addHeadElement did not have any effect on my HTML pages. For instance, when adding the following lines in a component's code: Element title = response.createElement("title"); title.setTextContent("Foo"); response.addHeadElement(title, "hst.seo.document.title"); I would expect the corresponding Foo markup to be included in the response, but it is not. What did I miss?
tagged with: hippocms

http://stackoverflow.com/a/22069484
type: AcceptedAnswer
downvote count: 1
type: Answer
score: 2
has body: Your best option is Google Could Messaging - http://developer.android.com/google/gcm/index.html It is free and provides a simple way of implementing them.
accepted answer of: http://stackoverflow.com/q/22068820
upvote count: 3
answers question: http://stackoverflow.com/q/22068820

http://stackoverflow.com/comment/33383523
type: AnswerComment
has text: you are using set so it will not contain similar entry
type: Comment
comment on: http://stackoverflow.com/a/22022165
score: 0

http://stackoverflow.com/comment/33389749
score: 0
type: Comment
has text: @user2065083 Comparators are usually stateless. Giving them captured variables is rare.
comment on: http://stackoverflow.com/a/22025275
type: AnswerComment

http://stackoverflow.com/comment/33408244
type: Comment
type: QuestionComment
has text: I assume you shouldn't hassle with all those ids. Check out [this example](http://antoniogoncalves.org/2009/11/01/mapping-and-querying-a-list-of-primitive-types-with-jpa-2-0/) which also uses a list of simple types.
comment on: http://stackoverflow.com/q/22035445
score: 0

http://stackoverflow.com/comment/33434515
score: 2
comment on: http://stackoverflow.com/q/22051019
has text: Sounds like you should just use GSON.
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/33513910
type: AnswerComment
comment on: http://stackoverflow.com/a/22094219
type: Comment
has text: To be fair every major OS will only commit a page or two at thread creation to actual memory, so the 1 MB is only a problem if you're running out of address space not memory. Still 4kb vs. 24 byte isn't that much better.
score: 1

http://stackoverflow.com/comment/33625405
has text: can we see the build plugin nodes of the POM?
comment on: http://stackoverflow.com/q/22157221
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22143480
upvote count: 2
tagged with: testing
tagged with: java
type: UnansweredQuestion
tagged with: eclipse
tagged with: infinitest
score: 2
answer count: 0
downvote count: 0
tagged with: javascript
favorite count: 0
type: Question
has title: is there an inside-Eclipse continuous-integration tool for javascript that looks like infinitest?
has body: When I program in Java, I have recently discovered the free unit-testing tool Infinitest, and installed it as an Eclipse Plugin. The GUI is minimalistic and looks like this statusbar at bottom of picture: (The bar is green when all tests pass, and it is red if tests fail.) Is there a similar tool that inserts a status bar into Eclipse like this, but works for unit tests written in Javascript? I would also be interested in solutions that work for any other language but can be adapted for javascript. And the test runner does not necessarily have to be an eclipse plugin. I'm interested in having seamless workflow with instant feedback from the test runner (just as in Infinitest). Whenever I save a script file, the testrunner gets triggered.

http://stackoverflow.com/q/22065178
has title: IReport and getter between classes
tagged with: jasper-reports
has answer: http://stackoverflow.com/a/22065270
type: UnansweredQuestion
tagged with: javabeans
has answer: http://stackoverflow.com/a/22069355
type: Question
has body: I'm using IReport (JasperStudio plugin for Eclipse) and I'm trying to create a report with a JavaBean as source. Suppose I have these two classes: public class MyClass { private String myClassAttribute; // getter and setter for myClassAttribute } public class AnotherMyClass { private String anotherMyClassAttribute; private MyClass myClass; // getter and setter for anotherMyClassAttribute // getter and setter for myClass } If I choose AnotherMyClass as JavaBeanSource I can set only fields from that class (anotherMyClassAttribute), I didn't find a way to set a text to getMyClass().getmyClassAttribute(). Do JavaBeans stop at level one or is there a way to use attribute from other classes between references? Thanks.
answer count: 2
tagged with: ireport
score: 0
tagged with: java

http://stackoverflow.com/q/22110004
tagged with: selenium
has answer: http://stackoverflow.com/a/22447784
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22447784
has title: how to override implicitlywait() while doing try catch in Selenium Webdriver?
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33544643
has comment: http://stackoverflow.com/comment/33547733
answer count: 1
score: 0
has comment: http://stackoverflow.com/comment/33637873
tagged with: selenium-webdriver
has body: I have a framework where I have written implicitlywait() in superTESTNG class and all other sub class extends superTESTNG. In many of my sub classes I have try catch. The problem I am facing is due to this implicitlywait(). The sub class try catch is taking too much time to execute. Please suggest a solution so that it will not wait during try catch. This is my code: in supertestNG driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); in subclass try { ProjectLibrary.SelectPreviousRecord(xlpath, sheetName, 2, 1); } catch (NoSuchElementException ex) { ProjectLibrary.SelectPreviousRecord(xlpath, sheetName, 2, 2); } try { ProjectLibrary.CompareStringTextByID(xlpath, sheetName, 2, 1, "Name","ctl00_ContentPlaceHolder1_txtName"); } catch (NoSuchElementException ex) { ProjectLibrary.CompareStringTextByID(xlpath, sheetName, 2, 2, "Name", "ctl00_ContentPlaceHolder1_txtName"); }

http://stackoverflow.com/comment/33465964
type: AnswerComment
score: 0
type: Comment
has text: I believe so :) I'm not refreshed enough on java to know what your second line in your if statement does, but yeah, you will just need to do `idData.add(tokens[1]);`. If it works and you like it, please accept the answer :)
comment on: http://stackoverflow.com/a/22068774

http://stackoverflow.com/comment/33637923
score: 20
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22164401
has text: Your `docs' refers to a third-party library... And the OP is asking about the setup of a cron job to launch a java program. You're seemingly setting up a job from within your code.

http://stackoverflow.com/a/22128355
answers question: http://stackoverflow.com/q/22127156
has comment: http://stackoverflow.com/comment/33573842
has comment: http://stackoverflow.com/comment/33573991
has comment: http://stackoverflow.com/comment/33576203
has comment: http://stackoverflow.com/comment/33575226
downvote count: 0
has body: I think what you want is to listen for data changes in the TableModel by using a TableModelListener. It's also possible to use a custom editor, but I think the TableModelListener is the simplest way to go. Your overriden tableChanged method could look something like this @Override public void tableChanged(TableModelEvent e) { int row = e.getFirstRow(); int column = e.getColumn(); if (column == BOOLEAN_COLUMN) { TableModel model = (TableModel) e.getSource(); String columnName = model.getColumnName(column); Boolean checked = (Boolean) model.getValueAt(row, column); if (checked) { System.out.println(columnName + ": " + true); } else { System.out.println(columnName + ": " + false); } } } Here's a complete running example import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.SwingUtilities; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; public class TestTableModelListener { private static final int BOOLEAN_COLUMN = 2; public TestTableModelListener() { JTable table = createTable(); table.getModel().addTableModelListener(new CheckBoxModelListener()); JFrame frame = new JFrame(); frame.add(new JScrollPane(table)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } private JTable createTable() { String[] cols = {"COL", "COL", "COL"}; Object[][] data = {{"Hello", "Hello", false}, {"Hello", "Hello", false}}; DefaultTableModel model = new DefaultTableModel(data, cols) { @Override public Class getColumnClass(int column) { return column == BOOLEAN_COLUMN ? Boolean.class : String.class; } }; JTable table = new JTable(model); return table; } public class CheckBoxModelListener implements TableModelListener { public void tableChanged(TableModelEvent e) { int row = e.getFirstRow(); int column = e.getColumn(); if (column == BOOLEAN_COLUMN) …
type: Answer
upvote count: 13
has comment: http://stackoverflow.com/comment/33576005
has comment: http://stackoverflow.com/comment/33576649
score: 13

http://stackoverflow.com/q/22145897
has title: How do I make imageView look better
has comment: http://stackoverflow.com/comment/33603910
score: -5
type: UnansweredQuestion
has body: I have a android imageview and its working perfectly fine.The only problem is it doesnot look good.I want to make UI like flicker UI where images are shown in a nice way. 1)How do i make it look better? 2)Are there any open src libs for this?
tagged with: java
downvote count: 5
has answer: http://stackoverflow.com/a/22146001
type: Question
upvote count: 0
answer count: 1
tagged with: user-interface
favorite count: 0
tagged with: android

http://stackoverflow.com/a/22140427
answers question: http://stackoverflow.com/q/22140314
has comment: http://stackoverflow.com/comment/139136764
has comment: http://stackoverflow.com/comment/33637012
has comment: http://stackoverflow.com/comment/33614851
has comment: http://stackoverflow.com/comment/33594699
upvote count: 4
has body: Tool tips support HTML, so display that image as you might display it in HTML. E.G. as seen in this answer.
type: AcceptedAnswer
downvote count: 0
score: 4
type: Answer
has comment: http://stackoverflow.com/comment/33594685
has comment: http://stackoverflow.com/comment/33672125
accepted answer of: http://stackoverflow.com/q/22140314

http://stackoverflow.com/comment/33403264
type: Comment
comment on: http://stackoverflow.com/q/22033409
score: 0
has text: Your assumption about the order of operations can basically be proved to be correct. Otherwise it would print true.
type: QuestionComment

http://stackoverflow.com/comment/33557648
score: 1
has text: If you've got a regex question. Please include the language/tool you're using.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22119665

http://stackoverflow.com/comment/33365513
type: Comment
comment on: http://stackoverflow.com/a/22012299
has text: @Voo I can't for the life of me figure out how to browse to the actual source code from your link.
type: AnswerComment
score: 0

http://stackoverflow.com/q/22132268
tagged with: encryption
tagged with: cryptography
tagged with: c++
linked to: http://stackoverflow.com/q/143523
type: AnsweredQuestion
has body: How to get ASN1 Declarations from DER file. I have a der file like .der or pem file like . I am looking to see how to get the ASN1 declaration file. EDIT: I tried using BouncyCastle and Libasn1 but all of them require an asn1 declaration to process it.
has comment: http://stackoverflow.com/comment/33585479
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33586517
upvote count: 1
has title: Get ASN1 Declarations from DER
has comment: http://stackoverflow.com/comment/33586171
has comment: http://stackoverflow.com/comment/33585851
type: Question
tagged with: ssl
accepted answer: http://stackoverflow.com/a/22135668
has comment: http://stackoverflow.com/comment/33582432
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/78279124
favorite count: 0
has answer: http://stackoverflow.com/a/22135668

jsp-tags
tags question: http://stackoverflow.com/q/22157505
tags question: http://stackoverflow.com/q/22108865
tags question: http://stackoverflow.com/q/22055236
tag name: jsp-tags
tags question: http://stackoverflow.com/q/22016978
type: Tag

http://stackoverflow.com/a/22029506
answers question: http://stackoverflow.com/q/22029473
type: Answer
has comment: http://stackoverflow.com/comment/33396626
has comment: http://stackoverflow.com/comment/33396747
score: 2
downvote count: 0
upvote count: 2
has body: First, your are using the assignment operator = to compare test to true, which results in test always being true. It's already a boolean, just use it without the extraneous comparison: if(test){ Second, you are overwriting the value of test in each for loop iteration. Initialize it to true, and only set it to false if you find a factor. test = true; for(testNumber = 2; testNumber &lt; numb; testNumber++){ if(numb % testNumber == 0){ test = false; } } Additionally, you don't need to test testNumbers past the square root of the number numb. int limit = (int) Math.sqrt(numb); for(testNumber = 2; testNumber &lt;= limit; testNumber++){
has comment: http://stackoverflow.com/comment/33396727

http://stackoverflow.com/comment/33380061
has text: @AlexanderJardim Yeah I found the NoHttpResponseException in httpcore-4.2.5
score: 0
comment on: http://stackoverflow.com/q/22019886
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33554813
type: AnswerComment
score: 0
type: Comment
has text: I had already come across Darryl's Stretch Icon class, but didn't try it yet because I first wanted to hear other potential solutions. But I now inserted his code, and it works wonderful and how I expected! Thanks. And thanks, Darryl.
comment on: http://stackoverflow.com/a/22116517

http://stackoverflow.com/q/22062056
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has answer: http://stackoverflow.com/a/36307654
has answer: http://stackoverflow.com/a/67849324
has answer: http://stackoverflow.com/a/77598763
has comment: http://stackoverflow.com/comment/33453513
type: Question
has answer: http://stackoverflow.com/a/50838870
has comment: http://stackoverflow.com/comment/33454100
has title: A JSONObject text must begin with '{' at 1 [character 2 line 1] with '{' error
has body: String JSON = "http://www.json-generator.com/j/cglqaRcMSW?indent=4"; JSONObject jsonObject = new JSONObject(JSON); JSONObject getSth = jsonObject.getJSONObject("get"); Object level = getSth.get("2"); System.out.println(level); I referred many solutions for parsing this link, still getting the same error in question. Can any give me a simple solution for parsing it.
has answer: http://stackoverflow.com/a/56781985
has comment: http://stackoverflow.com/comment/33453860
has answer: http://stackoverflow.com/a/22064321
favorite count: 0
answer count: 14
has comment: http://stackoverflow.com/comment/33456864
upvote count: 28
accepted answer: http://stackoverflow.com/a/22064321
tagged with: android
has answer: http://stackoverflow.com/a/22198020
has answer: http://stackoverflow.com/a/59684013
tagged with: parsing
possible better answer: http://stackoverflow.com/a/57784975
downvote count: 2
has comment: http://stackoverflow.com/comment/33453826
has answer: http://stackoverflow.com/a/57784975
has answer: http://stackoverflow.com/a/54465066
has answer: http://stackoverflow.com/a/34767374
has answer: http://stackoverflow.com/a/67619031
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/50397732
has answer: http://stackoverflow.com/a/24688096
score: 26

http://stackoverflow.com/comment/33418140
score: 0
has text: Go to json.org and study the JSON syntax. It only takes 5-10 minutes to learn. And if you're storing a JSON string in a local DB you should generally store it as a "blob". (Though why use JSON in the first place, vs storing Name/Age/Address as 3 separate columns?)
type: Comment
comment on: http://stackoverflow.com/q/22041707
type: QuestionComment

http://stackoverflow.com/comment/33448532
score: 0
type: AnswerComment
type: Comment
has text: Thanks for the info. My prof said not to use an array for this. That's why I chose to use the substring and charAt methods.
comment on: http://stackoverflow.com/a/22058764

http://stackoverflow.com/comment/33639263
comment on: http://stackoverflow.com/q/22165295
type: Comment
has text: Change it to this: Log.e("From Server", ex.getMessage()+"");
score: 0
type: QuestionComment

http://stackoverflow.com/comment/33422546
score: 0
comment on: http://stackoverflow.com/q/22043846
type: Comment
type: QuestionComment
has text: The syntax for your query is wrong, you need an extra quote at the end like WHERE l.locale = '" + locale + "'"

http://stackoverflow.com/q/22131527
downvote count: 1
has answer: http://stackoverflow.com/a/22131700
type: Question
linked to: http://stackoverflow.com/q/18874681
has answer: http://stackoverflow.com/a/22131659
has comment: http://stackoverflow.com/comment/33579725
linked to: http://stackoverflow.com/q/13748124
upvote count: 5
answer count: 6
duplicate of: http://stackoverflow.com/q/18874681
tagged with: inheritance
score: 4
has body: I'm new to Java. I've had following classes: public abstract class Beverage { String description = "Unknown beverage"; public String getDescription() { return description; } public abstract double cost(); } and: public class DarkRoast extends Beverage { String description = "Dark roast"; @Override public double cost() { return 0.99; } } When I construct a new DarkRoast object: Beverage beverage2 = new DarkRoast(); I expect it to have desctiption equal to "Dark roast": assertEquals("Dark roast", beverage2.getDescription()); But actually it's "Unknown beverage". I know I should implement DarkRoast constructor that sets description, but I don't know why, I don't know how it works internally. Shouldn't the subclass field overwrite superclass field?
duplicate of: http://stackoverflow.com/q/13748124
has answer: http://stackoverflow.com/a/22131556
has comment: http://stackoverflow.com/comment/33579843
has comment: http://stackoverflow.com/comment/33580051
has answer: http://stackoverflow.com/a/22131642
favorite count: 0
has answer: http://stackoverflow.com/a/22131940
has answer: http://stackoverflow.com/a/22131686
has comment: http://stackoverflow.com/comment/33579712
possible better answer: http://stackoverflow.com/a/22131642
accepted answer: http://stackoverflow.com/a/22131556
type: AnsweredQuestion
has title: java inheritance field setup vs constructor
tagged with: java

http://stackoverflow.com/comment/33390813
type: Comment
type: QuestionComment
has text: After glancing at the code I don't see any obvious errors. What problems are you having, specifically? Have you tried running it?
comment on: http://stackoverflow.com/q/22026301
score: 0

http://stackoverflow.com/q/22127344
has answer: http://stackoverflow.com/a/22127556
has answer: http://stackoverflow.com/a/22127673
accepted answer: http://stackoverflow.com/a/22127673
type: AnsweredQuestion
tagged with: java
type: Question
answer count: 2
has body: I want go get spring security authentication form. Here part of spring-security.xml file &lt;bean id="authenticationFilter" class="com.portal.framework.web.security.CustomAuthenticationFilter"&gt; &lt;property name="authenticationManager" ref="authenticationManager" /&gt; &lt;property name="filterProcessesUrl" value="/login/validate" /&gt; &lt;property name="usernameParameter" value="usernameOrEmail" /&gt; &lt;property name="passwordParameter" value="password" /&gt; &lt;property name="authenticationSuccessHandler" ref="restAuthenticationSuccessHandler" /&gt; &lt;property name="authenticationFailureHandler" ref="restAuthenticationFailureHandler" /&gt; &lt;/bean&gt; &lt;authentication-manager alias="authenticationManager" xmlns="http://www.springframework.org/schema/security"&gt; &lt;authentication-provider ref="customAuthenticationProvider" /&gt; &lt;/authentication-manager&gt; I got error: No bean named 'customAuthenticationProvider' is defined The beans resolution is done by Java configuration as follows: @Configuration @ComponentScan(basePackages = {"com.portal"}) public class MainConfiguration { @Bean public CustomAuthenticationProvider customAuthenticationProvider() { return new CustomAuthenticationProvider(); } } Is it any problem with this configuration?
tagged with: spring-security
score: 0
has title: Spring security No bean named 'CustomAuthenticationProvider' is defined
possible better answer: http://stackoverflow.com/a/22127556
tagged with: spring

http://stackoverflow.com/comment/33422106
type: Comment
comment on: http://stackoverflow.com/a/22043772
type: AnswerComment
score: 0
has text: but I need to register information <Sentences, Score> in class 1, than I should use them in class 2 whith saving to each instances <Sentence, Score> an other criterion <Type>, there not other solution.

http://stackoverflow.com/q/22138185
has comment: http://stackoverflow.com/comment/33597559
has comment: http://stackoverflow.com/comment/33599269
tagged with: java
has comment: http://stackoverflow.com/comment/33591778
has comment: http://stackoverflow.com/comment/33591674
has comment: http://stackoverflow.com/comment/33595327
type: Question
has comment: http://stackoverflow.com/comment/33590925
has answer: http://stackoverflow.com/a/22192070
has comment: http://stackoverflow.com/comment/33595610
tagged with: resin
answer count: 1
has body: My English is not so good. Code first. @ResponseBody @RequestMapping(value = "testcall") public UnifiedResponse testMethodCall( HttpServletRequest request, HttpServletResponse response) { UnifiedResponse unifiedResponse = new UnifiedResponse(); logger.info("t1:"+System.currentTimeMillis()); Fun(0,1452,"abd",1); logger.info("t2:"+System.currentTimeMillis()); userSignService.testcall(); logger.info("t3:"+System.currentTimeMillis()); return unifiedResponse; } String Fun(int i,long l,String s,int ii){ logger.info("f1:"+System.currentTimeMillis()); return ""; } and log output : t1:1393816077311 f1:1393816077312 t2:1393816077312 f2:1393816077345 t3:1393816077410 testcall() is a method in a service, with neither parameter nor return value. just output the timestamp. Service is implemented like this: @Service public class UserSignServiceImpl extends BaseServiceImpl implements IUserSignService { public void testcall() { logger.info("f1:"+System.currentTimeMillis()); } } instantiated by annotation @Autowired IUserSignService userSignService; This only happen on some of the servers. On others t3-t1 is less than 2ms.All servers use same version of JDK and Resin. Why? stack trace between caller and method: UserSignServiceImpl.testcall() line: 448 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object...) line: 597 AopUtils.invokeJoinpointUsingReflection(Object, Method, Object[]) line: 319 ReflectiveMethodInvocation.invokeJoinpoint() line: 183 ReflectiveMethodInvocation.proceed() line: 150 TransactionInterceptor.invoke(MethodInvocation) line: 110 ReflectiveMethodInvocation.proceed() line: 172 ExposeInvocationInterceptor.invoke(MethodInvocation) line: 90 ReflectiveMethodInvocation.proceed() line: 172 JdkDynamicAopProxy.invoke(Object, Method, Object[]) line: 202 $Proxy49.testcall() line: not av…
has title: Call a method in Spring mvc service cost too much time
has comment: http://stackoverflow.com/comment/33595444
has comment: http://stackoverflow.com/comment/33591352
has comment: http://stackoverflow.com/comment/33591334
type: UnansweredQuestion
score: 0
has comment: http://stackoverflow.com/comment/33591472
tagged with: spring
has comment: http://stackoverflow.com/comment/33595293
has comment: http://stackoverflow.com/comment/33591387

http://stackoverflow.com/comment/33375238
has text: press `ctrl+shift+o`... it will remove unnecessary imports
type: QuestionComment
comment on: http://stackoverflow.com/q/22018203
score: 3
type: Comment

android-sdcard
tags question: http://stackoverflow.com/q/22015488
tags question: http://stackoverflow.com/q/22131819
tag name: android-sdcard
type: Tag

http://stackoverflow.com/a/22135587
type: Answer
upvote count: 2
score: 2
has comment: http://stackoverflow.com/comment/33706539
downvote count: 0
has body: There is no (clean) way (that I am aware of) to extend the classpath of the storm workers. Apart from the topology jar itself, the classpath is defined at JVM start-up => anything present there is visible to (thus is shared by) all topologies running on each node. Moreover, because of the cluster nature of storm, putting topology-specific files on the filesystem of storm worker would render your deployment a bit trickier to deploy since you have to copy/update those topology-specific files to every node. The Storm Deployer is meant to hide that from us. Bundling dependant jars into myapp.jar worked well for me so far since it makes sure my dependencies are always deployed and updated in every node. Bundling config files there technically works as well, but that renders myapp.jar environment-specific which is indeed not a best practise. I usually copy any supplementary config file in the node from where I do deployment (not the nodes where the topologies are running), serialise them in a json-friendly format and add them to the Storm config at deployment time. Like that I can read them again from any prepare() method anytime my topology starts on some node of the cluster. Here again, this approach makes me sure that my config is present and up to date in any node of my cluster.
answers question: http://stackoverflow.com/q/22118213
has comment: http://stackoverflow.com/comment/33711196

http://stackoverflow.com/q/22163496
score: 1
tagged with: java
type: Question
upvote count: 1
tagged with: arrays
favorite count: 0
has comment: http://stackoverflow.com/comment/33635956
has answer: http://stackoverflow.com/a/22164355
has title: Index of ordered array in Java
answer count: 5
has answer: http://stackoverflow.com/a/22163646
has comment: http://stackoverflow.com/comment/33636179
has comment: http://stackoverflow.com/comment/33636016
has answer: http://stackoverflow.com/a/22163586
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22163637
has answer: http://stackoverflow.com/a/22163606
downvote count: 0
has body: How Can I have index of a sorted array in Java? For instance: int[] myIntArray = new int[]{20,100,69,4}; and Arrays.sort(myIntArray) result is: {4,20,69,100} What if , index of original array is desired? which means : {3,0,2,1}

http://stackoverflow.com/comment/33365783
score: 0
type: AnswerComment
has text: @Arran then the code is wrong. He either needs to declare driver as a static global variable or pass to getElementWithIndex(). I dont think this would work either ways although I havent tried it yet.
type: Comment
comment on: http://stackoverflow.com/a/22009568

http://stackoverflow.com/comment/33597671
type: QuestionComment
has text: 7.4 ..... ..................
score: 0
comment on: http://stackoverflow.com/q/22142145
type: Comment

http://stackoverflow.com/comment/33568485
type: AnswerComment
has text: Yes, and you'll then get an exception when saving the phone, due to a violated foreign key constraint. Doing it with get() is no different: the em will return the employee only if it exists, but another transaction might very well delete the employee just afer it has been loaded from the database. The foreign key constraint is what guarantees the coherence.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22120876

http://stackoverflow.com/comment/78585799
comment on: http://stackoverflow.com/a/40306577
has text: yes, just saw that after someone tried to edit/update my comment to remove the "1.0-SNAPSHOT". in fact is seems the repo has been removed by its creator, but it has been cloned before here: https://github.com/pramoth/excel-object-mapping I'm pretty it's the same due to the nickname "na5cent" referred to in the original post: http://na5cent.blogspot.fr/2015/01/excel-object-mapping.html
score: 1
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33451548
has text: Look at my updated answer.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22060290

http://stackoverflow.com/q/22110262
has body: I have a problem : When I take a photo in my apps,my app open Camera app and take a photo but when return Activity seem my device is low memory and onCreate() function is recalled. In this case onActivityResult() is called before onCreate() or onCreate() is called before onActivityResult() ? Is there a sequence diagram for Activity's @Override function? public void dispatchTakePictureIntent(int actionCode) { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File dir= new File("/sdcard/Test/"); dir.mkdir(); String fileName = "IMG_"+System.currentTimeMillis()+".JPG"; GlobalData.IMAGE_PATH_CAMERA = "/sdcard/Test/"+fileName; File output= new File(dir, fileName); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(output)); startActivityForResult(takePictureIntent, 1); } Thank in advanced,
linked to: http://stackoverflow.com/q/11507999
type: Question
has comment: http://stackoverflow.com/comment/33540987
answer count: 2
downvote count: 0
has title: onActivityResult() function when Activity is recreated?
favorite count: 0
tagged with: onactivityresult
tagged with: android
has answer: http://stackoverflow.com/a/58868762
tagged with: android-activity
linked to: http://stackoverflow.com/q/5059028
upvote count: 3
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/30717466
has comment: http://stackoverflow.com/comment/33541114
score: 3
tagged with: oncreate
tagged with: java

http://stackoverflow.com/comment/33585483
comment on: http://stackoverflow.com/q/22134510
type: Comment
score: 1
has text: @mastercork That shouldn't be necessary.
type: QuestionComment

http://stackoverflow.com/a/22151454
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/22151400
score: 1
has body: It's how switch was built into Java. What you can do, though, is cast long values as int types before you put them into switch.
downvote count: 0

http://stackoverflow.com/a/22020529
score: 1
upvote count: 1
downvote count: 0
has body: Make a reference to a ListView in your layout Listview mListView = (ListView) findViewById(R.id.myListView); Then call things like mListView.setAdapter(mAdapter);
answers question: http://stackoverflow.com/q/22020464
type: Answer

http://stackoverflow.com/comment/33391586
has text: I didn't understand the concept of adding the loop indexes. Please explain the reason for using this addition.
comment on: http://stackoverflow.com/a/22026049
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/22040392
score: 0
has body: I'm trying to write some test messages or some text content to file through java in ofbiz framework. If the file already has content, recent messages has to append at bottom of file. In brief, I want a functionality like Debug.log in ofbiz. As it writes everything to debug.log file, I want a separate file to write my text messages. I tried this, File file = new File("/applications/party/webapp/partymgr/test.txt"); if (!file.exists()) { try { file.createNewFile(); FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); Debug.logInfo("writing...........", module); bw.write("this is first line in file"); bw.close(); } catch (IOException e) { e.printStackTrace(); } } But it is throwing FileNotFoundException. As, I'm not expert in ofbiz, i'm not sure about the file path. If file path is the problem please suggest me solution.
has answer: http://stackoverflow.com/a/22049918
has comment: http://stackoverflow.com/comment/33416817
tagged with: ofbiz
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/22049918
has comment: http://stackoverflow.com/comment/33420345
has title: How to write text or log to file in ofbiz framework
type: Question
answer count: 1

http://stackoverflow.com/q/22154183
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/33620520
upvote count: 1
has comment: http://stackoverflow.com/comment/33621411
has comment: http://stackoverflow.com/comment/33620762
downvote count: 1
has answer: http://stackoverflow.com/a/22154343
has answer: http://stackoverflow.com/a/28996585
tagged with: java
type: UnansweredQuestion
has title: How to call awk script in java file?
tagged with: awk
favorite count: 0
has body: I have an awk script which filters the file contents and i want that awk script to be called from java file.How to do ?
type: Question

http://stackoverflow.com/comment/33470472
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22044003
has text: Did you try to select the complete model class by using `String q = "SELECT l FROM " + className + " l WHERE etc.`? Otherwise you don't query your model class, but just the title as a string (as @Matt remarked).

http://stackoverflow.com/comment/33403220
comment on: http://stackoverflow.com/q/22033501
score: 1
has text: teacher probably want an answer with nested loop and without "1010101010"
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22034046
has comment: http://stackoverflow.com/comment/33650340
tagged with: java
has comment: http://stackoverflow.com/comment/33444246
tagged with: javascript
type: Question
has comment: http://stackoverflow.com/comment/33648947
has comment: http://stackoverflow.com/comment/33444202
has body: I want to extract thumbnail of a website using java.javascript or jquery but not using PHP or .Net.Can I do it because i Surfed on Google and they show that this can only be possible using Java.I have an input box where user will enter the website and I want to show the thumbnail of a website in the div?Is there an plugin or API through which I can do it?
upvote count: 0
has comment: http://stackoverflow.com/comment/33648835
answer count: 1
has comment: http://stackoverflow.com/comment/33404530
has comment: http://stackoverflow.com/comment/33404454
has comment: http://stackoverflow.com/comment/33499051
has comment: http://stackoverflow.com/comment/33650482
has title: How to extract thumbnail of a website in Java?
tagged with: jquery
favorite count: 0
has answer: http://stackoverflow.com/a/22087202
has comment: http://stackoverflow.com/comment/33404540
linked to: http://stackoverflow.com/q/757675
score: -2
has comment: http://stackoverflow.com/comment/33444187
has comment: http://stackoverflow.com/comment/33650198
has comment: http://stackoverflow.com/comment/33651792
has comment: http://stackoverflow.com/comment/33405904
has comment: http://stackoverflow.com/comment/33650066
downvote count: 2
accepted answer: http://stackoverflow.com/a/22087202
type: AnsweredQuestion

http://stackoverflow.com/comment/33448106
type: QuestionComment
has text: @MrTi I am waiting for 60 second and I can see that field on page(open by selenium webdriver). May you please explain how to check its a bad selector or not?
type: Comment
comment on: http://stackoverflow.com/q/22049976
score: 0

http://stackoverflow.com/comment/33391069
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22026283
type: QuestionComment
has text: I don't think XStream has native support for namespaces (it depends on parser configuration and it's limited). XStreamAlias is kind of a hack and doesn't always work. But what you want could be achieved quite easily with JAXB.

http://stackoverflow.com/comment/33435168
score: 0
type: Comment
has text: additionally, the documentation defines exceptions which should be thrown in specific cases when adding is refused, including the UnsupportedOperationException
comment on: http://stackoverflow.com/a/22051105
type: AnswerComment

http://stackoverflow.com/a/22042365
has comment: http://stackoverflow.com/comment/33419786
has comment: http://stackoverflow.com/comment/33419611
has comment: http://stackoverflow.com/comment/33420585
type: Answer
has comment: http://stackoverflow.com/comment/33420176
has comment: http://stackoverflow.com/comment/33420433
has body: At client side you are reading with BufferedReader#readLine which expect a \n to come. But from server, you are sending string(writeBytes(string)) without \n so how readLine will read that string. Append \n in string which you are sending to client. The main problem is here: At client side you are expecting to get data from server after sending each line to server while ((sentence = inFromUser.readLine()) != null) { outToServer.writeBytes(sentence + "\n"); modiﬁedSentence = inFromServer.readLine();// here you are expecting the answer from server but server is busy in listening more data lines.add(modiﬁedSentence); System.out.println("FROM SERVER: " + modiﬁedSentence); } Your server is still busy in listening data. while ((clientSentence = inFromClient.readLine()) != null) { capitalizedSentence = clientSentence.toUpperCase(); lines.add(capitalizedSentence); } Do some changes in server side code like this while ((clientSentence = inFromClient.readLine()) != null) { capitalizedSentence = clientSentence.toUpperCase(); outToClient.writeBytes(capitalizedSentence+"\n"); // imideately send data after converting it as client is expecting the data to receive and must append '\n' } One more solution is:: Change the client side code as shown below: while ((sentence = inFromUser.readLine()) != null) { outToServer.writeBytes(sentence + "\n"); // modiﬁedSentence = inFromServer.readLine(); Remove this line from here // lines.add(modiﬁedSentence); // System.out.println("FROM SERVER: " + modiﬁedSentence); } Make a while loop for reading data from server while ((modiﬁedSentence = inFromServer.readLine()) != null) { // make 'clientlines' as a set at client side and store all lines coming from server clientlines.add(capitalizedSentence); } A tip: If you are using DataOutputStream for writing then use DataInputStream for reading.
has comment: http://stackoverflow.com/comment/33420292
has comment: http://stackoverflow.com/comment/33419543
score: 0
has comment: http://stackoverflow.com/comment/33419019
answers question: http://stackoverflow.com/q/22042022

http://stackoverflow.com/a/22065475
downvote count: 1
has comment: http://stackoverflow.com/comment/33459464
score: 0
answers question: http://stackoverflow.com/q/22065385
has comment: http://stackoverflow.com/comment/33461380
type: Answer
upvote count: 1
has body: Yes you are correct, both will acutal create a local pointer in the stack which will point to an address in the heap. In case of a it will point to some address allocated in the heap, in case of b it points to null which in Java, is a special type which specifies invalid pointer. You can read more about the null itself here: What is null in Java? Also, Primitives types like int, long, etc... usually have a default value and they are not reference themselves, Since String is an object, you actually create a reference in the stack and set it to somewhere on the heap or to null.

http://stackoverflow.com/q/22146549
upvote count: 3
tagged with: java
has body: I was wondering whether is there a data structure that offers constant effort (O(1)) for both insertion/removal from/to both ends, as for example a LinkedList offers, and retrieval from a random index, as for example a HashMap offers. Or maybe if I can achieve something similar somehow with a combination of data structures.
has title: Data structure which offers both insertion/removal from/to both ends and retrieval from middle constant effort?
has answer: http://stackoverflow.com/a/22146611
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22146631
score: 3
downvote count: 0
favorite count: 0
type: Question
answer count: 2

http://stackoverflow.com/comment/33526631
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22102248
type: Comment
has text: Both purpose you are implementing is different, it depends on the requirement what you need .

http://stackoverflow.com/comment/33642786
type: QuestionComment
has text: Do you see two live datanodes on the web UI? Do you see two active-tasktrackers in the web UI/ running the command `hadoop job -list-active-trackers`? Any messages in the logs of the datanodes? Do you see rack-local tasks on the Web UI?
comment on: http://stackoverflow.com/q/22167302
score: 0
type: Comment

http://stackoverflow.com/a/22107857
type: Answer
upvote count: 2
answers question: http://stackoverflow.com/q/22107771
has body: Here's the statement at TreeMap.java 1188: return comparator==null ? ((Comparable&lt;? super K&gt;)k1).compareTo((K)k2) : comparator.compare((K)k1, (K)k2); So if comparator is null, then it will try to cast the set member to a (Comparable). If your class doesn't implement Comparable, this will cause the ClassCastException you saw. comparator is non-null only if you call the TreeMap constructor that provides a Comparator (or if you copy it from another SortedMap that already has a comparator).
score: 2
downvote count: 0

http://stackoverflow.com/comment/33437740
comment on: http://stackoverflow.com/q/22052639
type: QuestionComment
score: 0
has text: Agreed. For this type of search with a large list, it's much better to use a loop to do the job instead of recursion. Use recursion only if it's more convenient. Actually all recursive algorithms can be replaced by non-recursive algorithms.
type: Comment

http://stackoverflow.com/q/22090610
type: Question
tagged with: digits
has answer: http://stackoverflow.com/a/22090748
has answer: http://stackoverflow.com/a/22090793
has answer: http://stackoverflow.com/a/22090711
has title: Creating 0.000.. with certain decimals
has comment: http://stackoverflow.com/comment/33505122
possible better answer: http://stackoverflow.com/a/22090793
has answer: http://stackoverflow.com/a/22091000
has answer: http://stackoverflow.com/a/22090718
downvote count: 0
favorite count: 0
answer count: 5
tagged with: double
accepted answer: http://stackoverflow.com/a/22090711
has comment: http://stackoverflow.com/comment/33505157
has comment: http://stackoverflow.com/comment/33505192
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33505112
score: 1
tagged with: java
has body: I am trying to create the number 0.00000.... with as many '0' as the user input wants. What is wrong with my code below? int n; double dec = 0.0; in = new Scanner(System.in); n = in.nextInt(); for (i = 1; i &lt;= n; i++) dec = dec / 10.0d; Number doesn't change.
upvote count: 1

http://stackoverflow.com/comment/42744041
type: Comment
has text: can you up vote the answer please? :)
type: QuestionComment
comment on: http://stackoverflow.com/q/22147419
score: 0

http://stackoverflow.com/a/22122381
type: Answer
score: 2
has body: Simple is exactly what can help you here: deserialize your xml into java objects. And here's how to do this: Class Letters public class Letters { @ElementList(name = "letters", inline = true) private List&lt;Letter&gt; letters; // ... } Class Letter @Root(name = "letter") public class Letter { @Attribute(name = "linkable") private boolean linkable; @Text private String letter; // ... } How to use Serializer ser = new Persister(); Letters l = ser.read(Letters.class, xml); // xml is your input source; a string, file, stream, whatever ... Now, your xml is fully deserialized to java objects. Btw. those can contain further methods / fields. Serializing a Lists object back to xml is possible too: just replace ser.read(...) with ser.write(...).
downvote count: 0
answers question: http://stackoverflow.com/q/22032976
upvote count: 2

http://stackoverflow.com/q/22050913
has body: I have a web service that uses Jersey. For each request, I expect that the header will include an authentication token. With that token, I need to initialize a UserSecurity object that will use that authentication token to load this users security settings from the database. I then want this UserSecurity object to be visible in all my web service methods. How would I go about doing this, does jersey have filters or something?
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22052085
tagged with: jersey
has title: How to build a ReferralUrl that works with sites that have a virtual directory and those that don't
score: 0
answer count: 1
type: UnansweredQuestion

http://stackoverflow.com/comment/84817040
comment on: http://stackoverflow.com/a/22019115
type: AnswerComment
has text: @Marteng [No, according to the doc](https://www.postgresql.org/docs/9.1/static/sql-truncate.html)
type: Comment
score: 1

http://stackoverflow.com/q/22099400
has comment: http://stackoverflow.com/comment/33520878
has body: I'm working on an assignment in Java programming about calculating your age in days, without any Date classes. Here is the part of the code where I'm stuck. As you can see the second IF uses the same int as the first IF if both are true. int åSkillnad = år - years; int mSkillnad = (månad + 1) - months; int dSkillnad = dag - days; if (mSkillnad &lt; 0) { åSkillnad = åSkillnad - 1; mSkillnad = 12 + mSkillnad; System.out.println(mSkillnad); } if (dSkillnad &lt; 0) { mSkillnad = mSkillnad - 1; dSkillnad = månader[months - 1] + dSkillnad; System.out.println(mSkillnad); System.out.println(dSkillnad); } The problem that I can't solve is that if both the Month and Day difference are negative when subtracting the current date and the date you were born on, the second IF statement gets the new value of mSkillnad which was used in the first IF statement. Is there any way to work around this?
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22099685
tagged with: java
type: Question
has title: Avoid overriding when two IF statements contain the same int?
has comment: http://stackoverflow.com/comment/33521164
answer count: 1
has comment: http://stackoverflow.com/comment/33521205
score: 0
has comment: http://stackoverflow.com/comment/33521118
has answer: http://stackoverflow.com/a/22099685

http://stackoverflow.com/comment/33556996
comment on: http://stackoverflow.com/q/22119280
score: 0
has text: I want to define those values as part of method declaration and expect that Interceptor will know about them. I just don't want to make several Interceptors with the same logic, so I'm wondering how to provide this additional values.
type: Comment
type: QuestionComment

glassfish
tags question: http://stackoverflow.com/q/22117126
tags question: http://stackoverflow.com/q/22022114
tags question: http://stackoverflow.com/q/22117377
tags question: http://stackoverflow.com/q/22025380
tags question: http://stackoverflow.com/q/22071427
tags question: http://stackoverflow.com/q/22127567
tags question: http://stackoverflow.com/q/22136214
tags question: http://stackoverflow.com/q/22085970
tags question: http://stackoverflow.com/q/22013145
tags question: http://stackoverflow.com/q/22054482
tags question: http://stackoverflow.com/q/22031538
tags question: http://stackoverflow.com/q/22167592
tag name: glassfish
tags question: http://stackoverflow.com/q/22122626
tags question: http://stackoverflow.com/q/22017474
type: Tag

http://stackoverflow.com/q/22045710
tagged with: jinternalframe
favorite count: 0
tagged with: swing
has comment: http://stackoverflow.com/comment/33425313
has comment: http://stackoverflow.com/comment/33461400
type: AnsweredQuestion
tagged with: java
type: Question
linked to: http://stackoverflow.com/q/9554636
downvote count: 0
score: 4
accepted answer: http://stackoverflow.com/a/22045869
has title: How to do something when Close (X) button is clicked in JInternalFrame
has body: I got a assignment to create a JInternalFrame that can call mutiple of my applet work (last assignment call SpherePainter) and can count how many 'applets' are running inside the JinternalFrame. [the applet are running inside another JInternalFrame] public class MyInternalFrame extends JInternalFrame { static int openFrameCount = 0; static final int xOffset = 30, yOffset = 30; public MyInternalFrame() { super("SpherePainter #" + (++openFrameCount), true, true, true, true); setSize(500,500); //Set the window's location. setLocation(xOffset*openFrameCount, yOffset*openFrameCount); SpherePainterApplet sp = new SpherePainterApplet (); sp.init(); this.add(sp); } } I can call the applet with no problem, but I cannot count how many of them are 'actually' running. My method is to checkApp++ when one applet is create and checkApp-- when one is closed. Is there a way to use listener of closing button (X) or similar?
has comment: http://stackoverflow.com/comment/33461115
answer count: 1
tagged with: applet
upvote count: 4
has answer: http://stackoverflow.com/a/22045869

http://stackoverflow.com/a/23507135
answers question: http://stackoverflow.com/q/22155837
type: Answer
has comment: http://stackoverflow.com/comment/36052987
has body: I have also dealt with this exception after a fully working context.xml setup was adjusted. I didn't want environment details in the context.xml, so I took them out and saw this error. I realized I must fully create this datasource resource in code based on System Property JVM -D args. Original error with just user/pwd/host removed: org.apache.tomcat.jdbc.pool.ConnectionPool init SEVERE: Unable to create initial connections of pool. Removed entire contents of context.xml and try this: Initialize on startup of app server the datasource object sometime before using first connection. If using Spring this is good to do in an @Configuration bean in @Bean Datasource constructor. package to use: org.apache.tomcat.jdbc.pool.* PoolProperties p = new PoolProperties(); p.setUrl(jdbcUrl); p.setDriverClassName(driverClass); p.setUsername(user); p.setPassword(pwd); p.setJmxEnabled(true); p.setTestWhileIdle(false); p.setTestOnBorrow(true); p.setValidationQuery("SELECT 1"); p.setTestOnReturn(false); p.setValidationInterval(30000); p.setValidationQueryTimeout(100); p.setTimeBetweenEvictionRunsMillis(30000); p.setMaxActive(100); p.setInitialSize(5); p.setMaxWait(10000); p.setRemoveAbandonedTimeout(60); p.setMinEvictableIdleTimeMillis(30000); p.setMinIdle(5); p.setLogAbandoned(true); p.setRemoveAbandoned(true); p.setJdbcInterceptors( "org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"); org.apache.tomcat.jdbc.pool.DataSource ds = new org.apache.tomcat.jdbc.pool.DataSource(); ds.setPoolProperties(p); return ds;
score: 2
downvote count: 2
has comment: http://stackoverflow.com/comment/36052847
has comment: http://stackoverflow.com/comment/36053075
upvote count: 4

http://stackoverflow.com/a/22011339
type: Answer
upvote count: 1
has body: The problem is it matches the of the right place and the end of the This is because you let your expression consume everything, as long as it's not a vertical bar. If you change your expression to avoid closing brackets in the first group, it should capture the text that you want: \[\[([^\]|]*?)\|([^]]*?)\]\] Another positive aspect of this change is that it would eliminate backtracking from the process of evaluation of your regular expression, which could significantly improve performance. Demo on ideone.
accepted answer of: http://stackoverflow.com/q/22011164
answers question: http://stackoverflow.com/q/22011164
type: AcceptedAnswer
downvote count: 0
score: 1

http://stackoverflow.com/q/22013356
downvote count: 0
score: 1
tagged with: java
type: Question
has body: In my current ant build, I have a target which calls a Java class using a refid to specify a set of files. I would like to be able to expand all Ant properties within the file prior to processing it (the same way the sql task has an expandproperties flag). How can I go about doing this?
type: AnsweredQuestion
tagged with: ant
tagged with: properties-file
has answer: http://stackoverflow.com/a/22013872
upvote count: 1
accepted answer: http://stackoverflow.com/a/22013872
answer count: 1
has title: Expanding properties in custom ant task
favorite count: 0
tagged with: expand

http://stackoverflow.com/a/22169096
has comment: http://stackoverflow.com/comment/33778155
type: Answer
has comment: http://stackoverflow.com/comment/33843732
upvote count: 6
answers question: http://stackoverflow.com/q/22081505
has comment: http://stackoverflow.com/comment/33682999
has comment: http://stackoverflow.com/comment/33673929
accepted answer of: http://stackoverflow.com/q/22081505
has comment: http://stackoverflow.com/comment/33683892
has comment: http://stackoverflow.com/comment/33675378
has comment: http://stackoverflow.com/comment/33778000
score: 6
has comment: http://stackoverflow.com/comment/33674122
type: AcceptedAnswer
downvote count: 0
has body: The 'no-op' finalize() methods should definitely be removed as they are likely to make any GC performance problems worse. But I suspect that you have other memory leak issues as well. Advice: First get rid of the useless finalize() methods. If you have other finalize() methods, consider getting rid of them. (Depending on finalization to do things is generally a bad idea ...) Use memory profiler to try to identify the objects that are being leaked, and what is causing the leakage. There are lots of SO Questions ... and other resources on finding leaks in Java code. For example: How to find a Java Memory Leak Troubleshooting Guide for Java SE 6 with HotSpot VM, Chapter 3. Now to your particular symptoms. First of all, the place where the OutOfMemoryErrors were thrown is probably irrelevant. However, the fact that you have huge numbers of AbstractReferenceMap$WeakRef and AbstractReferenceMap$ReferenceEntry objects is a string indication that something in your application or the libraries it is using is doing a huge amount of caching ... and that that caching is implicated in the problem. (The AbstractReferenceMap class is part of the Apache Commons Collections library. It is the superclass of ReferenceMap and ReferenceIdentityMap.) You need to track down the map object (or objects) that those WeakRef and ReferenceEntry objects belong to, and the (target) objects that they refer to. Then you need to figure out what is creating it / them and figure out why the entries are not being cleared in response to the high memory demand. Do you have strong references to the target objects elsewhere (which would stop the WeakRefs from being broken)? Is / are the map(s) being used incorrectly so as to cause a leak. (Read the javadocs carefully ...) Are the maps being used by multiple threads without external synchronization? That could result in corruption, which potentially could manifest as a massive storage leak. Unfortunately, these are only theories and there could be other thi…

http://stackoverflow.com/comment/34030595
type: QuestionComment
score: 0
has text: I have the same problem, no idea why...
comment on: http://stackoverflow.com/q/22081823
type: Comment

http://stackoverflow.com/a/22120443
upvote count: 2
answers question: http://stackoverflow.com/q/22119155
has body: An idea could be to use @OneToMany reverse mapping and @OrderBy on it. I think you do no need that query. The following could load a menu given an ID from Menu m where m.id = ID That query will fetch your menu object and all reverse mappings will be populated ordered by your @OrderBy annotation
has comment: http://stackoverflow.com/comment/33577230
type: Answer
has comment: http://stackoverflow.com/comment/33584048
score: 2
downvote count: 0

http://stackoverflow.com/comment/33630382
type: AnswerComment
comment on: http://stackoverflow.com/a/22159815
type: Comment
score: 0
has text: @Adam Aha, I'll have to get back to you later. (Consider upgrading.)

http://stackoverflow.com/a/40596144
answers question: http://stackoverflow.com/q/22050194
upvote count: 1
type: Answer
has body: OK, if the above does not work, try the following. It worked for me. Moral of the story: Periodically save .metadata and .recommenders of your project. They may be useful. Why the problem happened: I added project Y to Project X and then removed it. Eclipse did not properly and fully remove Y and began to complain as above. Versions and configuration: Eclipse Neon. Legacy. No maven etc. What worked: 0) Exit eclipse. 1) Made a copy of the entire directory of X. To be on the safe side. 2) deleted the above two . directories. 3) Copied old saved versions of these directories to replace the deleted versions. 4) Restarted Eclipse. It made some routine complains. But I did the following: 4.1) Clean 4.2) Refresh 4.3) Build all 5) It worked. I exited and restarted Eclipse many times to make sure that the problem does not reappear. So far so good.
downvote count: 0
score: 1

http://stackoverflow.com/comment/33611051
type: Comment
has text: A tuple is a general-purpose immutable container of an arbitrary length. But a tuple is also typically *typed*.
type: AnswerComment
comment on: http://stackoverflow.com/a/22149577
score: 0

http://stackoverflow.com/comment/33459313
has text: In the heap both will be refer, a as hello World and b as null
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22065385
type: QuestionComment

http://stackoverflow.com/a/22135079
answers question: http://stackoverflow.com/q/22134881
has comment: http://stackoverflow.com/comment/33586204
has comment: http://stackoverflow.com/comment/33586133
has body: Please, stop it, your code is giving me cancer! There are a number of stylistic errors in the code that you need to fix. First off in java, method names always begin with a lowercase letter. You are programming in Java, not C#, so you need to use the Java naming conventions. That means your method should be called search, not Search. The same goes for variable names. What is BF supposed to mean, anyway? Replace it with in, please. Next up, unless this method is in an object that itself represents that particular file, the global variable f should be passed as a parameter instead. BufferedReader is AutoCloseable, so you should use a try-with-resources to deal with closing it. You need to add a javadoc comment to it, documenting its parameters with @param, its return with @return, and exactly why it might need to throw an IOException with @exception. Here is a mostly-fixed version of your code: /** * Needs Javadoc */ String search(String key, File f) throws IOException { int lines = 0 String line = ""; String foundAt = ""; try(BufferedReader in = new BufferedReader(new FileReader(f)) { while ((line = in.readLine().toLowerCase()) != null) { //the line in question lines++; StringTokenizer words = new StringTokenizer(line); while(words.hasMoreTokens()) if (words.nextToken().equals(key.toLowerCase())) foundAt = foundAt + "\n" + lines + ":" + line; } } catch(FileNotFoundException e){} return foundAt; } Now, the problem here is that in.readline() returns a null sometimes. Calling a method on a null is always a NullPointerException. Therefore you get a NullPointerException when you attempt to call that null's missing toLowerCase() method. You need to convert it toLowerCase after you ensure it is non-null.
has comment: http://stackoverflow.com/comment/33586360
score: 0
type: Answer

http://stackoverflow.com/q/22161356
has body: I'd started datanode successfully before, but when I tried today it shows the following info. It sounds like I have not mkdir the /home/hadoop/appdata/hadoopdata directory,but I confirmed that the directory already exists in my computer. So what's the problem? Why I couldn't start the datanode normally? Ex:I've tried to delete /home/hadoop/appdata/ and mkdir a new one, but it still doesn't work. I've also deleted /home/hadoop/tmp/hadoop_tmp and mkdir a new one, it still doesn't work... 2014-03-04 09:30:30,106 WARN org.apache.hadoop.metrics2.impl.MetricsSystemImpl: Source name ugi already exists! 2014-03-04 09:30:30,349 INFO org.apache.hadoop.hdfs.server.common.Storage: Cannot access storage directory /home/hadoop/appdata/hadoopdata 2014-03-04 09:30:30,350 INFO org.apache.hadoop.hdfs.server.common.Storage: Storage directory /home/hadoop/appdata/hadoopdata does not exist 2014-03-04 09:30:30,453 ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: java.io.IOException: All specified directories are not accessible or do not exist. at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:139) at org.apache.hadoop.hdfs.server.datanode.DataNode.startDataNode(DataNode.java:414) at org.apache.hadoop.hdfs.server.datanode.DataNode.&lt;init&gt;(DataNode.java:321) at org.apache.hadoop.hdfs.server.datanode.DataNode.makeInstance(DataNode.java:1712) at org.apache.hadoop.hdfs.server.datanode.DataNode.instantiateDataNode(DataNode.java:1651) at org.apache.hadoop.hdfs.server.datanode.DataNode.createDataNode(DataNode.java:1669) at org.apache.hadoop.hdfs.server.datanode.DataNode.secureMain(DataNode.java:1795)
has answer: http://stackoverflow.com/a/45671413
has title: Couldn't start hadoop datanode normally
type: AnsweredQuestion
tagged with: java
type: Question
tagged with: hadoop
answer count: 2
possible better answer: http://stackoverflow.com/a/45671413
has answer: http://stackoverflow.com/a/22174253
accepted answer: http://stackoverflow.com/a/22174253
has comment: http://stackoverflow.com/comment/33632418
score: 0

http://stackoverflow.com/comment/33637610
type: AnswerComment
comment on: http://stackoverflow.com/a/22163492
type: Comment
score: 2
has text: Thanks it worked after changing content type to :-headers="Content-Type=application/x-www-form-urlencoded"

http://stackoverflow.com/comment/33419857
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22042859
has text: look at updated version of my question. I've added context definition.

http://stackoverflow.com/a/22058708
type: Answer
upvote count: 2
downvote count: 2
has comment: http://stackoverflow.com/comment/33448376
score: 0
answers question: http://stackoverflow.com/q/22058695
has body: replace the dot inside the splitted string replace(".",""); String testString = "This. is. a. test. string."; String[] test = testString.split(" "); for (int i = 0; i &lt; test.length; i++) { System.out.println(test[i].replace(".","")); }}
has comment: http://stackoverflow.com/comment/33448346

http://stackoverflow.com/a/22125139
upvote count: 1
type: Answer
has body: Based on your requirement it seems IllegalStateException is more appropriate. As your class is managing some state of the Timer. From Java Doc for IllegalStateException : Signals that a method has been invoked at an illegal or inappropriate time. In other words, the Java environment or Java application is not in an appropriate state for the requested operation. From Java doc for IllegalAccessException, it says: An IllegalAccessException is thrown when an application tries to reflectively create an instance (other than an array), set or get a field, or invoke a method, but the currently executing method does not have access to the definition of the specified class, field, method or constructor. so, IllegalAccessException is not at all appropriate.
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/22125102
answers question: http://stackoverflow.com/q/22125102
type: AcceptedAnswer

http://stackoverflow.com/comment/85651894
score: 2
type: AnswerComment
has text: I don't understand why Selenium believes that my Save button isn't visible, but you saved (pun intended) me with this snippet.
type: Comment
comment on: http://stackoverflow.com/a/22125510

http://stackoverflow.com/a/22098527
upvote count: 1
downvote count: 0
has body: Yes, there is difference between them. Accssibility of methods are different depends on what kind of reference you use.
type: Answer
answers question: http://stackoverflow.com/q/22098461
score: 1

http://stackoverflow.com/a/22009569
upvote count: 4
has body: If you didn't specify your own ListModel for the JList component, it will use DefaultListModel. So, you can safely type cast for the model to DefaultListModel and remove all the items in JList like this: ((DefaultListModel)l_storieslist.getModel()).clear(); Swing components which have data have its Model object for storing data. You should get the model first, then manipulate the data through the model instance.
has comment: http://stackoverflow.com/comment/33360576
downvote count: 0
answers question: http://stackoverflow.com/q/22009301
score: 4
has comment: http://stackoverflow.com/comment/75710264
type: Answer

radio-button
tags question: http://stackoverflow.com/q/22164674
tags question: http://stackoverflow.com/q/22094700
tags question: http://stackoverflow.com/q/22076148
tag name: radio-button
type: Tag

http://stackoverflow.com/comment/33447978
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22058473
score: 0
has text: Can add a little more description to your question. It is unclear the problem you're facing.

http://stackoverflow.com/comment/33425259
has text: You are defining the type by calling registerStoredProcedureParameter so you might have a provider bug or configuration issue. What provider and version are you using?
comment on: http://stackoverflow.com/q/22045641
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/q/22006446
has comment: http://stackoverflow.com/comment/33354828
has comment: http://stackoverflow.com/comment/33355040
has comment: http://stackoverflow.com/comment/33354874
has comment: http://stackoverflow.com/comment/33355221
score: -5
tagged with: java
downvote count: 5
has title: How to exit from loop when find matched parameter in java
has comment: http://stackoverflow.com/comment/33355173
type: Question
has comment: http://stackoverflow.com/comment/33354925
has comment: http://stackoverflow.com/comment/33354956
upvote count: 0
answer count: 1
tagged with: arraylist
has comment: http://stackoverflow.com/comment/33355828
has body: Assume that I have an ArrayList containing 5 data as follows: testarrar=[optio1, option2, option3, realdata, option5]; I want to iterate over the above list and if i get realdata, then collect respective data, but in my case the code further excute after realdata and returns null. Edited: my Intention in my method if found realdata then i want to return data otherwise i dont want to return any value from this method. but in my case it at least null if data notfound.So that , I am trying to returning value if realdata found and exit.but my function goes end of testarrar.Only this function call if data have. here is my code: private Object getData() { if (testarrar.contains("realdata")) { if (obj != null) { //do something and get data return b.getValue(data);// I want to exit when matched parameter return this value } } return null; // I am getting this } If realdata in last then it work but any of position except last then return null, because it assume realdata in last. how to solve this, if i have any position realdata.
has answer: http://stackoverflow.com/a/22006589
has comment: http://stackoverflow.com/comment/33354871
has comment: http://stackoverflow.com/comment/33354927
favorite count: 0
type: UnansweredQuestion

http://stackoverflow.com/comment/33646159
type: AnswerComment
has text: Checkboxes are handled in a particular way in Struts2. Ensure you have the CheckboxInterceptor (and that it is before the ParamsInterceptor), and take a look at this: http://stackoverflow.com/a/21292722/1654265
score: 0
comment on: http://stackoverflow.com/a/22069987
type: Comment

http://stackoverflow.com/a/22048264
type: Answer
answers question: http://stackoverflow.com/q/22048151
downvote count: 0
has body: if (this.truckType.equals("1")) { //Code } else if (this.truckType.equals("2")) { //Code } else { System.out.println("Invalid option"); }
score: 1
upvote count: 1

http://stackoverflow.com/a/22152194
accepted answer of: http://stackoverflow.com/q/22133073
has comment: http://stackoverflow.com/comment/33626883
type: Answer
downvote count: 0
score: 1
has body: If you just need a PhraseQuery with slop (that is, extra words thrown in), then you can set the slop on a phrase query like: queryBuilder.phrase() .setSlop(2) .onField("myField") .sentance("this sentence missing something") .createQuery(); However, I'm not aware of anything in the Hibernate APIs that supports embedding fuzzy queries in phrases, but in Lucene, you can work with the SpanQuery API to build that. SpanMultiTermQueryWrapper and SpanNearQuery, in particular, are what you would need. Something like: FuzzyQuery query1 = new FuzzyQuery(new Term("field", "fuzy")); FuzzyQuery query2 = new FuzzyQuery(new Term("field", "phrse")); Query wrappedQuery1 = new SpanMultiTermQueryWrapper&lt;FuzzyQuery&gt;(query1); Query wrappedQuery2 = new SpanMultiTermQueryWrapper&lt;FuzzyQuery&gt;(query2); SpanQuery[] clauses = {wrappedQuery1, wrappedQuery2}; SpanNearQuery(clauses, 0, true);
answers question: http://stackoverflow.com/q/22133073
upvote count: 1
type: AcceptedAnswer

http://stackoverflow.com/comment/33608161
type: Comment
comment on: http://stackoverflow.com/a/22145264
score: 0
type: AnswerComment
has text: Still doesn't mate, thanks for your trying but I now understood that I had no idea that such thing as wiki markup existed, and what I basically tried to do is regex it, I should look for a wiki markup parser instead.

http://stackoverflow.com/comment/33635456
type: QuestionComment
comment on: http://stackoverflow.com/q/22163146
has text: what is your definition of sparse matrix? (it's *sparse*, not *spares*)
score: 0
type: Comment

http://stackoverflow.com/comment/52495678
type: Comment
has text: I also had this problem and in my case it was caused by the fact, that the app was running with a 32-bit JDK, but I used a 64-bit VisualVM.
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/22084195

http://stackoverflow.com/a/22129631
answers question: http://stackoverflow.com/q/22129573
type: Answer
score: 2
upvote count: 2
has body: The explanation: don't do that. Text editors never do that for a reason. First problem: you open a new FileWriter() over a file without the boolean argument; by default, this class will truncate the destination file. Second problem: even if you did open the FileWriter in append mode, the behaviour of your FileReader in this case is undefined. If you wrote this sample program to see how you could modify the contents of the file, remind that you must NOT take the "modify the contents of the file" stuff literally. What you SHOULD do is: create another temporary file in which you write the modified content; ensure that the temporary file is "safe and sound"; atomically rename the temporary file to the original file. If you fail to obey the scenario above, chances that your original file becomes corrupted in various ways are high.
downvote count: 0

http://stackoverflow.com/a/43580736
type: Answer
answers question: http://stackoverflow.com/q/22137283
upvote count: 1
has body: In you MainActivity just put set setContentView(R.layout.activity_main) before super.onCreate(savedInstanceState); like below: @Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_profile); super.onCreate(savedInstanceState); }
score: 1
downvote count: 0

http://stackoverflow.com/comment/33436699
type: AnswerComment
score: 0
type: Comment
has text: I haven't been able to find a Maven plugin for the Google Code Style stuff that was linked to in the question
comment on: http://stackoverflow.com/a/22050685

http://stackoverflow.com/a/22831521
answers question: http://stackoverflow.com/q/22084307
type: Answer
has comment: http://stackoverflow.com/comment/39892939
has body: I had the same problem, and well, the solution was simple, do not use any widget, simply use the RemoteControlClientCompat class. Here is my lockScreenControls() method code , which I call whenever I want to show this type of control (when plays a song). This is which GooglePlayMusic does. private void lockScreenControls() { // Use the media button APIs (if available) to register ourselves for media button // events MediaButtonHelper.registerMediaButtonEventReceiverCompat(mAudioManager, mMediaButtonReceiverComponent); // Use the remote control APIs (if available) to set the playback state if (mRemoteControlClientCompat == null) { Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON); intent.setComponent(mMediaButtonReceiverComponent); mRemoteControlClientCompat = new RemoteControlClientCompat(PendingIntent.getBroadcast(this /*context*/,0 /*requestCode, ignored*/, intent /*intent*/, 0 /*flags*/)); RemoteControlHelper.registerRemoteControlClient(mAudioManager,mRemoteControlClientCompat); } mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); mRemoteControlClientCompat.setTransportControlFlags( RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_STOP); //update remote controls mRemoteControlClientCompat.editMetadata(true) .putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, "NombreArtista") .putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, "Titulo Album") .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, nombreCancion) //.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION,playingItem.getDuration()) // TODO: fetch real item artwork .putBitmap(RemoteControlClientCompat.MetadataEditorCompat.METADATA_KEY_ARTWORK, getAlbumArt()) .apply(); } } ***********EDIT************ RemoteControlClientCompat class: @SuppressWarnings({"rawtypes", "unchecked"}) public class RemoteControlClientCompat { private static final String TAG …
has comment: http://stackoverflow.com/comment/54492850
upvote count: 5
has comment: http://stackoverflow.com/comment/39987370
score: 5
has comment: http://stackoverflow.com/comment/70703795
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/52954868
downvote count: 0
has comment: http://stackoverflow.com/comment/60729835
accepted answer of: http://stackoverflow.com/q/22084307

http://stackoverflow.com/a/22087672
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/22087039
type: Answer
has body: tabCount is forced to 0 in every iteration of the while loop. Do the declaration and initialization of tabCount before the while loop and leave only the postfix increment of tabCount inside the if clause of while loop. This way it will retain the correct tabCount value.
upvote count: 1

http://stackoverflow.com/a/22108665
upvote count: 5
type: Answer
score: 4
answers question: http://stackoverflow.com/q/22108641
downvote count: 1
has body: This is because of an optimization the Java compiler performs. While compiling it sees that you have a constant string "abc", so when it encounters another constant string it checks and finds that it already has that string loaded in memory. So, it just uses the same object again. The result is that they are the same exact object in memory.

http://stackoverflow.com/comment/33464495
comment on: http://stackoverflow.com/a/22068341
score: 0
type: AnswerComment
has text: And is there any way to get in Java unsigned bytes instead signed in C# ?
type: Comment

http://stackoverflow.com/a/22134229
has body: Try to check the XML file in a simple text editor for errors. Sometimes when you let Eclipse/ADT autocomplete inline it just leaves some garbage there that is not visible in the editor somehow. It happens frequently to me.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/22133940

database-design
tags question: http://stackoverflow.com/q/22130692
type: Tag
tag name: database-design

http://stackoverflow.com/q/22119365
has answer: http://stackoverflow.com/a/22119389
has comment: http://stackoverflow.com/comment/33557065
has body: I'm struggling understanding how work with java objects from other objects. I have 3 simple classes: 1) environment object public class Environment { protected String envName; public Environment(String envName){ this.envName = envName; } // get and set methods public String getenvName(){ return envName; } public void setenvName(String envName){ this.envName = envName; } } 2) Class that will populate this object public class FetchConfig { Environment environment; public FetchConfig() { } public void buildConfig() { environment.setenvName("Steve"); } } 3) A class with main method with will work with my Environment objects: public class WorkWithEnvironment { private FetchConfig config; public static void main(String[] args) throws FileNotFoundException, IOException { WorkWithEnvironment w = new WorkWithEnvironment(); w.setupConfig(); w.readEnvNames(); } private void setupConfig() throws FileNotFoundException, IOException { config = new FetchConfig(); config.buildConfig(); } private void readEnvNames() { System.out.println("Environment name is: " + config.environment.getenvName()); } } But when I run it, I keep getting an NPE(NullPointerException) here -> environment.setenvName("Steve");
type: Question
has answer: http://stackoverflow.com/a/22119390
tagged with: java
has title: Understanding referencing other classes in java - null pointer exception
possible better answer: http://stackoverflow.com/a/22119390
accepted answer: http://stackoverflow.com/a/22119389
score: 0
answer count: 2
tagged with: nullpointerexception
type: AnsweredQuestion

http://stackoverflow.com/comment/33615996
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22151550
has text: don't forget there are actually **3** streams when dealing with the Runtime.exec(). Stdin, Stout, and **stderr** . This doesn't sound like your problem exactly, but it probably will bite you down the road. ( unless you merge the stdout and stderr streams, in which case ignore me)

http://stackoverflow.com/comment/33464879
comment on: http://stackoverflow.com/q/22044163
type: Comment
type: QuestionComment
has text: Fair enough, I've overlooked this one.
score: 0

http://stackoverflow.com/comment/33470670
type: Comment
has text: @KevinMeredith - The two XML formats are similar in that they both accomplish the same task but for different tools. You could 1) write a program that does the conversion from one to the other or 2) look through each check manually and create the checkstyle XML by hand - http://checkstyle.sourceforge.net/writingchecks.html
type: AnswerComment
comment on: http://stackoverflow.com/a/22050685
score: 0

http://stackoverflow.com/comment/33436593
type: Comment
comment on: http://stackoverflow.com/a/22051568
has text: now look at the image at the top that is what I want.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33522677
type: AnswerComment
has text: @keshlam Right, you just have to remember to scale it yourself. The Ada language has fixed-point numbers built-in, where numbers are represented as integers but the compiler keeps track of the scale factor. It shouldn't be hard to devise a class to do the same thing in Java, if this hasn't been done already.
comment on: http://stackoverflow.com/a/22084217
score: 0
type: Comment

http://stackoverflow.com/q/22098884
score: 0
answer count: 2
upvote count: 1
downvote count: 1
has body: My question is regarding the shutdown() method from the ExecutorService class. If i am calling the submit() method in an infinite loop... do i ever need to call shutdown()? Essentially i have something like this (pseudo-code here): for(;;){ for(some event){ if(some event does something i want to capture){ threadPool.submit() } } } So with a set up like the above when is it appropriate to call shutdown() ? In my actual code when i try to call shutdown() outside the infinite loop i get unreachable code error - which i understand. But it seems to me that i would probably not call the shutdown() method. What do you guys think?
favorite count: 0
tagged with: multithreading
has title: Calling ExecutorService submit() inside an infinite loop
possible better answer: http://stackoverflow.com/a/22098963
tagged with: executorservice
has answer: http://stackoverflow.com/a/22098963
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22098938
accepted answer: http://stackoverflow.com/a/22098938
tagged with: java
type: Question

http://stackoverflow.com/a/22055531
accepted answer of: http://stackoverflow.com/q/22054187
answers question: http://stackoverflow.com/q/22054187
score: 0
type: AcceptedAnswer
has body: Use JTextArea.append rather then JTextArea.setText. Don't forget to place a new line (\n) at the end of each line You may also wish to place the JTextArea in a JScrollPane or as you add more text to the text area, it will grow, taking up more space in your UI, for example... p_right.add(new JScrollPane(textArea), BorderLayout.CENTER); Take a look at How to Use Text Areas and How to Use Scroll Panes for more details
type: Answer
has comment: http://stackoverflow.com/comment/33472753

http://stackoverflow.com/a/22083685
type: Answer
answers question: http://stackoverflow.com/q/22083494
upvote count: 1
has body: Just leave everything as it is and use this actual working java code for sum public int sum(Planet[] planets) { int sum = 0; for(Planet planet : planets){ sum += planet.moons; } return sum; }
has comment: http://stackoverflow.com/comment/33493730
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33493452
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/22083494

http://stackoverflow.com/comment/33403581
score: 0
type: QuestionComment
has text: The flag allows new compilers to support (enforce) older versions of the language. There's also a target version that can be set so code can run on older JDKs. I'm assuming these are typically used together. It's just weird that your compiler decided to default to 1.4 or something.
type: Comment
comment on: http://stackoverflow.com/q/22032765

http://stackoverflow.com/comment/33618374
score: 0
type: AnswerComment
type: Comment
has text: Where you want to return the result value ? if you mean you want it to return inside onReceive, this can not be done.
comment on: http://stackoverflow.com/a/22153390

http://stackoverflow.com/comment/33384914
score: 0
type: Comment
type: AnswerComment
has text: Well then you have something to lecture your lecturer about ;). Teachers really shouldn't encourage bad coding habits...
comment on: http://stackoverflow.com/a/22022924

http://stackoverflow.com/comment/33642059
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22141316
type: AnswerComment
has text: yes the first time, that is why I suggested to use a static initializer in the extending classes.

http://stackoverflow.com/comment/33589593
comment on: http://stackoverflow.com/q/22135824
score: 0
type: Comment
type: QuestionComment
has text: So what i have done above. With using the two arrayLists, is not efficient, since they are still in memory? Also, whenever i call System.gc() the program stutters as well. Even though i have not created any objects during the running of the game.

http://stackoverflow.com/q/22137411
type: Question
tagged with: messaging
tagged with: ipc
has body: Usually people would just work above this layer - but I am now working on this layer where I need to map the PUB/SUB many-to-many messaging relationship to a IPC or TCP infrastructure - which naturally, I could have only 1 publisher binding per address. The alternative I could think of each has their own drawbacks: Adding a daemon and route the messages. This add a single point of failure as well as an additional layer during messaging. Adding a registry. Adds a single point of failure and also cannot notify the newly started processes. Disallow multiple publishers on the same topic - lose some flexibility on arranging architecture. Pre-define a port range and IPC address range and every process periodically retry connecting to them. Add delay on service discovery and all ports must be available from OS. So how does the modern messaging software packages like JMS, LBM doing this? I know Tibco RV and Reuters doing through approach 1) - anyway I could avoid such a daemon process? I am using Java if it matters. Thanks.
has comment: http://stackoverflow.com/comment/33589853
score: 0
answer count: 1
tagged with: jms
has comment: http://stackoverflow.com/comment/33589921
type: UnansweredQuestion
tagged with: tibco-ems
has title: How messaging infrastructure maps topic to IPC/TCP layer for PUB/SUB?
tagged with: java
has answer: http://stackoverflow.com/a/27431147

http://stackoverflow.com/comment/33635016
has text: possible duplicate of [How do I compare strings in Java?](http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java)
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22162871
score: 0

http://stackoverflow.com/a/22104013
has comment: http://stackoverflow.com/comment/33530269
has body: Copy constructors have a lot of problems, and in general, cloning is preferable, but if you do want to use a copy constructor here is how: public University( University univ ){ University univ_copy = new University(); univ_copy.name = univ.getname(); univ_copy.numOfPublications = univ.getnumOfPublications(); univ_copy.departments = new Department[univ.numOfDepartments]; System.arrayCopy( univ.departments, 0, univ_copy.departments, 0, univ.departments.length ); return univ_copy; } You can also copy the departments one by one, as opposed to copying them in one step with array copy. The key thing is that you need to allocate a new array for the copy, not re-use the existing array from univ because then you would not have a copy of the array, just a pointer to the original array.
has comment: http://stackoverflow.com/comment/33530743
answers question: http://stackoverflow.com/q/22103771
has comment: http://stackoverflow.com/comment/33529988
type: Answer
has comment: http://stackoverflow.com/comment/33530227
has comment: http://stackoverflow.com/comment/33529562
score: 0

http://stackoverflow.com/comment/33568144
type: Comment
type: QuestionComment
has text: nope, not on your blog. here.
comment on: http://stackoverflow.com/q/22117353
score: 0

http://stackoverflow.com/comment/33462386
type: Comment
has text: Note also the javadocs from DriverManagerDataSource: "NOTE: This class is not an actual connection pool; it does not actually pool Connections. It just serves as simple replacement for a full-blown connection pool, implementing the same standard interface, but creating new Connections on every call."
type: AnswerComment
comment on: http://stackoverflow.com/a/22066589
score: 0

task
type: Tag
tags question: http://stackoverflow.com/q/22098288
tag name: task

http://stackoverflow.com/q/22049973
type: UnansweredQuestion
score: -3
tagged with: swing
has body: What's wrong with the following code? I'm getting "Tool completed with exit code 1" which doesn't tell me much. I want to prompt user for input, take input, parse it to an int, and then display the value in another message dialogue. import javax.swing.JOptionPane public class First { public static void main(String[] args) { result = JOptionPane.showInputDialog(null, "How many?"); int ans = Integer.parseInt(result); JOptionPane.showMessageDialog("You have " + ans + " Things."); } }
has title: JOptionPane not working
tagged with: java
type: Question
answer count: 1
favorite count: 0
downvote count: 3
has comment: http://stackoverflow.com/comment/33436264
has answer: http://stackoverflow.com/a/22050106
upvote count: 0
tagged with: compiler-errors

http://stackoverflow.com/comment/33636103
type: AnswerComment
comment on: http://stackoverflow.com/a/22161571
type: Comment
has text: you know the strings test and testing they should only drop into one textArea and be rejected by the rest. the whole point of this program is to have 30 images and 30 strings. each image matches 1 string. the user selects a string and drags it to textArea but only one textArea will accept the string and the rest of the textAreas will reject the strings... is this possible to do? i had this working but i had the string inside the method although it worked the strings needed to be passed through the class
score: 0

http://stackoverflow.com/q/22025943
tagged with: observer-pattern
type: Question
has body: Is it more likely to use the observer pattern in Java to handel for example game rules like in some simple games or just throw exceptions to handel these in the UserInterface classes? Each time an user clicks onto a button on the UserInterface, this controller just delegates this action to the model with the data in it. The model decides whether the data is correct compared to some game rules or just throw exceptions to handle this in the controller and react on each custom exception. E.g. (in model class; don't need to show you the corresponding controller class): Observer Pattern with PropertyChangeListener and PropertyChangeSupport: public void setPlayerNames(ArrayList&lt;String&gt; playerNames) { if(playerNames.size() == 0) propertyChangeSupport.firePropertyChange("pleaseEnterAtLeastOnePlayerName); else startGame(); } And with some custom exceptions in the model: public void setPlayerNames(ArrayList&lt;String&gt; playerNames) throws NoPlayerException { if(playerNames.size() == 0) throw new NoPlayerException(); else startGame(); } Which of these methods complies more to the MVC paradigma?
answer count: 1
accepted answer: http://stackoverflow.com/a/22026054
score: 0
has title: Use observer pattern ot throw exceptions in model
tagged with: exception
has answer: http://stackoverflow.com/a/22026054
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/q/22129955
tagged with: concurrency
upvote count: 0
answer count: 1
has answer: http://stackoverflow.com/a/22129981
favorite count: 0
tagged with: blocking
has body: I read about PriorityBlockingQueue, and seems I've got some delusions about it. You can see four statements below. I hope if you disagree with them you'll correct me. Blocking collections block a thread if the thread can't execute operation on collection. (Block till condition when the thread can continue). Main purpose - producer-consumer scheme. Non-blocking collections doesn't block a thread and the thread proceeds execution. Main purpose - schemes where reader shouldn't wait for writer. I mean schemes where the delay read-oparation delay after write is not significant. As it follows from the name of PriorityBlockingQueue - it's a blocking collection. PriorityBlockingQueue offer such non-blocking methods as poll, remove, put etc; and seems only poll(long timeout, TimeUnit unit) and take methods are blocking. Conclusion: From the fourth statement I conclude that PriorityBlockingQueue can be used both as blocking and non-blocking queue. Question: Am I right in my conclusion? Can I say the same about all other blocking collections?
has title: PriorityBlockingQueue: is it realy blocking
has comment: http://stackoverflow.com/comment/33576699
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33576660
tagged with: java
accepted answer: http://stackoverflow.com/a/22129981
tagged with: multithreading
tagged with: collections
downvote count: 1
type: Question
score: -1

dicom
tag name: dicom
tags question: http://stackoverflow.com/q/22064108
type: Tag
tags question: http://stackoverflow.com/q/22126774
tags question: http://stackoverflow.com/q/22119680

http://stackoverflow.com/q/22032016
answer count: 2
has comment: http://stackoverflow.com/comment/33404935
has comment: http://stackoverflow.com/comment/33401287
has comment: http://stackoverflow.com/comment/33401241
tagged with: arrays
has comment: http://stackoverflow.com/comment/33402062
has comment: http://stackoverflow.com/comment/33400890
has answer: http://stackoverflow.com/a/22032194
score: 0
linked to: http://stackoverflow.com/q/390181
has comment: http://stackoverflow.com/comment/33401123
has comment: http://stackoverflow.com/comment/33401116
has comment: http://stackoverflow.com/comment/33400940
linked to: http://stackoverflow.com/q/2896374
has comment: http://stackoverflow.com/comment/33401617
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33400853
has comment: http://stackoverflow.com/comment/33400843
has answer: http://stackoverflow.com/a/22032488
has body: I have declared a few arrays, in these array we have the following values: {0, 1, 1, 0, 0} {1, 0, 0, 0, 1} {0, 1, 0, 0, 0} I have multiple arrays with the same number of values. For my Android application I am going to have a set of buttons. If Button 1 is pushed, I want to know if any 1's are in positions 1, 3, and 5 and how many. If Button 2 is pushed, I want to know if any 1's are in positions 1, 2, 3, and 4 and how many. Everything I have searched shows how to find out if 1's exist in the array, but not at a specific position. Any suggestions/help? Details on what I am trying to accomplish if you wish to read, though I should be able to figure everything out with a helpful solution to my above question: I have 64 buttons arranged in an 8x8 grid to represent sections of the human torso, and 64 numbers (0's or 1's) in my 13 arrays. The arrays identify if an organ is present in one of the aforementioned torso sections (1 if the organ is present, 0 if not present). I want to push a button, and search all of the arrays for a 1 at that position. If I push button 35, I want to know if the liver is present in that section. My ultimate output will tell the user what percentage of the organ is likely to be in that section. If a section contains a piece of the organ it will be a 1, and then divided by the total number of sections containing that organ. If you've read this far, am I attacking this problem from the correct angle, do you have additional ideas?
tagged with: java
has title: Searching arrays for a value at specific indices
type: Question

http://stackoverflow.com/comment/33557116
type: AnswerComment
has text: @AwfullyAwesome you should mention that it is not thread safe.
type: Comment
comment on: http://stackoverflow.com/a/22119299
score: 0

http://stackoverflow.com/comment/33590294
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22137674
score: 1
has text: Wild guess, maybe you did your own physics/collision and create there loads of vectors/matrices?

http://stackoverflow.com/a/22029973
has comment: http://stackoverflow.com/comment/33397564
has comment: http://stackoverflow.com/comment/33397634
has comment: http://stackoverflow.com/comment/33397500
has comment: http://stackoverflow.com/comment/33397535
type: Answer
answers question: http://stackoverflow.com/q/22029848
has body: You'll need to use something known as an abstract class. abstract class Calculation { public int calCost(int x, int y) { // put your long definition here return x + y; } } class FirstCalc extends Calculation { public void someOtherMethod() { int a = 10; int b = 20; int c = calCost(a, b); System.out.println(c); } } You could also make calCost an abstract method, if you'd like each class that extends the Calculation class to define their own implementations. Or, use composition: class Calculation { public int calCost(int x, int y) { return x + y; //or other implementation } } class C1 extends M { private Calculation calculation = new Calculation(); public void someOtherMethod() { int a = 10; int b = 20; int c = calculation.calCost(a, b); } } class C2 extends M { private Calculation calculation = new Calculation(); public void someOtherOtherMethod() { // ... int c = calculation.calCost(10, 20); } }
score: 3
accepted answer of: http://stackoverflow.com/q/22029848
upvote count: 3
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33397841
downvote count: 0
has comment: http://stackoverflow.com/comment/33397452

http://stackoverflow.com/comment/33401399
type: Comment
comment on: http://stackoverflow.com/a/22032381
has text: Hi Jitesh, thanx for the help but can you tell me where I will be notified that the Wifi has been changed. I mean suppose I am on wifi named "Inside", and I move to "Outside", can you please tell me where to write the code to toast a message like "Wifi has been changed from "Inside" to "Outside"."
score: 0
type: AnswerComment

http://stackoverflow.com/q/22110759
type: UnansweredQuestion
tagged with: jdbc
tagged with: java
downvote count: 2
has body: I am going to build web application in Java (JSP). In my web application ;JApplet will communicate with the database that is on other place(Remote Database). My question is that how applet can take and give the data from the database. I am Using MYSQL database. Can I use JDBC for that ?If so then how?
tagged with: mysql
upvote count: 1
has title: How Applet talk to Web server
has answer: http://stackoverflow.com/a/22112348
type: Question
has answer: http://stackoverflow.com/a/22111385
score: -1
answer count: 2
tagged with: jsp
tagged with: applet
favorite count: 0

http://stackoverflow.com/comment/33545017
comment on: http://stackoverflow.com/q/22112580
has text: i mean your loop statement was not correct
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33403681
comment on: http://stackoverflow.com/a/22033460
score: 0
type: AnswerComment
type: Comment
has text: @Prabha - No. "" is empty string. and its different from " ". (a space). ""+s1 will be created on the heap, So, s1 and ""+s1 will be different.

http://stackoverflow.com/a/22146473
type: Answer
has comment: http://stackoverflow.com/comment/33607257
score: 2
upvote count: 2
accepted answer of: http://stackoverflow.com/q/22146173
answers question: http://stackoverflow.com/q/22146173
has comment: http://stackoverflow.com/comment/33605395
has body: It is because of {. It is used to specify how many times something should it be repeated. For instance x{2,4} will match x repeated 2 (xx), 3 (xxx) or 4 (xxxx) times. If you want regex to match { literal it needs to be escaped: (?:--|#|\/\*|\{)
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/22119312
has body: Use an aggregator: private static class JpaAggregationRouteBuilder extends RouteBuilder { @Override public void configure() { from("jpa:com.pns.ab.model.LoanRequest?consumeDelete=false" + "&amp;consumer.delay=20000" + "&amp;consumer.namedQuery=selectLoanRequests" + "&amp;persistenceUnit=LoanServicePU") .aggregate(constant(true), new ArrayListAggregationStrategy()) .completionFromBatchConsumer() .process(new JpaProcessor()); } } // Simply combines Exchange body values into an ArrayList&lt;Object&gt; // Taken from http://camel.apache.org/aggregator2 private static class ArrayListAggregationStrategy implements AggregationStrategy { @SuppressWarnings("unchecked") @Override public Exchange aggregate(final Exchange oldExchange, final Exchange newExchange) { final Object newBody = newExchange.getIn().getBody(); ArrayList&lt;Object&gt; list = null; if (oldExchange == null) { list = new ArrayList&lt;Object&gt;(); if (newBody != null) { list.add(newBody); } newExchange.getIn().setBody(list); return newExchange; } else { list = oldExchange.getIn().getBody(ArrayList.class); if (newBody != null) { list.add(newBody); } return oldExchange; } } } More information about the aggregator can be found on the Camel webpage.
score: 8
downvote count: 0
upvote count: 8
accepted answer of: http://stackoverflow.com/q/22116789
answers question: http://stackoverflow.com/q/22116789
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/q/22158018
score: 4
favorite count: 0
answer count: 1
has answer: http://stackoverflow.com/a/22158111
accepted answer: http://stackoverflow.com/a/22158111
has body: I'm trying to test whether a set of strings contains a particular string, independent of case. For example, if mySet contained "john" xor "John" xor "JOHN" xor..., then mySet.contains("john") (or something similar) should return true.
upvote count: 4
linked to: http://stackoverflow.com/q/8751455
has comment: http://stackoverflow.com/comment/33626625
has comment: http://stackoverflow.com/comment/33627209
type: AnsweredQuestion
downvote count: 0
has comment: http://stackoverflow.com/comment/33626782
tagged with: java
type: Question
has title: Check if a Java Set contains a particular string, independent of case

http://stackoverflow.com/q/22034269
answer count: 2
linked to: http://stackoverflow.com/q/17234359
downvote count: 0
linked to: http://stackoverflow.com/q/10836139
favorite count: 0
has body: Following are my encrypt/decrypt methods: private String decrypt_data(String encData) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { String key = "bad8deadcafef00d"; SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(), "AES"); Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding"); cipher.init(Cipher.DECRYPT_MODE, skeySpec); System.out.println("Base64 decoded: "+Base64.decode(encData.getBytes()).length); byte[] original = cipher.doFinal(Base64.decode(encData.getBytes())); return new String(original).trim(); } private String encrypt_data(String data) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { String key = "bad8deadcafef00d"; SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(), "AES"); Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding"); cipher.init(Cipher.ENCRYPT_MODE, skeySpec); System.out.println("Base64 encoded: "+ Base64.encode(data.getBytes()).length); byte[] original = cipher.doFinal(Base64.encode(data.getBytes())); return new String(original); } So now when I am trying to encrypt, I am getting this exception: javax.crypto.IllegalBlockSizeException: Input length not multiple of 16 bytes at com.sun.crypto.provider.CipherCore.finalNoPadding(CipherCore.java:854) at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:828) at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676) at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:313) at javax.crypto.Cipher.doFinal(Cipher.java:2087) I have tried with cipher instance AES/ECB/PKCS5Padding in both encrypt and decrpt. It works only for encryption and not for decryption. I suppose padding is needed as data size is not multiple of 16bytes. 'data' byte length was printed as 152 so tried appending eight \0 characters to data and then encrypt, it didn't work either.
has answer: http://stackoverflow.com/a/22035187
tagged with: cryptography
score: 1
has answer: http://stackoverflow.com/a/22034858
has comment: http://stackoverflow.com/comment/33404638
type: UnansweredQuestion
tagged with: encryption
upvote count: 1
has comment: http://stackoverflow.com/comment/33404578
has title: encryption/decryption using AES/ECB/NoPadding
tagged with: java
has comment: http://stackoverflow.com/comment/33404470
type: Question

http://stackoverflow.com/a/53908660
upvote count: 0
answers question: http://stackoverflow.com/q/22034650
downvote count: 3
has body: CriteriaBuilder cb = session.getCriteriaBuilder(); CriteriaQuery&lt;MessageWrapper&gt; q = cb.createQuery(MessageWrapper.class); Root&lt;Chain&gt; c = q.from(Chain.class); Join&lt;Chain, Message&gt; m = p.join("messages"); q.groupBy(c.get("id")); q.select(cb.construct(MessageWrapper.class, c.get("id"), cb.max(m.get("id"))));
score: -3
type: Answer
has comment: http://stackoverflow.com/comment/94662167

http://stackoverflow.com/q/22036614
has comment: http://stackoverflow.com/comment/33408552
tagged with: image
answer count: 2
tagged with: recycle
has comment: http://stackoverflow.com/comment/33409041
score: 0
has body: I'm trying to implement Android-wheel, a library that I can use to imitate a slot machine. The demo project works fine, it use's android's own drawables => android.R.drawable.* However when I change the default images to the ones I want it gives me this error : java.lang.IllegalArgumentException: Cannot draw recycled bitmaps All I changed was the id's array which contains the reference to the images from private final int items[] = new int[] { android.R.drawable.star_big_on, android.R.drawable.stat_sys_warning, android.R.drawable.radiobutton_on_background, android.R.drawable.ic_delete }; to private final int items[] = new int[] { R.drawable.sunglasses, R.drawable.ball, R.drawable.box}; Here's the rest of the code. private class SlotMachineAdapter extends AbstractWheelAdapter { // Image size final int IMAGE_WIDTH = 267; final int IMAGE_HEIGHT = 200; // Slot machine symbols private final int items[] = new int[] { R.drawable.sunglasses, R.drawable.ball, R.drawable.box}; // Cached images private List&lt;SoftReference&lt;Bitmap&gt;&gt; images; // Layout inflater private Context context; /** * Constructor */ public SlotMachineAdapter(Context context) { this.context = context; images = new ArrayList&lt;SoftReference&lt;Bitmap&gt;&gt;(items.length); for (int id : items) { images.add(new SoftReference&lt;Bitmap&gt;(loadImage(id))); } } /** * Loads image from resources */ private Bitmap loadImage(int id) { Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), id); Bitmap scaled = Bitmap.createScaledBitmap(bitmap, IMAGE_WIDTH, IMAGE_HEIGHT, true); bitmap.recycle(); return scaled; } @Override public int getItemsCount() { return items.length; } // Layout params for image view final LayoutParams params = new LayoutParams(IMAGE_WIDTH, IMAGE_HEIGHT); @Override public View getItem(int index, View cachedView, ViewGroup parent) { ImageView img; if (cachedView != null) { img = (ImageView) cachedView; } else { img = new ImageView(context); } img.setLayoutParams(params); S…
tagged with: android
has answer: http://stackoverflow.com/a/30271240
type: UnansweredQuestion
tagged with: bitmap
has title: java.lang.IllegalArgumentException: Cannot draw recycled bitmaps - Android
has answer: http://stackoverflow.com/a/22036929
type: Question
tagged with: java

http://stackoverflow.com/a/22086047
score: 29
answers question: http://stackoverflow.com/q/22085985
has comment: http://stackoverflow.com/comment/87934418
has body: Abstract classes permit providing a partial set of default implementations of methods in a class. Since they're incomplete, they can't be instantiated and used as they stand, but they can be subclassed to add the missing details in a way that's specific to that particular implementation, and those subclasses can be instantiated. Without abstract classes, you would have to provide dummy implementations of the methods you intend to override ... which could be done, but then there'd be the risk of forgetting to implement one of them. Having some methods remain entirely abstract ensures that the real implementations have to fill in the gaps, or continue to be abstract themselves and force their descendents to do so. It's not something the language couldn't live without. But it's very useful. You'll discover just how useful as you become more proficient in Java and OO design.
downvote count: 0
type: Answer
upvote count: 29

http://stackoverflow.com/q/22013361
has comment: http://stackoverflow.com/comment/33573448
has body: Why this is illegal: switch(x) { case 1: int a = 1; break; case 2: int a = 2; break; } It looks like it could have been legal. What are some deeper reasons for that to be illegal?
has comment: http://stackoverflow.com/comment/33366802
has title: Why we can not define a variable twice in switch?
possible better answer: http://stackoverflow.com/a/22013408
accepted answer: http://stackoverflow.com/a/22013409
linked to: http://stackoverflow.com/q/10932997
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22013408
has answer: http://stackoverflow.com/a/22015293
answer count: 7
has comment: http://stackoverflow.com/comment/33366496
has answer: http://stackoverflow.com/a/22013460
duplicate of: http://stackoverflow.com/q/10932997
has comment: http://stackoverflow.com/comment/33366619
favorite count: 0
has comment: http://stackoverflow.com/comment/33366581
has comment: http://stackoverflow.com/comment/33366524
type: Question
score: 37
has comment: http://stackoverflow.com/comment/33366526
has comment: http://stackoverflow.com/comment/33366558
has answer: http://stackoverflow.com/a/22013564
has answer: http://stackoverflow.com/a/22013409
tagged with: java
downvote count: 3
has answer: http://stackoverflow.com/a/22013406
tagged with: switch-statement
has comment: http://stackoverflow.com/comment/33366509
upvote count: 40
has comment: http://stackoverflow.com/comment/33573546
has answer: http://stackoverflow.com/a/22014022

http://stackoverflow.com/a/22160697
type: Answer
answers question: http://stackoverflow.com/q/22062411
score: 0
has body: Got the issue. It seems response came in. But in the response one of the value is not comply to the pre defined values. But I wonder why I got remote exception for that. Thanks for all your support!
has comment: http://stackoverflow.com/comment/33631599

http://stackoverflow.com/comment/33466297
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22069348
type: Comment
has text: Read the javadoc. It's explained in here.

http://stackoverflow.com/q/22162176
answer count: 1
tagged with: signature
accepted answer: http://stackoverflow.com/a/22163039
linked to: http://stackoverflow.com/q/10703416
tagged with: linefeed
score: 0
has title: SignedCms.Decode() causes "ASN1 bad tag value met.\r\n"
has body: I'm doing about verifying digital signature. And when I was trying to use SignedCms.Decode() , it caused System.Security.Cryptography.CryptographicException {"ASN1 bad tag value met.\r\n"} I generate the signature data in Java, and try to verify it in C#. Here is C# code for verifying signature. //base64 signature data string encodedMessage_b64 = "ahXwmjFNUVxxxxxx=="; byte[] encodedMessage = Convert.FromBase64String(encodedMessage_b64); SignedCms signedCms = new SignedCms(); //throw exception signedCms.Decode(encodedMessage); And here is Java code for generating signature. Signature rsaSig = Signature.getInstance("SHA1withRSA"); //privateKey from keytore rsaSig.initSign(priKey); rsaSig.update(data.getBytes()); //org.apache.commons.codec.binary.Base64; String signedData = Base64.encodeBase64String(rsaSig.sign()); The problem is carriage return and line feed, I don't know where they come from. Any advice would be greatly appreciated :)
tagged with: c#
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22163039
tagged with: carriage-return
tagged with: java
type: Question

http://stackoverflow.com/a/22135751
has body: The exact issue is very clearly explained by the others, but I can provide some additional insight as to how exactly you can prevent this from ever being an issue in the first place. The basic, core problem with the code, the one that caused this mishap, is the fact that studentID is mutable. You need to ask yourself, "is at any point, ever, the student ID of the object going to change?". If your school works anything like a real one, the answer is a resolute no, and in fact, that is the entire reason for having a student ID - it is something that will never ever change. Because of this, you should not have a setter for that field; it should only be initialized in the constructor. (You should implement the hashCode method around studentID.hashCode(), and the equals method around studentID.equals().) Of course, if you can only initialize the student ID it in the constructor, then when you add a record, you will have to construct a new student object, and if you construct a new student object, then you will not have a NullPointerException. So: Delete setStudentID Add studentID as a parameter to the constructor Impelement hashCode and equals
answers question: http://stackoverflow.com/q/22135562
downvote count: 0
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/q/22070826
favorite count: 0
type: UnansweredQuestion
upvote count: 0
has body: I have create a Netbeans project in which I want to execute a Java file. To do that I have create an input type="button" that is contained in a form. If the user clicks on button he is redirected to a page called barrier.jsp (with the action=barrier.jsp). On this page I have imported a java class file that is located in WEB_inf/classes/nameofmyjavapackage The only problem that I have is that the file is imported but it doesn't run. In fact, my Java file has to delect a directory but it doesn't do anything. If I compile the Java file by shell It works. MY jsp is this: <%@ page import="java.io.File" %> <%@ page import="cancelladirettory.cancelladir" %> JSP Page BARRIER REMOVE! My java file is this: import java.io.File; public class cancelladir { private static void DelDir(String dir) { boolean success = (new File(dir)).delete(); if (success) { System.out.println("Ho cancellato la cartella: " + dir); }else{ System.out.println("Impossibile cancellare la cartella: " + dir); } } private static boolean DelDir2(File dir) { if (dir.isDirectory()) { String[] contenuto = dir.list(); for(int i=0; i<contenuto.length; i++) { boolean success = DelDir2(new File(dir, contenuto[i])); if (!success) { return false; } } } return dir.delete(); } public static void main(String[] args) { DelDir("dir"); String dir ="/home/lisa/graphhopper/europe_germany_berlin-gh"; boolean success = DelDir2(new File(dir)); if(success) { System.out.println("Ho cancellato la cartella: " + dir); }else{ System.out.println("Impossibile cancellare la cartella: " + dir); } } }
has answer: http://stackoverflow.com/a/22071694
has comment: http://stackoverflow.com/comment/33504458
tagged with: java
has comment: http://stackoverflow.com/comment/33475541
has title: Add a .java file in a jsp or run a java file in a .js
type: Question
has comment: http://stackoverflow.com/comment/33469879
score: -2
downvote count: 2
has comment: http://stackoverflow.com/comment/33471117
answer count: 1

http://stackoverflow.com/comment/33623130
comment on: http://stackoverflow.com/q/22108605
type: Comment
type: QuestionComment
has text: @fge It's determined at build time using Gradle that IE8 is being used by running a task that passes the BROWSER=internetExplorer system property in.
score: 0

http://stackoverflow.com/a/22033562
has body: Check SimpleDateFormat.parse(String) doc. It clearly says it. Parses text from the beginning of the given string to produce a date. The method may not use the entire text of the given string. http://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html#parse(java.lang.String)
answers question: http://stackoverflow.com/q/22033487
score: 2
upvote count: 2
downvote count: 0
type: Answer

http://stackoverflow.com/comment/33368049
comment on: http://stackoverflow.com/q/22014037
type: QuestionComment
has text: @BrianRoach This forum is not a place for you to judge what i know and what I dont. I'm here to learn. If you have any useful advice give it, otherwise, don't comment
type: Comment
score: 1

http://stackoverflow.com/q/22055097
tagged with: java
score: 0
accepted answer: http://stackoverflow.com/a/22055157
has title: Capture the value of JSP Expression Language variable into a java variable
tagged with: jsp
type: AnsweredQuestion
favorite count: 0
has answer: http://stackoverflow.com/a/22055157
tagged with: el
type: Question
possible better answer: http://stackoverflow.com/a/22056691
answer count: 2
upvote count: 1
has answer: http://stackoverflow.com/a/22056691
downvote count: 1
has body: is it possible to capture the value of JSP Expression Language variable into a java variable in a jsp page? Eg: I have a variable ${error.type} and i want to capture the value of ${error.type} into a java variable, say something like this: String errortype = ${error.type} (I know this isn't possible) Is there anyway for doing this? Actually I want to check if ${error.type} is null or not, if there is any value available I will show success message else an error message. Thanks I'm new to java and JSP :) Update: I tried this code &lt;c:choose&gt; &lt;c:when test="${not empty error.type}"&gt; test error message &lt;/c:when&gt; &lt;c:when test="${empty error.type}"&gt; test success message &lt;/c:when&gt; &lt;/c:choose&gt; But now both the text are displayed simultaneously irrespective of empty or not! Even i tried ${errors.errors ? "some text when true" : "some text when false"} and guess what, every time i'm getting "some text when false" printed in browser though the value is getting initialized correctly. any idea why?

http://stackoverflow.com/comment/33560553
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22117683
score: 0
has text: also, it's generally not great practice to rely on an exception being thrown to do some action in your code... if you can detect whether or not it's a gzip'ed file before an exception is thrown, it is much better. looks to me like you could accomplish this with a simple `if (Paths.get(path).contains("GZIP")) { /* handle gzip code /* } else { /* handle non-gzip code */ }`

http://stackoverflow.com/comment/33567120
comment on: http://stackoverflow.com/a/22122838
has text: Could you post this: `R.layout.activity_main`.xml?
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33593256
type: Comment
comment on: http://stackoverflow.com/a/22139447
has text: Thanks saran. But my `getFromDatabaseA` will change as well right? Or just the return type needs to change?
score: 0
type: AnswerComment

http://stackoverflow.com/q/22044641
has answer: http://stackoverflow.com/a/22044957
answer count: 3
favorite count: 0
has answer: http://stackoverflow.com/a/54909923
has body: I am working on android application. I have to add a menu on the left side of Action Bar. I am able to add menu on the right side but along with right side menu, I also want to add a menu on left side of Action Bar just like : I have spent hours on searching how to achieve that left side menu, but no success. How can I achieve that? Thanks!
tagged with: android
tagged with: android-actionbar
possible better answer: http://stackoverflow.com/a/54909923
type: AnsweredQuestion
downvote count: 0
tagged with: java
score: 6
accepted answer: http://stackoverflow.com/a/22044784
type: Question
tagged with: android-layout
has title: Android Actionbar Left Menu
has comment: http://stackoverflow.com/comment/33422920
upvote count: 6
has answer: http://stackoverflow.com/a/22044784

http://stackoverflow.com/a/22069253
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/33470754
upvote count: 1
answers question: http://stackoverflow.com/q/22069118
score: 1
has comment: http://stackoverflow.com/comment/33471238
has body: This sort of configuration is usually stored in a configuration file (usually XML or properties) and then read at run-time. You can generate the configuration file at build time automatically with a customized build script or you can just put the file in manually. The other alternative is to use command line parameters or environment variables to pass the configuration in. The file approach is likely to be simplest and most robust though.

http://stackoverflow.com/a/23762201
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/22040873
has body: Essentially, you already found the correct answer, with only a bit of commenting needed. The other answer is just wrong. Firstly, getType() returns a Class&lt;?&gt; reference, with a Class class implementing a Type interface; using a Type variable for a isAssignableFrom() call is wrong for two reasons: Type doesn't have isAssignableFrom() method Class#isAssignableFrom() requires a Class&lt;?&gt; parameter, not a Type parameter Simply put, you probably shouldn't compare a Class/Type this way, because you're hiding the relevant typing and requiring unnecessary casts. On the other hand, you just upcasted the Class&lt;?&gt; reference to Type reference, and since equals() called on Class (even casted to Type) actually calls Object#equals(), it simply calls public boolean equals(Object obj) { return (this == obj); } straight from Object.java, as Class.java doesn't override it in any way. Secondly, you could do what you already done, but is one of the proper ways: if ( myField.getType() == MyOwnClass.class ) { // Now I know myField is of type MyOwnClass } // note that this requires a single ClassLoader to be used! Two ClassLoaders could in theory load one class with two separate Class instances alternatively, you could if ( myField.getType().getCanonicalName().equals( MyOwnClass.class.getCanonicalName() ) { // Now I know myField is of type MyOwnClass } // note that this uses a name comparison, not a class comparison or even if ( myField.getType().isAssignableFrom( MyOwnClass.class )) { // Now I know MyOwnClass objects can be cast to myField.getType() safely } // note: they are either equal or MyOwnClass is a subclass of myField.getType() tl;dr Using equals() on a Class object is unnecessary here, as two equal classes have to be == anyway, as is casting to Type - still, the answer you provided in your question is a working solution indeed.
type: Answer
upvote count: 1

http://stackoverflow.com/comment/33448014
type: AnswerComment
has text: Your code don't even compile.
type: Comment
comment on: http://stackoverflow.com/a/22058437
score: 0

http://stackoverflow.com/q/22161700
favorite count: 0
tagged with: atmosphere
type: UnansweredQuestion
has title: Which TomcatCometSupport class to use in Tomcat 7.0.52?
answer count: 0
upvote count: 2
tagged with: java
has body: I am migrating tomcat 6.0.35 to 7.0.52 and noticed following warning message in catalina.out. 2014-03-03 17:35:05,655 WARN DefaultAsyncSupportResolver - Found multiple containers, please specify which one to use: org.atmosphere.container.Tomcat7CometSupport, org.atmosphere.container.TomcatCometSupport, until you do, Atmosphere will use:class org.atmosphere.container.Tomcat7CometSupport It appears that atmosphere-runtime-2.0.0.RC2.jar file contains TomcatCometSupport and Tomcat7CometSupport. Currently, Tomcat7.0.52 display a warning message and using Tomcat7CometSupport. Is it ok to ignore the warning message? How can I configure tomcat container class? Which one is recommended to use? TomcatCometSupport Tomcat7CometSupport I am using gwt-atmosphere in my web application. Look like cometsupport can be configured with o.a.cpr.asyncSupport init params http://async-io.org/config_table.html ,https://github.com/Atmosphere/atmosphere/wiki/Forcing-Atmosphere-AsyncSupport
type: Question
tagged with: comet
score: 2
downvote count: 0
tagged with: tomcat

http://stackoverflow.com/comment/33599208
has text: Which android version?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22142940

http://stackoverflow.com/comment/33422118
comment on: http://stackoverflow.com/q/22043480
type: QuestionComment
type: Comment
has text: Strictly with a `Set`, I don't think there's an alternative to the double loop since you have to iterate through the elements. Even with 400 possibilities, it's going to be pretty fast.
score: 0

http://stackoverflow.com/q/22009578
has title: Invoke method with generic argument using Object argument
has body: I am trying to make some RessourceManager in a light 2D game engine. I want to have a RessourceManager like this : package com.Arsleust.DayumCorp.DayumEngine.Ressource; import java.awt.Graphics2D; import java.util.HashMap; public class RessourceManager { private HashMap&lt;Class&lt;?&gt;, Renderer&lt;?&gt;&gt; renderers; public void registerRenderer(Class&lt;?&gt; objclass, Renderer&lt;?&gt; renderer) { this.renderers.put(objclass, renderer); } public void render(Graphics2D g, Object object) { Class&lt;?&gt; objclass = object.getClass(); if(this.renderers.get(objclass) != null) { this.renderers.get(objclass).render(g, object); } } } using this object : package com.Arsleust.DayumCorp.DayumEngine.Ressource; import java.awt.Graphics2D; public abstract class Renderer&lt;T&gt; { public abstract void init(); public abstract void render(Graphics2D g, T object); } but this.renderers.get(objclass).render(g, object); makes an error, and Eclipse asks me to create a new method or to change the Renderer.render method's argument type T to Object. Somehow I have to cast to that T generic type the object without know what type it is... I'm getting really confused so i'm asking your help to see it more clearly.
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/33362823
type: Question
has answer: http://stackoverflow.com/a/22009776
has answer: http://stackoverflow.com/a/22009731
possible better answer: http://stackoverflow.com/a/22009697
score: 0
accepted answer: http://stackoverflow.com/a/22009731
has comment: http://stackoverflow.com/comment/33361330
has answer: http://stackoverflow.com/a/22009697
answer count: 3
tagged with: generics

http://stackoverflow.com/q/22137485
tagged with: mapreduce
has body: I have some counters I created at my Mapper class: (example written using the appengine-mapreduce Java library v.0.5) @Override public void map(Entity entity) { getContext().incrementCounter("analyzed"); if (isSpecial(entity)){ getContext().incrementCounter("special"); } } (The method isSpecial just returns true or false depending on the state of the entity, not relevant to the question) I want to access those counters when I finish processing the whole stuff, at the finish method of the Output class: @Override public Summary finish(Collection&lt;? extends OutputWriter&lt;Entity&gt;&gt; writers) { //get the counters and save/return the summary int analyzed = 0; //getCounter("analyzed"); int special = 0; //getCounter("special"); Summary summary = new Summary(analyzed, special); save(summary); return summary; } ... but the method getCounter is only available from the MapperContext class, which is accessible only from Mappers/Reducers getContext() method. How can I access my counters at the Output stage? Side note: I can't send the counters values to my outputted class because the whole Map/Reduce is about transforming a set of Entities to another set (in other words: the counters are not the main purpose of the Map/Reduce). The counters are just for control - it makes sense I compute them here instead of creating another process just to make the counts. Thanks.
has title: How can I access the Mapper/Reducer counters on the Output stage?
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/22158093
tagged with: google-app-engine
answer count: 1
favorite count: 0
upvote count: 2
accepted answer: http://stackoverflow.com/a/22158093
score: 2
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/q/22024056
tagged with: generics
has answer: http://stackoverflow.com/a/22024085
favorite count: 0
type: UnansweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22024117
has comment: http://stackoverflow.com/comment/33386924
has title: Java: "? extends I" cannot be converted to "? extends I"
score: 4
upvote count: 4
has answer: http://stackoverflow.com/a/22024229
has body: This code: interface I {} public class Test { TableView&lt;? extends I&gt; table; Test(ObservableList&lt;? extends I&gt; list) { table = new TableView&lt;&gt;(); table.setItems(list); } } ...produces this message: error: method setItems in class TableView&lt;S&gt; cannot be applied to given types; table.setItems(list); required: ObservableList&lt;CAP#1&gt; found: ObservableList&lt;CAP#2&gt; reason: argument mismatch; ObservableList&lt;CAP#2&gt; cannot be converted to ObservableList&lt;CAP#1&gt; where S is a type-variable: S extends Object declared in class TableView where CAP#1,CAP#2 are fresh type-variables: CAP#1 extends I from capture of ? extends I CAP#2 extends I from capture of ? extends I How can there be a type mismatch between two identical types? What am I missing?
answer count: 3
downvote count: 0

http://stackoverflow.com/q/22060290
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33451343
has comment: http://stackoverflow.com/comment/33451548
has comment: http://stackoverflow.com/comment/33451305
has answer: http://stackoverflow.com/a/22060372
tagged with: arraylist
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/22060311
favorite count: 0
has comment: http://stackoverflow.com/comment/33450960
has comment: http://stackoverflow.com/comment/33452614
tagged with: android
has comment: http://stackoverflow.com/comment/33460662
accepted answer: http://stackoverflow.com/a/22060372
has title: How to break condition and return data in java
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22060320
tagged with: java
has answer: http://stackoverflow.com/a/22060320
has body: some part deleted. that may not necessary now. I am using following code, My main intention is if condition matched then exit from the loop and return expected data . In Below list , where i am getting actual expected list but could not return data, what i am want. I am returning testting data value. public String getlistdata(){ String s = "testting data"; if(!(this.element==null)){ ListIterator<ElementData> li = this.element.listIterator(); List<String> list = new ArrayList<String>();; while (li.hasNext()) { list.add(li.next().getElemType().toString()); } Log.e("LIST", "TEST LIST"+list+"=="+list.size()); for (String temp : list) { System.out.println(temp); if (temp.toString().equalsIgnoreCase("group")){ s = li.next().getGrpResult(); break ; } } } return s; } please identify where i am doing wrong with this code. Edited: I solve above problem of user2310289 answers which is below but problem i have another problem here again I have problem, if i have two or more group here, all time executed first group. How to execute second time this method call next group. or third time third group. it means how to start this if second time call this function, starting index from first groupindex+1 and third call this method second groupindex+1 and so on. I have lots of confusing here. aspect ting some hint text, group, group, normal, number, group, text
upvote count: 1
has comment: http://stackoverflow.com/comment/33459889

http://stackoverflow.com/a/22135443
answers question: http://stackoverflow.com/q/22135355
type: Answer
has comment: http://stackoverflow.com/comment/33586897
has body: Use a pattern that forces the format to two decimal places: DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance(); df.setMaximumFractionalPlaces(2); df.format(income); Alternatively, you may want to look into a currency formatter since you are formatting currency values.
score: 0

http://stackoverflow.com/comment/33666754
score: 0
type: QuestionComment
has text: @yaki_nuka Have you confirmed that `path` and `file` are exactly what you think they are? I would do two things: First, look at each of those variables in a debugger _right_ before the `String result =...` line (alternatively, print them out using `System.out.println`). Maybe `path` ends in "...null" or `file` starts with "null..."? If those look right, you can triple-check by printing out their bytes: `System.out.println(Arrays.toString(path.getBytes())` (and similarly for `file`). If you update your question with that output, it'll let us see the exact bytes that are in your string.
type: Comment
comment on: http://stackoverflow.com/q/22160748

http://stackoverflow.com/a/22134889
score: 2
has comment: http://stackoverflow.com/comment/95637317
has comment: http://stackoverflow.com/comment/95637160
downvote count: 0
has comment: http://stackoverflow.com/comment/95637146
upvote count: 2
has body: In addition to @MartijinCourteaux answer (+1), you can also use the NumberFormat class directly to make adjustments to how a number is formatted... double value = 123.4567890123456789; NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(5); System.out.println(nf.format(value)); nf.setMaximumFractionDigits(3); System.out.println(nf.format(value)); Which outputs... 123.45679 123.457 Now, obviously, I've started with a double, if you have String, you would only need to following @MartijnCourteaux answer to parse the value to a double...
has comment: http://stackoverflow.com/comment/95637246
type: Answer
answers question: http://stackoverflow.com/q/22134783

http://stackoverflow.com/a/26229557
has body: For this you should use MediaRecorder class. Please have a look at this : http://developer.android.com/reference/android/media/MediaRecorder.html
upvote count: 1
answers question: http://stackoverflow.com/q/22087563
score: 1
downvote count: 0
type: Answer

http://stackoverflow.com/comment/33486232
comment on: http://stackoverflow.com/a/22079508
type: AnswerComment
score: 0
type: Comment
has text: i did everything you said and now in my code i am getting error messages saying "NameManipulation.java:20: error: size has private access in ArrayList names.set(names.size-1, newname);" what does this mean? what am i doing wrong

http://stackoverflow.com/q/22079885
answer count: 1
has body: I am making an application for Android where it displays your exact coordinates via GPS in a text view when you open the app. You then press a button, and an SMS is sent to a preset number with your coordinates. I have everything working, but the SMS body. I can't figure out how to take the textview with your coordinates and have it send in the SMS body. Any help would be awesome! MAIN JAVA PAGE package com.example.test; import android.app.Activity; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.telephony.gsm.SmsManager; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; @SuppressWarnings("deprecation") public class MainActivity extends Activity implements LocationListener{ protected LocationManager locationManager; protected LocationListener locationListener; protected Context context; TextView txtLat; String lat; String provider; protected String latitude,longitude; protected boolean gps_enabled,network_enabled; Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); txtLat = (TextView) findViewById(R.id.textview1); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1000, this); { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button = (Button) findViewById(R.id.button1); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { String messageToSend = "R.id.textview1"; String number = "8143664050"; SmsManager.getDefault().sendTextMessage(number, null, messageToSend, null,null); } catch (Exception e) { Toast.makeText(getApplicatio…
tagged with: sms
type: AnsweredQuestion
has title: textview into an SMS body Android
tagged with: java
accepted answer: http://stackoverflow.com/a/22080101
type: Question
has answer: http://stackoverflow.com/a/22080101
score: 0
tagged with: android

http://stackoverflow.com/a/22096318
score: 0
type: Answer
answers question: http://stackoverflow.com/q/22074729
has body: well I feel closer to monkeys every day, finally the solution is: Criteria consulta = this.getSessionFactory().getCurrentSession() .createCriteria(GirMotiuRebuig.class, "g") .createAlias("idRecursRebuig", "i") .add(Restrictions.eq("g.id.expedientId.idEns", clauExpedient.getIdEns())) .add(Restrictions.eq("g.id.expedientId.anyExp", clauExpedient.getAnyExp())) .add(Restrictions.eq("g.id.expedientId.numExp", clauExpedient.getNumExp())) .addOrder(Order.asc("g.id.numOrdre")) .setProjection(Projections.projectionList() .add(Projections.property("g.id.expedientId.idEns"),"idEns") .add(Projections.property("g.id.expedientId.anyExp"),"anyExp") .add(Projections.property("g.id.expedientId.numExp"),"numExp") .add(Projections.property("g.desAmpliRebuig"),"observacionsRebuig") .add(Projections.property("g.id.numOrdre"),"numOrdre") .add(Projections.property("g.tipusRebuig"),"tipusRebuig") .add(Projections.property("i.desRecursRebuig"),"descripcioRebuig") ) .setResultTransformer( Transformers.aliasToBean(MotiusRebuig.class)); llistaMotiusRebuig = consulta.list();

http://stackoverflow.com/a/63971857
score: 0
answers question: http://stackoverflow.com/q/22117738
has body: You can use private for all the methods as well as variables and then call the method by creating an object. An object in Java can be created like Circle run = new Circle(); and then call all the private methods like: run.Circle(); run.MakeVisible(); The object must have the class name and the syntax will be like: ClassName ObjectName = new ClassName(); and for calling the method the syntax is: Objectname.MethodName(); Make sure the object name are correct for method calling also. Same object can be used for calling multiple methods. You have to call methods for all methods with the object and it must be placed in: public static void main() { //object creation and all your method calls here } Or more specifically the code in main will be like public static void main() { Circle run = new Circle(); run.Circle(); run.MakeVisible(); } To prevent confusion it is better to change the method name from Circle to another name as the class also has the same name.
type: Answer

http://stackoverflow.com/comment/33412099
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22019886
has text: @AlexanderJardim Thank you so much to remind me this! It worked! The same problem happened once before when I was trying to start Solr through Tomcat!
score: 0

http://stackoverflow.com/comment/33549659
score: 1
type: AnswerComment
has text: I haven't printed out the contents of the array yet, but since my `else` says "Code Error" (so that I know if I'm doing anything wrong), and the text I'm appending in my `else if` statement is appending to my textArea, I'm pretty sure it's working. Thanks again!
type: Comment
comment on: http://stackoverflow.com/a/22115062

http://stackoverflow.com/a/22156212
has body: Iterate over all of the scanner values: public final class CountLetters { public static void main (String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()) { String word = sc.next(); System.out.println(word.length() ); } } }
score: 0
type: Answer
answers question: http://stackoverflow.com/q/22155775

http://stackoverflow.com/a/22127911
has comment: http://stackoverflow.com/comment/33573986
has comment: http://stackoverflow.com/comment/33575914
has comment: http://stackoverflow.com/comment/33573149
score: 0
has body: Since you're using <% ... %>, you should write valid Java code, so you're missing a semicolon ; in the end of your statement: <%Interets inte=new Interets(${IdUser})%> ^here you're missing a semicolon... Also, you cannot mix EL with scriptlets, so the code should be: <% Integer idUser = (Integer)request.getAttribute("IdUser"); //if the attribute is stored in HttpSession (probably) //or ServletContext (oddly), use the right method to get it Interets inte =new Interets(idUser); %> Just to note, this may solve your current compilation problem but there are several problems in your current design e.g. you're not initializing the Statement anywhere in your Interets class but still using it in the constructor... You should learn basic Java and basic JDBC first before trying to open a connection to database and print the results in a web environment. I won't dive into any of these topics but rather write a possible solution to your current code, I'll comment the wrong code in order for you to notice what is wrong or what you should not do: public class Interets { //static Statement St ; //public ResultSet rs; public List<String> getDescriptionOfInterets(Integer idUser) { String res=" "; //these three: Connection, Statement, ResultSet MUST ALWAYS be local //variables of a method, NEVER assigned to class field AND NEVER to //static variables to avoid synchronization problems in a //multithreaded environment such as a web application Connection con = null; PreparedStatement ps = null; ResultSet rs = null; List<String> descriptionList = new ArrayList<String>(); try{ //this is one way to open a database connection //you should change it to a database connection pool //which is a different topic you should search about //since you didn't say which database you're working with //I'll assume it's mysql Class.forName("com.mysql.jdbc.Driver"); //similar with the database credentials String user = "root"; String password = "root"; con = DriverManager.getConnection( "jdbc:mysql://loca…
has comment: http://stackoverflow.com/comment/33578123
has comment: http://stackoverflow.com/comment/33574019
type: Answer
answers question: http://stackoverflow.com/q/22127570
has comment: http://stackoverflow.com/comment/33573183

http://stackoverflow.com/a/22047448
has body: Here you assign a Class to s: s = s.getClass().getSuperclass(); Then the loop condition is: s.getClass().getSuperclass(); A Class object's class is Class.class whose getSuperclass returns Object.class so the loop condition evaluates to true. Then you assign s to Object.class: s = s.getClass().getSuperclass(); Whose class is Class.class and has a super class. Repeat ad infinitum. Use a different variable for the class. Class&lt;?&gt; cls = s.getClass().getSuperclass(); while(cls != null) { cls = cls.getSuperclass(); }
type: Answer
answers question: http://stackoverflow.com/q/22047074
score: 4
upvote count: 4
accepted answer of: http://stackoverflow.com/q/22047074
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/22086342
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33518427
answers question: http://stackoverflow.com/q/22081314
type: Answer
accepted answer of: http://stackoverflow.com/q/22081314
has body: The reason why is that the web services API is designed to be protocol-independent, and SOAP is just one of many potential protocols you could use to implement your web services, so it makes sense that the message context is not a SOAPMessageContext unless the container is sure that you're dealing exclusively with the SOAP protocol, like in the case of a SOAPHandler. But it's ok, you can still retrieve your attachments, try this, @Override public String upload() { MessageContext mc = wsctx.getMessageContext(); Map&lt;String, DataHandler&gt; atts = mc.get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS); // ... return "done"; } the map atts maps the Content-ID for every attachment to its respective DataHandler. To see all the other properties you can get from the message context, check the docs.

http://stackoverflow.com/comment/33585357
has text: What does `Game` extend from? How is `paint` called?
type: QuestionComment
comment on: http://stackoverflow.com/q/22134366
score: 0
type: Comment

http://stackoverflow.com/comment/33442111
has text: Please edit your question and post the relevant code.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22055191

http://stackoverflow.com/comment/33520723
comment on: http://stackoverflow.com/q/22093583
has text: Have you upgraded your Eclipse lately? Happened to me once, that I've upgraded and re-used old workspace with old `.metadata` and the debugger behaved quite randomly. **Try to run the project in a fresh clean workspace!**
type: Comment
type: QuestionComment
score: 1

http://stackoverflow.com/comment/33531626
comment on: http://stackoverflow.com/a/22104972
has text: -clean did it. props to sandeep as well :)
type: Comment
score: 1
type: AnswerComment

http://stackoverflow.com/comment/33374408
score: 0
has text: I thought [this answer](http://stackoverflow.com/a/4236751/758831) and associated comments seemed like a well thought out description of what you would need to do. I've not done it personally though.
comment on: http://stackoverflow.com/q/22014894
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33424977
score: 0
type: AnswerComment
type: Comment
has text: Not a problem! I'm not quite sure you've completely grasped the notion of unit testing (specifically using JUnit). Each class should have a test class which exercises the code within. E.g. a Math class and a MathJUnitTest class. Lets say that the Math class has an add and a subtract method. You would then create tests for those methods in the MathJUnitTest class. It's worth reading up on unit testing a little more, perhaps watching a few more videos and working with simpler code examples. Sorry I can't be anymore help.
comment on: http://stackoverflow.com/a/22045279

http://stackoverflow.com/comment/33622816
has text: Where is the compiled `.class` file for `com.app.util.Data` inside your packaged application?
comment on: http://stackoverflow.com/q/22155957
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/22067573
has body: It's not necessarily thrown only in case of recursive calls. It is thrown whenever the stack memory space is filled with typical data that are placed on stack: local variables, local parameters and so on. Obviously, the chance of getting a stack overflow error grows with the size of the stack (how many method calls are there between the current method being executed and the root of the thread) and with the number of active threads. But, as I mentioned, recursive calls are not the only cause for getting a large stack.
upvote count: 2
answers question: http://stackoverflow.com/q/22067414
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/comment/40170525
score: 5
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/22149459
has text: `org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554) at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:276) at org.openqa.selenium.remote.RemoteWebDriver$RemoteNavigation.to(RemoteWebDriver.java:800) at KDF3.FnavigateBrowser(KDF3.java:185) at KDF3.myDriver(KDF3.java:50) at ` is the location that caught my attention, the solution was a guess : )

http://stackoverflow.com/comment/33632131
has text: Thanks for the responses! Didnt expect answers this quick. Was planning to sleep and put some fresh eyes on it tomorrow, been working on this for about 3 hours now! Will go through the responses tomorrow and report back. Cheers :)
comment on: http://stackoverflow.com/q/22161092
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22013290
score: 0
type: Answer
has body: Do you expect the unimplemented interface to be implemented by a party external to your package ? If not, then why is the unimplemented interface even there ? If yes, what is the point of anybody doing so if you let PG "optimize" away the invocations of that method ?
has comment: http://stackoverflow.com/comment/33369334
answers question: http://stackoverflow.com/q/22012622

http://stackoverflow.com/comment/33434341
type: Comment
type: QuestionComment
score: 2
comment on: http://stackoverflow.com/q/22050907
has text: Also, what do you mean to match with `[\d\D]`? This matches any character since `\D` is `\d`'s complement

http://stackoverflow.com/a/22151227
upvote count: 1
has comment: http://stackoverflow.com/comment/33614032
has body: Try this.. one = (Switch) findViewById(R.id.switchOne); Instead of this.. one = findViewById(R.id.switchOne); EDIT switchArray[0] = (Switch) findViewById(R.id.switchOne);
has comment: http://stackoverflow.com/comment/33614058
answers question: http://stackoverflow.com/q/22151158
downvote count: 0
has comment: http://stackoverflow.com/comment/33613806
has comment: http://stackoverflow.com/comment/33613858
has comment: http://stackoverflow.com/comment/33614003
type: Answer
score: 1

http://stackoverflow.com/comment/128166183
score: 1
type: AnswerComment
has text: It will always be a list, and they'll always be in the order returned by the database. Abdullah is right - it makes sense to return these as `List`, not as `Collection`.
type: Comment
comment on: http://stackoverflow.com/a/53955183

http://stackoverflow.com/q/22133774
has answer: http://stackoverflow.com/a/22134129
has body: I am making a simple drawling program and the drawling panel will not show up. I don't know if it is a problem with the Circle class, or the drawingPanel class. The colorButtons and the sizeButtons do show up but the drawingPanel does not. Can you help me please, take your time and thanks in advance! P.S. I add the frames in the drawingFrame. public class Assign72 { public static void main(String[] args) { DrawingFrame f= new DrawingFrame(); f.setTitle("Drawing Program"); f.setSize(462,312); f.setLocationRelativeTo(null); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); } public class DrawingFrame extends JFrame implements ActionListener { private DrawingPanel drawPanel; private JPanel panel; private JPanel colorPanel; private JPanel sizePanel; private JRadioButton redRadioButton; private JRadioButton blueRadioButton; private JRadioButton greenRadioButton; private JRadioButton blackRadioButton; private JRadioButton smallRadioButton; private JRadioButton mediumRadioButton; private JRadioButton largeRadioButton; private JButton eraseButton; private ButtonGroup colorButtonGroup; private ButtonGroup sizeButtonGroup; final int SMALL = 4; final int MEDIUM = 8; final int LARGE = 10; public DrawingFrame() { colorPanel = new JPanel(); sizePanel = new JPanel(); redRadioButton = new JRadioButton(); redRadioButton.setText("Red"); colorPanel.add(redRadioButton); redRadioButton.addActionListener(this); blueRadioButton = new JRadioButton(); blueRadioButton.setText("Blue"); colorPanel.add(blueRadioButton); blueRadioButton.addActionListener(this); greenRadioButton = new JRadioButton(); greenRadioButton.setText("Green"); colorPanel.add(greenRadioButton); greenRadioButton.addActionListener(this); blackRadioButton = new JRadioButton(); blackRadioButton.setText("Black"); colorPanel.add(blackRadioButton); blackRadioButton.addActionListener(this); smallRadioButton = new JRadioButton(); smallRadioButton.setText("Small"); sizePanel.add(smallRadioButton); smallRadioButto…
has answer: http://stackoverflow.com/a/22134580
score: 0
has title: Broken drawing program. Java
favorite count: 0
linked to: http://stackoverflow.com/q/70324
upvote count: 1
downvote count: 1
accepted answer: http://stackoverflow.com/a/22134580
type: AnsweredQuestion
tagged with: java
type: Question
possible better answer: http://stackoverflow.com/a/22134129
answer count: 2

http://stackoverflow.com/q/22031091
has title: Jsoup - French font parsed encoded value
answer count: 1
favorite count: 0
tagged with: http://stackoverflow.com/tag/html
has comment: http://stackoverflow.com/comment/44893192
has answer: http://stackoverflow.com/a/22031252
type: UnansweredQuestion
tagged with: rtf
downvote count: 1
type: Question
tagged with: java
score: -1
tagged with: jsoup
has body: Document doc = Jsoup.parse(result); ArrayList&lt;String&gt; elements = new ArrayList&lt;String&gt;(); Elements e = doc.select("span"); for (int i = 0; i &lt; e.size(); i++) { elements.add(e.get(i).html()); } The above code parses french fonts from this réhydraté, to this r&amp;eacute;hydrat&amp;eacute;. I got issue to print this in the tool. I've planned to use replace() function but it won't be the proper way since there are a lot fonts having same issue. How do I solve this?
upvote count: 0

http://stackoverflow.com/a/22162504
upvote count: 2
type: Answer
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/22162231
has body: All arrays in Java have a special field "length" that contains the number of elements in the array, that is array length in other words. String test( String[] array ) { if ( array == null ) { return "array is null"; } if ( array.length == 0 ) { return "array is empty, meaning it has no element"; } for ( String s : array ) { if (s == null) { return "array contains null element"; } if (s.length() == 0) { return "array contains empty string"; } // or if (s.isEmpty()) { return "array contains empty string"; } } return "array is not null or empty and does not contain null or empty strings"; } To test whether the array contains a null element or an empty string you need to iterate through it and check each element individually. Do not forget that the length of array is the special field array.legnth and the length of the string is the function string.length().

http://stackoverflow.com/q/22143361
has comment: http://stackoverflow.com/comment/33599578
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/22143555
linked to: http://stackoverflow.com/q/37628
duplicate of: http://stackoverflow.com/q/3050967
tagged with: eclipse
has title: How to make the method name in the class dynamic?
type: Question
has comment: http://stackoverflow.com/comment/33599905
has comment: http://stackoverflow.com/comment/33599881
has comment: http://stackoverflow.com/comment/33599731
score: 0
has body: I want to make the method name in the class dynamic when I create a object from the class I want to execute the method name dynamically bellow is my code . public static void ExecuteTest() throws Exception { for (int i = 1, j = 1; i &lt; 2; i = i+1, j = j+1) { FW_ReadExcelFile N = new FW_ReadExcelFile(); FW_ReadExcelFile.setExcelSheetEnvValues(i,i); //java.lang.String Flag2 = N.getTCExecuteFlag() ; String Flag = "YES"; String Flag21 = N.getTCExecuteFlag(); if ( Flag.equals(Flag21) ){ String TCName = N.getTCName(); FW_Report u = new FW_Report(); u.TCName; // the FW_Report class has many methods and I want to call the method on my demand . }
answer count: 2
linked to: http://stackoverflow.com/q/3050967
has answer: http://stackoverflow.com/a/22143555
has answer: http://stackoverflow.com/a/22143553
accepted answer: http://stackoverflow.com/a/22143553
has comment: http://stackoverflow.com/comment/33599714

http://stackoverflow.com/comment/33450237
score: 2
comment on: http://stackoverflow.com/q/22059837
has text: Looks like the HashMap should be HashMap<Integer,Character> since you are using integer as key and comparing the value with 'c' which I assume is a character?
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33470598
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/22057198
type: Comment
has text: For Java bytecode it makes no difference if the JRE is 32-bit, 64-bit or something else, but Reid mentions in his question that he is using a 32-bit native library, so his program only works on a 32-bit JVM; a 64-bit JVM cannot load 32-bit native libraries.

http://stackoverflow.com/comment/33441696
has text: @christopher if you write that as an answer, I will upvote it.
comment on: http://stackoverflow.com/q/22054966
score: 0
type: Comment
type: QuestionComment

intellij-idea
tags question: http://stackoverflow.com/q/22054242
tags question: http://stackoverflow.com/q/22081370
tags question: http://stackoverflow.com/q/22117250
tags question: http://stackoverflow.com/q/22093943
tags question: http://stackoverflow.com/q/22054061
tags question: http://stackoverflow.com/q/22093561
tags question: http://stackoverflow.com/q/22101332
type: Tag
tags question: http://stackoverflow.com/q/22157220
tags question: http://stackoverflow.com/q/22073371
tag name: intellij-idea
tags question: http://stackoverflow.com/q/22030504
tags question: http://stackoverflow.com/q/22101056
tags question: http://stackoverflow.com/q/22084052
tags question: http://stackoverflow.com/q/22104008
tags question: http://stackoverflow.com/q/22102077
tags question: http://stackoverflow.com/q/22078501
tags question: http://stackoverflow.com/q/22138733
tags question: http://stackoverflow.com/q/22087373
tags question: http://stackoverflow.com/q/22047860
tags question: http://stackoverflow.com/q/22055708
tags question: http://stackoverflow.com/q/22086633
tags question: http://stackoverflow.com/q/22019451
tags question: http://stackoverflow.com/q/22147177
tags question: http://stackoverflow.com/q/22022110
tags question: http://stackoverflow.com/q/22097677
tags question: http://stackoverflow.com/q/22111603
tags question: http://stackoverflow.com/q/22121651
tags question: http://stackoverflow.com/q/22021485
tags question: http://stackoverflow.com/q/22070666
tags question: http://stackoverflow.com/q/22101711
tags question: http://stackoverflow.com/q/22026104
tags question: http://stackoverflow.com/q/22056223
tags question: http://stackoverflow.com/q/22082449

http://stackoverflow.com/q/22140260
tagged with: arrays
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/22140374
tagged with: arguments
tagged with: foreach
score: 2
type: AnsweredQuestion
upvote count: 2
accepted answer: http://stackoverflow.com/a/22140374
has title: Java Casting Object into Object[] Array And Enriched For Loop
type: Question
tagged with: object
has answer: http://stackoverflow.com/a/22140364
has body: Lets say I pass my arguments into my function like this. Seems the Object outside arguments knows it's a Object[] array. But the Object[] inside it are not Object Array's but plain Object's Object[] arguments = { new Object[] {"command", "value"}, new Object[] {"List_test", Arrays.asList("1", "2", "3", "4")}, new Object[] {"single command"} }; myFunc(arguments); public void myFunc(Object[] args) { if(args == null || args.length == 0) { System.out.println("Error!"); return; } //How I do this below? for(Object objArray : args) { //this one is good. if(objArray == null) continue; //objArray = (Object[]) objArray; //can't figure this out. for(Object eachObject : objArray) { //this don't work. System.out.println("eachObject reference = " + eachObject); } } for(Object[] objArray : args) { //this don't work. if(objArray == null) continue; for(Object eachObject : objArray) { //this don't work. System.out.println("eachObject reference = " + eachObject); } } } I tried this in Java Console &gt; for(Object[] a : arguments) { System.out.println(a); } Got this error Static Error: Bad types in assignment: from Object to Object[] This looks much worse. Object[][] arguments = { { new Object[]{"command", "value"}}, { new Object[]{"List_test", Arrays.asList("1", "2", "3", "4")}}, { new Object[]{"single command"}} };
possible better answer: http://stackoverflow.com/a/22140304
tagged with: java
has answer: http://stackoverflow.com/a/22140304
answer count: 3

http://stackoverflow.com/a/22117723
has body: finalize() method is called when an object is about to be destroyed. If you have a custom class, then you can override this method in order to do something. You shouldn't call this method directly. JVM's garbage collector will do that for you automatically. And you shouldn't depend on the finalize() method to clear any resources, as it may never happen during the execution of your program.
score: 0
answers question: http://stackoverflow.com/q/22117656
type: Answer

http://stackoverflow.com/q/22010744
has title: Best way to call a method inside a singleton class
has answer: http://stackoverflow.com/a/22010828
possible better answer: http://stackoverflow.com/a/22010898
has body: I have a singleton class public class Singleton { static Singleton instance; public static Singleton getInstance() { if (instance == null) { instance = new Singleton(); } return instance; } Consider a public function method() is defined inside the class Singleton. Which is the best way to call a method inside a singleton class: Singleton.method() - method calling statically or Singleton.getInstance.method() - method not static ?
has answer: http://stackoverflow.com/a/22010898
favorite count: 0
has answer: http://stackoverflow.com/a/22010999
accepted answer: http://stackoverflow.com/a/22010828
tagged with: singleton
answer count: 7
has answer: http://stackoverflow.com/a/22010802
upvote count: 3
tagged with: singleton-methods
has answer: http://stackoverflow.com/a/22010820
downvote count: 1
has answer: http://stackoverflow.com/a/22010961
score: 2
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/45776662
type: Question

http://stackoverflow.com/a/22055339
has comment: http://stackoverflow.com/comment/33442915
score: 1
has comment: http://stackoverflow.com/comment/33474960
has comment: http://stackoverflow.com/comment/33444635
answers question: http://stackoverflow.com/q/22055271
upvote count: 1
has body: . does not match the newline character, so when you have a new line, it fails. Use \s to match newline characters. I am not a regex pro, but (.|\s) is one way to combine the two, using | (symbol for OR). The combination should match any character, including newline characters. Thus, your expression becomes "(.|\\s)*\\b" + key + "\\b(.|\\s)*"
has comment: http://stackoverflow.com/comment/33469544
type: Answer
has comment: http://stackoverflow.com/comment/33444351
downvote count: 0

xpath
tags question: http://stackoverflow.com/q/22042197
tags question: http://stackoverflow.com/q/22099124
tag name: xpath
tags question: http://stackoverflow.com/q/22092623
tags question: http://stackoverflow.com/q/22010614
tags question: http://stackoverflow.com/q/22116106
tags question: http://stackoverflow.com/q/22132042
tags question: http://stackoverflow.com/q/22011711
tags question: http://stackoverflow.com/q/22008936
tags question: http://stackoverflow.com/q/22043895
type: Tag
tags question: http://stackoverflow.com/q/22130540
tags question: http://stackoverflow.com/q/22034583

http://stackoverflow.com/q/22118114
tagged with: hashcode
upvote count: 3
tagged with: java
tagged with: hibernate
tagged with: set
answer count: 1
has comment: http://stackoverflow.com/comment/33554821
has comment: http://stackoverflow.com/comment/33554880
has answer: http://stackoverflow.com/a/22120348
has comment: http://stackoverflow.com/comment/33555059
has title: Weird behavior of Set.equals
type: UnansweredQuestion
score: 3
has body: I am encountering a weird behavior when trying to see if two sets are equal. I have overridden the equals and hashcode: public class Metric { private String id; private Sensor sensor; private String metricName; private String metricDescription; //getters, setters, toString()... @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((metricDescription == null) ? 0 : metricDescription.hashCode()); result = prime * result + ((metricName == null) ? 0 : metricName.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Metric other = (Metric) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; if (metricDescription == null) { if (other.metricDescription != null) return false; } else if (!metricDescription.equals(other.metricDescription)) return false; if (metricName == null) { if (other.metricName != null) return false; } else if (!metricName.equals(other.metricName)) return false; return true; } } I have intentionally left the Sensor information out of the hashCode and equals, but in both so it should not make a difference. Now, consider the following code: SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction tx = null; try { tx = session.beginTransaction(); session.save(datasource); session.save(sensorType); session.save(sensor); session.save(metric1); session.save(metric2); session.getTransaction().commit(); } catch (HibernateException e) { if (tx != null) tx.rollback(); throw e; } finally { if (session.isOpen()) session.close(); } try { session = sessionFactory.getCurrentSession(); tx = session.beginTransaction(); sameSensor = (Sensor) session.get(Sensor.class, new String(sensor.getId())); } catch (Hibern…
downvote count: 0
has comment: http://stackoverflow.com/comment/33554902
favorite count: 0
tagged with: equals
type: Question
has comment: http://stackoverflow.com/comment/33555283
has comment: http://stackoverflow.com/comment/33554965
has comment: http://stackoverflow.com/comment/33555071

http://stackoverflow.com/q/22152916
type: Question
tagged with: flash
tagged with: air
tagged with: ios
downvote count: 0
tagged with: jvm
has comment: http://stackoverflow.com/comment/52303214
favorite count: 0
type: UnansweredQuestion
has title: Flash CS 5.5 Professional requires 32-bit JVM when publishing for iOS
answer count: 0
score: 1
tagged with: java
upvote count: 1
has body: When trying to publish my file to AIR for iOS I get the following error: Error: This Java instance does not support a 32-bit JVM. Please install the desired version. I'm on Mac OS (Mavericks) and have both java 6 (which supports 32-bit) and 7 (which does not) installed. I've verified I can launch a 32-bit jvm from the terminal with "java -d32". Interestingly, it publishes to AIR with no problems when it's not to iOS. How can I get Flash to use the correct version of Java? I've tried setting JAVA_HOME to point to version 6 in /etc/profile with still no luck. Thanks for reading, I will really appreciate the help!!

http://stackoverflow.com/comment/117851760
comment on: http://stackoverflow.com/a/22023981
has text: Perfect explanation. Cheers.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/22018249
has comment: http://stackoverflow.com/comment/33393507
has comment: http://stackoverflow.com/comment/33375966
downvote count: 0
has comment: http://stackoverflow.com/comment/33394677
has comment: http://stackoverflow.com/comment/33376131
has comment: http://stackoverflow.com/comment/33377990
has comment: http://stackoverflow.com/comment/33377649
type: Answer
has comment: http://stackoverflow.com/comment/33375435
accepted answer of: http://stackoverflow.com/q/22017480
has comment: http://stackoverflow.com/comment/33375997
has body: I think the solution for you would be to implement CharSequence as a wrapper over very large text files. Why? Because building a Matcher from a Pattern takes a CharSequence as an argument. Of course, easier said than done... But then you only have three methods to implement, so that shouldn't be too hard... EDIT I took the plunge and I ate my own dog's food. The "worst part" is that it actually works!
answers question: http://stackoverflow.com/q/22017480
has comment: http://stackoverflow.com/comment/33375835
has comment: http://stackoverflow.com/comment/34648106
has comment: http://stackoverflow.com/comment/33393289
has comment: http://stackoverflow.com/comment/33375862
upvote count: 15
has comment: http://stackoverflow.com/comment/33376198
has comment: http://stackoverflow.com/comment/33375493
has comment: http://stackoverflow.com/comment/33378394
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33393165
score: 15
has comment: http://stackoverflow.com/comment/57707875

http://stackoverflow.com/comment/33640909
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22166243
has text: thank you so much,i think this is the piece of code that i want:)
score: 0

audioformat
type: Tag
tag name: audioformat
tags question: http://stackoverflow.com/q/22099948

http://stackoverflow.com/comment/33544776
has text: Okay thanks, that makes sense. What is good practice for offering remote clients (think Android app) a way to log in then? Offering an extra login url for non-browser logins? Or maybe using the regular one and encoding the login result in the response header?
type: AnswerComment
comment on: http://stackoverflow.com/a/22104613
score: 0
type: Comment

http://stackoverflow.com/comment/39034721
type: Comment
comment on: http://stackoverflow.com/q/22053306
has text: Your example is not valid if `getFoo` is publicly reachable, according to the Java technote ["Programming With Assertions"](http://docs.oracle.com/javase/7/docs/technotes/guides/language/assert.html#usage)
score: 0
type: QuestionComment

http://stackoverflow.com/q/22116236
has answer: http://stackoverflow.com/a/22127662
tagged with: bufferedreader
has comment: http://stackoverflow.com/comment/33551433
score: 0
answer count: 2
has body: I'm making a simple client server application where you enter a password on the server, the client enters a password which is then sent to server and compared. The password isn't sending using the GUI I've made, however if I scan a string using the console it works fine. The code which isn't working correctly is PS.println(passwordguess) here is the client code: class client extends JFrame implements ActionListener { JTextArea textarea; JTextField textfield; JPanel p1, p2; JButton button; String fieldtext; int buttonflag = 0; public static void main (String args[]) throws Exception { client CLIENT = new client(); //create object of class CLIENT CLIENT.run(); } public client() //constructor for frame { setTitle("client"); setLocation(100,100); setSize(500,500); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); p1 = new JPanel(); //panel for text area p2 = new JPanel(); //panel for textfield textarea = new JTextArea(); textarea.setText("Starting...\n"); textfield = new JTextField("", 15); button = new JButton("Enter"); p1.add(textarea); p2.add(textfield); button.addActionListener(this); p2.add(button); add(p1,BorderLayout.NORTH); add(p2,BorderLayout.SOUTH); setVisible(true); } public void run() throws Exception { Socket SOCK = new Socket("localhost", 8888); textarea.append("Connected to server\n"); InputStreamReader ISR = new InputStreamReader(SOCK.getInputStream()); BufferedReader BR = new BufferedReader(ISR); //buffered reader receives text using readLine method String MESSAGE = BR.readLine(); //expects String message from server textarea.append(MESSAGE); while (buttonflag == 0) //empty loop pauses program until JButton is pressed { } String passwordguess = fieldtext; buttonflag = 0; PrintStream PS = new PrintStream(SOCK.getOutputStream()); PS.println(passwordguess); //sends passwordguess to server to authenticate MESSAGE = BR.readLine(); textarea.append("\n" + MESSAGE); } public void actionPerformed(ActionEvent e) { if (e.getSource() == button) { fieldtext = textfiel…
has answer: http://stackoverflow.com/a/22116524
type: UnansweredQuestion
tagged with: sockets
has comment: http://stackoverflow.com/comment/33572150
has title: socket client/server application not returning value
tagged with: java
type: Question

http://stackoverflow.com/comment/33558277
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22119889
has text: An important rule in coding: when adding something new and different, to a program, especially something that you're not very familiar with, first get it working in a simple small program before trying to implement it into a large program. This not only makes it easier for you to work the bugs out, it also makes it much easier for ***us*** to help you if you're still stuck. As it is, you've posted a Godzilla of a program, most of it redundant code completely unrelated to your problem, and thus quite distracting to us.
type: Comment

http://stackoverflow.com/comment/33635793
has text: @sᴜʀᴇsʜᴀᴛᴛᴀ What do you mean? There's an java.utils.Objects in java7
score: 0
comment on: http://stackoverflow.com/q/22163320
type: QuestionComment
type: Comment

http://stackoverflow.com/a/22082893
accepted answer of: http://stackoverflow.com/q/22078859
score: 3
upvote count: 3
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33523784
answers question: http://stackoverflow.com/q/22078859
type: Answer
has body: import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; import java.security.MessageDigest; import java.security.SecureRandom; import java.security.spec.AlgorithmParameterSpec; import java.util.Arrays; import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; final class CrapEncryption { private static final byte[] MAGIC = "Salted__".getBytes(StandardCharsets.US_ASCII); private static final int KEY_LEN = 8; private static final int SALT_LEN = 8; private static final SecureRandom random = new SecureRandom(); static byte[] pretendToEncrypt(byte[] password, byte[] msg) throws GeneralSecurityException { byte[] salt = new byte[SALT_LEN]; random.nextBytes(salt); MessageDigest md5 = MessageDigest.getInstance("MD5"); md5.update(password); md5.update(salt); byte[] dk = md5.digest(); Cipher des; try { SecretKey key = new SecretKeySpec(dk, 0, KEY_LEN, "DES"); AlgorithmParameterSpec iv = new IvParameterSpec(dk, KEY_LEN, SALT_LEN); des = Cipher.getInstance("DES/CBC/PKCS5Padding"); des.init(Cipher.ENCRYPT_MODE, key, iv); } finally { Arrays.fill(dk, (byte) 0); } byte[] pkg = new byte[des.getOutputSize(msg.length) + MAGIC.length + SALT_LEN]; System.arraycopy(MAGIC, 0, pkg, 0, MAGIC.length); System.arraycopy(salt, 0, pkg, MAGIC.length, SALT_LEN); des.doFinal(msg, 0, msg.length, pkg, MAGIC.length + SALT_LEN); return pkg; } static byte[] decrypt(byte[] password, byte[] pkg) throws GeneralSecurityException { if ((pkg.length &lt; MAGIC.length) || !Arrays.equals(Arrays.copyOfRange(pkg, 0, MAGIC.length), MAGIC)) throw new IllegalArgumentException("Expected magic number \"Salted__\""); if (pkg.length &lt; MAGIC.length + SALT_LEN) throw new IllegalArgumentException("Missing salt"); MessageDigest md5 = MessageDigest.getInstance("MD5"); md5.update(password); /* password */ md5.update(pkg, MAGIC.length, SALT_LEN); /* salt */ byte[] dk = md5.digest(); Cipher des; try { SecretKey s…

http://stackoverflow.com/comment/33639454
type: Comment
type: QuestionComment
has text: Error is - `local variable ok is accessed from within inner class; needs to be declared final`, made the variable `ok` final
score: 0
comment on: http://stackoverflow.com/q/22165489

http://stackoverflow.com/comment/33464739
has text: `I need to generate this` What stops you? You haven't asked any question yet.
type: QuestionComment
score: 3
comment on: http://stackoverflow.com/q/22068406
type: Comment

http://stackoverflow.com/comment/33432852
comment on: http://stackoverflow.com/q/22049924
score: 0
type: Comment
type: QuestionComment
has text: You're running classic ASP pages in Tomcat? Is that possible really?

http://stackoverflow.com/q/22039991
tagged with: compare
tagged with: datetime
has comment: http://stackoverflow.com/comment/41549044
has answer: http://stackoverflow.com/a/30092835
type: AnsweredQuestion
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/60579878
has answer: http://stackoverflow.com/a/22040488
has body: I have two Date objects with the below format. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); String matchDateTime = sdf.parse("2014-01-16T10:25:00"); Date matchDateTime = null; try { matchDateTime = sdf.parse(newMatchDateTimeString); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } // get the current date Date currenthDateTime = null; DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); Date dt = new Date(); String currentDateTimeString = dateFormat.format(dt); Log.v("CCCCCurrent DDDate String is:", "" + currentDateTimeString); try { currenthDateTime = sdf.parse(currentDateTimeString); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } Now I want to compare the above two dates along with time. How should I compare in Java. Thanks
accepted answer: http://stackoverflow.com/a/22040067
type: Question
linked to: http://stackoverflow.com/q/2592501
score: 24
answer count: 6
has answer: http://stackoverflow.com/a/22040067
has answer: http://stackoverflow.com/a/26452408
linked to: http://stackoverflow.com/q/38922754
upvote count: 24
possible better answer: http://stackoverflow.com/a/22040488
has answer: http://stackoverflow.com/a/22040073
favorite count: 0
has title: How to compare two dates along with time in java

http://stackoverflow.com/comment/33635764
comment on: http://stackoverflow.com/a/22163150
score: 0
type: AnswerComment
type: Comment
has text: @user3260955 No problem. You can mark this question closed and answer as accepted by clicking the check mark under my score above, unless you have further questions.

http://stackoverflow.com/a/22098142
type: Answer
has comment: http://stackoverflow.com/comment/33518275
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/22097876
has body: Copy Pasta error. You have: tabBodyPart.setText("General Symptoms"); tabBodyPart.setTabListener(MainActivity.this); You want : tabGeneralSymptoms.setText("General Symptoms"); tabGeneralSymptoms.setTabListener(MainActivity.this);
accepted answer of: http://stackoverflow.com/q/22097876
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/22018018
score: 0
answers question: http://stackoverflow.com/q/22017380
has comment: http://stackoverflow.com/comment/33375790
type: Answer
has body: I think it expects that your foo setter accepts java.util.List as a parameter.
has comment: http://stackoverflow.com/comment/33375710
has comment: http://stackoverflow.com/comment/33378895
has comment: http://stackoverflow.com/comment/33375965
has comment: http://stackoverflow.com/comment/33376589

http://stackoverflow.com/comment/33625310
type: QuestionComment
has text: Writing the wrapper would be quite straight forward and take minimal code, and be usable with minimal changes to existing code and be compatible with almost everything expecting a plain StringWriter. I'm guessing the code would be ~20 lines.
comment on: http://stackoverflow.com/q/22156842
score: 0
type: Comment

http://stackoverflow.com/a/22091531
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/33506975
has comment: http://stackoverflow.com/comment/33506896
has comment: http://stackoverflow.com/comment/33506884
has comment: http://stackoverflow.com/comment/33507943
has comment: http://stackoverflow.com/comment/33507171
has body: As per eclipse, if there are 2 Person objects with id == null, then they are equal. You can remove it if it doesn't work in your context You can replace it with below code, to avoid the same if (id == null || other.id == null) { return false; }
has comment: http://stackoverflow.com/comment/33507002
upvote count: 1
has comment: http://stackoverflow.com/comment/33506990
has comment: http://stackoverflow.com/comment/33506848
has comment: http://stackoverflow.com/comment/33507587
answers question: http://stackoverflow.com/q/22091488
has comment: http://stackoverflow.com/comment/33508058
has comment: http://stackoverflow.com/comment/33506953
has comment: http://stackoverflow.com/comment/33507987
has comment: http://stackoverflow.com/comment/33506760
type: Answer
has comment: http://stackoverflow.com/comment/33507160
has comment: http://stackoverflow.com/comment/33507889
has comment: http://stackoverflow.com/comment/33506814

http://stackoverflow.com/comment/33447628
type: QuestionComment
comment on: http://stackoverflow.com/q/22058272
has text: Thanks! it's nice to hear I'm actually doing something right. I'm just so lost when it comes to sorting the darn thing, its like I spent all my brain power doing the above
score: 0
type: Comment

http://stackoverflow.com/a/22056523
downvote count: 1
answers question: http://stackoverflow.com/q/22056322
type: Answer
has body: The following code will fix your problem for (int i = 0 ; i &lt; 5; i++) { for (int j = 5-i ; j &lt;= 5; j++) System.out.print("*"); System.out.println(); }
upvote count: 0
score: -1

http://stackoverflow.com/comment/42217667
type: AnswerComment
score: 0
type: Comment
has text: @EJP You haven't answered my question. Neither you've answered OP's question.
comment on: http://stackoverflow.com/a/26771479

http://stackoverflow.com/comment/33599217
type: Comment
comment on: http://stackoverflow.com/a/22087638
has text: The do-while loop is necessary as your first hasWin() was detecting win for the 0th player :) Also glad to know that your code worked after rectifying the other hiccups.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33631780
comment on: http://stackoverflow.com/q/22160928
score: 0
type: Comment
has text: Think of how you'd do it on paper first
type: QuestionComment

http://stackoverflow.com/comment/33385169
score: 0
comment on: http://stackoverflow.com/a/22022924
type: AnswerComment
type: Comment
has text: It's not the only way but I feel it's the most sensible one since you're alreading passing the `BookFile` to the constructor and the reference doesn't need to change during the lifetime of `BookGUI`.

http://stackoverflow.com/comment/33558102
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22119883
has text: `for getName(teamName)`... What did you expect?

http://stackoverflow.com/q/22088217
favorite count: 0
tagged with: javafx-2
has body: I want to get First column value as we can achieve in Jtable using swing. below is my code and image for jtable. String Table_Clicked = jTable1.getModel().getValueAt(row, 0).toString(); As you can see in image when i click to the Name column value eight it gives me first column value like 8. But I select Name Column So how to achieve this in JavaFX with TableView Componenet. I get the selected Value from the TableView as you can see in image below with the code. tableview.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observableValue, Object oldValue, Object newValue) { if(tableview.getSelectionModel().getSelectedItem() != null) { TableViewSelectionModel selectionModel = tableview.getSelectionModel(); ObservableList selectedCells = selectionModel.getSelectedCells(); TablePosition tablePosition = (TablePosition) selectedCells.get(0); Object val = tablePosition.getTableColumn().getCellData(newValue); System.out.println("Selected value IS :" + val); } } }); So I want the same in tableview First column data as we can get in Jtable? so how to get that NO value.. as using my above code I get the value of selected Cell that is eight print in console.. but I want to get First Column Value.. Help me to go thorough Ahead. Thanks.. UPDATE FOR DATA FILLING CODE OF TABLEVIEW PreparedStatement psd = (PreparedStatement) conn.prepareStatement("SELECT No,name FROM FieldMaster"); psd.execute(); ResultSet rs = psd.getResultSet(); for(int i=0 ; i&lt;rs.getMetaData().getColumnCount(); i++){ //We are using non property style for making dynamic table final int j = i; namecol = new TableColumn(rs.getMetaData().getColumnName(i+1)); namecol.setCellValueFactory(new Callback&lt;CellDataFeatures&lt;ObservableList, String&gt;, ObservableValue&lt;String&gt;&gt;() { @Override public ObservableValue&lt;String&gt; call(CellDataFeatures&lt;ObservableList, String&gt; param) { return new SimpleStringProperty(param.getValue().g…
has comment: http://stackoverflow.com/comment/33635830
accepted answer: http://stackoverflow.com/a/22089747
has comment: http://stackoverflow.com/comment/33549910
upvote count: 1
tagged with: swing
has comment: http://stackoverflow.com/comment/33635957
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33608770
has comment: http://stackoverflow.com/comment/33636570
score: 1
tagged with: java
tagged with: javafx
has comment: http://stackoverflow.com/comment/33636948
type: Question
has title: How to Get First Column Value on click in JavaFX TableView like JTable in swing?
has comment: http://stackoverflow.com/comment/33635148
tagged with: tableview
has answer: http://stackoverflow.com/a/22346402
downvote count: 0
has answer: http://stackoverflow.com/a/22089747
has comment: http://stackoverflow.com/comment/33591849
answer count: 3
possible better answer: http://stackoverflow.com/a/22089444
has answer: http://stackoverflow.com/a/22089444

http://stackoverflow.com/a/22118365
has comment: http://stackoverflow.com/comment/88805717
has comment: http://stackoverflow.com/comment/50238065
type: AcceptedAnswer
has body: Change &lt;uses-permission android:name="com.example.manyexampleapp.c2dm.permission.RECEIVE" /&gt; to &lt;!-- This app has permission to register and receive data message. --&gt; &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt; You are getting the exception because you have not defined the required permissions
type: Answer
has comment: http://stackoverflow.com/comment/48149902
upvote count: 11
accepted answer of: http://stackoverflow.com/q/22117317
answers question: http://stackoverflow.com/q/22117317
has comment: http://stackoverflow.com/comment/48235011
downvote count: 1
score: 10

http://stackoverflow.com/q/22168399
has comment: http://stackoverflow.com/comment/33645121
has comment: http://stackoverflow.com/comment/33644847
answer count: 2
has comment: http://stackoverflow.com/comment/33645073
has comment: http://stackoverflow.com/comment/33645153
upvote count: 1
has comment: http://stackoverflow.com/comment/33644515
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33645403
has comment: http://stackoverflow.com/comment/33644485
has comment: http://stackoverflow.com/comment/33645361
downvote count: 0
score: 1
tagged with: java
tagged with: filewriter
has answer: http://stackoverflow.com/a/22168484
has comment: http://stackoverflow.com/comment/33645329
has comment: http://stackoverflow.com/comment/33644802
type: Question
has body: I have to accomplish a task of writing a set of data to file, use it, then overwrite it with new data. Thus overwrite of the file takes place repeatedly.I know i can accomplish the above by creating FileWriter object each time with the option to overwrite like below FileWriter object = new FileWriter("fileName", false) and close it to write to the file. If i am supposed to overwrite the file n number of times , according to the above method i need to create n number of FileWriter objects. Is there any efficient way to overwrite a file repeatedly by only creating a single FileWriter object?
has answer: http://stackoverflow.com/a/22168932
has comment: http://stackoverflow.com/comment/33644644
has title: overwriting a file in java using FileWriter

http://stackoverflow.com/comment/33550943
comment on: http://stackoverflow.com/q/22115705
score: 0
has text: This question is answered at least a thousand times on the web already. Please do some research before asking...
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/33493795
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22084010
has text: Since he's using catalog[ (catalog.length + 1) ] it doesn't even matter; it will always throw an exception regardless
type: AnswerComment

http://stackoverflow.com/q/22158687
has body: CREATE TABLE order ( order_id INT ,... ,CONSTRAINT ... PRIMARY KEY (order_id) ); CREATE TABLE item ( item_id INT ,item_list_price DECIMAL(10,2) ,... , CONSTRAINT ... PRIMARY KEY (item_id) ); CREATE TABLE order_item ( order_id INT ,item_id INT ,order_item_current_price DECIMAL(10,2); ,CONSTRAINT ... PRIMARY KEY (order_id, item_id) ,CONSTRAINT ... FOREIGN KEY (order_id) ... ,CONSTRAINT ... FOREIGN KEY (item_id) ... ); An Order has Many Items; Each Item may belong to Many Orders. An Item's price can change at any time. In order for a Customer to check how much he paid for an Item in the past, the order_item_cost field exists in the order_item table. When the end user checks the Items for sale, it would pull a List of Items with the item id, name, and listPrice, but not the currentPrice (as the currentPrice only relates to historical reporting in conjunction with an order, not purchasing a new item) . When the customer wishes to check his historical purchases and what he paid for each item at the time, it would pull an Order with a List of Items including the item id, name, and currentPrice, but not the listPrice (as the listPrice only relates to purchasing a new item, not historical reporting). So even though my relational schema has a Many to Many relationship between Order and Item, my POJOs think that there is a One to Many relationship between Order and Item, because there will never be an access pattern that requires the Many to Many Here are my current POJOs (stripped down to be concise): public class Order { private int id; private String status; private Customer customer; @OneToMany(mappedBy="order") private List&lt;Item&gt; items; ... } public class Item { private int id; private String name; @ManyToOne private Order order; private double listPrice; // List price of item, capable of changing over time private double currentPrice; // represents the order_item_cost field in order_item table ... } As you can notice, I did not put a List&lt;Order&gt; in the Item c…
answer count: 1
tagged with: one-to-many
has title: How to Handle Additional Attributes in Many to Many Table in POJOs when Access Patterns Rely on One to Many?
has answer: http://stackoverflow.com/a/22158805
type: UnansweredQuestion
tagged with: orm
tagged with: many-to-many
tagged with: java
tagged with: hibernate
type: Question
score: 0

http://stackoverflow.com/comment/33535794
score: 1
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22107231
has text: According to your indentation you're missing `{` and `}` after `if(name.equals("Java"))`.

http://stackoverflow.com/comment/33358963
type: Comment
type: QuestionComment
has text: Here is my actual question. What is the certificate that you are talking about? Can you be as much specific as you can about it?
comment on: http://stackoverflow.com/q/22006620
score: 0

http://stackoverflow.com/comment/33387331
score: 1
has text: What did you try so far, and why do you think it's too slow?
comment on: http://stackoverflow.com/q/22024474
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33524053
comment on: http://stackoverflow.com/q/22100667
score: 0
type: Comment
type: QuestionComment
has text: okey marco I thought of this bit also,but with the getGraphics option i am not sure, because the Images OSG is also constructed like that

http://stackoverflow.com/a/22294175
score: 0
type: Answer
answers question: http://stackoverflow.com/q/22157084
has body: You cannot hide the IDE in background during script execution. However,there's an alternative to view the logs. You can install the package which launches your sikuli via command prompt(sikuli-script.jar), refer to https://launchpad.net/raiman/+download you won't need the IDE to launch your scripts this way. Now after changing necessary environment settings you can type-in simple path like "java -jar %Sikuli_Home%\sikuli-script.jar -r %Sikuli_Scripts%\main.sikuli" in cmd and get started. here 'main' is my driver script where I have imported my modules under single .sikuli folder (main.sikuli) you can have any file name like abc.sikuli (here you need to store your path in a variable like ,path = os.environ['Sikuli_Scripts']) Also ,it is a good practice to launch applications creating batch files and accessing files using relative path.

http://stackoverflow.com/comment/33445695
score: 0
type: QuestionComment
type: Comment
has text: @nachokk That's for Find My Error Round #2 ;-)
comment on: http://stackoverflow.com/q/22057113

http://stackoverflow.com/comment/33512227
score: 0
type: AnswerComment
has text: Hmm, and are we interested only in answers or we would like to know, who writes that? (thus the link between Answer and Person is not needed)
type: Comment
comment on: http://stackoverflow.com/a/22094423

http://stackoverflow.com/a/22066610
type: Answer
upvote count: 3
has comment: http://stackoverflow.com/comment/58066952
score: 3
has comment: http://stackoverflow.com/comment/48189032
downvote count: 0
answers question: http://stackoverflow.com/q/22065542
has body: Such replays of failed tuples should represent only a tiny proportion of the overall tuple traffic, so the efficiency of this simple replay-from start policy is usually not a concern. Supporting a "replay-from-error-step" would bring lot's of complexity since the location of errors are sometimes hard to determine and there would be a need to support "replay-elsewhere" in case the cluster node where the error happened is currently (or permanently) down. It would also slow down the execution of the whole traffic which would probably not be compensated by the efficiency gained on error handling (which, again, is assumed to be triggered rarely). If you think this replay-from-start strategy would impact negatively your topology, try to break it down into several smaller ones separated by some persistent queuing system like Kafka.

http://stackoverflow.com/comment/54999342
has text: @Holger don't misunderstand: your solution is cool in the given limitations, I'm not against you, I'm just quite angry about handling static methods so badly from the java guys.
type: Comment
score: 0
comment on: http://stackoverflow.com/a/22102121
type: AnswerComment

http://stackoverflow.com/a/22021462
has comment: http://stackoverflow.com/comment/33429798
answers question: http://stackoverflow.com/q/22021291
has comment: http://stackoverflow.com/comment/33468645
type: Answer
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33407391
has body: Update: But: I need to glue my lines together with newlines, and what if the original file didn't have the "right" newlines for my platform (DOS files on Linux or vice versa)? I guess I could read ahead a bit in the stream and see what kind of line endings I find, even though that's really hacky. You can create a BufferedReader with a specified charset. So if the file is wacky, you'll have to supply the file's charset. Files.newBufferedReader(Path p, Charset cs) Is there a library (or even better, core Java7 class!) that will just let me call a method similar to readLine() that returns one line of text from a stream, with the EOL character(s) intact? If you're going to read a file, you have to know what charset it is. If you know what charset it is, then you don't need the EOL character to be "intact" since you can just add it on yourself. From BufferedReader.readLine: Reads 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. Returns: A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached So BufferedReader.readLine does not return any line-termination characters. If you want to preserve these characters, you can use the read method instead. int size = 1000; // size of file BufferedReader br = new BufferedReader(new FileReader("file.txt")); char[] buf = new char[size]; br.read(buf, 0, size); That is just a simple example, but if the file has line termination then it will show up in the buffer.
has comment: http://stackoverflow.com/comment/33428945
upvote count: 2
has comment: http://stackoverflow.com/comment/33429389

http://stackoverflow.com/a/22040645
answers question: http://stackoverflow.com/q/22040457
score: 0
type: Answer
has body: For your specific example, where each dollar amount is seperated by a '+' character, I would go for the split method in the String class, after having made the string from the StringBuilder. If you could be a bit more specific about why you want to remove the strings again, that would help in choosing the right solution. I guess what you are really looking for is a remove method on a StringBuilder object, but I am afraid such a thing does not exist.

http://stackoverflow.com/comment/33589635
comment on: http://stackoverflow.com/q/22137333
has text: @univerio I tried a lot.., I tried to parse it myself but got stuck on recursion and making sure every 'inner' array closes before continuing, I tried to use several JSON libraries but they depend on static structure of the JSON array, or that the JSON array only consists of the same type (e.g. not Strings, Integers and Arrays mixed).. If you know anything, please help..
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22110753
has title: converting string to public key android
has comment: http://stackoverflow.com/comment/33542593
has comment: http://stackoverflow.com/comment/33541957
has body: I am trying to develop application for SMS encryption. I have to communicate public key through SMS. Now i am being able to do encryption/decryption by generating the key pair(on same mobile client) but when i send the key as encoded string then on other side i am unable to recover the public key from string. Code is given below. In strToPublicKey() function, parameters are not returned in obj. byte[] keyBytes = Base64.decode(getPublicKey()); PublicKey publickey = strToPublicKey(new String(keyBytes)); //private String publicKey; private String getPublicKey() { // this string is received through SMS.. here it is hardcoded for testing purpose // Base 64 encoded public key return "[binary]"; } public static PublicKey strToPublicKey(String s) { PublicKey pbKey = null; BufferedReader br = new BufferedReader( new StringReader(s) ); PEMReader pr = new PEMReader(br); Object obj = pr.readObject(); if( obj instanceof PublicKey ) { pbKey = (PublicKey) pr.readObject(); } else if( obj instanceof KeyPair ) { KeyPair kp = (KeyPair) pr.readObject(); pbKey = kp.getPublic(); } pr.close(); return pbKey; } there are no errors in logcat *03-01 06:54:00.054: I/System.out(4033): debugger has settled (1412) 03-01 06:54:01.614: D/dalvikvm(4033): GC_CONCURRENT freed 211K, 12% free 2573K/2904K, paused 75ms+76ms, total 251ms 03-01 06:54:02.784: D/dalvikvm(4033): GC_CONCURRENT freed 208K, 11% free 2763K/3096K, paused 77ms+5ms, total 176ms 03-01 06:54:06.384: D/dalvikvm(4033): GC_CONCURRENT freed 128K, 8% free 3025K/3280K, paused 75ms+94ms, total 282ms 03-01 06:54:09.866: D/dalvikvm(4033): GC_CONCURRENT freed 269K, 12% free 3144K/3540K, paused 76ms+93ms, total 259ms 03-01 06:56:52.745: D/dalvikvm(4033): threadid=1: still suspended after undo (sc=1 dc=1) 03-01 06:56:52.765: D/dalvikvm(4033): GC_CONCURRENT freed 235K, 10% free 3316K/3680K, paused 83ms+9ms, total 208ms* there certainly is some casting issue...please someone help me:(
upvote count: 1
has comment: http://stackoverflow.com/comment/33542507
favorite count: 0
has comment: http://stackoverflow.com/comment/33545924
type: UnansweredQuestion
tagged with: android
answer count: 0
downvote count: 0
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33542726
type: Question

http://stackoverflow.com/a/22051142
upvote count: 10
has comment: http://stackoverflow.com/comment/33434689
has comment: http://stackoverflow.com/comment/33434715
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22051060
has comment: http://stackoverflow.com/comment/33435316
has comment: http://stackoverflow.com/comment/33435399
answers question: http://stackoverflow.com/q/22051060
type: Answer
has comment: http://stackoverflow.com/comment/33434887
has body: try this org.apache.maven.plugins maven-surefire-report-plugin 2.7.2 true install report
has comment: http://stackoverflow.com/comment/33436690
has comment: http://stackoverflow.com/comment/33435158
has comment: http://stackoverflow.com/comment/33435224
score: 10

http://stackoverflow.com/comment/33427924
type: QuestionComment
comment on: http://stackoverflow.com/q/22046690
score: 2
has text: @LouisWasserman Can you quote an official source if there is any? I'm unable to find one.
type: Comment

http://stackoverflow.com/q/22164480
tagged with: eclipse
type: Question
has title: Unable to use the FileEditorInput class in Eclipse
downvote count: 0
has body: I am working on an Eclipse Editor Project where I am supposed to get the location of the currently open file in the Editor. I searched the Eclipse documentation to actually find FileEditorInput Class. But to much of my surprise, my project is not able to locate this class in Eclipse. How can it be done ?
answer count: 1
has answer: http://stackoverflow.com/a/22166421
accepted answer: http://stackoverflow.com/a/22166421
tagged with: eclipse-plugin
favorite count: 0
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java

http://stackoverflow.com/comment/33706412
type: Comment
has text: @GregS Well, if I remember correctly, the Bouncy Castle provider supports both strings. PKCS5 is a bit of a misnomer anyway since technically it's only defined for 64-bit blocks.
comment on: http://stackoverflow.com/a/22157423
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33465868
comment on: http://stackoverflow.com/a/22056372
type: Comment
type: AnswerComment
has text: The Unix terminal is an eternal source of discovery ;) Have fun!
score: 0

http://stackoverflow.com/comment/33406598
has text: An `int` is a primitive type and a primitive type has no methods; what is more, `Integer` (which is the wrapper class) has no `.getBytes()`. Hint: use a `ByteBuffer`.
type: Comment
score: 1
comment on: http://stackoverflow.com/q/22035424
type: QuestionComment

http://stackoverflow.com/q/22078111
type: Question
answer count: 2
has body: I'm trying to use this in JSF to dynamically show the title of a page. &lt;h:panelGroup rendered="#{not empty searchBean.fsResultsTitleOne}"&gt;&lt;h2&gt;#{msgs.fireStudySearchTitle}&lt;/h2&gt;&lt;/h:panelGroup&gt; And I'm getting this error: rendered="#{not empty searchBean.fsResultsTitleOne}": Property 'fsResultsTitleOne' not found on type However, I did define it in on the type like this: private String fsResultsTitleOne; public String getFSResultsTitleOne(){return fsResultsTitleOne;} public void setFSResultsTitleOne(String newValue){fsResultsTitleOne = newValue;} And set it to something: setFSResultsTitleOne("I'm not Empty!"); And even used this to make sure it would be set: System.out.println("This is the FS Results Page Title: " + fsResultsTitleOne); And it seems to be working: This is the FS Results Page Title: I'm not Empty! Am I setting it wrong someplace?
has comment: http://stackoverflow.com/comment/33482785
tagged with: jsf
score: 0
tagged with: java
linked to: http://stackoverflow.com/q/21986326
has answer: http://stackoverflow.com/a/22078139
has answer: http://stackoverflow.com/a/22222644
has comment: http://stackoverflow.com/comment/33484839
tagged with: jsf-2
accepted answer: http://stackoverflow.com/a/22078139
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22222644
has title: Property Not Found On Type

http://stackoverflow.com/q/22020338
has comment: http://stackoverflow.com/comment/33379727
score: 0
has comment: http://stackoverflow.com/comment/33379938
has comment: http://stackoverflow.com/comment/33380416
type: UnansweredQuestion
type: Question
tagged with: spring-mvc
tagged with: enums
tagged with: hashmap
tagged with: java
has answer: http://stackoverflow.com/a/22021263
has title: Convert string into enum during @RequestBody deserialization with a HashMap
answer count: 1
has body: I'm having a hard time converting a String into an ENUM in @RequestBody annotated method argument. The Map in the argument somehow has a value of a string even though the value is an Enum type. What do I do to automatically convert the String into the correct type? Enum public enum Fruit{ ORANGE, APPLE, PEAR } Request: {"123":"ORANGE", "456":"APPLE"} Controller @RequestMapping(value="/updateFruit", method = RequestMethod.POST) public void updateFruit(@RequestBody Map&lt;String, Fruit&gt; fruitMap){ // Fruit comes in as a String. So the map is a Map&lt;String, String&gt; // do stuff.... }

http://stackoverflow.com/comment/33639725
has text: @Kobus, there are a lot of constructor that take other types of argument for your data. you could use `DefaultTableModel(Object[][] data, Object[] columnNames)`. you can read more about it in the link above.
comment on: http://stackoverflow.com/a/22165297
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33534323
comment on: http://stackoverflow.com/q/22104870
has text: @Daniel on my linux shell, $ java -version java version "1.6.0_27" OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.4) OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33425281
comment on: http://stackoverflow.com/q/22033027
has text: @ipohfly yes, I copied it to libs and then imported it into the workspace and added it as a library to MyApp. I did it that way so that when I push it to repo others can download it.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33465162
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22068749
has text: Do you have permission to write where it is supposed to write?
score: 0

http://stackoverflow.com/a/22093193
upvote count: 1
has comment: http://stackoverflow.com/comment/33509369
has comment: http://stackoverflow.com/comment/33509577
has body: U can create button with loops Vector&lt;Button&gt; lists = new Vector&lt;Button&gt;(); for(int i = 0 ; i &lt; 10000 ; i++) { JButton button = new JButton("Empty"); lists.add(button); } And more, more.. other way
type: Answer
has comment: http://stackoverflow.com/comment/33509366
downvote count: 0
has comment: http://stackoverflow.com/comment/33509557
score: 1
has comment: http://stackoverflow.com/comment/33509447
answers question: http://stackoverflow.com/q/22093132
has comment: http://stackoverflow.com/comment/33509404

http://stackoverflow.com/comment/33586475
score: 0
type: Comment
type: QuestionComment
has text: Because, in the context of the standard algebraic statement notation, only one result can be utilized. To allow multiple results would require inventing a new notation, and a suitable one has not bubbled to the surface.
comment on: http://stackoverflow.com/q/22135035

http://stackoverflow.com/comment/33413730
type: AnswerComment
score: 0
type: Comment
has text: Cryptographic keys are required to perform authentication to the card before it lets you install anything. Some card will also require that packages are signed.
comment on: http://stackoverflow.com/a/22022888

http://stackoverflow.com/comment/33420425
type: Comment
comment on: http://stackoverflow.com/a/22037941
has text: You don't normally have an `application` extension for e4 apps, you just use the `org.eclipse.e4.ui.workbench.swt.E4Application` application.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33517955
has text: Be sure to check that you have the JUnit library in your build path and not just as an import statement.
comment on: http://stackoverflow.com/a/22095076
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/22131818
has body: You could never loop. If you have a return statement inside of a loop, then the compiler doesn't take the bonafide guarantee that the loop will execute and that you will return. To get around that, you must also return after your loop. Or, better yet, have one variable to return, like such: block ret = null; for(block b : blocks) { if(b.x == x) { // I'm going to go over this in a mo ret = b; break; } } return ret;
score: 0
type: Answer
answers question: http://stackoverflow.com/q/22131437

http://stackoverflow.com/comment/33590110
has text: Can you use `protected`?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22137700

http://stackoverflow.com/comment/33491949
type: Comment
comment on: http://stackoverflow.com/a/22082786
has text: I still get 0 items selected as the result and by the way I know it is .size(), which I already changed so that is not a problem either it returns the correct size, and goes through the loop but it is as if it does not return any selected items
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33352953
type: Comment
type: QuestionComment
has text: missing a `}` before the last `else`
score: 1
comment on: http://stackoverflow.com/q/22005230

http://stackoverflow.com/comment/33450060
type: AnswerComment
score: 0
has text: if you want to do this, you can first fetch the string resource, alter its value by calling the function and then you can use shared prefences or database to store that string.
type: Comment
comment on: http://stackoverflow.com/a/22059478

http://stackoverflow.com/a/22044065
type: Answer
has body: Presumably you have your XML parsed as a document? You could get all the nodes using, lets say XPath, then call getParentNode().removeChild(node) on each node.
score: 0
answers question: http://stackoverflow.com/q/22043616

http://stackoverflow.com/a/22166852
accepted answer of: http://stackoverflow.com/q/22166799
score: 0
type: Answer
answers question: http://stackoverflow.com/q/22166799
has body: Why is my answer 2, and not 11? For one, you wanted to write public static void reassign (int[] nums) { int[] A = {10,11,22}; nums = A; } But than won't help you either: you cannot assign to one method's local variable from another method. The value of the variable (a reference to the array) is passed to reassign, not the address of the variable itself. In reassign you merely create a new array and then assign its reference to the local variable nums (in my corrected code). Does it have something to do with the relative sizes of the arrays? No, the reason behind it is fully general and applies to all of Java.
type: AcceptedAnswer

http://stackoverflow.com/comment/33546007
has text: ok, I'm going to "formalize" the answer; anyway, it is better avoiding spaces in paths when using batch scripting (alas, Windows still provides a "program files" default dir)
comment on: http://stackoverflow.com/q/22112688
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22133406
has body: I wrote a service class which creates a transparent view (LinearLayout). If the user is holding down, some music starts to play. This runs fine, but the problem is that if I am in the android menu or in another app, I am not able to press any buttons. (My view seems to don't let the TouchEvents pass) I have tried a lot of things like returning false or stopping the interception, but I am still not able to press any gui controls when the service is running. How do I correctly pass the TouchEvent back to the System? @Override public boolean onTouch(View v, MotionEvent event) { v.getParent().requestDisallowInterceptTouchEvent(true); if(event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_UP) Log.i(TAG, "Action :" + event.getAction() + "\t X :" + event.getRawX() + "\t Y :" + event.getRawY()); if(event.getAction() == MotionEvent.ACTION_DOWN) { if(!mp.isPlaying()) mp.start(); } if(event.getAction() == MotionEvent.ACTION_UP) { mp.pause(); } //View parent = (View) v.getParent().getParent(); //parent.onTouchEvent(event); v.onTouchEvent(event); return false; }
tagged with: java
type: Question
tagged with: android-service
tagged with: android-view
answer count: 1
has title: Android: Letting the touch event through my transparent view (service)
score: 0
tagged with: android
has answer: http://stackoverflow.com/a/22133598
type: UnansweredQuestion

http://stackoverflow.com/q/22096009
has title: How to make eclipse pick customized source dir in maven environment?
favorite count: 0
has answer: http://stackoverflow.com/a/22096590
type: UnansweredQuestion
tagged with: maven
upvote count: 1
score: 1
tagged with: java
tagged with: directory-structure
tagged with: eclipse
type: Question
tagged with: customization
downvote count: 0
answer count: 1
has body: Here is my project in window explorer: Here is when I import it as Existing Maven Project: Here is the build path: You can see that the source directory is not picked by maven/eclipse by default; maven by default picks the following directory by default: src/main/java src/main/resources src/test/java I was wondering if there is a way to configure maven(m2e plugin)/eclipse to pick src/main-java-templates source directory aswell automatically on import instead of manually adding it to build path? Any help would be appreciated!

http://stackoverflow.com/q/22032260
tagged with: hibernate-mapping
tagged with: spring
type: AnsweredQuestion
tagged with: java
upvote count: 10
has answer: http://stackoverflow.com/a/22033238
type: Question
has body: I have two POJO's ,STOCK and STOCK_DETAILS (one to many relationship). Also I have one interface IAUDITLOG (having two methods). I need to implement this interface with BOTH POJO's and want to write some implementation within those methods. But when I implement IAUDITLOG interface with child class "STOCKDETAILS" then it gives exception "that you should have setter property" STOCK CLASS: @Entity @Table(name = "stock") public class Stock implements java.io.Serializable, IAuditLog { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "id") private Integer stockId; @Column(name = "STOCK_CODE") private String stockCode; @Column(name = "STOCK_NAME") private String stockName; @OneToMany( fetch = FetchType.LAZY, mappedBy = "stock") public Set&lt;StockDetail&gt; stockDetails = new HashSet&lt;StockDetail&gt;(0); public Set&lt;StockDetail&gt; getStockDetails() { return stockDetails; } public void setStockDetails(Set&lt;StockDetail&gt; stockDetails) { this.stockDetails = stockDetails; } public Integer getStockId() { return stockId; } public void setStockId(Integer stockId) { this.stockId = stockId; } public String getStockCode() { return stockCode; } public void setStockCode(String stockCode) { this.stockCode = stockCode; } public String getStockName() { return stockName; } public void setStockName(String stockName) { this.stockName = stockName; } // overridded methods of IAUDITLOG interface public int getLogId() { return stockId; } public String getLogDetail() { return "some implementaion"; } } STOCK DETAILS CLASS @Entity @Table(name = "StockDetail") public class StockDetail implements Serializable, IAuditLog { /** * */ private static final long serialVersionUID = 1L; private Integer recordId; private Stock stock; private Float priceOpen; @Id @GeneratedValue @Column(name = "RECORD_ID", unique = true, nullable = false) public Integer getRecordId() { return this.recordId; } public void setRecordId(Integer recordId) { this.recordId = re…
tagged with: hibernate
has title: HIbernate Mapping Exception: PropertyNotFoundException: Could not find a setter
score: 10
answer count: 2
possible better answer: http://stackoverflow.com/a/40266745
accepted answer: http://stackoverflow.com/a/22033238
downvote count: 0
has answer: http://stackoverflow.com/a/40266745
favorite count: 0

http://stackoverflow.com/comment/33573070
score: 0
type: Comment
has text: I thought about it. It makes things uglier i thought. I will rethink about how i can do that more cleanly.
type: AnswerComment
comment on: http://stackoverflow.com/a/22127422

http://stackoverflow.com/comment/33558027
comment on: http://stackoverflow.com/q/22119665
type: Comment
type: QuestionComment
has text: @Bugs That might be a funny answer but [it's a *rant*](http://meta.stackexchange.com/q/182189).
score: 0

http://stackoverflow.com/comment/70703795
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22831521
has text: `RemoteControlClientCompat` deprecated in API 21.
type: AnswerComment

http://stackoverflow.com/comment/33431635
type: QuestionComment
comment on: http://stackoverflow.com/q/22049353
has text: Yeah I tried that using sample[b][0].equals(sample[a][0] and only outputs: variables stored: [hates, p1, p1, p2, p2, hatesCopy, p2, p2, p1, p1] attribute stored: [hates, boy, girl, girl, boy, hatesCopy, girl, boy, boy, girl]
score: 0
type: Comment

http://stackoverflow.com/q/22125102
has answer: http://stackoverflow.com/a/22125126
tagged with: exception
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
type: Question
possible better answer: http://stackoverflow.com/a/22125126
has comment: http://stackoverflow.com/comment/33567846
has body: Say you have a class called Timer. When a user tries to call the method Timer#start(), the code checks if the timer has already been started. If it has, then it can't start it again. Now, say this class is a part of a library/API. The developer can't know that the method isn't being called inappropriately, so they want to bring attention to any improper calls. The two ways to do so would be to a) print a simple error message (so-and-so has called a method inappropriately), or b) throw an exception. In my opinion, the exception that would make the most sense is an IllegalAccessException, though this isn't its intention as stated by Sun. However, I've seen it used in cases that have nothing to do with visibility and are simply throwing it to call attention to a bad call. My question is, would this situation call for (haha, pun) said exception, or is there a better one suited to it? Or, would it be best to create a new one or to simply print an error line?
has title: When is an IllegalAccessException appropriate?
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/22125139
accepted answer: http://stackoverflow.com/a/22125139
has comment: http://stackoverflow.com/comment/33567897
favorite count: 0

http://stackoverflow.com/a/22115183
has body: +1 to Dave's point about using @EanbleBatchProcesssing. That will add a StepScope to your context. However, your code still won't work once you've done that because you're returning an ItemReader for "myInputObjectItemReader" instead of ParameterSettingJdbcCursorItemReader. See the issue here for details on why that matters: Spring-batch @BeforeStep does not work with @StepScope
downvote count: 0
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/33627388
score: 1
answers question: http://stackoverflow.com/q/22108315

http://stackoverflow.com/a/22044067
has comment: http://stackoverflow.com/comment/33507355
has body: You have to iterate on single line: InputStream fis = null; BufferedReader br = null; String aFileLine; String fileName = "the_file_name"; Pattern pattern = Pattern.compile("create table \\D[^;]+\\([^;](.*?)+[^;]+\\)"); Matcher mat = null; try { fis = new FileInputStream(fileName); br = new BufferedReader(new InputStreamReader(fis)); // start to check line by line while ((aFileLine = br.readLine()) != null) { mat = pattern.matcher(aFileLine); if (mat.find()) { String s = mat.group(1); // now you have your string in 's' } } } catch (FileNotFoundException e) { System.err.println("File " + "'"+ fileName + "'" + "not found!!"); } catch (IOException e) { e.printStackTrace(); } // Done with the file try { br.close(); } catch (IOException e) { e.printStackTrace(); } br = null; fis = null; }
has comment: http://stackoverflow.com/comment/33430820
type: Answer
answers question: http://stackoverflow.com/q/22042009
score: 0
has comment: http://stackoverflow.com/comment/33507697

http://stackoverflow.com/q/22010658
has title: BoxLayout inside a BorderLayout
score: 1
has comment: http://stackoverflow.com/comment/33362371
tagged with: java
has comment: http://stackoverflow.com/comment/33362500
tagged with: boxlayout
type: Question
linked to: http://stackoverflow.com/q/5621338
tagged with: layout-manager
has comment: http://stackoverflow.com/comment/33362682
has body: I have a BorderLayout and I wish to include a BoxLayout in it such that I have three vertical buttons it . The design is like this: I want one horizontal borderlayout,below which I have two borderlayouts. In the left borderlayout I want boxlayout with three vertical buttons. Here is the code I have tried: JLabel label2 = new JLabel("LOGO"); pane.add(label2, BorderLayout.PAGE_START); button = new JButton("Button 2 (CENTER)"); button.setPreferredSize(new Dimension(200, 100)); pane.add(button, BorderLayout.CENTER); button = new JButton("Button 3 (LINE_START)"); pane.add(button, BorderLayout.LINE_START); button = new JButton("Long-Named Button 4 (PAGE_END)"); pane.add(button, BorderLayout.PAGE_END); How should I go about such that I get the design mentioned. Right now I am not getting it and I do not know how to add boxlayout inside borderlayout.
has answer: http://stackoverflow.com/a/22010921
downvote count: 0
answer count: 1
favorite count: 0
type: UnansweredQuestion
upvote count: 1
tagged with: swing
linked to: http://stackoverflow.com/q/17874717
tagged with: border-layout

maven-jaxb2-plugin
type: Tag
tags question: http://stackoverflow.com/q/22009518
tag name: maven-jaxb2-plugin

http://stackoverflow.com/a/22123437
has comment: http://stackoverflow.com/comment/33564868
type: Answer
has comment: http://stackoverflow.com/comment/33566592
has body: Your Band class needs a member of the type GuitarPlayer that both classes inherit from. public class Band { private GuitarPlayer gPlayer; public Band(GuitarPlayer gPlayer) { this.gPlayer = gPlayer; } } Because both ElectricGuitarPlayer and AcousticGuitarPlayer inherit from GuitarPlayer you can do this: Band metalBand = new Band(new ElectricGuitarPlayer()); Band folkBand = new Band(new AcousticGuitarPlayer()); And as an example of the kinds of ways you can interact with the objects: // assume GuitarPlayer has a play() method metalBand.getGuitarPlayer().play(); folkBand.getGuitarPlayer().play(); // assume ElectricGuitarPlayer only has a whammy() method ElectricGuitarPlayer electric = (ElectricGuitarPlayer) metalBand.getGuitarPlayer(); electric.whammy(); // assume AcousticGuitarPlayer only has a strum() method AcousticGuitarPlayer acoustic = (AcousticGuitarPlayer) folkBand.getGuitarPlayer(); acoustic.strum(); you should use a try...catch block that catches a ClassCastException when you try to do any casting in case things don't fit. To be more helpful we'll need more details of what your exact issue is.
answers question: http://stackoverflow.com/q/22123409
downvote count: 1
upvote count: 5
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22123409
score: 4

http://stackoverflow.com/comment/33446083
has text: Your requirement is not clear!
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22057438

http://stackoverflow.com/a/22029244
upvote count: 2
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33396463
has comment: http://stackoverflow.com/comment/33396386
has comment: http://stackoverflow.com/comment/33398929
has body: I'd be willing to bet you're not passing the name of your data file to your program. if args.length == 0 then args[0] throws ArrayIndexOutOfBoundsException That's about the only way you can get that error on that line.
accepted answer of: http://stackoverflow.com/q/22029021
type: Answer
answers question: http://stackoverflow.com/q/22029021
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33412966

http://stackoverflow.com/comment/33441287
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22054708
has text: Of course it is difficult task but at first try this: 1. Get next word or name in first file. 2. Find current word or line in tho others
score: 0

http://stackoverflow.com/comment/33480817
type: Comment
type: QuestionComment
has text: Frankly, I'm not sure anymore as it seems that no one knows '#' :) I don't have access to the server where this script runs successfully, but I guess there must be some additional magic there.
score: 0
comment on: http://stackoverflow.com/q/22075310

http://stackoverflow.com/comment/33492221
has text: Agreed. I'm actually working on a case where I have an abstraction stack of objects and this issue is coming up in protected methods only, so it's not going to break any contract. I think of it as conceptually equivalent to what happens when you override a class's constructor with something with different parameters, where you then can't use the old one any more in future extensions.
type: Comment
comment on: http://stackoverflow.com/a/22082784
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33585131
has text: @HovercraftFullOfEels Seriously? And I thought this questions was dumb :D :)
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/22133993

http://stackoverflow.com/comment/33390880
type: Comment
comment on: http://stackoverflow.com/q/22026301
type: QuestionComment
score: 0
has text: there's no problem, but I want to throw an exception if the input is not a number. So if it's a string would display an error message saying that is not possible to use a string, and I have no clue how to do it.

http://stackoverflow.com/comment/33401929
has text: So in my case, the only situation where the strings are of equal length is that both are empty strings which will be of complexity O(0) and in all other cases the complexity will be O(1). So is there any modification needed for performance improvement? The 1000 invocations i mentioned is arbitrary, it may increase.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22032413
type: AnswerComment

http://stackoverflow.com/comment/33517657
has text: Actually it's 10th value and index number 9
score: 2
comment on: http://stackoverflow.com/a/22097818
type: AnswerComment
type: Comment

http://stackoverflow.com/q/22080344
has title: Encoding url in java avoiding special characters
has comment: http://stackoverflow.com/comment/33487690
score: 0
has comment: http://stackoverflow.com/comment/33487136
has body: I need to pass the encoded url but it needs to avoid special characters as well. So how do I encode it? None of the answers on stackoverflow worked for me. Can any one help? I want to do it in java public String tweet_quote_func(Map attrs, FilterParam param) { String url = param.getShorturi(); String text = attrs.get("display"); if (url != null &amp;&amp; text != null) { try { text = StringEscapeUtils.unescapeHtml(text); // for double quotes String encodedurl = "https://twitter.com/intent/tweet?url="+URLEncoder.encode(url, "UTF-8"); encodedurl = encodedurl + "&amp;text=" + StringUtil.escapeUrl(text); return "&lt;span class=\"tweet_quote\"&gt; &lt;a href=" + encodedurl+ "&gt;" + text.trim() + "&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;"; } catch (UnsupportedEncodingException e) { System.err.println(e); return null; } } else return null; }
linked to: http://stackoverflow.com/q/213506
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33487325
has comment: http://stackoverflow.com/comment/33487257
tagged with: url-encoding
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33487516
tagged with: encoding
has answer: http://stackoverflow.com/a/22082207
has comment: http://stackoverflow.com/comment/33487177
answer count: 1

http://stackoverflow.com/comment/33504562
score: 0
type: Comment
type: QuestionComment
has text: You have to show that you at least attempted to solve this problem by yourself. At least provide us with the code you wrote and we will attempt to help you.
comment on: http://stackoverflow.com/q/22090291

http://stackoverflow.com/q/22108121
accepted answer: http://stackoverflow.com/a/22108248
possible better answer: http://stackoverflow.com/a/22108220
has title: Java JTexfield Input and Output for Property Tax
answer count: 2
downvote count: 0
favorite count: 0
upvote count: 2
tagged with: swing
has answer: http://stackoverflow.com/a/22108220
has body: I have been trying to run this code which takes the user's assessed home value, the county and school taxes and then outputs them to a text field. This code compiles and runs but there is a logical error somewhere that doesn't let it output any text. I'm just starting with Java so any help would be appreciated. import javax.swing.*; import java.awt.*; import java.awt.event.*; public class PropertyTax3 extends JFrame { // set parameters to define extent of the window private static final int WIDTH = 500, HEIGHT = 300; private ExitHandler ebHandler; private CalculateHandler cbHandler; private JTextField assessTF, schoolRateTF, countyRateTF, schoolTaxTF, countyTaxTF, totalTaxTF; public PropertyTax3() { // set title, size and visibility aspects of window setTitle("Calculation of Property Taxes"); //Label Definitions JLabel assessL = new JLabel("Assesment Home Value:", SwingConstants.RIGHT); JLabel schoolRateL = new JLabel("Decimal Value of School Tax Rate:", SwingConstants.RIGHT); JLabel countyRateL = new JLabel("Decimal Value of County Tax Rate:", SwingConstants.RIGHT); JLabel schoolTaxL = new JLabel("School Taxes:", SwingConstants.RIGHT); JLabel countyTaxL = new JLabel("County Taxes:", SwingConstants.RIGHT); JLabel totalTaxL = new JLabel("Total Taxes:", SwingConstants.RIGHT); //Text Field Definitions JTextField assessTF = new JTextField(10); JTextField schoolRateTF = new JTextField(10); JTextField countyRateTF = new JTextField(10); JTextField schoolTaxTF = new JTextField(10); JTextField countyTaxTF = new JTextField(10); JTextField totalTaxTF = new JTextField(10); //Exit Button JButton exit = new JButton("Exit"); ebHandler = new ExitHandler(); exit.addActionListener(ebHandler); //Calculate Button JButton calculate = new JButton("Calculate"); cbHandler = new CalculateHandler(); calculate.addActionListener(cbHandler); //Container format Container pane = getContentPane(); pane.setLayout(new GridLayout(7,2)); pane.add(assessL); pane.add(assessTF); pane.add(schoolRateL); pa…
score: 2
type: AnsweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22108248

http://stackoverflow.com/comment/33599481
comment on: http://stackoverflow.com/q/22143215
type: Comment
type: QuestionComment
has text: could you give me more details pls?
score: 0

http://stackoverflow.com/a/22121733
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/22121221
downvote count: 0
has body: An easier way is to make a runnable JAR file. Go into eclipse choose file > export > runnable JAR. It will then ask you to choose a class for a launch configuration. Choose the class that has the main method for the desired program. After that you will have a file that will run (like a .exe but just a different format). If can't get it to work with your input and output files, thats because eclipse has this weird thing that sometimes occurs regarding the location of external sources when exporting to JAR. To fix it, just put the files instead of the src (source) folder, one folder up in the directory. For example, if this is your current directory: C:\workspace\myprogram\src put it in C:\workspace\myprogram Hope this helps.
score: 1

http://stackoverflow.com/q/22145356
has title: How to get Data from a Task in afterExecute of ScheduledThreadPoolExecutor
has body: I'm using ScheduledThreadPoolExecutor and I don't know hot to deal with something. I'm scheduling some tasks this way: scheduledExecService = new ExtendedScheduledExecutor(numThreads, myThreadFactory); TareaActualizacion act = new TareaActualizacion(inst); ScheduledFuture&lt;?&gt; handle = scheduledExecService.scheduleWithFixedDelay(act, retrasoInicial, segundosRefresco, TimeUnit.SECONDS); act is a Runnable class that recive some data by parameter: public class TareaActualizacion implements Runnable { private Instalacion instalacion; public TareaActualizacion(Instalacion instalacion) { this.instalacion = instalacion; } @Override public void run() { //Do something } public Instalacion getInstalacion() { return instalacion; } } Now in the afterExecute method of the ExtendedSecheduledExecutor I want to get the object Instalacion of the task TareaActualizacion but I don't know how to do it. My ExtendedScheduledExecutor class looks like this: public class ExtendedScheduledExecutor extends ScheduledThreadPoolExecutor{ public ExtendedScheduledExecutor(int arg0) { super(arg0); } public ExtendedScheduledExecutor(int arg0, ThreadFactory arg1) { super(arg0, arg1); } @Override protected void afterExecute(Runnable r, Throwable t) { super.afterExecute(r, t); System.out.println("Executing afterExecute. Throwable is " + t); if (t != null) t.printStackTrace(); //I need to get the Instalacion attribute from TareaActualizacion task. How can I do it?? } } Any idea of how can I solve it?? Thank you! Neus
tagged with: scheduledexecutorservice
type: UnansweredQuestion
type: Question
has answer: http://stackoverflow.com/a/22145530
tagged with: java
has answer: http://stackoverflow.com/a/22149554
score: 0
answer count: 2

http://stackoverflow.com/q/22027843
possible better answer: http://stackoverflow.com/a/22028198
favorite count: 0
has comment: http://stackoverflow.com/comment/33393864
has answer: http://stackoverflow.com/a/22028168
accepted answer: http://stackoverflow.com/a/22028168
has comment: http://stackoverflow.com/comment/33393677
has title: Sorting using comparable
type: AnsweredQuestion
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/33393750
type: Question
has body: Intro My code to do a custom sort by using Comparable is not work the way I want it to. I'm basically taking an Array of directories and sorting them by: First number of directories, the fewer comes first. If it's a tie alphabetically. The problem An example of an input you be: ["/", "/usr/", "/usr/local/", "/usr/local/bin/", "/games/", "/games/snake/", "/homework/", "/temp/downloads/" ] Which should return this: ["/", "/games/", "/homework/", "/usr/", "/games/snake/", "/temp/downloads/", "/usr/local/", "/usr/local/bin/" ] But for some reason my code is return this: ["/", "/usr/", "/games/", "/homework/", "/usr/local/", "/games/snake/", "/usr/local/bin/", "/temp/downloads/" ] My code [edited with comments] import java.util.*; public class Dirsort { public String[] sort(String[] dirs) { //Creates Array list containing Sort object ArrayList&lt;Sort&gt; mySort = new ArrayList&lt;Sort&gt;(); //Loop that gets the 3 needed values for sorting for (String d: dirs){ String [] l = d.split("/");//String array for alphabetical comparison int di = d.length();//Length of array for sorting by number of directories mySort.add(new Sort(di,l,d));//adds Sort object to arraylist (note d (the entire directory) is needed for the toString) } Collections.sort(mySort);//sorts according to compareTo String [] ans = new String [mySort.size()];//Creates a new string array that will be returned int count = 0;//to keep track of where we are in the loop for appending for (Sort s: mySort){ ans[count] = s.toString(); count++; } return ans; } class Sort implements Comparable&lt;Sort&gt;{ private int d;//number of directories private String [] arr;//array of strings of names of directories private String dir;//full directory as string for toString //Constructor public Sort(int myD, String [] myArr, String myDir){ d = myD; arr = myArr; dir = myDir; } //toString public String toString(){ return dir; } @Override public int compareTo(Sort arg0) { // TODO Auto-generated method stub //If they are the same …
has answer: http://stackoverflow.com/a/22028891
tagged with: sorting
tagged with: comparable
has answer: http://stackoverflow.com/a/22028198
upvote count: 2
answer count: 3
downvote count: 1

http://stackoverflow.com/comment/33408345
type: Comment
type: QuestionComment
has text: Il take a look at it fge, thanks. @Awesome so u say i should go with my thoughts on doing a simple +1 timer thing? if yes, i do not understand what u mean by "helper method" or running it as a daemon thread. im still pretty new to java =P
score: 0
comment on: http://stackoverflow.com/q/22036331

http://stackoverflow.com/comment/33547283
comment on: http://stackoverflow.com/q/22113813
score: 0
has text: @skiwi the application is for any one so if they run it on a java version that is not compatible then the jar wont work.
type: QuestionComment
type: Comment

http://stackoverflow.com/a/22149577
has comment: http://stackoverflow.com/comment/33616654
has comment: http://stackoverflow.com/comment/33613585
has body: I've been known to implement an ArrayKey object which allows me to use an array as a key in maps etc. public class ArrayKey { private Object[] array; public ArrayKey(Object... array) { this.array = array; } public boolean equals(Object other) { ... } public int hashCode() { ...} public Object[] getArray() { return array; } } Then you could do: Map&lt;ArrayKey, String&gt; map = new HashMap(); map.put(new ArrayKey(DiceEyes.ONE,CardSuit.HEARTS), "/path/to/file.jpg"); map.get(new ArrayKey(DiceEyes.ONE,CardSuit.HEARTS)); Of course, this could be extended to create an ArrayKeyMap for convenience public class ArrayKeyMap&lt;T&gt; { private Map&lt;ArrayKey, T&gt; map = new HashMap(); public T put(Object... key, T value) { return map.put(new ArrayKey(key), value); } public T get(Object... key) { return map.get(new ArrayKey(key)); } }
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/33611673
downvote count: 0
has comment: http://stackoverflow.com/comment/33611394
has comment: http://stackoverflow.com/comment/33613241
has comment: http://stackoverflow.com/comment/33611499
answers question: http://stackoverflow.com/q/22149403
has comment: http://stackoverflow.com/comment/33611118
has comment: http://stackoverflow.com/comment/33611051
has comment: http://stackoverflow.com/comment/33610837
upvote count: 3
has comment: http://stackoverflow.com/comment/33610956

http://stackoverflow.com/comment/33644011
type: AnswerComment
comment on: http://stackoverflow.com/a/22167902
score: 0
type: Comment
has text: So D is correct? Can you instantiate a class that "implements Inty but does not provide implementations for any of the five interface methods"?

http://stackoverflow.com/q/22018921
tagged with: compiler-errors
downvote count: 0
has answer: http://stackoverflow.com/a/22019014
tagged with: java
has answer: http://stackoverflow.com/a/22018990
type: Question
score: 5
has comment: http://stackoverflow.com/comment/33377148
has answer: http://stackoverflow.com/a/22019138
answer count: 3
possible better answer: http://stackoverflow.com/a/22019014
has body: Why do I get an error when attempting to initialize a Double to an int, even though it does not throw an exception when using the primitive type, double? Double a = 1; // error - incompatible types Double b = 1.0; // OK double c = 1; // OK Why is the behavior different between the class Double and the primitive type, double?
has title: Why can't I set a Double object equal to an int? - Java
favorite count: 0
upvote count: 5
has comment: http://stackoverflow.com/comment/33377180
has comment: http://stackoverflow.com/comment/33376773
accepted answer: http://stackoverflow.com/a/22018990
type: AnsweredQuestion

communication
tag name: communication
tags question: http://stackoverflow.com/q/22019069
type: Tag
tags question: http://stackoverflow.com/q/22087101

http://stackoverflow.com/comment/33460318
comment on: http://stackoverflow.com/q/22018124
has text: Sorry for the late response. I tried debugging it and it game me a fatal error? I will revisit the problem when I have some time and get back to you with a better explanation. Thanks
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22121582
answer count: 2
has comment: http://stackoverflow.com/comment/33561208
has comment: http://stackoverflow.com/comment/33561145
has comment: http://stackoverflow.com/comment/33561239
has title: Java how to use global variables in switch statement
score: 0
tagged with: java
has body: I have three integer global variables: public static int a = 1; public static int b = 2; public static int c = 3; I want to do: int code = dis.readInt(); switch(code) { case a: ...... break; case b: ...... break; case c: ...... break; } But it is not working, can anyone help? Thanks!
has answer: http://stackoverflow.com/a/22141690
tagged with: switch-statement
linked to: http://stackoverflow.com/q/14308129
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33561439
has answer: http://stackoverflow.com/a/22122362
has comment: http://stackoverflow.com/comment/33561167
has comment: http://stackoverflow.com/comment/33561193
has comment: http://stackoverflow.com/comment/33561216
type: Question

http://stackoverflow.com/comment/33632447
has text: You need to show a reasonable attempt, not just "here - solve this please."
comment on: http://stackoverflow.com/q/22161372
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/q/22058738
has body: I have a jLabel with an Icon that I want to print in a printer (canon,hp,epson anything) using a button. How can I do that? Any useful code? Code snippet? links? All I can see is like this: How to print content of a label in java? But It's not what I want. I'm using netbeans Thanks in advance.
tagged with: netbeans
has answer: http://stackoverflow.com/a/22059079
tagged with: jlabel
type: UnansweredQuestion
downvote count: 2
has title: Print jLabel's icon in a printer using a button
upvote count: 1
linked to: http://stackoverflow.com/q/4942480
tagged with: jbutton
type: Question
tagged with: java
score: -1
tagged with: printing
answer count: 1
has comment: http://stackoverflow.com/comment/33448633
favorite count: 0
has comment: http://stackoverflow.com/comment/33448582
linked to: http://stackoverflow.com/q/12764634
has comment: http://stackoverflow.com/comment/33448449

http://stackoverflow.com/q/22060705
has title: Lowering Time Complexity of Producing Rank Array
linked to: http://stackoverflow.com/q/4859261
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22061138
tagged with: java
type: Question
tagged with: algorithm
tagged with: sorting
tagged with: rank
accepted answer: http://stackoverflow.com/a/22061138
score: 0
has comment: http://stackoverflow.com/comment/33451675
answer count: 1
has body: public Ranking(String[] names, float[] scores) { nameTest = new Cities[names.length]; rankTest = new Cities[names.length]; city = new Cities[names.length]; scoreRanks = new Float[scores.length]; for (int i = 0; i &lt; scores.length - 1; i++) { if (scores[i] == scores[i + 1]) throw new IllegalArgumentException(); } if (names == null || scores == null) throw new NullPointerException(); if (names.length != scores.length) throw new IllegalArgumentException(); for (int p = 0; p &lt; scoreRanks.length; p++) { scoreRanks[p] = scores[p]; } int[] ranking = new int[names.length]; for (int k = 0; k &lt; ranking.length; k++) { ranking[this.smallestIndex()] = k + 1; } for (int i = 0; i &lt; ranking.length; i++) { city[i] = new Cities(names[i], ranking[i]); nameTest[i] = new Cities(names[i], ranking[i]); rankTest[i] = new Cities(names[i], ranking[i]); } Arrays.sort(nameTest, Cities.BY_NAME); Arrays.sort(rankTest, Cities.BY_RANK); for (int i = 0; i &lt; names.length - 1; i++) { if (nameTest[i].getName().equals(nameTest[i + 1].getName()) || nameTest[i].getName() == null || rankTest[i].getRank() == rankTest[i + 1].getRank()) throw new IllegalArgumentException(); } } public int smallestIndex() { float smallest = 0.0f; int i; for (i = 0; i &lt; scoreRanks.length; i++) { if (scoreRanks[i] &gt; 0.0f) { smallest = scoreRanks[i]; break; } else continue; } int j = 1; while (j &lt; scoreRanks.length) { if (scoreRanks[j] &lt; smallest &amp;&amp; scoreRanks[j] != 0.0f) { smallest = scoreRanks[j]; i = j; } j++; } scoreRanks[i] = 0.0f; return i; } This is my ranking constructor. Currently, the call to smallestIndex() inside the for loop bumps it up to O(n^2) time, but I need it to run in no more than O(n log n) time. What this does is takes an array of Scores and names. Then the spot with the LOWEST score will be rank 1, next lowest is rank 2 so on and so forth. Then I can create Cities objects where names[i] corresponds with ranking[i]. Hope that makes sense. Buy yeah I don't get what I can do…

http://stackoverflow.com/comment/33759457
has text: Yes! Exactly! If the OS has a limit of 1000 native threads, then native threads are a scarce resource. Every time the main thread in the example creates a new suicide thread, it consumes one unit of that resource. Every time one a suicide thread achieves its mission, it releases one unit of the resource. The OOM is thrown if the resource is exhausted, but giving priority to the suicide threads prevents that from happening. The same general principle applies whether we are talking about native threads, file handles, ports, memory, disk space, or whatever.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22072161
type: Comment

http://stackoverflow.com/q/22119889
tagged with: java
tagged with: swing
has body: I am an undergrad student working on creating a Java weather app (Executable JAR) with NetBeans IDE 7.4 and Swing GUI.So far I have managed to create this much. I have a very limited knowledge of Java as of now. I am having problems with loading images after the first time (that is problem loading the 2nd and further subsequent images onto another jFrame that is opened after clicking a jButton in jFrame 1) onto the GUI Panel. I have tried several methods including getResource() , ImageIcon and also tried Java 2-D documentation examples. I had a partially success with ImageIcon, but after I have loaded one image I cannot load any others. The subsequent image(s) displayed is the same as before with no change and when I diagnosed with getImageLoadStatus() it returns a value of '8' which might indicate some connection problems. I need to load the images from a URL . Specifically I'm using Yahoo weather RSS feeds to implement everything in my program, including the images. What is utterly baffling to me is that the same code works differently (in this case it doesn't work) when used in the same context. Please check below two snippets of code for further clarification P.S. I don't know JSON/ XML parsing to get data , so what I've used is a very naive URL to string method. Working Code in 1st jFrame > // TO GET CODE num = weather.indexOf("code"); num1 = weather.indexOf(" ", num); String cod = weather.substring(num + 6, num1 - 1); String imgurl = "http://l.yimg.com/a/i/us/we/52/" + cod; String imgurl1 = imgurl + ".gif"; System.out.println(imgurl1); // TO DISPLAY IMAGE try{ BufferedImage img = ImageIO.read(new URL(imgurl1)); jLabel19.setIcon(new ImageIcon(img)); } catch(Exception e){ } -- Non - Working Code in 2nd jFrame that opens up on clicking a button in jFrame 1 ( // TO GET CODE num = weather_1.indexOf("day"); num1 = weather_1.indexOf("code", num); num2 = weather_1.indexOf("/", num1); String cod = weather_1.substring(num1 + 6, num2 - 2); String imgurl = "http://l.yimg.…
type: Question
has comment: http://stackoverflow.com/comment/33560296
has comment: http://stackoverflow.com/comment/33558274
has comment: http://stackoverflow.com/comment/33584265
has comment: http://stackoverflow.com/comment/33563587
has title: Dynamic image content in Java NetBeans Swing GUI
has comment: http://stackoverflow.com/comment/33558611
score: 0
has comment: http://stackoverflow.com/comment/33559064
has comment: http://stackoverflow.com/comment/33559144
tagged with: user-interface
answer count: 1
has comment: http://stackoverflow.com/comment/33558277
has comment: http://stackoverflow.com/comment/33559204
has comment: http://stackoverflow.com/comment/33558570
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22123417
tagged with: yahoo-weather-api
has comment: http://stackoverflow.com/comment/33569700
tagged with: netbeans

http://stackoverflow.com/a/22143863
has comment: http://stackoverflow.com/comment/33601920
has body: ArrayAdapter has the remove(T object) method that you should call to clean the dataset you provide to the superclass: inside onClick you should call remove(list.get(position));
type: Answer
has comment: http://stackoverflow.com/comment/33600619
has comment: http://stackoverflow.com/comment/33600671
upvote count: 1
score: 1
accepted answer of: http://stackoverflow.com/q/22143712
answers question: http://stackoverflow.com/q/22143712
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/33458677
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22064841
has text: And if the encoding is wrong it would return an UnsupportedEncodingException as you can read in the Documentation and not an NullPointerException
score: 0

http://stackoverflow.com/comment/33388974
comment on: http://stackoverflow.com/q/22025285
type: QuestionComment
has text: check your connection url "jdbc:mysql://localhost/bms", BTW usual format is jdbc:mysql://localhost:urportno/urdb
score: 0
type: Comment

http://stackoverflow.com/q/22045720
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/22053312
upvote count: 8
possible better answer: http://stackoverflow.com/a/48907676
has answer: http://stackoverflow.com/a/48907676
favorite count: 0
score: 8
accepted answer: http://stackoverflow.com/a/22053312
type: AnsweredQuestion
has title: Twitter4j: how to get twit url from status?
tagged with: java
tagged with: twitter
has body: I am using twitter4j-3.0.5 on Windows. When new status arrives to the StatusListener.onStatus() method, I would like to print out it's URL but I don't find any appropriate method. status.getURLEntities() is always empty, even tough if I look at the json passed to the client, the url field is not empty and contains valid URL. I just don't know how to get this value from java. Please advise.
type: Question

http://stackoverflow.com/q/22097586
answer count: 2
has title: Java Connect to Online Database
linked to: http://stackoverflow.com/q/1457716
has comment: http://stackoverflow.com/comment/33517515
has comment: http://stackoverflow.com/comment/33517388
has answer: http://stackoverflow.com/a/22097792
has body: I was wondering if anyone can help me I am trying to connect to an online database. The database is placed on http://labs.cms.gre.ac.uk/db/mysqlnew.php but i can't seem to connect, heres what I have so far, can anyone help? Plus do i need import anything? I have import.hava.sql.*; but that is it? try { System.out.println("Attempting Database Connection"); Class.forName("com.mysql.jdbc.Driver"); String url = "jdbc:mysql://http://labs.cms.gre.ac.uk/database"; connection = DriverManager.getConnection(url, "user", "pass"); stmt = connection.createStatement(); System.out.println("Connection made"); } catch (Exception e) { System.out.println("Database connection attempt failed"); System.out.println(e); } }
tagged with: database-connection
type: UnansweredQuestion
type: Question
tagged with: java
tagged with: database
tagged with: mysql
has answer: http://stackoverflow.com/a/22097743
score: 0

http://stackoverflow.com/comment/33459767
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22065279
has text: @Vimzy Typically, `x` would be the power and `n` would be the number of terms to estimate `e^x` to.

http://stackoverflow.com/q/22009282
has comment: http://stackoverflow.com/comment/33359725
score: -8
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22009909
accepted answer: http://stackoverflow.com/a/22009909
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33359598
answer count: 2
has answer: http://stackoverflow.com/a/22009791
has body: The program that I am developing needs to determine if a given date is older than a week. I have come up with the following code: ((new Date()).getTime() - date.getTime() &gt; 7 * 24 * 60 * 60 * 1000) Tell me if the code is correct. Help me write correct code if it's incorrect. Also, if you have better ways to code, let me know.
has comment: http://stackoverflow.com/comment/33359645
has comment: http://stackoverflow.com/comment/33360097
upvote count: 1
favorite count: 0
has title: Is a given date older than a week?
downvote count: 9
possible better answer: http://stackoverflow.com/a/22009791

http://stackoverflow.com/a/22053110
answers question: http://stackoverflow.com/q/22052394
has body: I'm not sure I understood your question. If you're asking if this if (i == hi) break; and this: if (j == lo) break; can be removed, then I answer no. These checks are important, in particular when the array is already sorted. If you removed these checks, in case of a sorted array, less(a[++i], v) would never be false, and would throw an ArrayIndexOutOfBoundsException when trying to evaluate a[hi+1]. As for the second while loop, you need it as well as the first. The first while looks for the lowest index i where a[i]&gt;a[lo], and the second looks for the highest j where a[j]&lt;a[lo]. These two indices are used for the swap.
type: Answer
score: 0

http://stackoverflow.com/comment/33549767
comment on: http://stackoverflow.com/q/22114903
has text: findNext(TreeNode node) should return the successor node. This works fine until node = root where root is the top node in the tree (has no parent)
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33370452
comment on: http://stackoverflow.com/q/22015237
score: 0
type: Comment
has text: yes i have but it mainly covers the communication, which i already established. My 2nd question kind of includes the communication, like: can i install the .cap-file with the IsoDep.transceive funtion?
type: QuestionComment

http://stackoverflow.com/comment/33395027
has text: What "game" are you talking about? Is this an application you are writing or someone else's code?
type: Comment
comment on: http://stackoverflow.com/q/22028538
type: QuestionComment
score: 1

http://stackoverflow.com/comment/33636558
comment on: http://stackoverflow.com/a/22163680
score: 0
type: AnswerComment
has text: alias does exist. The query is generating the HQL fine it's just that the createAlias query is being added outside the parent query with an and and I need an or. Basically they searchKeyword can be on Customer.name, Customer.state or Customer.Client.name. Right now the SQL produced is Customer.name or Customer.state and Customer.client.name but I need an or on Customer.client.name
type: Comment

http://stackoverflow.com/comment/33454751
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22062226
has text: try notifying like what bro? i'am not understand. can you teach me? thank you @ASP
score: 0

tcp
type: Tag
tags question: http://stackoverflow.com/q/22089456
tags question: http://stackoverflow.com/q/22080443
tags question: http://stackoverflow.com/q/22058092
tags question: http://stackoverflow.com/q/22131915
tags question: http://stackoverflow.com/q/22018305
tags question: http://stackoverflow.com/q/22107380
tags question: http://stackoverflow.com/q/22140023
tags question: http://stackoverflow.com/q/22090558
tag name: tcp

http://stackoverflow.com/comment/33479125
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/22076103
has text: I was wondering to find out how can I optimize the code, I mean optimization.

http://stackoverflow.com/comment/33373769
score: 0
type: Comment
has text: what's wrong is that I can not display error messages in jsp page
comment on: http://stackoverflow.com/a/22017105
type: AnswerComment

http://stackoverflow.com/comment/33642163
type: QuestionComment
comment on: http://stackoverflow.com/q/22167004
type: Comment
score: 1
has text: Instread of Thread use [CountDownTimer](http://developer.android.com/reference/android/os/CountDownTimer.html) class.

http://stackoverflow.com/a/22076475
downvote count: 0
answers question: http://stackoverflow.com/q/22075543
has body: You can reconfigure java.utils.logging by adding /WEB-INF/classes/logging.properties to your war archive: org.apache.catalina.core.ContainerBase.[Catalina].level = INFO org.apache.catalina.core.ContainerBase.[Catalina].handlers = java.util.logging.ConsoleHandler The actual error message should then be visible. Also, check your application logs, if an additional logging framework is already configured (eg. log4j).
accepted answer of: http://stackoverflow.com/q/22075543
score: 20
has comment: http://stackoverflow.com/comment/33489323
type: AcceptedAnswer
type: Answer
upvote count: 20

http://stackoverflow.com/a/22011994
answers question: http://stackoverflow.com/q/22010955
type: Answer
has body: Something like this should work. You still need to do all the manipulation of the phone number yourself, but all the data will be in the call info so you should be able to work from that! while (fileScan.hasNext()) { //Get a single record Phonefile = fileScan.nextLine(); //Seperate the elements of the record String[] callInfo = Phonefile.split("#"); for(String infoPart: callInfo) { System.out.print(infoPart+ "\t"); } System.out.println() }
score: 0

http://stackoverflow.com/q/22109553
has title: array traversal algorithm to load the array with Rationals
tagged with: object
type: AnsweredQuestion
has body: I have a java class already made up of methods and am in the process of creating a driver java class and just need some help figuring out how to load my traversal array with rationals. I have the following but I need help figuring out how to load it with the rationals. public static void main(String [] args) { //Creates the array Rational[] rats = new Rational[6]; for(int i=0; i &lt; rats.length; i++) { rats[i] = new Rational(2,18); //this will call constructor. //{4/5, 4/19, 3/8, 9/3, 2/4, 24/7 }; I want to load these into the array instead of // just 2,8 (2/8) (numerator, denominator) } I have two constructors, an EVC and DVC named public Rational() and public Rational(int num,int den) thanks.
tagged with: java
tagged with: traversal
type: Question
has answer: http://stackoverflow.com/a/22109571
accepted answer: http://stackoverflow.com/a/22109571
tagged with: arrays
answer count: 1
score: 0

http://stackoverflow.com/a/22084966
has body: This is no way to copy streams. It assumes too many things that may not be true. The canonical way in Java is as follows: byte[] buffer = new byte[8192]; // or whatever you like, anything above zero. Note that it doesn't have to be the size of the file int count; while ((count = in.read(buffer)) &gt; 0) { out.write(buffer, 0, count); } If you know the length in advance and you want to keep the socket open afterwards, keep track of the bytes transferred so far via 'total += count;' after the read call inside the loop, and change the read call to read(buffer, 0, length-total &gt; buffer.length ? buffer.length : (int)(length-total)).
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33497622
has comment: http://stackoverflow.com/comment/33497576
type: Answer
has comment: http://stackoverflow.com/comment/33497093
has comment: http://stackoverflow.com/comment/33497181
accepted answer of: http://stackoverflow.com/q/22065050
has comment: http://stackoverflow.com/comment/33497522
answers question: http://stackoverflow.com/q/22065050
has comment: http://stackoverflow.com/comment/33497601

http://stackoverflow.com/q/22087256
has comment: http://stackoverflow.com/comment/33499408
has comment: http://stackoverflow.com/comment/33499910
favorite count: 0
has answer: http://stackoverflow.com/a/22087362
has comment: http://stackoverflow.com/comment/33499531
type: UnansweredQuestion
has body: /* trying to connect mysql but got an error error: class, interface, or enum expected*/ public class mysqlconnect{ try { // loads com.mysql.jdbc.Driver into memory Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException cnf) { System.out.println("Driver could not be loaded: " + cnf); } }
has answer: http://stackoverflow.com/a/22087310
tagged with: mysql
has title: error: class, interface, or enum expected
downvote count: 1
type: Question
tagged with: java
score: -1
has comment: http://stackoverflow.com/comment/33499355
answer count: 2
upvote count: 0

http://stackoverflow.com/comment/33738109
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22219536
has text: Thanks for Your answer I will check it ASAP and reply how it works

http://stackoverflow.com/comment/36796558
has text: @Joy thanks for answering.. now I'm preloading a bks keystore on raw folder. but I'm not completely happy with it since we will have problems with certificates rotation. Hope to find a better solution.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22083547
score: 0

http://stackoverflow.com/a/22266384
score: 0
type: Answer
answers question: http://stackoverflow.com/q/22020716
accepted answer of: http://stackoverflow.com/q/22020716
has body: Due to some exception errors from other correct answers, I decided to look bit further and found following wonderful class, works flawlessly! http://tips4java.wordpress.com/2008/11/08/message-console/
type: AcceptedAnswer

http://stackoverflow.com/a/22160483
has body: If you haven't already done so, I recommend you enable strict mode and look for activity on the main thread that way.
has comment: http://stackoverflow.com/comment/33631615
type: Answer
answers question: http://stackoverflow.com/q/22160451
score: 0
accepted answer of: http://stackoverflow.com/q/22160451
type: AcceptedAnswer

http://stackoverflow.com/comment/33401949
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22032765
type: Comment
has text: Which version of JDK are you using? it seems that your JRE might be 1.7 but your JDK might be <1.5

http://stackoverflow.com/comment/115300391
has text: Is there a straightforward way to access the disk sector size? Or native is necessary?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/26819750
type: Comment

http://stackoverflow.com/comment/33353743
comment on: http://stackoverflow.com/a/22005495
has text: dude even if i do String str2=scanner.next(); same thing..returning false
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/22161301
tagged with: neo4j
favorite count: 0
has answer: http://stackoverflow.com/a/22161539
type: AnsweredQuestion
tagged with: java
type: Question
upvote count: 4
tagged with: graph
accepted answer: http://stackoverflow.com/a/22161539
answer count: 2
downvote count: 0
score: 4
possible better answer: http://stackoverflow.com/a/22174215
has title: Weighted graph in Neo4j
has body: I have a Neo4j instance running. I have relationships which are weighted. One such example is representing all places in the world, and having a distance between each place. Now it seems easy to create a relationship between two nodes, A and B: Relationship relationship = A.createRelationshipTo(B, Relations.Knows ); But what about actual strength of the relationship. Theres been a suggestion on here as : create a-[:`KNOWS_0.34`]-&gt;b This works, but isn't a particularly great solution, particularly if you wanted to calculate a shortest distance dependent on the weights. Is there anyway of doing this and storing the relationship int or float?
has answer: http://stackoverflow.com/a/22174215

http://stackoverflow.com/a/22076505
score: 0
answers question: http://stackoverflow.com/q/22076358
type: Answer
has body: Based on http://regex101.com/ and https://www.debuggex.com/ ^800[25-9][2-9].*$ ^ assert position at start of the string 800 matches the characters 800 literally [25-9] match a single character present in the list below 2 the literal character 2 5-9 a single character in the range between 5 and 9 [2-9] match a single character present in the list below 2-9 a single character in the range between 2 and 9 .* matches any character (except newline) * Quantifier: Between zero and unlimited times, as many times as possible, giving back as needed [greedy] $ assert position at end of the string In other words [...] is character class. It means it matches one of characters placed inside it like [123] means it matches either 1 2 3. You can also write this range as [1-3]. In case of [25-9] it means it will match 2 or one of digits in rage 5-9 which are 5, 6, 7, 8, 9.

http://stackoverflow.com/a/22030846
upvote count: 2
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33399330
type: Answer
score: 2
has body: My guess, you don't call the incrementor() method before you request the vowel or consonant count. As an aside -- your isVowel only works for lower case vowels. You'd best generalize it. you really should show us how you test the code to get a better answer.
has comment: http://stackoverflow.com/comment/33399215
answers question: http://stackoverflow.com/q/22030825
accepted answer of: http://stackoverflow.com/q/22030825

http://stackoverflow.com/a/22086257
score: 0
has comment: http://stackoverflow.com/comment/33501712
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22085596
answers question: http://stackoverflow.com/q/22085596
type: Answer
has body: Missing converter name converter="#{countryDualListConverter}"? Change to converter="#{bizEntityDualListConverter}". You can also use Ominifaces's ListIndexConverter. It is a nice JSF Utility.

http://stackoverflow.com/a/22096577
score: 5
upvote count: 5
downvote count: 0
answers question: http://stackoverflow.com/q/22095838
type: Answer
has body: one of possible issues is very simple code snipped private void initializeProductMenuButtons() { pnlButtons.removeAll(); pnlButtons.add(btnSearchProduct); pnlButtons.add(btnViewIndividual); pnlButtons.add(btnAlternative); pnlButtons.add(btnDisplayInfo); pnlButtons.add(btnCancel); } should be private void initializeProductMenuButtons() { pnlButtons.removeAll(); pnlButtons.add(btnSearchProduct); pnlButtons.add(btnViewIndividual); pnlButtons.add(btnAlternative); pnlButtons.add(btnDisplayInfo); pnlButtons.add(btnCancel); pnlButtons.revalidate(); pnlButtons.repaint(); } Swings APIs haven't any notifier that content of container is changed e.g. JComponents are removed, removed and added, some kinds of relayout (change ordering of, e.i.) revalidate(); and repaint(); will notify used LayoutManager, use that as last code lines, after all changes to Swing GUI are done nothing cleaver without your SSCCE, MCVE/MCTRE Edit 1st. have look at use CardLayout for switching between views
has comment: http://stackoverflow.com/comment/33516482

http://stackoverflow.com/comment/33467474
comment on: http://stackoverflow.com/q/22069923
type: Comment
type: QuestionComment
has text: Vector is sort of semi-deprecated. It's slower, older, so it only sort of fits into the List paradigm, and the synchronization it provides is often not enough to be useful in a multi-threaded environment.
score: 2

http://stackoverflow.com/q/22137854
has comment: http://stackoverflow.com/comment/33590376
tagged with: java
answer count: 2
upvote count: 1
has answer: http://stackoverflow.com/a/29985139
type: UnansweredQuestion
tagged with: nio
has body: I'm using Watcher in JDK7 which relies on inotify events. If the file is on a NFS, I want my program to fallback and use polling instead. Is there a way to detect if a file is on a remote drive (other than using Runtime.exec and parsing the mount table)? I'm only concerned with Linux compatibility for now. I suppose one option is to use both inotify and polling when the program starts, but then disable the polling thread if an inotify event for my file is created.
tagged with: inotify
tagged with: nfs
has comment: http://stackoverflow.com/comment/33591802
downvote count: 0
score: 1
favorite count: 0
has title: Detecting remote files in Java
type: Question
has answer: http://stackoverflow.com/a/22138494

http://stackoverflow.com/comment/33521714
type: QuestionComment
has text: Hi, get the file as stream using context object. check the similar issue here http://stackoverflow.com/questions/2308188/getresourceasstream-vs-fileinputstream
comment on: http://stackoverflow.com/q/22099648
score: 0
type: Comment

http://stackoverflow.com/a/22078614
has body: They aren't the same because you are base-64 encoding the results of the decryption, rather than decoding it as text. Do this instead: byte[] decData = decryptData(cipher, privKey, encData); System.out.println("\n\nDecrypted data=" + new String(decData)); It is poor practice to use the platform default character encoding. Instead, you should convert text to bytes with with specific encoding, and use the same coding when decoding the bytes. byte[] plaintext = "#data1\n#data2\n#data3\n").getBytes(StandardCharsets.UTF_8); ... String recovered = new String(decData, StandardCharsets.UTF_8);
score: 0
type: Answer
answers question: http://stackoverflow.com/q/22078113

http://stackoverflow.com/a/22167483
has body: The only function i'm still using is the IndexOf function, but that is not that hard to create for yourself. static void Main(string[] args) { string sentence = "are you cracy"; int length = Program.StringLength(sentence); int currentpos = 0; List&lt;string&gt; wordList = new List&lt;string&gt;(); int wordCount = 0; while (currentpos &lt; length) { // find the next space int spacepos = sentence.IndexOf(' ', currentpos); string word; if (spacepos &lt; 0) { // end of string reached. word = sentence.Substring(currentpos, length - currentpos); wordList.Add(word); wordCount++; // no need to continue. break; } word = sentence.Substring(currentpos, spacepos - currentpos); wordList.Add(word); wordCount++; currentpos = spacepos + 1; } // display for (int i = wordList.Count - 1; i &gt;= 0; i--) { // after first word is display, add spaces to the output if (i &lt; wordList.Count - 1) { Console.WriteLine(" "); } // display word Console.WriteLine(wordList[i]); } } public static int StringLength(String sentence) { int numberOfChars = 0; while (!sentence.Equals("")) { sentence = sentence.Substring(1); ++numberOfChars; } return numberOfChars; }
has comment: http://stackoverflow.com/comment/33643102
downvote count: 1
has comment: http://stackoverflow.com/comment/33643187
has comment: http://stackoverflow.com/comment/33643260
type: Answer
has comment: http://stackoverflow.com/comment/33643361
answers question: http://stackoverflow.com/q/22167068
upvote count: 0
score: -1

http://stackoverflow.com/a/27651734
score: 0
type: Answer
answers question: http://stackoverflow.com/q/22088826
has body: You need to make sure FrameGrabber is valid. The error message is a clue that setting it up might have failed. The error message informs you did something like: FrameGrabber grabber = new OpenCVFrameGrabber(0); but device 0 is not your camera. In the beginning of the method you should add a safety check: private IplImage picGrab(FrameGrabber grabber, int ID) { if (grabber == null) { System.out.println("!!! Bad OpenCVFrameGrabber"); return null; } // ...

http://stackoverflow.com/q/22029359
upvote count: 5
tagged with: java
type: Question
has title: Can't compile .xslt into java class file
has comment: http://stackoverflow.com/comment/33397665
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/33425047
favorite count: 0
has comment: http://stackoverflow.com/comment/33396900
score: 5
has answer: http://stackoverflow.com/a/22036179
has comment: http://stackoverflow.com/comment/33400645
tagged with: http://stackoverflow.com/tag/xml
has body: I have been trying to compile xslt file into java class and keep getting this errors. Not sure what I am doing wrong here: java com.sun.org.apache.xalan.internal.xsltc.cmdline.Compile test.xslt java.lang.NullPointerException at com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.parse(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(Unknown Source) at com.sun.org.apache.xalan.internal.xsltc.cmdline.Compile.main(Unknown Source) Compiler errors: Could not compile stylesheet my test.xslt file: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/hello-world"> <TITLE> <xsl:value-of select="greeting"/> <xsl:apply-templates select="greeter"/> </xsl:template> <xsl:template match="greeter"> from <xsl:value-of select="."/> </xsl:template> </xsl:stylesheet>
has comment: http://stackoverflow.com/comment/33397392
has comment: http://stackoverflow.com/comment/33396456
accepted answer: http://stackoverflow.com/a/22036179
tagged with: xslt
type: AnsweredQuestion

http://stackoverflow.com/comment/33461746
comment on: http://stackoverflow.com/q/22066797
score: 0
has text: @ArtooDetoo, it is possible, but not in the direction is going through
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33555433
type: QuestionComment
has text: Can you paste the code,make sure java is case sensitive.Class name must match during compiling and running it
score: 0
comment on: http://stackoverflow.com/q/22118126
type: Comment

http://stackoverflow.com/q/22079272
possible better answer: http://stackoverflow.com/a/22079461
tagged with: long-integer
has answer: http://stackoverflow.com/a/22079413
has comment: http://stackoverflow.com/comment/33485169
answer count: 2
has body: I have a list like following: List&lt;SelectItem&gt; measurementList; I want to assign measurementList.get(i) into a Long variable. For example I want to assign it in the following way: Long sd = measurementList.get(0); But, it is showing type mismatch. That is really obvious. How can I assign the value from measurementList.get(0) to a Long variable. Thanks Code are given below: public List&lt;SelectItem&gt; measurementList(Long coModAssetId) { // log.info("Start"); // log.debug("finding MeasurementSeneorTypeList instance by example using dbMeasurementSeneorTypeList"); List&lt;SelectItem&gt; results; try { // Add SELECT with a nested select to get the 1st row String queryString = "SELECT M.Measurement_Id, M.NAME" + " FROM ems.COMPANY_MODULE_ASSET CMA, " + " ems.Asset_Measurement Am," + " ems.MEASUREMENT M" + " WHERE CMA.Co_Mod_Asset_Id = ?" + " And Cma.Asset_Id = Am.Asset_Id " + " AND AM.MEASUREMENT_ID = M.MEASUREMENT_ID" + " GROUP BY M.measurement_id, M.NAME" + " ORDER BY M.name"; MeasurementSeneorTypeListWork work = new MeasurementSeneorTypeListWork(); work.coModAssetId = coModAssetId; work.queryString = queryString; getSession().doWork(work); results = work.results; } catch (RuntimeException re) { // log.error("getMostRecentObservationId() failed", re); throw re; } //log.info("End"); return results; } Class definition public class MeasurementSeneorTypeListWork implements Work { List&lt;SelectItem&gt; results = new ArrayList&lt;SelectItem&gt;(); private String queryString; private Long coModAssetId; @Override public void execute(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement(queryString); int index = 1; ps.setLong(index++, coModAssetId); ResultSet rs = ps.executeQuery(); while(rs.next()) { //String userName = PropertyReader.getLabel(rs.getString(2)); Long id = rs.getLong(1); SelectItem item = new SelectItem(id, null); results.add(item); } rs.close(); ps.close(); } } }
has comment: http://stackoverflow.com/comment/33485100
favorite count: 0
has answer: http://stackoverflow.com/a/22079461
has comment: http://stackoverflow.com/comment/33485333
has title: Is it possible to Convert ArrayList < SelectItem> to ArrayList<Long> in java
has comment: http://stackoverflow.com/comment/33485362
type: AnsweredQuestion
upvote count: 2
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/22079413
has comment: http://stackoverflow.com/comment/33485103
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/33485071

interface
tags question: http://stackoverflow.com/q/22008581
tags question: http://stackoverflow.com/q/22077950
tag name: interface
tags question: http://stackoverflow.com/q/22096052
tags question: http://stackoverflow.com/q/22138475
tags question: http://stackoverflow.com/q/22156913
tags question: http://stackoverflow.com/q/22039675
tags question: http://stackoverflow.com/q/22116028
tags question: http://stackoverflow.com/q/22069400
tags question: http://stackoverflow.com/q/22157957
tags question: http://stackoverflow.com/q/22037263
type: Tag
tags question: http://stackoverflow.com/q/22163898
tags question: http://stackoverflow.com/q/22120334
tags question: http://stackoverflow.com/q/22085129
tags question: http://stackoverflow.com/q/22126196
tags question: http://stackoverflow.com/q/22055840
tags question: http://stackoverflow.com/q/22091880
tags question: http://stackoverflow.com/q/22091015
tags question: http://stackoverflow.com/q/22143652

http://stackoverflow.com/comment/33983403
type: AnswerComment
comment on: http://stackoverflow.com/a/22178150
score: 0
type: Comment
has text: Hi cneller, I've added my implementation of get() handler - could you check it and write what you think!!!

http://stackoverflow.com/a/22025107
answers question: http://stackoverflow.com/q/22024971
has comment: http://stackoverflow.com/comment/33388688
score: 0
type: Answer
has body: Here is how you change your view and Prespective , In your case you Will want to choose "JAVA" And "! Console"

http://stackoverflow.com/a/22025513
upvote count: 1
has body: After you've created your server runtime, right-click the project -> Properties -> Project Facets -> Select your server runtime from the Runtime tab.
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/22025380
type: Answer
accepted answer of: http://stackoverflow.com/q/22025380
score: 1

http://stackoverflow.com/q/22086616
has title: Rounding double to two decimal places using DecimalFormat
has body: Trying to round a number, 110.99 with a percentage taken off, say 10 to this: 99.90 Currently I am using, public static String GetDiscountedPrice(double OriginalPrice, int PercentDiscount) { DecimalFormat df = new DecimalFormat("##.##"); double roundedNumber = (OriginalPrice * (PercentDiscount / 100.0)); roundedNumber = (OriginalPrice - roundedNumber); //roundedNumber = Math.round(((roundedNumber * 100.0) / 100.0)); roundedNumber = Double.valueOf(df.format(roundedNumber)); String discountedPrice = String.valueOf(roundedNumber); return discountedPrice; } My issue is that I keep getting the value of 99.89. When I change DecimalFormat to ("##.#") it outputs 99.9. Well, I need 99.90! How do I go about doing this without hard coding a '0' at the end? Appreciate it.
favorite count: 0
type: UnansweredQuestion
tagged with: double
tagged with: decimalformat
answer count: 0
downvote count: 0
score: 1
tagged with: java
type: Question
tagged with: format
upvote count: 1

http://stackoverflow.com/comment/33509557
type: Comment
score: 1
has text: You can access each button as `JButton button = lists.get(i)`.
comment on: http://stackoverflow.com/a/22093193
type: AnswerComment

http://stackoverflow.com/q/22063390
has comment: http://stackoverflow.com/comment/33456062
has answer: http://stackoverflow.com/a/22065242
has comment: http://stackoverflow.com/comment/33457013
score: 1
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33455933
answer count: 2
has comment: http://stackoverflow.com/comment/90712605
has body: I am using Linux Ubuntu 13.10 I am trying to run a script and get the following error: /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar: Success Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object I have: javac -version javac 1.7.0_51 java -version java version "1.7.0_51" OpenJDK Runtime Environment (IcedTea 2.4.4) (7u51-2.4.4-0ubuntu0.13.10.1) OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode) When I run: echo $CLASSPATH: I get blank output echo $JAVA_HOME: blank output Please help me, how to resolve this.
linked to: http://stackoverflow.com/q/11808829
has comment: http://stackoverflow.com/comment/33455887
has comment: http://stackoverflow.com/comment/33456192
upvote count: 1
has comment: http://stackoverflow.com/comment/90712638
favorite count: 0
has answer: http://stackoverflow.com/a/22063497
has title: Error: java/lang/NoClassDefFoundError: java/lang/Object
downvote count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33456506

http://stackoverflow.com/q/22134219
answer count: 3
tagged with: getter-setter
tagged with: android
score: -2
has title: Android: Shared Preferences & Setters and Getters
downvote count: 3
tagged with: sharedpreferences
upvote count: 1
has comment: http://stackoverflow.com/comment/33630504
has answer: http://stackoverflow.com/a/22139329
has body: I'm using a simple set &amp; get class so that I can retrieve a variable throughout my app but I need to store this class for later use so I want to use shared preferences to store it but I am not sure how to implement this correctly. I tried to implementing the shared preferences within the setter method and there are no errors but this crashes when I run. Here is the class import android.app.Activity; import android.content.SharedPreferences; import android.widget.EditText; public class Passcode extends Activity { private String pin; public static final String PREFS_PASS = "MyPrefsFile"; EditText txtNewPin = (EditText)findViewById(R.id.txt_EnterNewPin); SharedPreferences Pincode = getSharedPreferences(PREFS_PASS,0); SharedPreferences.Editor editor = Pincode.edit(); public String getPin() { Pincode.getString(pin,"0000"); return pin; } public void setPin(String pin) { editor.putString(pin, txtNewPin.getText().toString()); editor.commit(); } }
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22134408
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/33595094
has comment: http://stackoverflow.com/comment/33586092
possible better answer: http://stackoverflow.com/a/22134380
accepted answer: http://stackoverflow.com/a/22139329
has comment: http://stackoverflow.com/comment/33585135
has answer: http://stackoverflow.com/a/22134380
favorite count: 0

http://stackoverflow.com/comment/33558944
type: QuestionComment
has text: theres a lot in the item clicked method, but the part that crashes the app is v = parent.getChildAt(i); where i is the position. how do I use a convertView?
comment on: http://stackoverflow.com/q/22119916
score: 0
type: Comment

http://stackoverflow.com/q/22069195
has title: Google endpoints can't receive utf-8 chars in localhost
type: UnansweredQuestion
tagged with: google-app-engine
has body: I'm having encoding issues with Google Endpoint's requests I send encoded utf-8 chars, but on the server I cannot retrieve them. When you display the strings, you could see those strange symbols The problems arise only in localhost. Never with production Google App Engine servers Is there a misconfiguration issue ? Request Header: Host: localhost:8888 Accept: application/json, text/plain, */* Accept-Language: en-us,es;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate Content-Type: application/json;charset=utf-8
tagged with: google-cloud-endpoints
tagged with: java
linked to: http://stackoverflow.com/q/20271020
type: Question
upvote count: 4
has comment: http://stackoverflow.com/comment/41195700
tagged with: javascript
score: 4
has comment: http://stackoverflow.com/comment/34030818
has answer: http://stackoverflow.com/a/22314080
answer count: 1
downvote count: 0
favorite count: 0
linked to: http://stackoverflow.com/q/17167475

http://stackoverflow.com/a/22136163
has comment: http://stackoverflow.com/comment/33595234
score: 0
answers question: http://stackoverflow.com/q/22133333
type: Answer
has comment: http://stackoverflow.com/comment/33630215
has body: When I tested your code on my Windows machine, I had no problems playing two different sounds in short succession: public static void main(String[] args) throws Exception { CustomSound.preloadSounds(); CustomSound.playSound(0, 0, 0); CustomSound.playSound(1, 0, 0); Thread.sleep(5000); } Note however, that DataLine#start() is an asynchronous call. That could be related to your problem. Also, according to the documentation of DataLine#start(), If invoked on a line that is already running, this method does nothing. If that is your problem, and you want to play the same sound twice simultaneously, one possible solution would be to get another Clip instance that plays the same sound and start that. However I'm no expert at Java's sound API so there might a more efficient way.

http://stackoverflow.com/comment/33455068
score: 0
type: Comment
has text: The biggest one is probably point #3 actually. You were sending your query with literal quotes around it, as if you sent your command line `mysql ... "\"SELECT ...\""`
type: AnswerComment
comment on: http://stackoverflow.com/a/22047067

http://stackoverflow.com/comment/33403064
comment on: http://stackoverflow.com/a/22033416
type: AnswerComment
score: 0
type: Comment
has text: Is server.sh in the current directory?

http://stackoverflow.com/q/22156779
possible better answer: http://stackoverflow.com/a/22157056
has answer: http://stackoverflow.com/a/22157056
answer count: 2
downvote count: 2
has body: I wonder if you can help me to understand why my decrypt method gives strange characters. Specifically, in this case, I get characters similar to �����c~�+�J*zC�iV�-��&amp;�_l��*. Here is my code: import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; import java.math.BigInteger; import java.nio.charset.Charset; import javax.crypto.*; import java.security.*; import java.util.Arrays; import javax.crypto.spec.*; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Hex; public class AESCrypto2 { private Cipher AEScipher; private KeyGenerator AESgen; private SecretKeySpec AESkey; private SecretKeySpec decodeKey; private String hexDecodeKey; private String decodeKey64; private byte[] cipherData; private String msg; private String encMsg; public static void main(String[] args) { try { AESCrypto2 a = new AESCrypto2(); a.encrypt("Hello!"); try { a.decrypt(a.getEncryptedMsg(), a.getDecodeKey()); } catch (DecoderException ex) { ex.printStackTrace(); } } catch (NoSuchAlgorithmException ex) { ex.printStackTrace(); } catch (NoSuchPaddingException ex) { ex.printStackTrace(); } catch (InvalidKeyException ex) { ex.printStackTrace(); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } catch (IllegalBlockSizeException ex) { ex.printStackTrace(); } catch (BadPaddingException ex) { ex.printStackTrace(); } } public AESCrypto2() throws NoSuchAlgorithmException, NoSuchPaddingException, UnsupportedEncodingException { AESgen = KeyGenerator.getInstance("AES"); AESgen.init(128); AESkey = (SecretKeySpec) AESgen.generateKey(); decodeKey = new SecretKeySpec(AESkey.getEncoded(), "AES"); hexDecodeKey = keyToString(decodeKey); AEScipher = Cipher.getInstance("AES/ECB/NoPadding"); } public AESCrypto2(String msg) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, UnsupportedEncodingException, IllegalBlockSizeException, BadPaddingException { this(); e…
has comment: http://stackoverflow.com/comment/33625028
has answer: http://stackoverflow.com/a/22157423
tagged with: java
upvote count: 4
has comment: http://stackoverflow.com/comment/33626039
score: 2
type: AnsweredQuestion
favorite count: 0
accepted answer: http://stackoverflow.com/a/22157423
has comment: http://stackoverflow.com/comment/33624894
type: Question
has title: Strange characters in AES decryption in java
tagged with: cryptography

http://stackoverflow.com/q/22014605
tagged with: guava
downvote count: 0
answer count: 0
has title: Guava's CharMatcher removeFrom
tagged with: java
has comment: http://stackoverflow.com/comment/33437670
type: Question
tagged with: performance
tagged with: algorithm
upvote count: 2
has body: There are two questions here actually. The first one: 1) Is Java smart enough not to copy one array element into itself? What I mean by that is : int i = 1; char [] chars=... //some chars char[1] = char[i]; // first element into itself 2) Are the benchmarking's that guava made available to the public? And what I mean by that is: I was looking into the source code of CharMatcher removeFrom method and saw this : // This unusual loop comes from extensive benchmarking OUT: while (true) { pos++; while (true) { if (pos == chars.length) { break OUT; } if (isLetter(chars[pos])) { break; } chars[pos - spread] = chars[pos]; pos++; } spread++; } return new String(chars, 0, pos - spread); I really liked the idea, but coded my own method: public static String removeMine(String input){ char [] chars = input.toCharArray(); int howManyLetters = 0; for(int i=0;i&lt;chars.length;++i){ if(isLetter(chars[i])) { chars[howManyLetters++] = chars[i]; } else { if(i == (chars.length - 1)) break; chars[i] = chars[i+1]; } } return new String(chars, 0, howManyLetters); } I then added some benchmarks (I will put them on github if needed), here are the results: https://microbenchmarks.appspot.com/runs/61e76bdc-b0d6-4145-8b8b-c1683287f038#r:scenario.benchmarkSpec.parameters.input,scenario.benchmarkSpec.methodName I have (serious?) doubts that creators of guava did not have a version like that and I assume there was a strong reason to drop it (the comment is more then obvious). What I would like to see is either the actual benchmarks that they made or some serious reason to have such a method. I assume it has to do with the type of JVM that you run your code into, but actual proof would be appreciated. P.S. I am still to test this with jmh also, will provide results once I'm done.
tagged with: jvm
favorite count: 0
has comment: http://stackoverflow.com/comment/33461646
type: UnansweredQuestion
score: 2

http://stackoverflow.com/q/22124816
tagged with: arraylist
score: 0
answer count: 2
has comment: http://stackoverflow.com/comment/33567390
has answer: http://stackoverflow.com/a/22124902
has answer: http://stackoverflow.com/a/22124898
tagged with: constructor
type: UnansweredQuestion
tagged with: parameters
has title: ArrayList and Array as parameters for Constructor
tagged with: java
type: Question
has body: I'm doing an assignment for my Computer Science class, but I got stuck in this one part. I am supposed to code the constructor for the given main method and instance variables. The constructor needs to have an ArrayList and an Array as parameters, but I'm not entirely sure how to. The instructions and main method is as follows: Use the comments and the code provided to complete the constructor import java.util.ArrayList; class RectangleStats { //instance variables go here //The constructor for the RectangleStats class takes an ArrayList and an array as parameters for // width and length, respectively. // code for constructor goes here // The RectangleStatsTesterClass assigns the width of two rectangles to an ArrayList and assigns the // length of two rectangles to an array. The calcRectangleArea() and printArea() methods are invoked to // calculate and print the area of the two rectangles. public class RectangleStatsTesterClass { public static void main(String[] args) { ArrayList dblWidth = new ArrayList(); dblWidth.add(5.2); dblWidth.add(9.3); double [ ] dblLength = {11.1, 4.7}; RectangleStats rectStats = new RectangleStats(dblWidth, dblLength); rectStats.calcRectangleArea(); rectStats.printArea(); } } The constructor I currently have is this: public RectangleStats(double w, double l) { width = w; length = l; area = 0; } but im not sure if its right or not.. Help?
has comment: http://stackoverflow.com/comment/33567422
tagged with: arrays

http://stackoverflow.com/a/74422059
answers question: http://stackoverflow.com/q/22043451
has body: My thanks to the @fge answer. Using it with some changes I've get it to support much larger integers with BigInteger, added support of negative integers and changed Arrays.binarySearch() with HashMap. BTW, it should be called base62 encoding because [0-9A-Za-z] contains just 62 chars. public class Base62{ private static final char[] ALPHABET = new char[ 62 ]; private static final Map&lt;Character, Integer&gt; ALPHABET_MAPPING = new HashMap&lt;&gt;(); private static final BigInteger ENCODE_LENGTH = BigInteger.valueOf( ALPHABET.length ); static{ int position = 0; // numbers for( int i = 48; i &lt;= 57; i++ ){ ALPHABET[ position++ ] = (char)i; } // uppercase letters for( int i = 65; i &lt;= 90; i++ ){ ALPHABET[ position++ ] = (char)i; } // lowercase letters for( int i = 97; i &lt;= 122; i++ ){ ALPHABET[ position++ ] = (char)i; } for( int i = 0; i &lt; ALPHABET.length; i++ ){ ALPHABET_MAPPING.put( ALPHABET[ i ], i ); } } public static String encode( final BigInteger in ){ final List&lt;Character&gt; list = new ArrayList&lt;&gt;(); boolean negative = in.signum() == -1; BigInteger use; if( negative ){ use = in.negate(); } else { use = in; } do{ BigInteger[] divisionResultAndReminder = use.divideAndRemainder( ENCODE_LENGTH ); list.add( ALPHABET[ divisionResultAndReminder[ 1 ].intValue() ] ); use = divisionResultAndReminder[ 0 ]; } while( use.equals( BigInteger.ZERO ) == false ); Collections.reverse( list ); char[] res = new char[ list.size() ]; for( int i = 0; i &lt; list.size(); i++ ){ res[ i ] = list.get( i ); } return ( negative ? &quot;-&quot; : &quot;&quot; ) + new String( res ); } public static BigInteger decode( final String encoded ){ BigInteger res = BigInteger.ZERO; char c; boolean negative; String use; if( '-' == encoded.charAt( 0 ) ){ negative = true; use = encoded.substring( 1 ); } else { negative = false; use = encoded; } for( int index = 0; index &lt; use.length(); index++ ){ c = use.charAt( index ); res = res.multiply( ENCODE_LENGTH ); res = res.add( BigInt…
upvote count: 1
score: 1
downvote count: 0
type: Answer

http://stackoverflow.com/comment/33372431
comment on: http://stackoverflow.com/q/22016401
type: Comment
type: QuestionComment
score: 1
has text: Can you post example of input end expected output, which would show problem you are facing? For now it seems that `appendReplacement` is correct way of doing things here. What is wrong with it?

http://stackoverflow.com/comment/33382299
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22021758
score: 0
has text: agree.. @user1760791 please put proper code snippet.

http://stackoverflow.com/q/22130447
answer count: 1
tagged with: java
tagged with: web-applications
has comment: http://stackoverflow.com/comment/33577835
tagged with: jar
type: UnansweredQuestion
tagged with: tomcat
has body: I'm new on a web project where we have to develop plugins (called "extensions" in that specific project). The main application runs in a modified Tomcat web server and we have to add our plugins' .jars in a common lib folder. I'm still not very used to the application and how it works, but I'm pretty sure there is a common classloader for the application and all its plugins. All libraries in that lib folder are shared. My question is how to deal with the plugins' dependencies and potentially conflictual versions, in that environment. Should we have shared libraries for example some-common-lib-1.3.4 as jars in the lib folder and plugins have to use those versions when they need to use a library? Or should a plugin contain its own dependencies (using Maven Shade Plugin for example) so different versions of a same dependency are not an issue? The problem I see with having shared libraries with a specific version to use for all plugins, is about transitive dependencies. If a common library has a dependency to some-transitive-dependency-1.0.0 and we have a specific plugin which requires a new library which itself have a transitive dependency on some-transitive-dependency-2.0.0 then we're screwed... We would then need both some-transitive-dependency-1.0.0 and some-transitive-dependency-2.0.0 in the lib folder and who knows what will happen. Also, if for one specific plugin we need to update a dependency to a new major version, we may have to update all plugins since that library is shared by all. Any real world experience with such situation? Any tips?
has title: Best practices for a "multi plugins" Java web application - Managing common libraries and conflictual versions
has answer: http://stackoverflow.com/a/22142466
type: Question
score: 0
tagged with: maven
has comment: http://stackoverflow.com/comment/33582463

http://stackoverflow.com/a/22068776
has body: a key is unique in a hashmap. so there can be only one value with your speicified key.
type: Answer
answers question: http://stackoverflow.com/q/22068705
score: 0

http://stackoverflow.com/comment/33428460
has text: That´s because in my code I parse the result from server and then send a message to a handler on postExecute. Just remove that and parse it you way.
type: Comment
comment on: http://stackoverflow.com/a/22046174
type: AnswerComment
score: 0

http://stackoverflow.com/a/22011768
score: 0
has body: I don't know about eclipse. The way you use a external library in an android project is by creating a 'libs' folder in the projects source folder and putting the jar files in their. Don't forget to add the path of libs to the build path so they are available when building the final project (in eclipse it's right click the jar and select 'add to build path' It has already been answered and a definite duplicate but I cannot seem to paste the answer URL.
type: Answer
answers question: http://stackoverflow.com/q/22011542

http://stackoverflow.com/q/22082854
downvote count: 1
tagged with: jfilechooser
type: Question
has title: Save JTextPane, and Open it Java
score: -1
has comment: http://stackoverflow.com/comment/33491879
has body: I'm trying to save a file using JFileChooser, but I cant seem to get it to actually save. I've tried a couple of different methods, but I want the user to able to save on desired location. When I hit the "Save" button it says that it's saved. But when I try to find the file, it does not exist. public class GUI extends JFrame implements ActionListener, DocumentListener{ JMenuItem aapne; JMenuItem lagre; JMenuItem sok; JMenuItem farge; JMenuItem oversett; JTextPane tekstomraadet; JTextPane dir; String fratekst; String tiltekst; String tekst; DefaultListModel listmodel = new DefaultListModel(); JList liste = new JList(listmodel); public GUI(){ this.setSize(1000,500); this.setLayout(null); //Passord passord pass = new passord(); pass.password = JOptionPane.showInputDialog(null, "Skriv inn et passord"); while(!(pass.password.equals("words"))){ pass.password = JOptionPane.showInputDialog(null, "Skriv inn passordet på nytt"); } //Liste liste.setBounds(900,0,100,600); liste.setBackground(Color.pink); this.add(liste); liste.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); listmodel.addElement("Hvit"); listmodel.addElement("Svart"); //Tekst tekstomraadet = new JTextPane(); dir = new JTextPane(); tekstomraadet.setBounds(0, 0, 890, 600); tekstomraadet.setContentType("text/html"); tekstomraadet.getDocument().addDocumentListener(this); this.add(tekstomraadet); //MENY JMenuBar menuBar = new JMenuBar(); JMenu fil = new JMenu("Fil"); aapne = new JMenuItem("Åpne"); lagre = new JMenuItem("Lagre"); sok = new JMenuItem("Søk"); farge = new JMenuItem("Endre farge"); oversett = new JMenuItem("Oversett"); aapne.addActionListener(this); lagre.addActionListener(this); sok.addActionListener(this); farge.addActionListener(this); oversett.addActionListener(this); fil.add(aapne); fil.add(lagre); fil.add(sok); fil.add(farge); fil.add(oversett); menuBar.add(fil); this.setJMenuBar(menuBar); this.setVisible(true); } //OVERSETTING public String oversett (String input){ input = input.rep…
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33492160
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33551721
upvote count: 0
has answer: http://stackoverflow.com/a/22082874
tagged with: java
tagged with: save
tagged with: jtextpane

http://stackoverflow.com/q/22034009
has comment: http://stackoverflow.com/comment/33404043
has answer: http://stackoverflow.com/a/22034752
has comment: http://stackoverflow.com/comment/33406736
has comment: http://stackoverflow.com/comment/33404092
has comment: http://stackoverflow.com/comment/33404108
has comment: http://stackoverflow.com/comment/33403992
has title: How to remove item from list based on attribute comparison?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22035557
accepted answer: http://stackoverflow.com/a/22035557
tagged with: java
has comment: http://stackoverflow.com/comment/33404254
possible better answer: http://stackoverflow.com/a/22034752
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/33404066
has body: I have a list of objects "Artical" which have 2 attributes articalid and articalVersion as shown below. enter public class Artical{ public int articalid; public double articalVersion; //with getter and setters } and now have list having following result articalid=1098 articalVersion=1.0 articalid=1098 articalVersion=1.1 articalid=1078 articalVersion=1.0 articalid=1078 articalVersion=1.1 articalid=1065 articalVersion=1.0 articalid=1043 articalVersion=1.0 now I want to make list that contain only that objects that have greater version no.(and articalid must not repeat ) like articalid=1098 articalVersion=1.1 articalid=1078 articalVersion=1.1 articalid=1065 articalVersion=1.0 articalid=1043 articalVersion=1.0
score: 0

http://stackoverflow.com/comment/50598211
has text: Answer given by @lae is correct but I would like to share my experience.I generally use the ImmutableList.copyOf() static factory method as it is a nice clean generic factory method
comment on: http://stackoverflow.com/a/22085144
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33614589
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22151131
has text: I have a better idea you can saved this variable into one constant class

http://stackoverflow.com/comment/74780360
has text: link to https://github.com/jittagornp/excel-object-mapping is broken :-(
type: AnswerComment
score: 1
type: Comment
comment on: http://stackoverflow.com/a/40306577

http://stackoverflow.com/q/22062226
type: Question
has comment: http://stackoverflow.com/comment/33454375
has comment: http://stackoverflow.com/comment/33454751
tagged with: listview
has comment: http://stackoverflow.com/comment/33454220
upvote count: 1
has comment: http://stackoverflow.com/comment/33455532
has comment: http://stackoverflow.com/comment/33453953
has comment: http://stackoverflow.com/comment/33455831
has comment: http://stackoverflow.com/comment/33454356
favorite count: 0
has comment: http://stackoverflow.com/comment/33454929
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/11619874
tagged with: android
has title: how to setText in Search Functionality for ListView
answer count: 0
downvote count: 0
score: 1
tagged with: java
has body: i make inputsearch in my listview and and i've make settext in the inputsearch when it open. i've set a word in the inputsearch field but the problem it can search by the word i've set. it must be type because in inputsearch field have filter the word that we type. may someone help me how i can set the text in inputsearch field without filter, when i open my listview , my listview will automatic just show the value from the word i set in inputsearch field. sorry for my bad english and thank you guys. protected void onPostExecute(String file_url) { pDialog.dismiss(); runOnUiThread(new Runnable() { public void run() { DatabaseHandler db = new DatabaseHandler(getApplicationContext()); /** * Hashmap to load data from the Sqlite database **/ HashMap&lt;String,String&gt; user = new HashMap&lt;String, String&gt;(); user = db.getUserDetails(); inputSearch = (EditText) findViewById(R.id.inputSearch); inputSearch.setText(user.get("fname"),TextView.BufferType.EDITABLE); adapter = new SimpleAdapter( semuatempat.this, data_map, R.layout.list_item, new String[] { tanya_nama, tanya_judul, tanya_komen,tanya_jawaban,tanya_waktu}, new int[] {R.id.nama, R.id.alamat, R.id.lat,R.id.lng,R.id.waktu}); setListAdapter(adapter); } }); // selecting single ListView item ListView lv = getListView(); inputSearch.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { // When user changed the Text semuatempat.this.adapter.getFilter().filter(cs); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable arg0) { // TODO Auto-generated method stub } });
has comment: http://stackoverflow.com/comment/33455023
has comment: http://stackoverflow.com/comment/33455477

http://stackoverflow.com/q/22164820
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22172166
tagged with: http://stackoverflow.com/tag/docx
has body: I have a docx file inside my android app. I want to view its contents on an activity , page wise. say, I want to view page no 2, i want something like display(DOCX_NAME,2); also, on display, there should not be any re-formatting(I want the docx page to be displayed as if a snapshot was taken of it) how do i go about it? also, its a 200 page docx, and I will use the display part quite a few times during runtime.
has title: Display contents of docx file in android activity
tagged with: java
type: Question
linked to: http://stackoverflow.com/q/22332791
linked to: http://stackoverflow.com/q/13019447
accepted answer: http://stackoverflow.com/a/22172166
tagged with: image
score: 0
linked to: http://stackoverflow.com/q/10447865
answer count: 1
tagged with: android

http://stackoverflow.com/comment/33615845
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22152272
has text: I mean for `get(int index)`. I see what you mean now though.
score: 0

http://stackoverflow.com/comment/33441824
comment on: http://stackoverflow.com/a/22055077
has text: Iv'e voted u up because I was at the same problem where you were before..:)..Lemme know if this explains..and if yes, accept my answer..;)
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/22028821
has comment: http://stackoverflow.com/comment/33396132
score: 0
has comment: http://stackoverflow.com/comment/33395784
has comment: http://stackoverflow.com/comment/33396263
has body: As your exception says, your matrix is rank deficient, it is mathematically impossible to compute an inverse matrix. The computer is not above mathematics in these affairs. This can have multiple reasons. First of all, inverse matrices only exist for square inputs, i.e., format n x n. You did not indicate that this is the case. There exists the idea of the pseudo-inverse that can be constructed for all matrices. But even for square matrices, the rank can be deficient, i.e., the matrix can be singular. In exact terms, this happens if the determinant is zero. In computational terms, this can also happen for ill-conditioned matrices with a wide magnitude range in their singular values. Can you provide the matrix where that problem occurs?
type: Answer
answers question: http://stackoverflow.com/q/22028756

http://stackoverflow.com/q/22032763
answer count: 0
type: UnansweredQuestion
upvote count: 1
has title: ASM code not injecting in the correct location
type: Question
has comment: http://stackoverflow.com/comment/33494706
tagged with: bytecode
score: 1
tagged with: java
tagged with: code-injection
has body: I am attempting to inject two lines of code into a class. I managed to get it working once before, but I am having trouble getting it working again. For some reason, no matter what I do, I cannot get the code to run at runtime, even though it supposedly injects successfully. Here is my injection method: public byte[] patchBlockRotatedPillarASM(String name, byte[] bytes, boolean obfuscated) { String targetMethodName = ""; if(obfuscated == true) { targetMethodName ="a"; System.out.println("******** Using obfuscated method"); } else { targetMethodName ="onBlockPlaced"; System.out.println("******** Using unobfuscated method"); } //set up ASM class manipulation stuff. Consult the ASM docs for details ClassNode classNode = new ClassNode(); ClassReader classReader = new ClassReader(bytes); classReader.accept(classNode, 0); //Now we loop over all of the methods declared inside the Block class until we get to the targetMethodName "onBlockPlaced" @SuppressWarnings("unchecked") Iterator&lt;MethodNode&gt; methods = classNode.methods.iterator(); while(methods.hasNext()) { MethodNode m = methods.next(); System.out.println("********* Method Name: "+m.name + " Desc:" + m.desc); int fdiv_index = -1; //Check if this is onBlockPlaced and it's method signature is (Lnet/minecraft/world/World;IIIIFFFI)I if ((m.name.equals(targetMethodName) &amp;&amp; m.desc.equals("(Lnet/minecraft/world/World;IIIIFFFI)I"))) { System.out.println("********* Inside target method!"); AbstractInsnNode currentNode = null; AbstractInsnNode targetNode = null; @SuppressWarnings("unchecked") Iterator&lt;AbstractInsnNode&gt; iter = m.instructions.iterator(); int index = -1; //Loop over the instruction set and find the instruction 21 which does the line before the ILOAD while (iter.hasNext()) { index++; currentNode = iter.next(); System.out.println("********* index : " + index + " currentNode.getOpcode() = " + currentNode.getOpcode()); System.out.println(currentNode); //Found it! save the index location of instructi…
downvote count: 0
has comment: http://stackoverflow.com/comment/53351699
favorite count: 0
has comment: http://stackoverflow.com/comment/33478128

http://stackoverflow.com/comment/33601239
has text: @Luke I have reworked the regex based on my understandings. I have removed `{2,4}` quantifier because I didn't understand the reason of its presence. Anyway, I hope the new regex and its demo will lead you to the solution.
comment on: http://stackoverflow.com/a/22143396
type: AnswerComment
type: Comment
score: 0

http://stackoverflow.com/comment/33482712
type: Comment
score: 1
has text: @SnakeDoc I think more issues are caused by overthinking than underthinking.
type: AnswerComment
comment on: http://stackoverflow.com/a/22077976

http://stackoverflow.com/q/22116859
has answer: http://stackoverflow.com/a/22116922
has body: I wanted to create dynamic list of buttons using ArrayList. If I copy the method which is written AddButton in constructor , it works. However, If I run this method in ActionListener, it won't work. How do I resolve this ? Code: package HelloJFrame; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JTextField; public class Main extends JFrame implements ActionListener { private static final long serialVersionUID = 1L; private JTextField text1; public static void main(String[] args) { // TODO Auto-generated method stub new Main().setVisible(true); } public Main() { super("Hello JFrame");// Set Title from JFrame constructor setSize(600, 600); setResizable(true); setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new FlowLayout()); text1 = new JTextField(20); // text.setSize(200, 20); add(text1); JButton submit = new JButton("Add Button"); submit.addActionListener(this); submit.setActionCommand("ekle"); add(submit); } @Override public void actionPerformed(ActionEvent e) { AddButton(2); } public void AddButton(int number) { ArrayList&lt;JButton&gt; buttons = new ArrayList&lt;JButton&gt;(); for (int i = 0; i &lt; number; i++) { buttons.add(new JButton("Button #" + i)); } /* * JButton button = new JButton("Click!"); * button.addActionListener(this); add(button); */ for (int i = 0; i &lt; buttons.size(); i++) { this.add(buttons.get(i)); } } }
type: AnsweredQuestion
tagged with: jframe
score: 0
accepted answer: http://stackoverflow.com/a/22116922
tagged with: swing
type: Question
tagged with: java
has title: Java JFrame cannot create button(arraylist)
tagged with: user-interface
answer count: 1

http://stackoverflow.com/comment/33443837
type: Comment
type: QuestionComment
has text: Well i tried putting the 'l' behind the numbers in the main() ,and that removed that error. But i still get these errors on other places in my code. Always when i am trying to manipulate my long[] delers.
comment on: http://stackoverflow.com/q/22055978
score: 0

http://stackoverflow.com/q/22153033
tagged with: while-loop
has comment: http://stackoverflow.com/comment/33617442
has answer: http://stackoverflow.com/a/22153431
has title: Java While Loop breaking with a negative
possible better answer: http://stackoverflow.com/a/22153262
linked to: http://stackoverflow.com/q/17513692
has answer: http://stackoverflow.com/a/22153265
has answer: http://stackoverflow.com/a/22153299
has answer: http://stackoverflow.com/a/22153178
has body: I am having a problem with this java project I am working on for tomorrow. I am supposed to make a while loop that prompts the user for the prices of items and end the loop with any negative number, that negative number cannot be counted. Then I have to prompt the user for their membership discount level plat 15% off/gold 7%/silver 3%/non member 0% off using variables 3,2,1,0 respectively. For invalid input of status of membership, the user needs to enter again with a valid one using a do-while loop. Then I use the appropriate discount % off the sum of the items then tax it. The last few steps are simple enough, but I am stuck at the loops. I did some searching and found this block of code on this site that does the job for the first while loop but does not end in the way I need it to. Using While Loop instead of a For Loop in Java to ask User Input I modified it to fit my needs but I still cannot find a way to make the throwable = to any negative number ie &lt;0. Is that even possible? I am pretty sure there is a way to do this much simpler without try/catch which I have not learned yet. Here is my very slightly modified version Scanner askPrice = new Scanner(System.in); BigDecimal totalPrice = new BigDecimal("0"); Scanner keyboard = new Scanner(System.in); while (true) { System.out.println("Enter item price or negative number to quit:") ; try { double price = askPrice.nextDouble(); totalPrice = totalPrice.add(new BigDecimal(String.valueOf(price))); } catch (Throwable t) { break; } System.out.println(totalPrice.toString()); } I tried turning the try and catch statements into if / else and replacing the catch throwable with else(askPrice &lt;0), but I was getting tons of errors. I greatly appreciate any help that can be offered. Thanks.
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33617797
has comment: http://stackoverflow.com/comment/33617340
tagged with: java
tagged with: loops
type: Question
accepted answer: http://stackoverflow.com/a/22153265
has comment: http://stackoverflow.com/comment/33617996
has comment: http://stackoverflow.com/comment/33617518
answer count: 6
has answer: http://stackoverflow.com/a/22153262
has answer: http://stackoverflow.com/a/22153254
score: 0

http://stackoverflow.com/comment/33626363
has text: Thank you to everyone who answered, each of you put it into different perspectives for me, and I am finding that I am beginning to actually understand this! TylerAndFriends, your answer really put it into the simplified way that I needed most, so thank you very much. I appreciate the help.
comment on: http://stackoverflow.com/a/22157637
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/22039569
has answer: http://stackoverflow.com/a/22079257
favorite count: 0
has answer: http://stackoverflow.com/a/22040123
has answer: http://stackoverflow.com/a/44750794
tagged with: thread-local
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/136033883
possible better answer: http://stackoverflow.com/a/22040058
tagged with: java
has answer: http://stackoverflow.com/a/22040058
accepted answer: http://stackoverflow.com/a/22040123
type: Question
tagged with: jakarta-ee
has body: I am working on a j2ee webapp divided in several modules. I have some metadata such as user name and preferences that I would like to access from everywhere in the app, and maybe also gather data similar to logging information but specific to a request and store it in those metadata so that I could optionally send it back as debug information to the user. Aside from passing a generic context object throughout every method from the upper presentation classes to the downer daos or using AOP, the only solution that came in mind was using a threadlocal "Context" object very similar to a session BTW, and add a filter for binding it on ongoing request and unbinding it on response. But such thing feels a little hacky since this breaks several patterns and could possibly make things complicated when it comes to testing and debugging so I wanted to ask if from your experience it is ok to proceed like this?
has title: Is it a bad practice to use a ThreadLocal Object for storing web request metadata?
has answer: http://stackoverflow.com/a/69780373
answer count: 6
score: 4
upvote count: 4
downvote count: 0
has answer: http://stackoverflow.com/a/22040111

http://stackoverflow.com/comment/33361176
has text: Alright I see what you mean. I'm gonna do some reading and figure this out. Thanks for the help
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22009283
type: AnswerComment

http://stackoverflow.com/q/22065818
tagged with: java
tagged with: comparator
has answer: http://stackoverflow.com/a/22065924
downvote count: 0
favorite count: 0
tagged with: autoboxing
has answer: http://stackoverflow.com/a/22066044
has answer: http://stackoverflow.com/a/22066260
answer count: 5
has comment: http://stackoverflow.com/comment/33460530
has answer: http://stackoverflow.com/a/22066402
has body: I thought the Collections.binarySearch()would return never return a 0 cause the comparison in the comparator is between two Integer which the == operation would always been false, but the run results let me down... Can someone help me out? public class ObjectCompare { static Comparator&lt;Integer&gt; com = new Comparator&lt;Integer&gt;(){ public int compare(Integer i, Integer j) { return i&lt;j?-1:(i==j?0:1);// i thought i==j would never return true } }; public static void main(String[] args){ String[] array = {"0","1","2","3","4","5"}; List&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;(); Integer k = new Integer(1); Integer l = new Integer(1); System.out.println(k==l); // this return's false for(String s : array) list.add(Integer.valueOf(s)); System.out.println(Collections.binarySearch(list,1,com));// this returns 1 } }
type: UnansweredQuestion
score: 1
has answer: http://stackoverflow.com/a/22067128
upvote count: 1
has comment: http://stackoverflow.com/comment/33459962
type: Question
has title: How does comparator work?
has comment: http://stackoverflow.com/comment/33460215

http://stackoverflow.com/a/22018303
has comment: http://stackoverflow.com/comment/33376554
answers question: http://stackoverflow.com/q/22017809
type: Answer
has comment: http://stackoverflow.com/comment/33376588
has comment: http://stackoverflow.com/comment/33409270
has comment: http://stackoverflow.com/comment/33377342
has body: You need some breaks in your case statements in the switch, otherwise it'll fall through.
has comment: http://stackoverflow.com/comment/33408885
score: 0

http://stackoverflow.com/comment/33596092
type: Comment
has text: The actual implementation is up to the JVM designers and has changed over time in the oracle JVM, as faster methods were found. You can look at the hotspot sources in openjdk to see how it is done. A simpler set of sources may be jamvm which is a very small but complete JVM
comment on: http://stackoverflow.com/a/22125121
type: AnswerComment
score: 0

http://stackoverflow.com/q/22155920
tagged with: blobstore
favorite count: 0
linked to: http://stackoverflow.com/q/14683530
tagged with: google-cloud-endpoints
has answer: http://stackoverflow.com/a/29239870
linked to: http://stackoverflow.com/q/22153910
upvote count: 3
type: UnansweredQuestion
tagged with: google-app-engine
has comment: http://stackoverflow.com/comment/54868786
score: 3
tagged with: java
linked to: http://stackoverflow.com/q/16246734
has body: I am developing an app-engine connected android project using the eclipse plugin. When I upload an image to the blobstore, how do I make it callback an endpoint method? I find great posts here that can be used as reference to understand my question better (if you need to). using blobstore with google cloud endpoint and android Saving blobs with Google Endpoint So really, I want to know how to make the callback url an endpoint method such as saveAnimalData below (I stole from referenced link) @ApiMethod(name = "saveAnimalData", httpMethod = HttpMethod.POST) public String saveAnimalData(AnimalData request) throws Exception { }
type: Question
has title: getting blobstore to callback to endpoint method
tagged with: google-cloud-datastore
answer count: 1
downvote count: 0

http://stackoverflow.com/a/64432172
answers question: http://stackoverflow.com/q/22161297
type: Answer
has body: Looking at it the other way, if you are defining a method as abstract that means you are surely inheriting that class to some other class/classes otherwise no use of defining it as abstract. Moreover, you should keep abstract methods in those classes which are parent class and have members that are inheritable and characteristics to other sub-class. So if for one abstract method a whole class is need to be inherited then we could define the other variables too with required access specifiers so that it also get inherited as needed and hence no need to create objects of parent class to call concrete members.
score: 0

http://stackoverflow.com/comment/33515875
comment on: http://stackoverflow.com/a/22094784
has text: Did I do what you meant by your suggestion, or is there something else I should be doing? Thanks
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33641170
score: 0
type: Comment
type: QuestionComment
has text: @WebServlet("/FileDao") this line is shown as error in eclipse WebServlet cannot be resolved to a type The attribute value is undefined for the annotation type WebServlet
comment on: http://stackoverflow.com/q/22166472

http://stackoverflow.com/a/22013765
upvote count: 3
score: 3
answers question: http://stackoverflow.com/q/22012817
has comment: http://stackoverflow.com/comment/33462423
has comment: http://stackoverflow.com/comment/33371061
downvote count: 0
has body: The limit is set in org.eclipse.ui.internal.views.markers.MarkerContentGenerator but this is an internal class so cannot be accessed directly. The only thing that sets the limit is org.eclipse.ui.internal.views.markers.FiltersConfigurationDialog which is also internal. You can display this filters configuration dialog by adding a menu contribution for the command id org.eclipse.ui.ide.configureFilters. This is the part of the Problems View plugin.xml menu definitions which links to the filters menu: You should be able to do something similar for your view.
type: Answer

http://stackoverflow.com/q/22140023
possible better answer: http://stackoverflow.com/a/22140411
accepted answer: http://stackoverflow.com/a/22140348
has answer: http://stackoverflow.com/a/22140411
score: 0
has title: Sending Message using TCP Socket not returning any data
has body: I am using following code OutputStream out = socket.getOutputStream(); PrintWriter output = new PrintWriter(out); @SuppressWarnings("unused") byte[] b = message.getBytes("US-ASCII"); String convertedString = Normalizer.normalize(message, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", ""); Log.d("ASCII", convertedString); output.println(convertedString); Log.e("TCP Message sent", convertedString); BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream())); //read line(s) String st = input.readLine(); Log.e("TCP Message received", st); But I am stuck at String st = input.readLine(); It just hangs there and never proceed to next line. Is this correct way of sending message using TCLP And then get response?
tagged with: sockets
tagged with: android
has answer: http://stackoverflow.com/a/22140348
has comment: http://stackoverflow.com/comment/33595650
type: AnsweredQuestion
tagged with: tcp
tagged with: java
tagged with: eclipse
has comment: http://stackoverflow.com/comment/33595162
type: Question
answer count: 2

http://stackoverflow.com/comment/33539909
type: AnswerComment
has text: lol thanks xp500, could I load the values in the array using an array traversal? if so how?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22109571

http://stackoverflow.com/comment/33459993
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22057038
has text: I execute the program, import a .wav, then I zoom in with Ctr+MouseWheel. At ãbout 33-34k pixels width it starts looking like that: http://imgur.com/X66C38f . There is no reference line, and it should draw from the beginning. Can anybody reproduce it or does it seem to be a system issue of mine? I am working on Xubuntu.

http://stackoverflow.com/comment/33374819
has text: I'm confused. What was in the other actionPerformed? Or is the piece of code in non-working state?
comment on: http://stackoverflow.com/q/22017269
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33490346
has text: "Do my homework!" was not part of the original post.
comment on: http://stackoverflow.com/a/22081979
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/q/22154456
possible better answer: http://stackoverflow.com/a/22154528
has answer: http://stackoverflow.com/a/22154528
answer count: 3
has title: JLabel alignment in JPanel
upvote count: 1
tagged with: layout-manager
favorite count: 0
has body: I'm trying to align a JLabel to the right in a JPanel. I'm adding a JTabbedPane, a JPanel which contains my JLabel and JTextArea to a main JPanel. I have searched SO and tried some methods like setAlignmentX, setHorizontalAlignment(SwingConstants.LEFT) and nested containers to no avail. Here's my code: import java.awt.*; import java.awt.event.*; import javax.swing.*; class LabelProblem { public static void main(String[] args) { JFrame frame = new JFrame("Label Problem"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel Main = new JPanel(); Main.setLayout(new BoxLayout(Main, BoxLayout.Y_AXIS)); JPanel ComponentPanel = new JPanel(); JLabel label = new JLabel("Sample Text"); label.setHorizontalAlignment(SwingConstants.LEFT); label.setBorder(BorderFactory.createLineBorder(Color.BLACK)); label.setAlignmentX(Component.RIGHT_ALIGNMENT); ComponentPanel.add(label); JTabbedPane Tab = new JTabbedPane(); Tab.add("Document 1", new JPanel()); Main.add(Tab); Main.add(ComponentPanel); JTextArea Area = new JTextArea(10,10); JScrollPane Scroll = new JScrollPane(Area); frame.add(Main); frame.add(Scroll, BorderLayout.SOUTH); frame.setSize(450,450); frame.setVisible(true); } } How can I align my JLabel to the right? Thanks!
has answer: http://stackoverflow.com/a/22155235
has answer: http://stackoverflow.com/a/22155251
accepted answer: http://stackoverflow.com/a/22155235
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
tagged with: swing
has comment: http://stackoverflow.com/comment/33620481
type: Question

http://stackoverflow.com/a/22138385
accepted answer of: http://stackoverflow.com/q/22138333
has comment: http://stackoverflow.com/comment/33591730
has comment: http://stackoverflow.com/comment/33592075
has body: This should give you an idea how to do it using InflaterInputStream: public static void decompress(File compressed, File raw) throws IOException { InputStream in = new InflaterInputStream(new FileInputStream(compressed)); OutputStream out = new FileOutputStream(raw); byte[] buffer = new byte[1000]; int len; while((len = in.read(buffer)) &gt; 0) { out.write(buffer, 0, len); } in.close(); out.close(); } Hope this helps.
has comment: http://stackoverflow.com/comment/33591378
score: 0
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22138333
type: Answer

jprofiler
tags question: http://stackoverflow.com/q/22168752
type: Tag
tag name: jprofiler

http://stackoverflow.com/comment/33411340
comment on: http://stackoverflow.com/q/22038199
score: 0
type: QuestionComment
has text: have you checked proximity alert in android. Here you can set the target lat/log along with radius. Please check http://www.javacodegeeks.com/2011/01/android-proximity-alerts-tutorial.html
type: Comment

http://stackoverflow.com/q/22099094
type: Question
answer count: 2
accepted answer: http://stackoverflow.com/a/22100366
has body: I am working on a small android project. I have a textbox on the screen ( given the ID lblDisplay). I have a separate class, that I want to make an instance of and have it be able to enter text into the lblDisplay EditText Object. How can I do this? I noticed that when I tried the way i did on in my Activity class, EditTxt eText = (EditText)findViewById(R.id.lblDisplay) It would not let me, as it can not find the findViewById() method, I assume I get that as I am not extending Activity, and I can't Extend Activity as I am Extending TimerTask. Can someone point me in the right direction so I can get my new class to be able to enter text into the textbox on my main class? The new class is a TimerTask which I want to be able to update the screen every few seconds. I really hope someone can point me in the right direction. Thanks. Scott EDIT: Posting Code: Here is the New class I made. import java.util.TimerTask; import android.content.Context; import android.os.Handler; import android.widget.EditText; import android.widget.SeekBar; public class ARCTimer extends TimerTask { private Context context; private Handler mHandler = new Handler(); public SeekBar skVelo; public SeekBar skAngle; public EditText etDisplay; public Double tTime = 0.1; public ARCTimer(Context con, SeekBar sVelo, SeekBar sAngle, EditText eDisplay){ this.context = con; this.skVelo = sVelo; this.skAngle = sAngle; this.etDisplay = eDisplay; } @Override public void run() { //CODE HERE //LETS UPDATE THE TIME AND DISPLAY SO WE CAN SEE IF THE TIMER IS WORKING PROPERLY //FIRE BUTTON CODE START //TESTING VALUES Double dVelo = Double.valueOf(skVelo.getProgress()); dVelo = dVelo/100; Double dAngle = Double.valueOf(skAngle.getProgress()); //Make an instance of the ARC class ARC arc = new ARC(); //Lets set the values we will need arc.setV(dVelo); arc.setA(dAngle); arc.setG(9.8); arc.setT(tTime); Double dY = arc.getY(); Double dX = arc.getX(); Double dXMax = arc.getXmax(); String sMsg = ""; sMsg += "At Time: "+ tTi…
has title: Access Object in main Activity with a different class in android
has comment: http://stackoverflow.com/comment/33520710
has comment: http://stackoverflow.com/comment/33520889
score: 0
has comment: http://stackoverflow.com/comment/33521455
favorite count: 0
tagged with: android
has answer: http://stackoverflow.com/a/22100366
possible better answer: http://stackoverflow.com/a/22100617
upvote count: 1
has comment: http://stackoverflow.com/comment/33522345
has answer: http://stackoverflow.com/a/22100617
type: AnsweredQuestion
tagged with: java
downvote count: 1

http://stackoverflow.com/a/22006044
has comment: http://stackoverflow.com/comment/33354731
has comment: http://stackoverflow.com/comment/33354638
upvote count: 2
has body: The models of of JTree and JTable are responsible for telling the view that they should be updated. What you need is some way to know when the data in your HashMap and tell the models to update themselves some how. Something like an Observer Pattern or Command/Producer-Consumer Pattern can work here. How you update the models will depend on which implementation of the models you're using, but since you've not provided that information, it's not easy to suggest how you should solve the problem further
has comment: http://stackoverflow.com/comment/33354891
type: Answer
has comment: http://stackoverflow.com/comment/33354686
score: 2
has comment: http://stackoverflow.com/comment/33354718
has comment: http://stackoverflow.com/comment/33354199
has comment: http://stackoverflow.com/comment/33354898
has comment: http://stackoverflow.com/comment/33355091
has comment: http://stackoverflow.com/comment/33354795
has comment: http://stackoverflow.com/comment/33354802
has comment: http://stackoverflow.com/comment/33354858
answers question: http://stackoverflow.com/q/22005859
has comment: http://stackoverflow.com/comment/33354754
downvote count: 0

http://stackoverflow.com/comment/33599474
type: AnswerComment
comment on: http://stackoverflow.com/a/22102121
score: 0
has text: You could stream them into a `Map<String,Enum>` using `stream.collect(Collectors.toMap(Enum::name, Function.identity()))`. But I think for typical `enum` sizes, a hash lookup is not faster than a linear search…
type: Comment

http://stackoverflow.com/q/22092168
tagged with: jlabel
type: UnansweredQuestion
has title: Adjust image and text in one line
tagged with: swing
score: 1
tagged with: java
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/22092459
tagged with: swingworker
tagged with: image
has body: I have the following code: import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.beans.*; import java.util.Random; @SuppressWarnings("serial") public class ProgressBarDemo extends JPanel implements ActionListener, PropertyChangeListener { private JProgressBar progressBar; private JButton generateButton; private JButton exceptionButton; private JTextArea taskOutput; private Task task; class Task extends SwingWorker&lt;Void, Void&gt; { /* * Main task. Executed in background thread. */ @Override public Void doInBackground() { Random random = new Random(); int progress = 0; //Initialize progress property. setProgress(0); while (progress &lt; 100) { //Sleep for up to one second. try { Thread.sleep(random.nextInt(1000)); } catch (InterruptedException ignore) {} //Make random progress. progress += random.nextInt(10); setProgress(Math.min(progress, 100)); } return null; } /* * Executed in event dispatching thread */ @Override public void done() { Toolkit.getDefaultToolkit().beep(); generateButton.setEnabled(true); setCursor(null); //turn off the wait cursor taskOutput.append("Done!\n"); JFrame newFrame = new JFrame(); newFrame.setVisible(true); JLabel label = new JLabel("Task Complete"); newFrame.add(label); newFrame.setSize(250, 250); } } public ProgressBarDemo() { super(new BorderLayout()); JPanel labelpanel = new JPanel(); JLabel headerLabel = new JLabel("", JLabel.LEADING); headerLabel.setText("TEST APPLICATION"); headerLabel.setFont(new Font("Calibri",Font.BOLD,25)); headerLabel.setForeground(Color.blue); ImageIcon icon = new ImageIcon("logo.jpg","hiii"); JLabel imgl=new JLabel(icon); labelpanel.add(imgl); labelpanel.add(headerLabel); imgl.setBounds(10,10, 150, 70); //Create the demo's UI. generateButton = new JButton("button1"); generateButton.setActionCommand("button1"); generateButton.addActionListener(this); generateButton.setBounds(50, 200, 150, 30); exceptionButton = new JButton("button2"); exceptionButton.setActionCommand("button2"); exce…
downvote count: 0
answer count: 1
favorite count: 0

http://stackoverflow.com/comment/33445622
comment on: http://stackoverflow.com/a/22056377
type: AnswerComment
score: 0
type: Comment
has text: Yeah. It was generated by the recruiters at zappos. This is a common interview question. It works now. Please see the answer I posted. And thanks a lot for your help.

http://stackoverflow.com/comment/33397841
type: AnswerComment
score: 0
has text: Actually, no. Composition is merely using objects within other objects. A utility class is more of a stateless class with utility methods. You could also use one in this case (ex. `CalcUtils.calCost()`), but I prefer composition.
type: Comment
comment on: http://stackoverflow.com/a/22029973

http://stackoverflow.com/q/22038213
has answer: http://stackoverflow.com/a/22046830
upvote count: 1
has comment: http://stackoverflow.com/comment/74874318
score: 1
has title: How to not acknowledge only one message with Spring-JMS?
tagged with: java
type: Question
answer count: 2
has body: There is a class 'MyConsumer' which receives messages from a queue, and processes them. There are two requirements: If there is a message contains invalid content, MyConsumer should not acknowledge it, but can process later messages The unconsumed message will be deliver again when MyConsumer restarts I tried with spring-jms, with the listener-container supports, but can't find a solution fits the first requirement. My code: &lt;amq:queue id="destination" physicalName="org.springbyexample.jms.test"/&gt; &lt;amq:connectionFactory id="jmsFactory" brokerURL="tcp://localhost:11111"/&gt; &lt;bean id="jmsConsumerConnectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory" p:targetConnectionFactory-ref="jmsFactory"/&gt; &lt;bean id="jmsConsumerTemplate" class="org.springframework.jms.core.JmsTemplate" p:connectionFactory-ref="jmsConsumerConnectionFactory" p:defaultDestination-ref="destination"/&gt; &lt;bean id="jmsMessageListener" class="test.MyConsumer"/&gt; &lt;bean id="errorHandler" class="test.MyErrorHandler"/&gt; &lt;jms:listener-container container-type="default" connection-factory="jmsConsumerConnectionFactory" error-handler="errorHandler" acknowledge="client"&gt; &lt;jms:listener destination="org.springbyexample.jms.test" ref="jmsMessageListener"/&gt; &lt;/jms:listener-container&gt; Class MyConsumer: @Override public void onMessage(Message message) { TextMessage textMessage = (TextMessage) message; try { System.out.println("!!!!!!!!! get message: " + textMessage.getText()); } catch (JMSException e) { e.printStackTrace(); } if (theNumberOfMessageIs(3)) { throw new RuntimeException("something is wrong"); } } You may notice that the acknowledge in listener-container is client, actually it has 3 values: auto (default) client transacted I tried all of them, but none fits my requirement. My test scenario: producer put 3 messages to queue start a thread to monitor the message count in queue, when the count changes, print it start consumer, it will…
has answer: http://stackoverflow.com/a/43941074
tagged with: spring-jms
downvote count: 0
tagged with: jms
favorite count: 0
type: UnansweredQuestion

http://stackoverflow.com/comment/36791286
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22083547
has text: @PedroTeran Sadly I haven't found a way to download the certificate dynamically. It must be preloaded onto the res folders before shipping out the apk. Is that what you are asking?
score: 0

http://stackoverflow.com/a/22166330
type: Answer
accepted answer of: http://stackoverflow.com/q/22160778
upvote count: 1
score: 1
has body: 3. Is there something else I'm not considering ? Yes, use ViewPager.setOffscreenPageLimit instead.
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/22160778

http://stackoverflow.com/comment/33452215
type: QuestionComment
comment on: http://stackoverflow.com/q/22059619
type: Comment
has text: I have copied the sample.war file into the webapps directory of Tomcat, and I can access localhost:8080. I need to open it in browser? So I accessed like "http://localhost:8080/sample" but it displays "You are not authorized to view this page."
score: 0

http://stackoverflow.com/comment/33383087
type: QuestionComment
score: 2
has text: Use `keyboard.nextLine();` after `keyboard.nextDouble()` to consume the `\n`.
comment on: http://stackoverflow.com/q/22022273
type: Comment

http://stackoverflow.com/q/22030424
tagged with: text-processing
tagged with: awt
upvote count: 1
has answer: http://stackoverflow.com/a/22030458
has comment: http://stackoverflow.com/comment/33398076
has title: Count occurrences of all 256 characters (GUI/Arrays)
favorite count: 0
has body: I need help tweaking my code. I need to write a program that outputs the count of individual ascii characters in a txt file that the user uploads, but I'm having a lot of problems trying to get the array that I count into the GUI portion of the program that "draws" the data on the screen. I have the output looking how I want, but I can't figure out how to get the character count up there import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.FileReader; // both needed import java.io.BufferedReader; import java.io.IOException; public class textreader extends Frame implements ActionListener { String dataFilePath = null; String dataFileName = null; int[] counter = new int[256]; String command = ""; public static void main(String[] args) { Frame frame = new textreader(); frame.setResizable(true); frame.setSize(1000,850); frame.setVisible(true); } public textreader() { setTitle("Text File Processing"); // Menu Creation MenuBar mn = new MenuBar(); setMenuBar(mn); // Create "File" and add it Menu fileMenu = new Menu("File"); mn.add(fileMenu); // Create Menu Items, Add action Listener, Add to "File" Menu Group // Open file MenuItem miOpen = new MenuItem("Open"); miOpen.addActionListener(this); fileMenu.add(miOpen); // Process file MenuItem miProcess = new MenuItem("Process"); miProcess.addActionListener(this); fileMenu.add(miProcess); // Exit program MenuItem miExit = new MenuItem("Exit"); miExit.addActionListener(this); fileMenu.add(miExit); // To Terminate WindowListener d = new WindowAdapter() { public void windowClosing(WindowEvent ev) { System.exit(0); } public void windowActivated(WindowEvent ev) { repaint(); } public void windowStateChanged(WindowEvent ev) { repaint(); } }; ComponentListener k = new ComponentAdapter() { public void componentResized(ComponentEvent e) { repaint(); } }; // listener registry this.addWindowListener(d); this.addComponentListener(k); } public void actionPerformed (ActionEvent ev) { // which command was issued? comm…
downvote count: 5
type: UnansweredQuestion
score: -4
tagged with: java
tagged with: jfilechooser
has comment: http://stackoverflow.com/comment/33398735
type: Question
has comment: http://stackoverflow.com/comment/33398127
tagged with: mixing
answer count: 1

http://stackoverflow.com/a/22128976
type: Answer
score: 1
upvote count: 1
has body: Do nextint(availableSpaces) and take that result as an ordinal, i.e. 3 means the third available position
answers question: http://stackoverflow.com/q/22128634
downvote count: 0

http://stackoverflow.com/comment/33606937
has text: Element is not currently visible and so may not be interacted with. Unfortunately, it doesn't work :/
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/22147243
type: Comment

http://stackoverflow.com/comment/33397674
score: 0
type: Comment
type: QuestionComment
has text: Holy crap I have no idea what you are saying. Is this what happens when the game completes, or when it exists? What is the "way longer" console text?
comment on: http://stackoverflow.com/q/22028538

http://stackoverflow.com/comment/33490636
comment on: http://stackoverflow.com/q/22081817
has text: The members must regards others. Maybe at that time I concentrated on one aspect of the problems and now you and others helped me to focus on the other aspects. So I tried to solve the problems and they solved!
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22045664
type: Question
has comment: http://stackoverflow.com/comment/33428022
tagged with: soap
has comment: http://stackoverflow.com/comment/33425910
tagged with: http://stackoverflow.com/tag/xml
has comment: http://stackoverflow.com/comment/33459102
has comment: http://stackoverflow.com/comment/33426701
has answer: http://stackoverflow.com/a/22065554
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/22046860
tagged with: java
has body: I am writing the code (below) in a Servlet. This has to return value in SOAP Response but this is not displaying the value from SOAP file. I am not having any error. I retrieve the xml from outside and have inlined it here for ease of reading. Thus I need to be able to parse that result to get out the relevant line. String xmlInput=" <S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" + " <S:Body>\n" + " <ns2:tataResponse xmlns:ns2=\"http://pack/\">\n" + " 12500 \n" + " </ns2:tataResponse>\n" + " </S:Body>\n" + "</S:Envelope>\n"; MessageFactory factory = MessageFactory.newInstance(); SOAPMessage message = factory.createMessage(new MimeHeaders(), new ByteArrayInputStream(xmlInput.getBytes( Charset.forName("UTF-8")))); SOAPBody body = message.getSOAPBody(); NodeList returnList = body.getElementsByTagName("ns2:tataResponse"); boolean isSucces = false; for (int k = 0; k < returnList.getLength(); k++) { NodeList innerResultList = returnList.item(k).getChildNodes(); for (int l = 0; l < innerResultList.getLength(); l++) { if (innerResultList.item(l).getNodeName().equalsIgnoreCase("return")) { isSucces = Integer.valueOf(innerResultList.item(l) .getTextContent().trim()) == 100 ? true : false; } } } if (isSucces) { NodeList list = body.getElementsByTagName("return"); for (int i = 0; i < list.getLength(); i++) { NodeList innerList = list.item(i).getChildNodes(); for (int j = 0; j < innerList.getLength(); j++) { System.out.println(innerList.item(j).getNodeName()); System.out.println(innerList.item(j).getTextContent()); } } }
has comment: http://stackoverflow.com/comment/33425199
has title: Retrieve SOAP response
type: UnansweredQuestion

http://stackoverflow.com/a/22075683
type: Answer
has comment: http://stackoverflow.com/comment/33723099
has comment: http://stackoverflow.com/comment/33727427
has comment: http://stackoverflow.com/comment/33482713
has comment: http://stackoverflow.com/comment/33726195
accepted answer of: http://stackoverflow.com/q/22050158
has comment: http://stackoverflow.com/comment/33728142
has comment: http://stackoverflow.com/comment/33727230
has body: Here's what you want to do to create the dynamic size from the input. You need to get the number of entries in the map, then multiply it by whatever you want the width of each bar to be. You need to get the highest value in the map and multiply that by you increment (to draw) amount and create the height from that. You create a new JPanel with dimension based on the height and width from the previous two points. Iterate through the map the draw the bars. I do the things above in the actionPerformed of a button and I add the JPanel to a JOptionPane. Let me know if you need clarification on anything. import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.HashMap; import java.util.Map; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.SwingUtilities; public class Histogram { private static final int BAR_WIDTH = 50; private static final int INCREMENT = 10; public Histogram() { final JTextArea textArea = new JTextArea(5, 40); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); JButton go = new JButton("Histogram-me!"); JPanel panel = new JPanel(new BorderLayout()); panel.add(textArea, BorderLayout.CENTER); panel.add(go, BorderLayout.SOUTH); JFrame frame = new JFrame(); frame.add(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); go.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String text = textArea.getText(); Map&lt;Integer, Integer&gt; counts = getCounts(text); int width = counts.size() * BAR_WIDTH; int max = maxCount(counts); int height = max * INCREMENT + 100; int horizon = height - 25; HistogramPanel panel = new HistogramPanel(width, counts, height, horizon); //panel.setBorder(new LineBorder(Color.BLACK, 2));…
has comment: http://stackoverflow.com/comment/33726860
answers question: http://stackoverflow.com/q/22050158
has comment: http://stackoverflow.com/comment/33480114
has comment: http://stackoverflow.com/comment/33481334
has comment: http://stackoverflow.com/comment/33728595
has comment: http://stackoverflow.com/comment/33726478
has comment: http://stackoverflow.com/comment/33726106
has comment: http://stackoverflow.com/comment/33728623
has comment: http://stackoverflow.com/comment/33728438
has comment: http://stackoverflow.com/comment/33726724
has comment: http://stackoverflow.com/comment/33727701
has comment: http://stackoverflow.com/comment/33728322
has comment: http://stackoverflow.com/comment/33728412
has comment: http://stackoverflow.com/comment/33728200
has comment: http://stackoverflow.com/comment/33727443
has comment: http://stackoverflow.com/comment/33727391
has comment: http://stackoverflow.com/comment/33728239
has comment: http://stackoverflow.com/comment/33726619
has comment: http://stackoverflow.com/comment/33481456
has comment: http://stackoverflow.com/comment/33481534
score: 0
has comment: http://stackoverflow.com/comment/33726449
has comment: http://stackoverflow.com/comment/33480223
has comment: http://stackoverflow.com/comment/33479315
has comment: http://stackoverflow.com/comment/33728483
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33479906
has comment: http://stackoverflow.com/comment/33726085
has comment: http://stackoverflow.com/comment/33481571
has comment: http://stackoverflow.com/comment/33727197
has comment: http://stackoverflow.com/comment/33481629
has comment: http://stackoverflow.com/comment/33479982
has comment: http://stackoverflow.com/comment/33727950
has comment: http://stackoverflow.com/comment/33725918
has comment: http://stackoverflow.com/comment/33728307

http://stackoverflow.com/comment/33502311
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22088286
has text: is builder a StringBuilder ? what is the content in it?
score: 0

http://stackoverflow.com/q/22167696
has title: interface implementation and instantiation
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/22167752
answer count: 2
upvote count: 0
score: -1
has answer: http://stackoverflow.com/a/22167902
has comment: http://stackoverflow.com/comment/33643230
favorite count: 0
type: UnansweredQuestion
has body: Suppose interface Inty defines five methods. Suppose class Classy declares that it implements Inty but does not provide implementations for any of the five interface methods. Which is/are true? A. The class will not compile. B. The class will compile if it is declared public. C. The class will compile if it is declared abstract. D. The class may not be instantiated. I think answer should be C only because an abstract class can not be instantiated in any way(letting apart the anonymous subclass). Please let me know if I am right or wrong.
tagged with: java

http://stackoverflow.com/comment/33558687
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22120150
has text: There should be a log message for class `RequestMappingHandlerMapping` with message `Mapped ..[registered handler here]`.
type: Comment

http://stackoverflow.com/q/22077020
has body: I use Hibernate as orm solution for my project and i don't understand what's happening. I have a entity user : @Entity @Table(name="users") public class User { @Id @GeneratedValue(strategy=GenerationType.AUTO) private long id; ... @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinTable(name = "users_projects", joinColumns = { @JoinColumn(name = "userid") }, inverseJoinColumns = { @JoinColumn(name = "projectid") }) private List&lt;Project&gt; projects; ... +getters and setters } I have the project entity. I am surprised about what happening : If a user have some projects and he want to add another using user interface. Hibernate delete first all projects in database for the current user. Then insert all project in database. Why hibernate delete all projects and insert them after instead of adding just the new one. Here is the Hibernate log : Hibernate: select this_.code as code1_1_0_, this_.name as name2_1_0_ from country this_ Hibernate: insert into projects (besoins, countryCode, description, title) values (?, ?, ?, ?) Hibernate: select last_insert_id() Hibernate: update users set activated=?, email=?, lastError=?, password=?, profil_id =?, role=? where id=? Hibernate: update profil set countryCode=?, countryName=?, description=?, firstname=?, lastName=?, phone=?, title=? where id=? Hibernate: update projects set besoins=?, countryCode=?, description=?, title=? where id=? Hibernate: update projects set besoins=?, countryCode=?, description=?, title=? where id=? Hibernate: update projects set besoins=?, countryCode=?, description=?, title=? where id=? Hibernate: update projects set besoins=?, countryCode=?, description=?, title=? where id=? Hibernate: delete from users_projects where userid=? Hibernate: insert into users_projects (userid, projectid) values (?, ?) Hibernate: insert into users_projects (userid, projectid) values (?, ?) Hibernate: insert into users_projects (userid, projectid) values (?, ?) Hibernate: insert into users_projects (useri…
upvote count: 2
has answer: http://stackoverflow.com/a/22834524
type: UnansweredQuestion
score: 2
tagged with: java
tagged with: hibernate
type: Question
has comment: http://stackoverflow.com/comment/33484604
linked to: http://stackoverflow.com/q/179259
has comment: http://stackoverflow.com/comment/34829507
has title: Hibernate Update : Why hibernate delete object before insert them after
downvote count: 0
answer count: 1
has comment: http://stackoverflow.com/comment/33481003
favorite count: 0

http://stackoverflow.com/q/22133218
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22133277
answer count: 4
has comment: http://stackoverflow.com/comment/33582793
has comment: http://stackoverflow.com/comment/33583155
tagged with: java
has answer: http://stackoverflow.com/a/22133284
has body: I have this code that keeps giving me stack overflow errors and I don't know how to fix it (i'm new to recursion). what is wrong with my code?
type: Question
has comment: http://stackoverflow.com/comment/33582781
has answer: http://stackoverflow.com/a/22133272
has comment: http://stackoverflow.com/comment/33582924
score: 0
has comment: http://stackoverflow.com/comment/33582824
has title: Java stack overflow error with recursion
has answer: http://stackoverflow.com/a/22133231

http://stackoverflow.com/comment/33388747
has text: @CrystalMeth I don't know, compound layouts is a good approach, so long as you were adding each row to the panel. The only problem with this approach would be the fact that the columns wouldn't match up...IMHO
comment on: http://stackoverflow.com/a/22021663
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33495272
comment on: http://stackoverflow.com/q/22084891
has text: Have you run some example files through your code to make sure it behaves correctly?
score: 0
type: Comment
type: QuestionComment

invokeandwait
tags question: http://stackoverflow.com/q/22058121
type: Tag
tag name: invokeandwait

http://stackoverflow.com/comment/33375710
score: 0
comment on: http://stackoverflow.com/a/22018018
type: Comment
type: AnswerComment
has text: No, when I had that, it didn't think there was a setter there at all. It was changing the argument to an array that made it work for analogous members that were String based.

http://stackoverflow.com/a/22164243
has comment: http://stackoverflow.com/comment/33637327
has comment: http://stackoverflow.com/comment/33638755
downvote count: 1
score: 7
answers question: http://stackoverflow.com/q/22163397
has body: You can bind the json to a POJO using MappingJacksonHttpMessageConverter . Thus your controller signature can read :- public ResponseEntity<Boolean> saveData(@RequestBody RequestDTO req) Where RequestDTO needs to be a bean appropriately annotated to work with jackson serializing/deserializing. Your *-servlet.xml file should have the Jackson message converter registered in RequestMappingHandler as follows :- </property>
upvote count: 8
type: Answer

http://stackoverflow.com/comment/33591504
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22138430
has text: There is no need to reverse the string back. We never lost it. If the user enters "banana", then the String input would be "banana", and the String newString would be "ananab". After the if statement, we still have the String input...

http://stackoverflow.com/comment/33640431
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22165295
score: 0
has text: Ehmm.. I get it.. thanks.

dynamic
tags question: http://stackoverflow.com/q/22034725
tag name: dynamic
tags question: http://stackoverflow.com/q/22124122
tags question: http://stackoverflow.com/q/22133721
tags question: http://stackoverflow.com/q/22088820
type: Tag

http://stackoverflow.com/a/22014726
has body: I think I have solved it by myself just by deep investigating (decompiling) some code and think and try around. There is an online SHA-256 calculator I used for this. If I type in the SecurityToken/Salt "tn+nms4=" first and appended the password "stackoverflow" to it. Hashing this then. I got exactly the hash which is stored in the database. Looks like the implementation of the encrytion provider which is used in the legacy app isn't plain .NET at all but more likely something self crafted.
type: AcceptedAnswer
score: 0
accepted answer of: http://stackoverflow.com/q/22007527
answers question: http://stackoverflow.com/q/22007527
type: Answer

http://stackoverflow.com/a/22043718
answers question: http://stackoverflow.com/q/22042638
has comment: http://stackoverflow.com/comment/102883960
score: 0
upvote count: 1
downvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/96094695
has body: Here is one crude example. You should be able to refine. (You may be interested in this Java "tutorial" http://docs.oracle.com/javaee/7/tutorial/doc/jsonp.htm#GLRBB (This example uses the JSON reference implementation included in Java EE (and available here: https://java.net/projects/jsonp/downloads/directory/ri) package com.demo; import java.io.FileWriter; import java.io.IOException; import javax.json.Json; import javax.json.stream.JsonGenerator; public class JSONExample { public static void main(String[] args) { FileWriter writer = null; try { writer = new FileWriter("C:\\Users\\Joseph White\\Downloads\\jsontext.txt"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } JsonGenerator gen = Json.createGenerator(writer); gen.writeStartObject().write("name", "sample") .writeStartArray("def") .writeStartObject().write("setId", 1) .writeStartArray("setDef") .writeStartObject().write("name", "ABC").write("type", "STRING") .writeEnd() .writeStartObject().write("name", "XYZ").write("type", "STRING") .writeEnd() .writeEnd() .writeEnd() .writeStartObject().write("setId", 2) .writeStartArray("setDef") .writeStartObject().write("name", "abc").write("type", "STRING") .writeEnd() .writeStartObject().write("name", "xyz").write("type", "STRING") .writeEnd() .writeEnd() .writeEnd() .writeEnd() .writeEnd(); gen.close(); } }
has comment: http://stackoverflow.com/comment/104278593
has comment: http://stackoverflow.com/comment/89293151

http://stackoverflow.com/q/22077535
has answer: http://stackoverflow.com/a/22077622
answer count: 2
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33482065
has answer: http://stackoverflow.com/a/22077628
favorite count: 0
has body: today we had a discussion at work what of the two follwing functions is more performant, has less memory consumption and doesn't stress the gc. public class Main { public void do1() { int result = 0; int val; do { val = calc(result); result = val * 2; } while (result &lt; 1000); } public void do2() { int result = 0; do { final int val = calc(result); result = val * 2; } while (result &lt; 1000); } private int calc(final int i) { return i + 2; } } in my opinion both are equivalent and it doesn't matter if val is defined inside or outside the loop. The only thing that came in my mind was that scope of variables should be narrowed as much as possible. But than we came to the discussion how the gc handle these case and we didn't find a solution. we looked at the bytecode and there is no difference Compiled from "Main.java" public class Main { public Main(); Code: 0: aload_0 1: invokespecial #1 // Method java/lang/Object."&lt;init&gt;":()V 4: return public void do1(); Code: 0: iconst_0 1: istore_1 2: aload_0 3: iload_1 4: invokespecial #2 // Method calc:(I)I 7: istore_2 8: iload_2 9: iconst_2 10: imul 11: istore_1 12: iload_1 13: sipush 1000 16: if_icmplt 2 19: return public void do2(); Code: 0: iconst_0 1: istore_1 2: aload_0 3: iload_1 4: invokespecial #2 // Method calc:(I)I 7: istore_2 8: iload_2 9: iconst_2 10: imul 11: istore_1 12: iload_1 13: sipush 1000 16: if_icmplt 2 19: return } Does anybody know if there is really no difference here or can solve the discussion?
tagged with: scope
tagged with: while-loop
has comment: http://stackoverflow.com/comment/33482427
has comment: http://stackoverflow.com/comment/33481733
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22077628
upvote count: 2
tagged with: garbage-collection
type: Question
has title: Scoping of variables with loops
possible better answer: http://stackoverflow.com/a/22077622
tagged with: java

http://stackoverflow.com/a/22097440
score: 7
upvote count: 7
answers question: http://stackoverflow.com/q/22097296
downvote count: 0
type: Answer
has body: It depends on how you want to use the numbers. If you are unlikely to need floating point and the numbers aren't going to get too big use int as the most efficient use of the CPU. If the numbers might get too big for int use long. Uses twice the memory but still cpu efficient. If too big for long use BigInteger. Uses the optimum number of bytes for the number. Breaks when number > about 2^65535 so works for most scenarios. Slower than int or long but still seriously fast. If too big for BigInteger you're on your own. Perhaps one day ... If you need float maths float or double are good so long as you are working in their range. For big float maths or a more predictable calculation than double or float, use BigDecimal. Ha sits limitations like BigInteger but it is rare to be bitten by them. Beyond that if you are working solely in rationals then you may find a rational number class useful and more accurate than BigDecimal. This looks ok. If you are likely to move into irrational territory you may find some of the continued-fractions classes of use. Here is an example.

http://stackoverflow.com/a/22086168
answers question: http://stackoverflow.com/q/22086128
has body: n.next != null Is your problem. Change it to n!=null Example : List : 1--&gt; 2 --&gt;3--&gt; 4--&gt;null Count : 1--&gt; 2--&gt;3--&gt;here n=4 and n.next=null. So, your loop will break and count will be 3 (i.e; the last node will not be counted.)
score: 0
type: Answer

http://stackoverflow.com/a/22161853
answers question: http://stackoverflow.com/q/22161754
has comment: http://stackoverflow.com/comment/33633676
score: 0
has comment: http://stackoverflow.com/comment/33634059
has comment: http://stackoverflow.com/comment/33634690
has comment: http://stackoverflow.com/comment/33634562
type: Answer
has comment: http://stackoverflow.com/comment/33633757
has body: Static members are common for all instances of a class. Non static members are specific to an instance of a class (object). Static methods and members (fields, properties) are used in cases where they don't need to change for the duration of a program's or API's life time. An example of this is Math.PI. A more common (correct) way of describing them is: Static methods and fields are useful when they conceptually don't belong to an instance of something. Static members also have the property of being accessible from anywhere (unless declared without public) without having an instance (object) of a class. The special static {} block of a class is run only once when the class is loaded by the JVM.
has comment: http://stackoverflow.com/comment/33633762
has comment: http://stackoverflow.com/comment/33633210

http://stackoverflow.com/q/22025161
downvote count: 0
has comment: http://stackoverflow.com/comment/33388607
tagged with: java
type: Question
has title: What are captured variables in Java Local Classes
has body: The Java documentation for Local Classes says that: In addition, a local class has access to local variables. However, a local class can only access local variables that are declared final. When a local class accesses a local variable or parameter of the enclosing block, it captures that variable or parameter. For example, the PhoneNumber constructor can access the local variable numberLength because it is declared final; numberLength is a captured variable. What is captured variable,what is its use and why is that needed? Please help me in understanding the concept of it.
upvote count: 19
possible better answer: http://stackoverflow.com/a/29689685
answer count: 3
has answer: http://stackoverflow.com/a/22025344
has comment: http://stackoverflow.com/comment/33388769
favorite count: 0
linked to: http://stackoverflow.com/q/4732544
has answer: http://stackoverflow.com/a/22025275
accepted answer: http://stackoverflow.com/a/22025275
score: 19
has comment: http://stackoverflow.com/comment/33388501
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/29689685

http://stackoverflow.com/comment/33462180
has text: "actually contains 77 million null objects" - no, it contains 77 million U+0000 characters. There's no such thing as a "null object". It's worth being precise in your use of terminology. It sounds like a bug in whatever is creating the `StringBuffer` - can you link to the relevant code?
type: Comment
comment on: http://stackoverflow.com/q/22067124
score: 1
type: QuestionComment

http://stackoverflow.com/a/38060808
has body: Elasticsearch index response has isCreated() method that returns true if the document is a new one or false if it has been updated and can be used to see if the document was successfully inserted/updated. If bulk indexing is not an option there are other areas that could be tweaked to improve performance like increasing index refresh interval using index.refresh_interval disabling replicas by setting index.number_of_replicas to 0 Disabling _source and _all fields if they are not needed.
type: Answer
answers question: http://stackoverflow.com/q/22068192
downvote count: 0
score: 1
upvote count: 1

http://stackoverflow.com/comment/33426503
type: QuestionComment
score: 1
type: Comment
has text: The exception indicates that you are trying to open the root directory, likely because you provide an effectively empty (or perhaps even null?) path. Log what your path string actually is, and figure out why it is not what you expect it to be. That problem is not in the posted code.
comment on: http://stackoverflow.com/q/22046449

http://stackoverflow.com/comment/33365772
type: Comment
comment on: http://stackoverflow.com/q/22012790
score: 0
has text: Your solution will depend how or where you will use it.
type: QuestionComment

http://stackoverflow.com/q/22083362
has comment: http://stackoverflow.com/comment/33492755
has title: What type of exception is (0)null?
downvote count: 0
has comment: http://stackoverflow.com/comment/33493069
has answer: http://stackoverflow.com/a/22083686
has comment: http://stackoverflow.com/comment/33492564
has comment: http://stackoverflow.com/comment/33492621
tagged with: exception
tagged with: axis
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/33492707
accepted answer: http://stackoverflow.com/a/22083686
has comment: http://stackoverflow.com/comment/33492733
score: 14
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33492950
upvote count: 14
has comment: http://stackoverflow.com/comment/33492723
has comment: http://stackoverflow.com/comment/33492962
tagged with: java
has comment: http://stackoverflow.com/comment/33492836
has body: I am using Apache Axis, and I am getting exception of type (0)null. Here is partial stack trace: .... .... org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:281) at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120) at java.lang.Thread.run(Thread.java:744) Caused by: (0)null at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744) at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) at org.apache.axis.client.Call.invokeEngine(Call.java:2784) at org.apache.axis.client.Call.invoke(Call.java:2767) at org.apache.axis.client.Call.invoke(Call.java:2443) at org.apache.axis.client.Call.invoke(Call.java:2366) at org.apache.axis.client.Call.invoke(Call.java:1812) at com.netsuite.webservices.platform_2012_1.NetSuiteBindingStub.upsertList(NetSuiteBindingStub.java:11841) .... .... Following is what I see in HTTPSender source code. .... AxisFault fault = new AxisFault("HTTP", "(" + returnCode + ")" + statusMessage, null, null); .... throw fault; ....
type: Question
has comment: http://stackoverflow.com/comment/33492923

http://stackoverflow.com/comment/33616534
score: 0
type: Comment
comment on: http://stackoverflow.com/q/22152632
type: QuestionComment
has text: What is the value of `(string.length() - 1);` ? Is `i <= 0` evaluated to true before starting the first iteration?

http://stackoverflow.com/comment/114591688
has text: everytime I try to use a .get() method on my ArrayList, it just returns gibberish. It doesn't return what Im actually looking for. How do I fix this?
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22023260

http://stackoverflow.com/comment/33589634
comment on: http://stackoverflow.com/q/22137283
has text: @Sushil I've added the logcat
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/22091681
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/22091488
score: 1
has body: The whole part after the .getClass() test can be rewritten as: return id == null ? other.id == null : id.equals(other.id); That is to say, Eclipse's default .equals() will generate code so that if an instance field can be null, it considers equality (for this field at least) true if the other instance's field is also null; otherwise it compares the values. (note that in the case where id is not null but other.id is, this will still work, since the .equals() contract stipulates that for any object o, o.equals(null) is false) Now, it may, or may not, suit your needs; but what Eclipse does here seems logical to me. Except that it generates code which is way too long ;) Note that it requires that the id field obeys the .equals() contract! Also, if you use Java 7, the code is even shorter: return Objects.equals(id, other.id);
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22091488

http://stackoverflow.com/q/22057801
answer count: 1
has body: I try to execute some sql during initialization with below script in my appContext.xml. But the sql can not be executed when using * char. I am using spring 4.0 and hibernate 4.0. Great thanks. &lt;jdbc:initialize-database data-source="dataSource" ignore-failures="ALL"&gt; &lt;jdbc:script location="classpath:sql/h2/schema-*.sql" /&gt; &lt;jdbc:script location="classpath:data/h2/import-data.sql"/&gt; &lt;/jdbc:initialize-database&gt;
type: UnansweredQuestion
tagged with: spring
has answer: http://stackoverflow.com/a/22058387
score: 0
tagged with: java
has title: jdbc:script can not be executed when using *
type: Question

http://stackoverflow.com/comment/50542034
has text: The smoking gun was I was using the soft float JDK and needed the hard float JDK.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/31215670
type: AnswerComment

http://stackoverflow.com/comment/33569995
comment on: http://stackoverflow.com/a/22126204
type: Comment
has text: So you are telling that ter is no standard format for Key flies. What if i want to send Public Key to some external application will it be that same.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33596390
comment on: http://stackoverflow.com/q/22141413
type: Comment
type: QuestionComment
has text: I guess for start, you do not want the answer to be input on every loop.
score: 0

http://stackoverflow.com/q/22089898
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22089933
tagged with: java
tagged with: methods
type: Question
has answer: http://stackoverflow.com/a/22089948
score: 0
has title: How can I extend a method that requires only a new parameter?
accepted answer: http://stackoverflow.com/a/22089948
has answer: http://stackoverflow.com/a/22089949
has answer: http://stackoverflow.com/a/22089968
possible better answer: http://stackoverflow.com/a/22089949
answer count: 4
has body: lets say we have such a method: public List&lt;Animal&gt; findByKeyword(String keyword){ List&lt;Animal&gt; animals = new ArrayList&lt;Animal&gt;(); // Validate keyword is not null etc.. // hit db for animals with name like keyword and add to list // hit db for animals with owner name like keyword and add to list // hit db for animals with nick name like keyword and add to list // remove duplicates in the list return animals; } Assume this method is used in quite a few places and assume it is a bit longer... Well now I want to add a simple boolean something like this: public List&lt;Animal&gt; findByKeyword(String keyword,boolean excludeDead){ // code here... } The only difference should be something like this: // remove duplicates in the list // if(excludeDead) removeDeadAnimalsFromTheList So I do not want to copy paste the whole method. But I do not want to add the parameter to the existing method either because the method is used in a lot of places ( where excludeDead = false by default.. Say that this is a new requirement.. ) But the thing is, I do not want to make this change: // remove duplicates in the list // if(excludeDead) removeDeadAnimalsFromTheList because I am unneccesarily loading all the dead Animals if exludeDead is true.. So what I want to do is to modify: // hit db for animals with name like keyword and add to list BASED ON THE GIVEN BOOLEAN VALUE What is the best way to extend such piece of code? Is there any way to make the parameter optional? Please do not assume this is a real code, I just tried to make it simple.

http://stackoverflow.com/q/22138460
possible better answer: http://stackoverflow.com/a/22138477
tagged with: replace
score: 0
answer count: 2
has title: Java String replace method doesn't replace my '\' with '/' File Finder class
has comment: http://stackoverflow.com/comment/33591881
has answer: http://stackoverflow.com/a/22138477
type: AnsweredQuestion
tagged with: file
type: Question
has body: my output has \. my expected output is: temp/F1.java temp/F2.java temp/subtemp/F3.java What's wrong?.................................................................................................................................................................................................................. public class FileFinder { public static void main(String[] args) throws IOException { File dir1 = new File("temp"); dir1.mkdir() ; File f1 = new File("temp/F1.java") ; f1.createNewFile() ; File f2 = new File("temp/F2.java") ; f2.createNewFile() ; File dir2 = new File("temp/subtemp") ; dir2.mkdir() ; File f3 = new File("temp/subtemp/F3.java") ; f3.createNewFile() ; find(dir1, ".java"); } /** Prints all files whose names end in a given extension. @param aFile a file or directory @param extension a file extension (such as ".java") */ public static void find(File aFile, String extension) { //-----------Start below here. To do: approximate lines of code = 10 // 1. if aFile isDirectory if (aFile.isDirectory()) { //2. use listFiles() to get an array of children files File[] children = aFile.listFiles(); //3. use sort method of Arrays to sort the children Arrays.sort(children); //4. for each file in the sorted children for (File child : children) { //5. recurse find(child, extension); } }// else {// //6. otherwise the file is not a directory, so //use toString() to get the file name String fileName = aFile.toString(); //7. use replace() to change '\' to '/' fileName.replace('\'' , '/'); //8. if the file name endsWith the extension if (fileName.endsWith(extension)) { //9. then print it. System.out.println(fileName); } } //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. } }
tagged with: java
has answer: http://stackoverflow.com/a/22138519
accepted answer: http://stackoverflow.com/a/22138519

ioexception
tags question: http://stackoverflow.com/q/22136137
tags question: http://stackoverflow.com/q/22165783
tags question: http://stackoverflow.com/q/22114126
tags question: http://stackoverflow.com/q/22077370
tags question: http://stackoverflow.com/q/22118184
tags question: http://stackoverflow.com/q/22092992
type: Tag
tag name: ioexception

http://stackoverflow.com/q/22062146
tagged with: jcalendar
has answer: http://stackoverflow.com/a/22062848
tagged with: java
tagged with: swing
has comment: http://stackoverflow.com/comment/33501194
type: Question
has title: jCalendar display trash in background
has comment: http://stackoverflow.com/comment/33471180
has answer: http://stackoverflow.com/a/42571954
score: 0
answer count: 2
has body: I have a JCalendar in a JPanel and a JList in another JPanel, but something happen in the month combobox, when I click in a JList item the background display a part of the JList item, like this: I'm on a Mac, I don't know if this is a nimbus look and a feel bug, or something. But a friend with Windows have the same issue. I'm using JCalendar v.1.4
type: UnansweredQuestion

http://stackoverflow.com/q/22060186
tagged with: java
tagged with: jasper-reports
has body: I want to customize my charts in reports (using JasperReports and iReport 4.5.0). I am using below code change Y-axis vertically but I want to write the value on X Axis vertically not the Y Axis. NumberAxis leftNumberAxis = (NumberAxis) catPlot.getRangeAxis(); leftNumberAxis.setVerticalTickLabels(true); How can I make that X-axis label read vertically?
type: AnsweredQuestion
has title: How can I make that X-axis label read vertically?
has answer: http://stackoverflow.com/a/22066029
type: Question
score: 0
accepted answer: http://stackoverflow.com/a/22066029
answer count: 1

http://stackoverflow.com/q/22034583
accepted answer: http://stackoverflow.com/a/25781380
upvote count: 2
tagged with: selenium
has body: I am intending to automate the charts displayed in qlikview pages with selenium.As such charts are accessed as image as a whole in these pages its getting difficult to interact &amp; locate specific elements/text on these charts. Qlikview Demo link:- http://ap.demo.qlik.com/QvAJAXZfc/opendoc.htm?document=qvdocs%2FRetail%20Omni-Channel%20Analytics.qvw&amp;host=Demo11&amp;anonymous=true Code to hover mouse over the chart:- Point coordinates = driver.findElement(By.xpath("//div[@id='68']/div[2]/div[2]/img")).getLocation(); Robot robot = new Robot(); robot.mouseMove(coordinates.getX(),coordinates.getY()); Thread.sleep(5000); Code to capture tooltip value:- String Tooltip = driver.findElement(By.xpath("//div[@class = 'QvHover']/span[2]")).getText(); System.out.println("Tooltip value:- "+Tooltip); Though I figured out a way to capture its tooltip value but other than this I'm unable to find ways to locate/capture other elements such as lables on the axis for line chart,legends,etc Any help would be appriciated
tagged with: selenium-webdriver
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/25781380
tagged with: java
type: Question
answer count: 1
downvote count: 0
tagged with: qlikview
favorite count: 0
tagged with: xpath
has title: Automating qlikview charts using selenium

http://stackoverflow.com/comment/33613916
comment on: http://stackoverflow.com/q/22151191
has text: Ternary operator has the following format (condition ? result when condition is true : result when condition is false). So here, we define the boolean a, then assign it the result of the ternary operator.
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/q/22017285
tagged with: hashset
has body: I'm trying to export a Hashset (integer) to file with the following code but it appears I can't use outputStream.write() to do it. There don't seem to be any previous questions here or on google that cover it which surprises me. Hashset is defined in the Activity as: HashSet&lt;Integer&gt; set = new HashSet&lt;Integer&gt;(); and Method is: public void savehashset(){ String filename="storedhashset.set"; File storedhashset = new File(getFilesDir(), filename); FileOutputStream outputStream; try { outputStream = openFileOutput(filename, Context.MODE_PRIVATE); outputStream.write(set); outputStream.close(); } catch (Exception e) { e.printStackTrace(); }
favorite count: 0
tagged with: android
accepted answer: http://stackoverflow.com/a/22017348
type: AnsweredQuestion
upvote count: 3
has answer: http://stackoverflow.com/a/22017401
type: Question
score: 3
has comment: http://stackoverflow.com/comment/33373804
tagged with: java
possible better answer: http://stackoverflow.com/a/22017401
has title: How to save Hashset to file in Android?
answer count: 2
has answer: http://stackoverflow.com/a/22017348
downvote count: 0

http://stackoverflow.com/comment/33554163
has text: I movedte Thread.sleep to where you have it and I still have the same problem when the max gets large (which what I am going to use it for max will be quite big) the program just freezes.
comment on: http://stackoverflow.com/a/22031159
score: 0
type: AnswerComment
type: Comment

collections
tags question: http://stackoverflow.com/q/22106428
tags question: http://stackoverflow.com/q/22123106
tags question: http://stackoverflow.com/q/22085129
tags question: http://stackoverflow.com/q/22037855
tags question: http://stackoverflow.com/q/22086982
tags question: http://stackoverflow.com/q/22129955
tags question: http://stackoverflow.com/q/22142731
tags question: http://stackoverflow.com/q/22050848
tags question: http://stackoverflow.com/q/22151968
tags question: http://stackoverflow.com/q/22138969
tags question: http://stackoverflow.com/q/22064044
tags question: http://stackoverflow.com/q/22022862
tags question: http://stackoverflow.com/q/22095401
tags question: http://stackoverflow.com/q/22141178
tags question: http://stackoverflow.com/q/22048819
tags question: http://stackoverflow.com/q/22147407
tags question: http://stackoverflow.com/q/22086153
type: Tag
tags question: http://stackoverflow.com/q/22041151
tags question: http://stackoverflow.com/q/22128298
tags question: http://stackoverflow.com/q/22087751
tags question: http://stackoverflow.com/q/22028199
tag name: collections
tags question: http://stackoverflow.com/q/22042750
tags question: http://stackoverflow.com/q/22156690
tags question: http://stackoverflow.com/q/22073619
tags question: http://stackoverflow.com/q/22021448
tags question: http://stackoverflow.com/q/22099153
tags question: http://stackoverflow.com/q/22067533
tags question: http://stackoverflow.com/q/22035337
tags question: http://stackoverflow.com/q/22117070

http://stackoverflow.com/comment/33637555
comment on: http://stackoverflow.com/q/22164247
score: 0
type: Comment
type: QuestionComment
has text: Running on the same machine, database is on a server, it just doesnt want to connect to it

http://stackoverflow.com/comment/33434587
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22050785
has text: Nobody can help you without knowing what line 30 is.
score: 0

http://stackoverflow.com/a/22051579
type: Answer
has comment: http://stackoverflow.com/comment/33435603
answers question: http://stackoverflow.com/q/22051345
score: 0
has body: Code just to give you an idea where to start: int a = 0; int b = 1; int n = 4; double fraction = (b - a) / (double) n; for (int i = 0; i &lt; n; ++i) { System.out.println("Lower bound: " + i * fraction + "; Upper bound: " + (i + 1) * fraction); }

http://stackoverflow.com/a/22149758
downvote count: 0
answers question: http://stackoverflow.com/q/22070894
has comment: http://stackoverflow.com/comment/104738916
type: Answer
has body: There are no explicitly specified "memory barriers" in spec of Java language or its standard libs. There is a Java Memory Model (JMM) which bases on "happens before" relationship. Of course, an implementation of JVM uses some memory barriers to implement JMM, but they are implementaion/hardware specific. See for instance: http://gee.cs.oswego.edu/dl/jmm/cookbook.html That article defines LoadLoad, LoadStore, StoreLoad, StoreStore abstract memory barriers (non-standard really, but widely used terminology) and describes how they can be implemented on specific hardware.
has comment: http://stackoverflow.com/comment/104745836
has comment: http://stackoverflow.com/comment/104739913
upvote count: 5
score: 5
has comment: http://stackoverflow.com/comment/104691034

http://stackoverflow.com/comment/33419636
has text: Seems to me like you don't want to fire one query, but two separate ones since you want to keep the results apart in stead of throwing them on one big pile. You might select an additional column, 'source' or something, in which you stick a value which identifies where the record came from. select 'blog' AS source.
comment on: http://stackoverflow.com/q/22042741
type: Comment
type: QuestionComment
score: 1

http://stackoverflow.com/comment/33495706
type: Comment
has text: Make the value a list of the desired type. Then add to it as you wish.
type: QuestionComment
comment on: http://stackoverflow.com/q/22085129
score: 0

http://stackoverflow.com/a/22143200
has body: Here is a simple explanation of what you need: http://www.mkyong.com/hibernate/different-between-session-get-and-session-load/ Or by looking at the API: http://docs.jboss.org/hibernate/orm/4.3/javadocs/ with get : Return the persistent instance of the given named entity. The persistent one, so the one stored in the database. with load: Read the persistent state associated with the given identifier into the given transient instance. In the first link you find very useful examples to test the differences..
score: 0
type: Answer
answers question: http://stackoverflow.com/q/22142920

http://stackoverflow.com/a/22145556
has body: Runnable is an interface in Java representing a type that defines a run method. A class that implements Runnable interface must provide the implementation for it. Thread is a well-known Runnable. From the docs: Causes doRun.run() to be executed asynchronously on the AWT event dispatching thread. This will happen after all pending AWT events have been processed. This method should be used when an application thread needs to update the GUI. In the following example the invokeLater call queues the Runnable object doHelloWorld on the event dispatching thread and then prints a message. If invokeLater is called from the event dispatching thread -- for example, from a JButton's ActionListener -- the doRun.run() will still be deferred until all pending events have been processed.
type: Answer
has comment: http://stackoverflow.com/comment/33603277
answers question: http://stackoverflow.com/q/22145515
score: 0

http://stackoverflow.com/q/22043411
tagged with: spring-mvc
tagged with: java
has body: We can validate input parameters via @Valid annotation before any param, like this: @RestController // new spring 4 annotation public class ApplicationServiceApiV1Controller { @RequestMapping(value = "/response") public SomeResponse getResponse(@Valid SampleInputParam request) { return new SomeResponse(); } } SampleInputParam own fields can be annotated with any javax.validation.constraints.* annotation and those values will be validated. If validation fail, client receives 400 or 406 http status. Is it possible to validate response as described above? I didn't find that usages with spring-mvc.
type: Question
tagged with: validation
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/33429635
score: 2
answer count: 0
upvote count: 2
type: UnansweredQuestion
has title: Is it possible to automatically validate RestController (via Spring MVC) methods response?

http://stackoverflow.com/comment/33610984
type: Comment
has text: so your sort works, but the problems is you want to print the larges, smallest and the number in the middle of the array?
score: 0
comment on: http://stackoverflow.com/q/22149615
type: QuestionComment

http://stackoverflow.com/comment/33521921
type: Comment
comment on: http://stackoverflow.com/a/22099693
type: AnswerComment
has text: It should be the tomcat directory. ../tomcat/webapps/App...but you don't need to hardcode the path. Try ServletContext.getResourceAsStream("yourfile") or String path = context.getRealPath("/")+"yourfile";
score: 0

http://stackoverflow.com/comment/33519485
comment on: http://stackoverflow.com/q/22098667
has text: FFFF_FFFF_FFFF_FFFF = -1L
type: Comment
type: QuestionComment
score: 1

http://stackoverflow.com/q/22012143
has title: HttpSession and JBoss. What is the effect of the session timing out?
has answer: http://stackoverflow.com/a/22012554
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/22012830
has answer: http://stackoverflow.com/a/22012234
tagged with: servlets
score: 0
answer count: 3
tagged with: httpsession
type: UnansweredQuestion
has body: Some code I have inherited creates a session with this line: HttpSession session = req.getSession(); //req is an instance of HTTPServletRequest In the config for the app the value for session-config is set to 10 (minutes). After that about the only use of the session is to get the session id: String sid = req.getSession().getId(); and to invalidate it: req.getSession().invalidate(); The session isn't used for storing user data. That is all done by Perl scripts in a database table just using the sid created by HttpSession as the identifier. (A bit of a monster of an application). So. My question is given the timeout setting I would expect something to fail. At least the line: String sid = req.getSession().getId(); would return an empty string after 10 minutes? However it all seems to continue quite happily despite the timeout setting of 10 minutes. Why is this? with thanks --Justin Wyllie

http://stackoverflow.com/comment/33364902
has text: Yes, as far as I know! I'm just calling all I already said, but I'm afraid I'm not so familiar with update, paint and so on, since they are almost all given by the api. I'm just using this update, as I was using the paint and repaint before. But I don't know wether the api is calling any method for GUI drawing on a synchronous way and I make it stop by calling my update, or whatever. I just have some controled "events" which change for example a boolean and when this boolean is changed I call the entity.draw(g) method which does something like g.drawImage(image,locationx,locationy,null).
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22011588
type: AnswerComment

http://stackoverflow.com/q/22043994
type: AnsweredQuestion
score: -2
has comment: http://stackoverflow.com/comment/33422130
tagged with: java
tagged with: substring
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/33421635
accepted answer: http://stackoverflow.com/a/22044282
has answer: http://stackoverflow.com/a/22044309
tagged with: string
favorite count: 0
has title: Stack overflow error during recursive String operation
has answer: http://stackoverflow.com/a/22044282
has comment: http://stackoverflow.com/comment/33421572
downvote count: 3
possible better answer: http://stackoverflow.com/a/22044309
upvote count: 1
tagged with: methods
has body: I'm trying to recursively add a dash in between of a string but it's not working, and it's giving me a stack overflow error. Here's my code: public static String expand (String word) { int stringLength = word.length (); String expandedWord = word; if (stringLength &lt;= 1) { return expandedWord; } else { expandedWord = word.substring (0, (stringLength - stringLength) + 1) + "-" + word.substring ((stringLength - stringLength) + 1, stringLength); stringLength++; expand(word); return expandedWord; } }

http://stackoverflow.com/a/22020771
type: Answer
upvote count: 4
score: 4
has body: You can use the HDFS API, this can be run from local.: Configuration configuration = new Configuration(); configuration.set("fs.defaultFS", "hdfs://namenode:8020"); FileSystem fs = FileSystem.get(configuration); Path filePath = new Path( "hdfs://namenode:8020/PATH"); FSDataInputStream fsDataInputStream = fs.open(filePath);
downvote count: 0
answers question: http://stackoverflow.com/q/22020286

http://stackoverflow.com/comment/79505200
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22019452
has text: https://stackoverflow.com/help/how-to-ask
score: 0

http://stackoverflow.com/q/22076183
tagged with: jpanel
score: 0
answer count: 1
tagged with: layout-manager
has answer: http://stackoverflow.com/a/22076237
tagged with: jlabel
type: AnsweredQuestion
has title: JLabel positioning into JPanel
accepted answer: http://stackoverflow.com/a/22076237
tagged with: swing
type: Question
has body: I have this code written to make a database connection and add a client: //adding the left panel JPanel left = new JPanel(); left.setPreferredSize(new Dimension(250, 500)); left.setLayout(new BoxLayout(left, BoxLayout.Y_AXIS)); add(left); //adding the right panel JPanel right = new JPanel(); right.setPreferredSize(new Dimension(250, 500)); right.setLayout(new BoxLayout(right, BoxLayout.Y_AXIS)); add(right); //adding the jlabel title to the left panel JLabel leftTitle = new JLabel("Add a client"); leftTitle.setAlignmentX(CENTER_ALIGNMENT); left.add(leftTitle); //adding the jlabel title to the right panel JLabel rightTitle = new JLabel("Make a reservation"); rightTitle.setAlignmentX(CENTER_ALIGNMENT); right.add(rightTitle); //adding the jlabel "name" JLabel nameL = new JLabel("Name:"); left.add(nameL); and I want to move this JLabel here: I've tried doing nameL.setAlignmentX(LEFT_ALIGNMENT); but it's still not working
tagged with: java

http://stackoverflow.com/comment/33432572
type: Comment
has text: follow https://issues.jboss.org/browse/JBDS-2865 and https://issues.jboss.org/browse/JBIDE-15476 - its new main feature in next version of openshift tools for eclipse.
score: 1
comment on: http://stackoverflow.com/a/22049668
type: AnswerComment

http://stackoverflow.com/q/22161967
has comment: http://stackoverflow.com/comment/42167038
has answer: http://stackoverflow.com/a/26819750
tagged with: java
tagged with: nio
type: Question
answer count: 3
has comment: http://stackoverflow.com/comment/42349742
linked to: http://stackoverflow.com/q/9465451
has comment: http://stackoverflow.com/comment/42213992
downvote count: 1
tagged with: disk
has comment: http://stackoverflow.com/comment/42157010
favorite count: 0
possible better answer: http://stackoverflow.com/a/26771479
has title: Accessing Windows disks directly with Java NIO
linked to: http://stackoverflow.com/q/2108313
has answer: http://stackoverflow.com/a/26771479
has comment: http://stackoverflow.com/comment/42158451
score: 8
upvote count: 9
has comment: http://stackoverflow.com/comment/42156993
accepted answer: http://stackoverflow.com/a/26819750
has answer: http://stackoverflow.com/a/26771927
has body: I am using a library that uses Java NIO in order to directly map files to memory, but I am having trouble reading disks directly. I can read the disks directly using FileInputStream with UNC, such as File disk = new File("\\\\.\\PhysicalDrive0\\"); try (FileInputStream fis = new FileInputStream(disk); BufferedInputStream bis = new BufferedInputStream(fis)) { byte[] somebytes = new byte[10]; bis.read(somebytes); } catch (Exception ex) { System.out.println("Oh bother"); } However, I can't extend this to NIO: File disk = new File("\\\\.\\PhysicalDrive0\\"); Path path = disk.toPath(); try (FileChannel fc = FileChannel.open(path, StandardOpenOption.READ)){ System.out.println("No exceptions! Yay!"); } catch (Exception ex) { System.out.println("Oh bother"); } The stacktrace (up to the cause) is: java.nio.file.FileSystemException: \\.\PhysicalDrive0\: The parameter is incorrect. at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102) at sun.nio.fs.WindowsFileSystemProvider.newFileChannel(WindowsFileSystemProvider.java:115) at java.nio.channels.FileChannel.open(FileChannel.java:287) at java.nio.channels.FileChannel.open(FileChannel.java:334) at hdreader.HDReader.testcode(HDReader.java:147) I haven't been able to find a solution, though I saw something close on How to access specific raw data on disk from java. The answer by Daniel Alder suggesting the use of GLOBALROOT seems to be relevant, as the answer uses FileChannel in the answer, but I can't seem to find the drive using this pattern. Is there a way to list all devices under GLOBALROOT or something like that? At the moment I am looking at replacing uses of NIO with straight InputStreams, but I want to avoid this if I can. Firstly, NIO was used for a reason, and secondly, it runs through a lot of code and will require a lot of work. Finally, I…
tagged with: unc
has comment: http://stackoverflow.com/comment/42212922
has comment: http://stackoverflow.com/comment/42214244
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/42157145
tagged with: drive

http://stackoverflow.com/comment/33370077
comment on: http://stackoverflow.com/a/22008972
score: 1
type: AnswerComment
type: Comment
has text: I thought it was relevant insofar as *"You would put the Look and Feel in the **class path**"* for time of deployment, as oppose to development. After all, you don't develop apps. just for you, right? You don't expect the end user to download Eclipse to run the app.? It is at *that* (later, but inevitable) stage that JWS becomes the best way to add a PLAF to the (deployment-time) *class-path,* which really does seem core to the question. +1 for adding the tag. :)

http://stackoverflow.com/a/22105581
has comment: http://stackoverflow.com/comment/33533000
type: Answer
answers question: http://stackoverflow.com/q/22105296
score: 0
has body: I'm assuming you're using Eclipse and in an introductory programming course. An important subject often overlooked in programming courses is how to use a debugger to help you troubleshoot problems. If any of your classmates, lab assistants, or fellow students further along in your major can take 15-30 minutes to sit down and show you how to use the debugger, it will help you through the rest of your programming career. If not, there are a lot of tutorials you can follow to get familiar with Eclipse's debugger. To start off, double-click along the left of your code, usually just left of the line numbers. This will add a break point, which will pause your program when it reaches. Add a break point at each of your methods besides main and make sure that all the methods you think should be called are actually called. When your program is at a break point, you can also take a look at the value of variables in the "Variables" view. If one of them has an unexpected value, you may have found your culprit. There is a resume button you'll have to hit to resume program execution when you're done at a given break point. It should be next to the Pause and Stop buttons in the top bar by default, and is easy to confuse with the Run button.
has comment: http://stackoverflow.com/comment/33532911

http://stackoverflow.com/a/25110179
has comment: http://stackoverflow.com/comment/68364241
upvote count: 42
has comment: http://stackoverflow.com/comment/136746707
type: AcceptedAnswer
downvote count: 0
score: 42
has comment: http://stackoverflow.com/comment/69377426
accepted answer of: http://stackoverflow.com/q/22047860
has comment: http://stackoverflow.com/comment/41290834
has comment: http://stackoverflow.com/comment/68365092
type: Answer
has comment: http://stackoverflow.com/comment/59121533
has comment: http://stackoverflow.com/comment/91580962
has comment: http://stackoverflow.com/comment/57594601
has body: If you are using maven, you can use this command mvn tomcat:run, but first you add in your pom.xml this structure into build tag, just like this: mvn-webapp-test org.apache.maven.plugins maven-compiler-plugin ${maven.compiler.plugin.version} 1.6 1.6
answers question: http://stackoverflow.com/q/22047860

http://stackoverflow.com/a/22040111
answers question: http://stackoverflow.com/q/22039569
upvote count: 1
downvote count: 0
has body: You must know that a servlet container can / will re-use threads for requests so if you do use ThreadLocals, you'll need to clean up after yourself once the request is finished (perhaps using a filter)
type: Answer
has comment: http://stackoverflow.com/comment/112989433
has comment: http://stackoverflow.com/comment/33419923
score: 1

http://stackoverflow.com/a/22062715
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/33462735
answers question: http://stackoverflow.com/q/22062019
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/22062019
type: Answer
has comment: http://stackoverflow.com/comment/33463555
has body: Your code doesn't work as it is, it will iterate forever over the node 39. The method inOrderTraversal() will indeed go to the left node, but will cycle over it forever because of the while. Each stack frame has it's own copy of the variables. When entering the method, variable node gets a copy of the object reference passed as argument. One way to think about recursion is that is similar to using a while loop, but instead of while, you have an if. Here's how the method should look like: public void inOrderTraversal(Node node) { if (node != null) { inOrderTraversal(node.left); System.out.println(node.data); inOrderTraversal(node.right); } } When you traverse the tree, you want to print first the smaller value, which is stored in left most node, so you use inOrderTraversal(node.left); to get to if. When you arrive at a null node, this means it's parent is the left-most node, so you print it. After that you go to the right node and repeat the process. It's like splitting the tree in smaller sub trees until you can't divide them any more and print their value. Each time you call a method (recursive or not), a new stack frame is allocated (push onto the stack) and after the method finishes, the stack is removed (pop), freeing the space for garbage collection. These stacks frames are only a temporary space where local variables live. The object member variables live in another place called the heap which has a longer life duration than the stack. The JVM handles the allocation of these spaces and the garbage collector frees them depending on the life of objects/variables. Depending on how much they live, there are a few generations (that's what they are called). All start on the eden (young) generation and if the garbage collector doesn't reclaim the space since they are still alive, they are moved to the survivor generation, after which if they still aren't collected, they move to the last one, the tenured generation. The longer the objects live, the rarer they are chec…

http://stackoverflow.com/comment/33659445
type: QuestionComment
type: Comment
score: 2
comment on: http://stackoverflow.com/q/22121694
has text: Making this static doesn't seem like the right approach. Rather try passing around the spritebatch to share it

http://stackoverflow.com/comment/33425754
type: QuestionComment
has text: Have you used some tool to have a look at the real response sended by the server (have had a look at the redirects)? - What was the response?
type: Comment
comment on: http://stackoverflow.com/q/22046180
score: 0

http://stackoverflow.com/comment/33508951
has text: You read a stack trace from the beginning. You first have the exception type and message, and the location where it's thrown: Integer.parseInt(Integer.java:417) . This method is called by the Integer constructor, in Integer.java:660. This constructor is called by CookieUsageServlet.getCookie(CookieUsageServlet.java:39). And this is your own class.
score: 0
comment on: http://stackoverflow.com/q/22091577
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33502853
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22088984
has text: Please explain what you did

http://stackoverflow.com/comment/33600338
comment on: http://stackoverflow.com/q/22099945
score: 0
type: Comment
type: QuestionComment
has text: I did try that but it still produces the same effect "Out: null". In the logs I do see it correlate the returned message later.

http://stackoverflow.com/comment/33574644
has text: Well, the exception raised, because the application was not able to deserialize the object with the wrong serialization-id. So the data stream seems corrupted and was unreadable
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22127128
type: AnswerComment

http://stackoverflow.com/comment/33532581
score: 0
comment on: http://stackoverflow.com/q/22103622
has text: *sign a document using a X.509 certificate?* - a certificate in essence is a wrapper for a public key, but to sign a document you need to apply the private key located on the smart card.
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22133590
linked to: http://stackoverflow.com/q/13603445
downvote count: 1
has comment: http://stackoverflow.com/comment/33584198
type: Question
has comment: http://stackoverflow.com/comment/33584190
has comment: http://stackoverflow.com/comment/33583518
has comment: http://stackoverflow.com/comment/33583883
score: 0
has comment: http://stackoverflow.com/comment/33584096
has body: I want my program to execute the first return statement if the conditions are true otherwise return it as normal. import java.util.Scanner; public class Untitled { public static void main(String[] args) { Scanner input = new Scanner(System.in); int x = input.nextInt(); int y = input.nextInt(); int answer = x + y; if (x == y) { System.out.println("These two numbers are the same and they equal: " + answer); return answer; } System.print.ln("These two numbers are not the same, but they equal: " + answer); return answer; } }
has comment: http://stackoverflow.com/comment/33583492
answer count: 4
favorite count: 0
has comment: http://stackoverflow.com/comment/33583570
has answer: http://stackoverflow.com/a/22133817
has comment: http://stackoverflow.com/comment/33583802
has comment: http://stackoverflow.com/comment/33583761
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22133868
has comment: http://stackoverflow.com/comment/33583507
has comment: http://stackoverflow.com/comment/33584205
upvote count: 1
has comment: http://stackoverflow.com/comment/33583832
has comment: http://stackoverflow.com/comment/33583823
has comment: http://stackoverflow.com/comment/33583875
has title: How can I return a statement in this program correctly?
has comment: http://stackoverflow.com/comment/33583491
has answer: http://stackoverflow.com/a/22133806
has answer: http://stackoverflow.com/a/22133853
tagged with: java

http://stackoverflow.com/comment/33463766
type: AnswerComment
has text: also, why delete the follow-up question explaining about you're database setup?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22067554

http://stackoverflow.com/q/22091689
has comment: http://stackoverflow.com/comment/33507500
has comment: http://stackoverflow.com/comment/33507000
has comment: http://stackoverflow.com/comment/33507471
score: 0
has body: I'm suffering this exception when run a instrumentation test: INSTRUMENTATION_RESULT: shortMsg=android.content.res.Resources$NotFoundException INSTRUMENTATION_RESULT: longMsg=android.content.res.Resources$NotFoundException: String resource ID #0x7f020001 I'm sure the resource exists! My project structrue: a user proj A, and a lib project B (apklib). In project B, I defined resource file B-project/res/values/strings.xml: <?xml version="1.0" encoding="utf-8"?> my app release Poject A depends on project B, and in project A, I override some properties (in A-project/res/values/strings.xml) defined in B: <?xml version="1.0" encoding="utf-8"?> For demo When packaging project A, things become stranger: In project A's generated resource, I found R.java: public final class R { public static final class attr { } public static final class string { public static int app_name=0x7f020000; public static int branding=0x7f020001; } } I also found a R.txt in the target dir (I was using maven to manage the project): int drawable icon 0x7f020000 int string app_name 0x7f030000 int string branding 0x7f030001 Error: R.branding is 0x7f020001, but the real resource id is: 0x7f030001! I think that's why I got the Resources$NotFoundException, But I've tried to clean and and re-compile the project many times, still got the same issue.
answer count: 1
has comment: http://stackoverflow.com/comment/33507129
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22092226
tagged with: android
tagged with: android-maven-plugin
has title: stranger exception: android.content.res.Resources$NotFoundException
tagged with: java
has comment: http://stackoverflow.com/comment/33507167
has comment: http://stackoverflow.com/comment/33507184
type: Question

http://stackoverflow.com/comment/33503859
type: Comment
type: QuestionComment
score: 0
has text: The question would be much nicer if the code you posted was actually focused on the problem. Where do I find the pieces that deal with blocking `+91` but not without?
comment on: http://stackoverflow.com/q/22089554

http://stackoverflow.com/q/22110106
has body: I am using JOptionPane to make a menu that calls and executes program separately (the applet and menu are not required, i'm just doing it to make it better). I tried to call the init() method but it says "non-static method init() cannot be referenced from a static statement." The applet is used to play a song Code: First Program: * import javax.swing.JOptionPane; public class MexicoProject { public static void main(String[] args) { String[] choice = {"History", "Trivia", "Intro", "Anthem", "Quit"}; String Menu; do { Menu = (String)JOptionPane.showInputDialog(null, "Welcome, this program will teach you about the history of Mexico.\nPick one of the options below.", "Mexico History", JOptionPane.QUESTION_MESSAGE, null, choice, choice[0]); if (Menu == null) JOptionPane.showMessageDialog(null, "Pick something!"); else { switch (Menu) { case "History": MexicoHistory.History(); break; case "Trivia": Quiz(); break; case "Intro": FrenchIntro.Intro(); break; case "Anthem": MexicoAnthem.Init(); break; case "Quit": JOptionPane.showMessageDialog(null, "Goodbye!"); break; default: JOptionPane.showMessageDialog(null, "Something went wrong! Try again!"); } } } while (Menu != "Quit"); } public static void History() { } public static void Quiz() { } }* Second Program: import java.applet.*; import java.net.*; public class MexicoAnthem extends Applet { Button button; public void Init() { BorderLayout layout = new BorderLayout(); setLayout(layout); Font font = new Font("TimesRoman", Font.BOLD, 32); setFont(font); button = new Button("Play Sound"); add("Center", button); resize(250, 250); } public boolean action(Event evt, Object arg) { if (evt.target instanceof Button) { URL codeBase = getCodeBase(); play(codeBase, "MexicanNationalAnthem.wav"); } return true; } }
tagged with: java
has answer: http://stackoverflow.com/a/22110159
has title: How do i call this Applet in this program?
type: Question
answer count: 2
tagged with: applet
score: 0
has comment: http://stackoverflow.com/comment/33542080
has comment: http://stackoverflow.com/comment/33542129
has comment: http://stackoverflow.com/comment/33542301
has answer: http://stackoverflow.com/a/22123704
tagged with: joptionpane
tagged with: javasound
type: UnansweredQuestion
tagged with: swing
has comment: http://stackoverflow.com/comment/33540731

http://stackoverflow.com/comment/33554212
type: QuestionComment
comment on: http://stackoverflow.com/q/22080452
score: 0
type: Comment
has text: Look on your disk for the bin directory. In any case that error seems to come up when the super class can not be found. There are several stack exchange questions related to "the hierarchy of type x is inconsistent".

http://stackoverflow.com/a/22059851
score: 2
has body: You can try using a StringBuilder: public String toString() { StringBuilder sb = new StringBuilder(); for(int i = 0; i &lt; planets.length; i++){ sb.append(planets[i].getName()); // getName() or toString() sb.append("\n"); } return sb.toString(); }
answers question: http://stackoverflow.com/q/22059802
downvote count: 0
upvote count: 2
type: Answer

http://stackoverflow.com/a/22117465
score: 0
type: Answer
has body: Based on the MySQLNonTransientConnectionException I'm going to bet that the MySQL wait_timeout variable on the DB is very short and you are losing the connection EM is attempting to access. One way around this is to use a Connection pool on your Glassfish server and let it control the DBConnections instead of EclipseLink. As a nice side effect it should be more preformative.
answers question: http://stackoverflow.com/q/22117210
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22117210

http://stackoverflow.com/comment/33364375
type: QuestionComment
comment on: http://stackoverflow.com/q/22011757
has text: on Junit in a test marked with '@Test' and '@Transactional' I call Product product1saved = productService.getProduct(product1.getProductId());
score: 0
type: Comment

xa
tags question: http://stackoverflow.com/q/22072100
tag name: xa
tags question: http://stackoverflow.com/q/22052464
type: Tag

http://stackoverflow.com/comment/33637912
has text: You have declared a persistence unit but you haven't defined the data source which it uses. That is: you've configured Hibernate, but not the Postgres connection. See https://docs.jboss.org/author/display/WFLY8/DataSource+configuration
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22149635

http://stackoverflow.com/a/22112155
answers question: http://stackoverflow.com/q/22112064
type: Answer
accepted answer of: http://stackoverflow.com/q/22112064
score: 2
downvote count: 0
has body: After looking at the website, The word you need "Open" is in a "h1" child element under the "main-campus-status" div element, hence what you need to do is get the text of the "h1" element, and you can do it like this: Element burnabyStatus = doc.getElementsByClass("main-campus-status").first(); Elements h1 = burnabyStatus.select("h1"); burnabyStatus = h1.get(0); String b_status = burnabyStatus.text(); TextView tv_b_status = (TextView) findViewById(R.id.b_status); tv_b_status.setTypeface(tf, Typeface.BOLD); tv_b_status.setText(b_status); The lines I've added are: Elements h1 = burnabyStatus.select("h1"); burnabyStatus = h1.get(0); Which selects all h1 elements under the "main-campus-status" div which when you call "text()" will only get you "Open" or "Closed".
upvote count: 2
type: AcceptedAnswer

http://stackoverflow.com/a/22065067
has comment: http://stackoverflow.com/comment/33458987
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33458901
has comment: http://stackoverflow.com/comment/33459328
has comment: http://stackoverflow.com/comment/33459143
has comment: http://stackoverflow.com/comment/33459319
type: Answer
accepted answer of: http://stackoverflow.com/q/22064841
has comment: http://stackoverflow.com/comment/33458819
answers question: http://stackoverflow.com/q/22064841
has comment: http://stackoverflow.com/comment/33458721
has comment: http://stackoverflow.com/comment/33459084
has body: What is inside your Login() ? Login myLogin = new Login(); pls log and check if myLogin object has the url. String encoded = UrlEncoder.encode(url,"UTF-8"); should be: String encoded = URLEncoder.encode(url,"UTF-8"); If you have declared it as a variable, then is it initialized properly. Pls check if you are getting the same error with URLEncoder (when used directly, no variable)
score: 0

http://stackoverflow.com/comment/33597210
score: 0
has text: @Balthazarion Yeah, you're right changing the answer to fit a more general sense.
type: Comment
comment on: http://stackoverflow.com/a/22140850
type: AnswerComment

http://stackoverflow.com/a/22055208
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/33446405
accepted answer of: http://stackoverflow.com/q/22054873
upvote count: 2
answers question: http://stackoverflow.com/q/22054873
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33446657
has body: A couple things: If you're going to define bounds for a generic type (e.g. T extends Number) you have to do it where the type is declared (e.g. not &lt;T&gt; Function... but &lt;T extends Number&gt; Function...). I see Louis has already covered this. I'm not sure it's really possible to implement a single function that can sum any type of Number, though you could come reasonably close I suppose. You'd have to take into consideration the possibility of numbers that are larger than any of the built in primitive types can represent (BigInteger, BigDecimal, and even possibly custom Number subclasses). Your method doesn't really need to a type parameter at all if your function returns Double. It can just be: Function&lt;List&lt;? extends Number&gt;, Double&gt; sum = new Function&lt;List&lt;? extends Number, Double&gt;() { public Double apply(List&lt;? extends Number&gt; numbers) { // the main code } }
type: Answer

http://stackoverflow.com/comment/33583519
comment on: http://stackoverflow.com/a/22133362
score: 0
type: AnswerComment
has text: Unfortunately not one of those works on ubuntu, even hardcoding the path to /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so, and removing openjdk-7-dbg and installing openjdk-7-jdk-dbgsym. Meanwhile i opened a bug report https://bugs.launchpad.net/ubuntu/+source/openjdk-7/+bug/1286895
type: Comment

http://stackoverflow.com/comment/33593846
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/22041067
has text: You want to exclude `fq` on need basis, right? Can you control the passing of parameters to the query?

http://stackoverflow.com/comment/33355706
comment on: http://stackoverflow.com/a/22006170
type: AnswerComment
score: 0
type: Comment
has text: @Rips Yes, space can be freed in the permanent generation after undeploying an app, but the details are heavily dependent on which garbage collector you’re using for the old generation. The [permanent generation is gone now anyway](http://openjdk.java.net/jeps/122) with Java 8.

http://stackoverflow.com/a/22102427
score: 0
answers question: http://stackoverflow.com/q/22102248
has body: I wouldn't recommend using any of the two for configuration purposes. The difference between these two are just that one uses an instance to hold the values, the other uses static variables. You might look into having a configuration class that utilises a ResourceBundle to load the values from a .properties file during initialisation.
has comment: http://stackoverflow.com/comment/33526613
type: Answer

xbrl
tag name: xbrl
tags question: http://stackoverflow.com/q/22017149
type: Tag

http://stackoverflow.com/a/22093823
has body: I have two comments for your code: As fge has said, args in Main function has the type of array, not String, you should access the args like this, args_0 = args[0], something like this. I didn't check that, but I think that Java will regard '-D' prompt as an args, in other words, the args in your program should has two parameters, args[0] = "-D" and args[1] = "1". Comment here: package testJawka; public class VarArgsDemo { public static void main(String[] args) { if (args.length &gt; 0) { if (args[0].equals("1")) { System.out.println("test 1"); } else if (args[0].equals("2")) { System.out.println("test 2"); } } } } And use the command "java -jar test.jar 1", should work, try it. Just in case you may have the path and package problems: Suppose you put your project "testJawka" under directory "C:\tmp". You should access in "c:\tmp\testJawka", open comman line: c:\tmp\testJawka&gt;javac VarArgsDemo.java This should generate the .class file "VarArgsDemo.class" under "c:\tmp\testJawka". Then you can just execute the program in command line, but remember change your directory to "c:\tmp", in command line: c:\tmp&gt;java testJawka.VarArgsDemo 1 If you want to generate the executable jar file, go to directory "c:\tmp", in command line: c:\tmp&gt;jar -cef testJawka.VarArgsDemo test.jar testJawka This will generate the test.jar file under directory "c:\tmp". Then in directory "c:\tmp", execute the jar file in command line: java -jar test.jar 1 Hope it will be useful for you.
has comment: http://stackoverflow.com/comment/33511707
score: 0
answers question: http://stackoverflow.com/q/22093274
has comment: http://stackoverflow.com/comment/33512631
type: Answer
has comment: http://stackoverflow.com/comment/33510666

http://stackoverflow.com/a/71439110
has body: I'm a Android developer, got this error when I upgraded the compile and build tool to Android 12 (31), I tried lots of ways to fix it and finally I found the only way that works is changing the JDK to the version of 11.0.14.1 (x86_64), I worked on Mac M1, the downloading link of this version is: https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/downloads-list.html
answers question: http://stackoverflow.com/q/22160780
score: 0
type: Answer

faceted-search
tag name: faceted-search
type: Tag
tags question: http://stackoverflow.com/q/22041067

http://stackoverflow.com/comment/33522170
type: AnswerComment
comment on: http://stackoverflow.com/a/22082640
score: 0
type: Comment
has text: i used the `@MangedProperty` to share the MangedBean e.g. the methods. This works fine!. My new Prolbem is to share the class. You write i must use the session context. Can i use a Syntax like `@MangedProperty` für my TestClass to get the variable in the secon managed bean?

http://stackoverflow.com/comment/33623652
has text: Would you post the Doctor code (and the mapping if it´s needed)?
comment on: http://stackoverflow.com/q/22156424
score: 0
type: QuestionComment
type: Comment

disk
tags question: http://stackoverflow.com/q/22161967
type: Tag
tag name: disk

http://stackoverflow.com/q/22101439
has body: Having the following two classes: class1 int a = 10; public void Main(String[] args){ System.out.println(a); // will print "10" class2 c2 = new class2(); class2.ChangeValue(a); System.out.println(a); // will print "10" even after the value has // been set to 20 in the other class } class2 public void ChangeValue(int a){ a = 20; System.out.println(a) // will print "20" } the question is, how do I make this value be 20 in all classes and not just the class that changed it.
has answer: http://stackoverflow.com/a/22101496
favorite count: 0
has answer: http://stackoverflow.com/a/22101776
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22101537
upvote count: 1
has answer: http://stackoverflow.com/a/22101698
has comment: http://stackoverflow.com/comment/33524652
has answer: http://stackoverflow.com/a/22101706
tagged with: java
downvote count: 1
has title: how do i change a variable in an others class that will change its value in all class in java
type: Question
tagged with: variables
tagged with: class
score: 0

http://stackoverflow.com/a/22039713
upvote count: 2
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22039528
has body: This is simplest solution that get on my mind, did you try it? public static double eTwo(double x, long n){ if(n==0) return 1; else return eTwo(x,n-1) + Math.pow(x, n)/factorial(n); } public double factorial (n){ if(n==0) return 1; else return n*factorial(n-1); }
answers question: http://stackoverflow.com/q/22039528
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/a/22167840
downvote count: 0
has body: Try to prefix that your Drawer layout with the corresponding lib, because there is may be a conflict when you import your lib (I had this pb when I tryed to implement FragmentManager) android.support.v4.widget.DrawerLayout myDrawer = ...
type: Answer
answers question: http://stackoverflow.com/q/22167682
score: 1
upvote count: 1

http://stackoverflow.com/comment/33468934
has text: @MarkRowlands: Exactly
score: 0
comment on: http://stackoverflow.com/q/22070709
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33435915
comment on: http://stackoverflow.com/q/22051816
type: Comment
type: QuestionComment
has text: what's a stacktrace? xD thanks for the help :)
score: 0

http://stackoverflow.com/comment/33601475
type: QuestionComment
comment on: http://stackoverflow.com/q/22142107
has text: I updated the question. I use Spring 4.0.2.
score: 0
type: Comment

wait
tags question: http://stackoverflow.com/q/22103807
tag name: wait
tags question: http://stackoverflow.com/q/22054867
type: Tag
tags question: http://stackoverflow.com/q/22113681
tags question: http://stackoverflow.com/q/22057465
tags question: http://stackoverflow.com/q/22147265
tags question: http://stackoverflow.com/q/22066619

http://stackoverflow.com/comment/33354382
type: Comment
has text: what Time means ?? is it a class.. u can use SimpleDateFormat
comment on: http://stackoverflow.com/q/22006161
score: 0
type: QuestionComment

http://stackoverflow.com/a/22117792
upvote count: 1
score: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/33556549
has body: Use a Custom HashMap. Map your indexes with the appropriate boolean values using that. Here's an example of such custom hash map: import java.util.HashMap; public class IndexMap extends HashMap&lt;Integer, Boolean&gt; { private static final long serialVersionUID = 7891095847767899453L; @Override public Boolean get(Object key) { if (containsKey(key)) return super.get(key); return false; } } And here's a demonstration of such map: public class Demo { public static void main(String[] args) { IndexMap map = new IndexMap(); map.put(5, true); map.put(73, true); System.out.println(map.get(73)); // Prints true. System.out.println(map.get(52)); // Prints false. } }
has comment: http://stackoverflow.com/comment/33555773
type: Answer
has comment: http://stackoverflow.com/comment/33554151
answers question: http://stackoverflow.com/q/22117741
has comment: http://stackoverflow.com/comment/33554127

http://stackoverflow.com/comment/33567769
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22125026
has text: nope it didnt work, it still colored all the cells in that row light green :( maybe there's something wrong with the conditions, but i cant seem to spot the mistake
type: Comment

http://stackoverflow.com/comment/33601938
comment on: http://stackoverflow.com/q/22144671
type: Comment
type: QuestionComment
score: 7
has text: `List<? extends Object>` should allow that to work

http://stackoverflow.com/a/22164078
downvote count: 0
has comment: http://stackoverflow.com/comment/33664999
score: 16
has comment: http://stackoverflow.com/comment/33667437
answers question: http://stackoverflow.com/q/22164036
upvote count: 16
has body: The runtime type of both the references would be different. Try: System.out.println(t1.getClass()); // class Test System.out.println(t2.getClass()); // class Test$1 You will see different output. Reason being, the new Test() { } expression creates instance of an anonymous subclass of Test. So, Test$1 is a subclass of Test. Now, the reason you're getting that error is, you're missing a + sign: System.out.println(t1.x + " " + t2.x); ^ You can find more details on this post, and this post
has comment: http://stackoverflow.com/comment/33665038
type: Answer

http://stackoverflow.com/a/22115774
type: Answer
has body: It helps to consider the rules of a Binary Search Tree. Let's suppose the previously returned node is n: If n has a right subtree, then the node with the next value will be the leftmost node of the right subtree. If n does not have a right subtree, then the node with the next value will be the first ancestor of n that contains n in its left subtree. Your code is correctly handling the first case, but not the second. Consider the case where node is the leftmost leaf of the tree (the starting case). node has no right child, so we go straight to the else. node has a parent, so the if-clause is skipped. node.parent.left == node, so the while clause is skipped without executing at all. The end result is that node gets returned. I'd expect your iterator to continue returning the same node forever.
score: 1
downvote count: 0
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33553407
accepted answer of: http://stackoverflow.com/q/22114903
answers question: http://stackoverflow.com/q/22114903

http://stackoverflow.com/q/22108903
upvote count: 4
type: AnsweredQuestion
downvote count: 0
accepted answer: http://stackoverflow.com/a/22109336
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/22109336
tagged with: macos
score: 4
has title: How to use Mac Developer Certificate with codesign tool to sign Java application?
has body: I am using Oracle App Bundler to sign my Java application for OSX. I use this following commands to sign my application: codesign -f -s "MyName" dist/MyCool.app codesign -vv dist/MyCool.app "MyName" is a self-signed certificate common name that I created with Key Chain Access. It went well, although OSX gives warning that it come from untrusted developer. Now that I have create a Mac Developer certificate from our Apple Developer subscription, how do I use it? I have already imported the downloaded mac_development.cer into Key Chain Access, but using its common name, codesign still complain no identity found. How do I properly import it into my development environment?
tagged with: signing
answer count: 1
tagged with: java

http://stackoverflow.com/a/23071879
has body: I would suggest you an intermediate way in between the proposals you made: The Apfloat library is a good way to try with, check out the API docs. Apcomplex is a wrapper class for e.g. a BigDecimal. So here you would have a big freedom on overriding and enhancing new methods just applying this class.
type: Answer
upvote count: 2
score: 2
accepted answer of: http://stackoverflow.com/q/22032483
answers question: http://stackoverflow.com/q/22032483
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/33417066
has text: Its not possible but you can use Phonegap or titanium kind of language to develop a mobile application that can run same across the platform.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22041466
score: 2

http://stackoverflow.com/a/37761621
has comment: http://stackoverflow.com/comment/75423495
type: Answer
has body: I know that the answer is too late but it is for anyone have the same issue You can bind the image icon in the hint text using ImageSpan SpannableStringBuilder builder = new SpannableStringBuilder(); builder.append(" "); builder.setSpan(new ImageSpan(getApplicationContext(), R.drawable.search_grey_icon), builder.length() - 1, builder.length(), 0); builder.append(" Search in okani"); searchView.setQueryHint(builder);
answers question: http://stackoverflow.com/q/22041733
score: 0

http://stackoverflow.com/a/29363808
score: 7
answers question: http://stackoverflow.com/q/22071198
upvote count: 7
type: Answer
downvote count: 0
has body: An alternative solution would be to use a feature called dynamic templates. The idea is very well described within this article http://joelabrahamsson.com/dynamic-mappings-and-dates-in-elasticsearch/ So this case uses a regular expression declaring any field that starts with tikaprop_ to be of type String. curl -XPUT "http://localhost:9200/myindex" -d' { "mappings": { "_default_": { "date_detection": true, "dynamic_templates": [ { "tikaprops": { "match": "tikaprop_.*", "match_pattern": "regex", "mapping": { "type": "string" } } } ] } } }' or if you'd rather prefer to do it via the Elasticsearch Java API CreateIndexRequestBuilder cirb = this.client.admin().indices().prepareCreate(INDEX_NAME).addMapping("_default_", getIndexFieldMapping()); CreateIndexResponse createIndexResponse = cirb.execute().actionGet(); private String getIndexFieldMapping() { return IOUtils.toString(getClass().getClassLoader().getResourceAsStream("elasticsearch_dynamic_templates_config.json")); } with elasticsearch_dynamic_templates_config.json beein: { "date_detection": true, "dynamic_templates": [ { "tikaprops": { "match": "tikaprop_.*", "match_pattern": "regex", "mapping": { "type": "string" } } } ] }

http://stackoverflow.com/q/22136211
answer count: 2
score: 5
tagged with: dependency-injection
upvote count: 5
downvote count: 0
has body: I am developing a maven plugin and to make it more testable I would like to use a light-weight dependency injection framework(like Guice) to manage services etc but while I can get them to integrate with applications I haven't been able to get them integrated with my plugin. Is there any way to do this save for doing the dependency-injection in a static fashion?
tagged with: maven-plugin
favorite count: 0
type: UnansweredQuestion
tagged with: maven
has title: Dependency injection in a maven plugin
tagged with: java
has answer: http://stackoverflow.com/a/39229257
has answer: http://stackoverflow.com/a/22137725
type: Question

http://stackoverflow.com/a/22093109
has comment: http://stackoverflow.com/comment/33511585
has body: use keytool provided by jdk for generating the certificate, you can sign your jar file with this certificate by using the jarsigner tool. Both keytool, jarsigner are available in bin folder of the jdk1.7.0 kit. http://docs.oracle.com/javase/tutorial/security/toolsign/rstep2.html
type: AcceptedAnswer
score: 0
accepted answer of: http://stackoverflow.com/q/22092585
type: Answer
answers question: http://stackoverflow.com/q/22092585
has comment: http://stackoverflow.com/comment/33520251

http://stackoverflow.com/q/22096104
linked to: http://stackoverflow.com/q/16473078
upvote count: 2
type: UnansweredQuestion
tagged with: java
tagged with: javafx
type: Question
has body: Added a mouse handler for a JavaFX LineChart, but the coordinates do not match the values on the NumberAxis for the X and Y Axes. Code snippet is below NumberAxis yAxis = new NumberAxis(); NumberAxis xAxis = new NumberAxis(); LineChart&lt;Number, Number&gt; lineChart = new LineChart&lt;Number, Number&gt;(xAxis, yAxis); lineChart.setOnMousePressed(mouseHandler); lineChart.setOnMouseReleased(mouseHandler); // Add some values to the chart and click the mouse And EventHandler&lt;MouseEvent&gt; mouseHandler = new EventHandler&lt;MouseEvent&gt;() { @Override public void handle(MouseEvent mouseEvent) { System.out.println(xAxis.getValueForDisplay(mouseEvent.getX()) + " " + yAxis.getValueForDisplay(mouseEvent.getY())); } }
tagged with: mouseevent
tagged with: linechart
has title: X and Y Coordinates for MouseEvent Not Correct for Java FX LineChart
answer count: 1
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/22096484
score: 2

http://stackoverflow.com/comment/33380185
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22020504
type: Comment
has text: @MaxFichtelmann There is no stackdemo directory. That's the package it's in when I use Netbeans. Should I create one and put everything in there? I'm trying to depend less on IDEs

http://stackoverflow.com/comment/33477648
type: QuestionComment
comment on: http://stackoverflow.com/q/22075342
has text: `a query to match it against a string` - so, you should add a **WHERE** clause to match a name, don't you?
score: 0
type: Comment

http://stackoverflow.com/a/22032450
has comment: http://stackoverflow.com/comment/33612475
answers question: http://stackoverflow.com/q/22012817
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/34897894
has comment: http://stackoverflow.com/comment/33633230
has comment: http://stackoverflow.com/comment/33465346
has body: ExtendedMarkersView get the number of limit from PreferenceStore. You have to change the value. If you disable the limit of MarkerView, write code as follows: IDEWorkbenchPlugin.getDefault().getPreferenceStore().setValue( IDEInternalPreferences.USE_MARKER_LIMITS, false); If you change the limit of MarkerView, write code as follows: IDEWorkbenchPlugin.getDefault().getPreferenceStore() .setValue(IDEInternalPreferences.MARKER_LIMITS_VALUE, 200); Attention: When you change the value of PreferenceStore, all of the MarkerView's limit will be changed. If you don't want to change it, you have to override ExtendedMarkersView#getStatusMessage on your own. EDIT: Add org.eclipse.ui.ide package to required plugins in your plugin.xml before using IDEWorkbenchPlugin.
has comment: http://stackoverflow.com/comment/33462464
type: Answer
accepted answer of: http://stackoverflow.com/q/22012817
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/34860450

http://stackoverflow.com/comment/33378024
comment on: http://stackoverflow.com/q/22017938
has text: @JonSkeet I'm using them under `strings.xml` inside `res/values` directory
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22166319
answer count: 3
has answer: http://stackoverflow.com/a/22166437
tagged with: jar
has answer: http://stackoverflow.com/a/22166453
has title: Allowing the jar file to access the folder inside it when the same jar file is placed in other project
linked to: http://stackoverflow.com/q/1464291
has answer: http://stackoverflow.com/a/22166431
has comment: http://stackoverflow.com/comment/33641128
has body: I have created an application which does some job and it has a configuration folder inside it(named /xml/Configuration.xml).Now, I am trying to use the same jar in multiple projects and the only change which I want to make it is by changing the configuration file contained within the jar file. String xmlConfigPath = System.getProperty(user.dir) + File.separator + "xml" + File.separator + "Configuration.xml"; As you can see here, I access the XML file by using the "user.dir" followed by the complete file name.This(user directory) obviously will change when the jar added in a project is run from a different user.dir which hence does not find the Configuration.xml file placed inside the jar file added to my project. Is there a way to make this jar access its own configuration folder irrespective of which project or location its placed in? Please see the following code Inside my jar file I have the following function which loads the configuration /** * This method is responsible for reading the EMail Configuration * @return &lt;MailSender&gt; * @throws Exception */ private static MailSender getConfig(String configPackagePath, String fileName) throws Exception { JAXBContext jaxbContext; Unmarshaller unmarshaller; StreamSource source; JAXBElement&lt;MailSender&gt; mailSenderElement; MailSender mailSenderConfig = null; String xmlConfigPath = getUserDirectoryPath() + File.separator + ApplicationConstants.XML + File.separator + fileName; try { jaxbContext = JAXBContext.newInstance(configPackagePath); File file = new File(xmlConfigPath); unmarshaller = jaxbContext.createUnmarshaller(); source = new StreamSource(file); mailSenderElement = unmarshaller.unmarshal(source, MailSender.class); mailSenderConfig = mailSenderElement.getValue(); } catch (JAXBException e) { String errorMessage = "Error encountered while reading the EMail XML Configuration file at " + xmlConfigPath; throw new Exception(errorMessage, e); } return mailSenderConfig; } /** * This method is responsible for fet…
type: UnansweredQuestion
tagged with: java
type: Question
tagged with: configuration-files
score: 0

http://stackoverflow.com/q/22116904
possible better answer: http://stackoverflow.com/a/22117037
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22117037
score: 1
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/22117179
tagged with: android-manifest
has comment: http://stackoverflow.com/comment/33552846
has comment: http://stackoverflow.com/comment/33554265
type: Question
accepted answer: http://stackoverflow.com/a/22118668
has comment: http://stackoverflow.com/comment/33552722
answer count: 3
has comment: http://stackoverflow.com/comment/33554754
downvote count: 0
has body: So, in my application I have a start screen image + sound that stays up 2 seconds and then it enters in menu. The menu items looks like this: &lt;activity android:name=".helloWorld" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="ro.dixy.Boston_Tutorial_App.HELLOWORLD"/&gt; &lt;category android:name="android.intent.category.DEFAULT"/&gt; &lt;/intent-filter&gt; &lt;/activity&gt; In my Menu.java file I have these code lines: protected void onListItem(ListView l, View v, int position, long id) { super.onListItemClick(l,v,position,id); String test = classes[position]; try { //Selectare meniu in functie de nume(pozitie) Class ourClass = Class.forName("ro.dixy.Boston_Tutorial_App." + test); Intent ourIntent = new Intent(Menu.this, ourClass); startActivity(ourIntent); } catch(ClassNotFoundException e) { e.printStackTrace(); } } The thing is that when I click a menu from "classes" it doesn't do anything. I am new in Android and I am trying to learn it from Boston Tutorials. Tell me if you need anything else. Thank you. LE: Menu.java public class Menu extends ListActivity { //Nume Meniuri String classes[] = {"helloWorld","TextPlay","example2","example3","example4","example5"}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //ListAdapter pentru ListActivity setListAdapter(new ArrayAdapter&lt;String&gt;(Menu.this, android.R.layout.simple_list_item_1, classes)); } protected void onListItem(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); String test = classes[position]; try { //Selectare meniu in functie de nume(pozitie) Class ourClass = Class.forName("ro.dixy.Boston_Tutorial_App." + test); Intent ourIntent = new Intent(Menu.this, ourClass); startActivity(ourIntent); } catch(ClassNotFoundException e) { e.printStackTrace(); } } }
has title: Android Manifest, Menu doesn't work
favorite count: 0
tagged with: android
has answer: http://stackoverflow.com/a/22118668

http://stackoverflow.com/a/22076103
has comment: http://stackoverflow.com/comment/33479042
answers question: http://stackoverflow.com/q/22076058
score: 3
has body: You can use a constant for the array: private static final int[] STYLES = new int[]{ R.drawable.count_bevel, R.drawable.count_blue, R.drawable.count_green, R.drawable.count_orange, R.drawable.count_pink, R.drawable.count_purple, R.drawable.count_red, R.drawable.count_gray }; private int notifCountBg(final int countstyle) { return STYLES[countstyle]; }
accepted answer of: http://stackoverflow.com/q/22076058
has comment: http://stackoverflow.com/comment/33479125
has comment: http://stackoverflow.com/comment/33479222
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/33479009
upvote count: 3

http://stackoverflow.com/comment/33370963
has text: Isn't that I can add a dependency with scope as system and add a file path and asking the POM to read it ?
comment on: http://stackoverflow.com/a/22015754
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/33377679
type: Comment
has text: @DaveNewton [Normalcy bias](http://en.wikipedia.org/wiki/Normalcy_bias) at company level...
comment on: http://stackoverflow.com/a/22017105
score: 0
type: AnswerComment

http://stackoverflow.com/q/22077892
upvote count: 1
has answer: http://stackoverflow.com/a/22092067
type: AnsweredQuestion
tagged with: java
tagged with: oracle11g
type: Question
answer count: 2
downvote count: 0
accepted answer: http://stackoverflow.com/a/22092067
possible better answer: http://stackoverflow.com/a/22078049
has answer: http://stackoverflow.com/a/22078049
tagged with: ojdbc
tagged with: sql
score: 1
favorite count: 0
has title: ora-03001 unimplemented feature when running select in java
has body: i tried to run following select query on an oracle 11g from java (using thin driver) when i got that error code back. my question is why i get this error? i assume it must be an issue with the thin driver but i cant figure out what it could be since it does support select querys... pls help me out ! java.sql.SQLException: ora-03001 unimplemented feature ora version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production PL/SQL Release 11.2.0.1.0 - Production "CORE 11.2.0.1.0 Production" TNS for 64-bit Windows: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Production the query was: query = "select e.eq_nr as \"Eqiptmentnummer\", f.file_name as \"Dateiname\" e.adress as \"Adresse\"," + " e.city as \"Ort\", e.county as \"Bundesland\", e.zip_code as \"PLZ\"," + " e.manufacturer as \"Hersteller\" f.doc_info as \"DOC INFO\"" + " from elevators e join files f on(e.eq_nr = (select eq_nr from file_links where file_id = f.file_id))"; using preparedStatement and executeQuery: PreparedStatement ps = c.getCon().prepareStatement(query); ResultSet rs = ps.executeQuery(); i ran this query in sql developer and it gave me this output(all elevators and their associated files), which is correct: eq_nr | file_name | adress | city |county| zip |manufaturer| note 1000 testname1.pdf somestreet 12 Vienna Vienna 1200 OTIS test insert brown 1 1000 testname2.pdf somestreet 12 Vienna Vienna 1200 OTIS test insert brown 2 1000 testname4.pdf somestreet 12 Vienna Vienna 1200 OTIS test insert brown 4 1001 testname.pdf somestreet 123 Vienna Vienna 1200 KONE test insert brown 1001 testname3.pdf somestreet 123 Vienna Vienna 1200 KONE test insert brown 3 1001 testname5.pdf somestreet 123 Vienna Vienna 1200 KONE test insert brown5 1001 testname6.pdf somestreet 123 Vienna Vienna 1200 KONE test insert brown 6 asd select * from elevators: elevator id| adress | city | county | zip | manufacturer 1000 somestreet 12 Vienna Vienna 1200 OTIS 1001 somestreet 123 Vienna Vienna 1…

http://stackoverflow.com/comment/33586700
type: Comment
type: QuestionComment
has text: Strings are objects, and unreferenced objects are subject to garbage collection. So when you change your array element to "Tom", "Henry" becomes unreferenced (if not referenced anywhere else) and eligible to be collected. True, String literals (where you literally write `"some string"` in your program) are treated a little differently, but that's chicken feed compared to all the objects in even a small Java application.
score: 0
comment on: http://stackoverflow.com/q/22135163

http://stackoverflow.com/q/22057100
has answer: http://stackoverflow.com/a/22057198
score: 4
possible better answer: http://stackoverflow.com/a/22057180
upvote count: 4
answer count: 3
downvote count: 0
tagged with: jvm
favorite count: 0
has answer: http://stackoverflow.com/a/22071799
has title: Make jar run in 32bit jre
has answer: http://stackoverflow.com/a/22057180
has comment: http://stackoverflow.com/comment/33446065
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22057198
tagged with: java
tagged with: eclipse
has body: How can I specify that in order to run a certain java application that I created you need to have 32 bit JRE installed on your system? Further how can I specify that the java application is to use the 32 bit JRE and not the 64 bit JRE if they are both installed? Background: I have created an application that uses a 3rd party 32 bit only library. The application can not run in a 64 bit JRE. I am going to be distributing this application to a lot of computers in my company, so I need to be able to in code or in the export process, specify the required JRE. I am using eclipse, Kepler to develop and build the java application.
type: Question

http://stackoverflow.com/a/22096140
score: -1
downvote count: 1
type: Answer
upvote count: 0
has body: the if condition should be like this: if ( item != null &amp;&amp; item.getId() == id){ return item; }
answers question: http://stackoverflow.com/q/22093994

http://stackoverflow.com/q/22119725
answer count: 1
tagged with: arraylist
score: 0
has answer: http://stackoverflow.com/a/22120148
type: AnsweredQuestion
has body: I’m working on a registry for persons and their belongings. This program is command based and therefore has some different functions. My problem here is that when the command ”show richest person" is performed, incorrect belongings of the calculated person are printed. The person and the total value of this owner’s items are correct; only the list of gadgets seem to be mixed up with someone else’s. This is how the code looks like: public void getRichest() { double maxValue = -1; ArrayList&lt;Person&gt; richestPersons = new ArrayList&lt;Person&gt;(); for (int i=0; i&lt;personRegistry.size(); i++) { double totalValue = personRegistry.get(i).getTotalValue(); if (totalValue &gt; maxValue) { maxValue = totalValue; richestPersons = new ArrayList&lt;Person&gt;(); richestPersons.add(personRegistry.get(i)); } else if (totalValue == maxValue) richestPersons.add(personRegistry.get(i)); } System.out.print("The richest person is "); for (int i=0; i&lt;richestPersons.size();i++) { System.out.print(richestPersons.get(i).getName() + " "); } System.out.println("with the total value " + maxValue); for (int i=0; i&lt;richestPersons.size();i++) { String name = richestPersons.get(i).getName(); ArrayList&lt;Item&gt; items = personRegistry.get(i).getItems(); // I GUESS THE PROBLEM STARTS HERE... System.out.println(name + " owns the following items:"); for (int j=0; j&lt;items.size(); j++) { String itemName = items.get(j).getName(); double itemValue = items.get(j).getValue(); System.out.println(itemName + " " + itemValue + " "); } } } The described problem only occurs in the execution of this command and no other. For example, If I perform a command called ”show information about specific person” and select the same person (the richest) the belongings of this person will now be correct. The code is almost identical with the earlier shown: } public void search(String name) { for (int i=0; i&lt;personRegistry.size(); i++) { if (name.equalsIgnoreCase(personRegistry.get(i).getName())) { String…
tagged with: registry
type: Question
tagged with: if-statement
tagged with: java
has title: Trouble linking the correct items to the correct owner in a registry
tagged with: for-loop
accepted answer: http://stackoverflow.com/a/22120148

http://stackoverflow.com/comment/33474125
score: 0
comment on: http://stackoverflow.com/q/22071632
type: Comment
type: QuestionComment
has text: To download and show the photo on your device is pretty straight forward, but you need to provide more details as to be able to help more.

http://stackoverflow.com/a/22138337
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33612258
type: Answer
accepted answer of: http://stackoverflow.com/q/22138158
has comment: http://stackoverflow.com/comment/33613510
downvote count: 0
answers question: http://stackoverflow.com/q/22138158
has comment: http://stackoverflow.com/comment/33613232
score: 1
has comment: http://stackoverflow.com/comment/33613423
has body: Once you set the rplcmntBfr into the matcher between the first and second replacement loops, you must clear out the buffer with rplcmntBfr.setLength(0); Otherwise, while you are correctly replacing the value of rplcmntBfr in the second loop, its result is being appended to the result of the first replacement, which is not correct. The result of the next replacement needs to replace the contents of rplcmntBfr.
upvote count: 1

http://stackoverflow.com/a/77860306
has comment: http://stackoverflow.com/comment/137266729
has comment: http://stackoverflow.com/comment/137275572
type: Answer
score: -2
downvote count: 2
has body: Given that the acronym 'IDEA' comes before the word 'Brain', it only makes sense for it to read as: 'The JetBrains Idea'. It's probably just a play of words.
answers question: http://stackoverflow.com/q/22026104
upvote count: 0

http://stackoverflow.com/a/22104080
type: Answer
has comment: http://stackoverflow.com/comment/33535311
has body: In the absence of explicit synchronization - synchronized blocks, locks, use of atomic variables - t2 and t3 can see the changes in different orders in Java as well as in C++.
score: 0
has comment: http://stackoverflow.com/comment/33530395
has comment: http://stackoverflow.com/comment/33533193
answers question: http://stackoverflow.com/q/22103791

http://stackoverflow.com/a/22096462
accepted answer of: http://stackoverflow.com/q/22096259
has body: According to your schema, you could try: select t.* from Treasures t join Treasures_has_Monsters tm on tm.Treasure_id=t.id where Monster_id=? where? is the monster id you want to list the treasures for.
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/22096259
score: 0
type: Answer

http://stackoverflow.com/comment/33589598
comment on: http://stackoverflow.com/q/22137386
type: Comment
has text: `printf` will not change the value. If you want it to print a different value, then compute the correct value. In your case, probably you need to divide something by 100.
type: QuestionComment
score: 2

http://stackoverflow.com/a/23830442
has body: This is a common misunderstanding, so just for clarification for other readers: Calling a Cobol/RPG program from Java is batch, just the same as calling the Cobol/RPG program from a Cobol/RPG/CL. How to begin: Create a program which you can call from CL: ... declare and fill MYFIELD1, MYFIELD2 ... CALL PGM(MYPGM) PARM(&amp;MYFIELD1 &amp;MYFIELD2) ... If this works, it will also work from Java using jt400, if you: call the right AS400 using correct credentials call the right program in the right library use the right number and lentgh of parameters In case of crash as described (waiting forever), DSPMSG QSYSOPR will show an open message, like "MCH0801 = wrong number of parameters". D=Dump will create a spoolfile where you see which incoming parameters are filled with which content, or you see "undefined".
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/22011018
score: 1
upvote count: 1

http://stackoverflow.com/q/22144402
downvote count: 0
tagged with: web-services
tagged with: servicenow
type: Question
has answer: http://stackoverflow.com/a/22186704
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22186704
has title: How to filter service now incident records based on caller?
tagged with: java
tagged with: http://stackoverflow.com/tag/json
possible better answer: http://stackoverflow.com/a/22170491
has answer: http://stackoverflow.com/a/22170491
answer count: 2
score: 4
favorite count: 0
has body: I'm using json web service for service-now to query on the incident records. I'm using java and apache Httpscomponents to make calls. There are huge many records in the incident table, but I want to filter the ones which I need to work upon. With some help from the wiki I was able to fetch the records which are newly added. I want to fetch the records called/created by a particular user. I make calls on the URL of the form below with the myUserName being the caller whose tickets I need to work upon. https://&lt;instance&gt;.service-now.com/incident.do?JSON&amp;sysparm_action=getRecords&amp;sysparm_query=incident_state=1%5Ecaller=myUserName The problem is that I'm still getting all the incidents that are new, meaning the sysparm_query=incident_state=1 is working but the one afterwards fail or gets omitted. Please tell me if my approach is wrong and point me in the direction, or if its a mistake what might be the correction in the URL?
upvote count: 4

http://stackoverflow.com/a/22036166
answers question: http://stackoverflow.com/q/22035970
type: Answer
has body: I think you should use : List&lt;List&lt;T&gt;&gt; = ArrayList&lt;ArrayList&lt;T&gt;&gt;; T is the class of you UserName.
score: 0

http://stackoverflow.com/comment/33689335
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22167773
has text: possible duplicate of [CVS Checkout to a directory](http://stackoverflow.com/questions/89181/cvs-checkout-to-a-directory)

http://stackoverflow.com/comment/33562775
type: Comment
comment on: http://stackoverflow.com/a/22122335
has text: Then obviously you'd need to **record the initial number of values** in the map, and compare it with the resulting number in the hashset. Edited to replace `3` with `N`
score: 0
type: AnswerComment

http://stackoverflow.com/comment/33610080
comment on: http://stackoverflow.com/a/22145264
type: AnswerComment
score: 0
type: Comment
has text: @eric.itzhak, check out > http://fiddle.re/5n4zg - you need to specify `dot matches new line`

http://stackoverflow.com/comment/33469090
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22051306
type: Comment
has text: Thanks a million. Appreciate the help.

httpsurlconnection
type: Tag
tags question: http://stackoverflow.com/q/22057326
tag name: httpsurlconnection

http://stackoverflow.com/comment/33515614
comment on: http://stackoverflow.com/q/22096052
type: Comment
score: 0
type: QuestionComment
has text: Although, I reproduced it with *Java(TM) SE Runtime Environment (build 1.8.0-b129)*

http://stackoverflow.com/comment/62298223
score: 3
type: AnswerComment
comment on: http://stackoverflow.com/a/22053661
type: Comment
has text: -1 because I think you missed the point. Sergio wanted to parameterise the suite itself, not only execute a single, parameterised test

http://stackoverflow.com/a/22169177
type: Answer
answers question: http://stackoverflow.com/q/22167730
upvote count: 1
score: 1
downvote count: 0
has body: @NamedQuery Persistence Provider converts the named queries from JPQL to SQL at deployment time. Until now, there is no feature to create/update the query with @NamedQuery annotation at runtime. On the other hand, you can use Reflection API, to change the annotation value at runtime. I think It is not solution, also it is not you wanted . em.createQuery() Persistence Provider converts the dynamic queries from JPQL to SQL every time it is invoked. The main advantage of using dynamic queries is that the query can be created based on the user inputs.

http://stackoverflow.com/q/22118525
type: Question
tagged with: dsl
tagged with: xtext
answer count: 1
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/33555953
tagged with: eclipse
has body: I'm new in Eclipse Modeling Project. I need to implement a small DSL using Xtext, so I read the Xtext documentation and try to define my own language. But when I create that I just could use it by running a new instance of Eclipse IDE and I have no idea about using it inside an independent java project or even as a standalone language. So I asked you to share your experience with me. Thanks in advance
has answer: http://stackoverflow.com/a/22164429
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33555740
tagged with: eclipse-plugin
has title: How to use a Xtext-based language?

http://stackoverflow.com/comment/33397121
comment on: http://stackoverflow.com/a/22029759
type: AnswerComment
score: 0
type: Comment
has text: Whoops. I made a huge mistake. Let me fix.

http://stackoverflow.com/comment/33606042
type: Comment
comment on: http://stackoverflow.com/q/22147080
type: QuestionComment
has text: how do I do that, I don't know what they are! Can you provide an example
score: 0

http://stackoverflow.com/q/22135464
possible better answer: http://stackoverflow.com/a/22135527
has answer: http://stackoverflow.com/a/22135612
has answer: http://stackoverflow.com/a/22135527
has title: Traversing a LinkedList tail to head
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33587418
tagged with: linked-list
accepted answer: http://stackoverflow.com/a/22135612
tagged with: java
has comment: http://stackoverflow.com/comment/33587459
has comment: http://stackoverflow.com/comment/33587572
type: Question
has answer: http://stackoverflow.com/a/22135518
tagged with: iterator
has comment: http://stackoverflow.com/comment/33587406
has body: I need to traverse through this custom linked list implementation and display its contents: from head to tail, then again from tail to head. I was able to display the lists contents from head to tail pretty easily with a for loop: for (AccountRecordSerializable account : list) { System.out.println(account); } and everything works fine. Now I am trying to reverse that. In provided LinkedList class to use which has a LinkedListIterator class inside it as well. The iterator class has methods such as hasNext(), hasPrevious() which I know can be used to do so, but I'm not quite sure how to use that iterator through my LinkedList to do so. Is there a simpler way as I had done before to reverse this? Or how would I use the Iterator class to iterate through my list so that it performs the task? I apologize if this doesn't make any sense... let me know if you need clarifications..Thanks.
has answer: http://stackoverflow.com/a/22136006
tagged with: traversal
has comment: http://stackoverflow.com/comment/33587066
has comment: http://stackoverflow.com/comment/33587052
score: 0
linked to: http://stackoverflow.com/q/354875
has comment: http://stackoverflow.com/comment/33587132
has comment: http://stackoverflow.com/comment/33587262
answer count: 4
has comment: http://stackoverflow.com/comment/33586957

http://stackoverflow.com/comment/33442008
score: 0
type: QuestionComment
has text: @DavidWallace I believe you have it right, A method as of right now seems the way to go although I would like to see what you say.
type: Comment
comment on: http://stackoverflow.com/q/22054966

http://stackoverflow.com/q/22159211
tagged with: jface
has answer: http://stackoverflow.com/a/22168444
score: 1
tagged with: java
upvote count: 1
type: Question
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/22176890
has body: In my DragSourceListener I receive events of type DragSourceEvent, which has the source widget, but not the destination widget. In my ViewerDropAdapter I receive events of type DropTargetEvent, which has the destination widget, but not the source widget. Part of the validation of whether a drag and drop is supported, depends on both the source and destination widgets together. How can I do validation that involves both the source and destination widget?
tagged with: eclipse-rcp
favorite count: 0
has title: How to get source and destination widgets with Eclipse Drag and Drop
tagged with: drag-and-drop
type: UnansweredQuestion
tagged with: swt

http://stackoverflow.com/comment/33617868
has text: I *think* where I'm confused at is that to catch the `NumberFormatException` I would need to do so in the jsp file, and from what I've read it is now considered bad practice to use java tags within HTML documents. Normally if I was catching this exception I would simply do `try {setWeight(input);}` followed by the appropriate catch; I don't believe there's any way to catch exceptions in the method itself? In other words, the JSP file simply has `<jsp:setProperty name="WebTest" property="weight" />`, I don't know how I would catch the NumberFormatException here
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/22108808
type: Comment

http://stackoverflow.com/a/22937067
answers question: http://stackoverflow.com/q/22010145
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/22010145
upvote count: 1
type: AcceptedAnswer
has body: It's definitely OK to use only one cluster/keyspace object in your entire application. Not doing so will actually probably result in a degraded performance.
type: Answer

http://stackoverflow.com/comment/33539013
comment on: http://stackoverflow.com/a/22109047
score: 0
type: AnswerComment
has text: I'm just fairly new and didn't know what to use. But since I'm doing Android and iOS would `MouseListener` still work?
type: Comment

http://stackoverflow.com/comment/33380138
comment on: http://stackoverflow.com/a/22018455
score: 0
type: Comment
has text: The server works correctly. Tried to create simple tcp client in c# and this worked fine.
type: AnswerComment

http://stackoverflow.com/a/22141362
type: Answer
answers question: http://stackoverflow.com/q/22141178
has comment: http://stackoverflow.com/comment/33596199
has body: Map&lt;List&lt;String&gt;,List&lt;String&gt;&gt; map = new HashMap&lt;List&lt;String&gt;,List&lt;String&gt;&gt;(); List keys = new ArrayList(); keys.add("one");keys.add("one");keys.add("two");keys.add("three"); List values = new ArrayList(); values.add("First");values.add("First12");values.add("second");values.add("second"); map.put(keys, values); System.out.println(map.keySet().toString()); System.out.println(map.values().toString()); System.out.println("map:"+map.toString());
score: 0

http://stackoverflow.com/comment/33568913
type: Comment
has text: You get back a array of bowlers. You can modifiy the "view" like you want ;)
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22125607

http://stackoverflow.com/q/22040845
score: 2
has answer: http://stackoverflow.com/a/22040994
has answer: http://stackoverflow.com/a/22041011
tagged with: java
tagged with: jtextfield
linked to: http://stackoverflow.com/q/12105639
type: Question
answer count: 2
downvote count: 0
has title: Mask the IP Address when the user enters in text field Java Swing
favorite count: 0
tagged with: jformattedtextfield
upvote count: 2
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/5339702
tagged with: swing
has body: I have a JTextField to accommodate an ip address with 3 dots. 255.120.320.123. When the user enters this IP address, I want to mask it like ... I was referring this thread, How to custom formatter JFormattedTextField to display an IP address? jFormattedTextField did not work for me. Can anyone give me an example with jFormattedTextField with 3 dots visible? Or do I need to use 4 jFomattedTextField/JPasswordField as mentioned in this thread? Thanks in advance.

http://stackoverflow.com/comment/33762438
type: Comment
type: QuestionComment
has text: @LuiggiMendoza: Thank you for the continuous help. I am marking your answer as the answer. I have one more question to ask. This `BlockingQueue` in `BigFileProcessor` store the data in heap right? so we can access it later at anytime right? Will this lead to `OutOfMemory` exception because the future files are in Gigabytes?
score: 0
comment on: http://stackoverflow.com/q/22152704

http://stackoverflow.com/a/22154343
has body: Try Runtime.getRuntime().exec("/path/to/your/awk_script") Take a look to Class Runtime
has comment: http://stackoverflow.com/comment/33620106
score: 0
has comment: http://stackoverflow.com/comment/33619884
type: Answer
has comment: http://stackoverflow.com/comment/33662852
has comment: http://stackoverflow.com/comment/33620143
has comment: http://stackoverflow.com/comment/33619874
has comment: http://stackoverflow.com/comment/33619751
answers question: http://stackoverflow.com/q/22154183

http://stackoverflow.com/q/22092704
tagged with: jdbc
has answer: http://stackoverflow.com/a/22093107
answer count: 4
has comment: http://stackoverflow.com/comment/33509031
has answer: http://stackoverflow.com/a/22094874
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33509733
has answer: http://stackoverflow.com/a/22093039
has body: I have to execute below query through JDBC call select primaryid from data where name in ("abc", adc", "anx"); Issue is inside in clause I have to pass 11000 strings. Can I use prepared statement here? Or any other solution any one can suggest. I dont want to execute the query for each record, as it is consuming time. I need to run this query in very less time. I am reading the strings from an XML file using DOMParser. and I am using sql server db.
tagged with: java
has comment: http://stackoverflow.com/comment/33508975
has answer: http://stackoverflow.com/a/22094616
linked to: http://stackoverflow.com/q/3107044
tagged with: prepared-statement
type: Question
has title: How to execute a SQL statement in Java with many values in a single variable in where in clause
has comment: http://stackoverflow.com/comment/33510288
has comment: http://stackoverflow.com/comment/33510068
has comment: http://stackoverflow.com/comment/33510802
has comment: http://stackoverflow.com/comment/33509064
tagged with: sql-server
score: 0
tagged with: sql

http://stackoverflow.com/q/22039458
answer count: 3
has answer: http://stackoverflow.com/a/22039483
has comment: http://stackoverflow.com/comment/33413396
has answer: http://stackoverflow.com/a/22039501
accepted answer: http://stackoverflow.com/a/22039501
has answer: http://stackoverflow.com/a/22039773
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/22039483
type: Question
has comment: http://stackoverflow.com/comment/33413657
has body: I am trying the following JSP code on server <%@ page language="java" contentType="text/html; charset=UTF-16" pageEncoding="UTF-16"%> Insert title here <% String s = "繁體中文"; String s1 = "繁體中文"; out.println(s + " "); out.println(s1 + " "); out.println(s.equalsIgnoreCase(s1 + " ")); %> and when I see the output, it gives me false for comparison. Could anyone please look into this and guide me whats wrong. Note: I have tried UTF-8 encoding as well. Thanks.
has title: JSP Scriplet Chinese String comparison
tagged with: jsp
score: 0

http://stackoverflow.com/q/22070465
tagged with: java
tagged with: hibernate
type: Question
has comment: http://stackoverflow.com/comment/33468610
score: 0
has body: I want to map the classes Node, Unit and Module to do this select: select n.nid, n.nnm, n.nhwtype, u.unnr, u.unhwtype, u.unslot, m.mpos, m.mhwtype from node n, unit u, module m where n.nid*=u.nid and n.nid*=m.nid and u.nid*=m.nid and u.unnr*=m.unnr and n.nhwtype in (10020, 10021, 10022, 10023, 10002, 10017, 10001) and m.mpos not between 11 and 10000 (ONE) Node -> Unit (MANY) (ONE) Unit -> Module (MANY) I tried so many times, but I didnt have success.
tagged with: mapping
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33468375
has title: How to map join classes in hibernate
answer count: 0

http://stackoverflow.com/a/22012021
answers question: http://stackoverflow.com/q/22011778
type: Answer
has body: Make sure you set the contentType element in the ajax options as documented here: https://api.jquery.com/jQuery.ajax/ I don't think you are using it properly right now (not sure what contentType:false, does actually)
score: 0
has comment: http://stackoverflow.com/comment/33364935

google-cloud-storage
tags question: http://stackoverflow.com/q/22029170
tags question: http://stackoverflow.com/q/22037528
tags question: http://stackoverflow.com/q/22128693
type: Tag
tags question: http://stackoverflow.com/q/22130830
tag name: google-cloud-storage

import
type: Tag
tags question: http://stackoverflow.com/q/22110409
tags question: http://stackoverflow.com/q/22116545
tags question: http://stackoverflow.com/q/22082112
tags question: http://stackoverflow.com/q/22167682
tag name: import
tags question: http://stackoverflow.com/q/22123692
tags question: http://stackoverflow.com/q/22018203
tags question: http://stackoverflow.com/q/22052305
tags question: http://stackoverflow.com/q/22052479
tags question: http://stackoverflow.com/q/22127409

http://stackoverflow.com/q/22085741
score: 0
has body: I recently stumbled upon this predicament I can't figure out. Say I want to load a text file, and have it in my JAR. In eclipse it goes "res/txt/text.txt" However, since res/ is a source folder, on exporting apparently it goes txt/text.txt Now, if I try to load that for debugging in Eclipse, new File("txt/text.txt"); I get an IOException, since in Eclipse it's located in res/txt/text.txt What part am I missing? I thought it was bad convention to put files from Res folder in the directory as src folder? Am I wrong? Also, differences between extracting and packaging required libraries upon export of runnable jar? EDIT: I also have a loose file in the "res/" folder called "log.txt" I normally, and successfully access it using File logFile = new File("res/log.txt"); But now, it creates the file (which is done if it doesn't exist), directly in the project folder, outside of the res folder. YES, res is a Source folder in the Build path Thank you in advance!
has title: Confused with paths and files and source folders
answer count: 0
type: UnansweredQuestion
tagged with: java
tagged with: eclipse
type: Question
has comment: http://stackoverflow.com/comment/33496915
has comment: http://stackoverflow.com/comment/33496816

http://stackoverflow.com/q/22066079
type: Question
upvote count: 1
answer count: 1
has body: I have interface Datagram and few classes that implements it, for example A and B. At some point during runtime, I receive via Bluetooth object that implements given interface (which is A or B). I distinguish them by adding special class identifying number as a first byte of send message. The point is that I need an array of all classes implementing given interface, so I could assign them to byte numbers. That number in unique identifier for class and I use it to get object from byte array, send via Bluetooth from another device. Now it's done "manually" by creating array like private static final Class[] datagramClasses = { A.class, B.class };, but it's very incontinent way - if I add class C to my program, I need to append it to datagramClasses array too. Alternatively, I could send full class name in every Datagram, but it would be silly. After doing some research, I've come up with few ideas: Getting information (class name) from .class files and use Class.forName("com.mypackage.A");. But Android use single .dex file instead of .class files. Use external library to do that - I've tried Reflections and few others, but I was unable to compile them on Android platform. Is there any simpler library that would do the trick? Creating Maven plugin, that would do the trick. I successfully added Maven to my Android project, but I was unable to compile some additional plugin developing related libraries (again, due to Android limitations). I could create another related project, in Java, and develop plugin there, but I worry that it'll be far too complicated. Any help would be much appreciated, Greg edit: I'd expect to be able to execute code like: final List&lt;Class&gt; list = new ArrayList&lt;&gt;(); for (final Class c : allAplicationClasses) if (isAssignableFrom(Datagram.class)) list.add(c);
favorite count: 0
has comment: http://stackoverflow.com/comment/33460458
tagged with: android
tagged with: maven-plugin
has comment: http://stackoverflow.com/comment/33470620
downvote count: 0
tagged with: reflection
type: UnansweredQuestion
tagged with: maven
has comment: http://stackoverflow.com/comment/33461421
has answer: http://stackoverflow.com/a/22066898
has title: Get all classes implementing given interface
score: 1
tagged with: java

http://stackoverflow.com/a/22298080
has body: You should read up on how to use PipeInput/OutputStream. FOP and the PdfStamper will need to run in separate threads. Basically, this has nothing to do with FOP per se. I'm sure you'll find various examples on the net on how this works. If you're not comfortable with multi-threaded programming, I suggest you just buffer FOP's output in a byte[] or a temporary file.
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/22042936
answers question: http://stackoverflow.com/q/22042936
score: 0
has comment: http://stackoverflow.com/comment/35025238

http://stackoverflow.com/q/22068406
has comment: http://stackoverflow.com/comment/33464444
tagged with: sql
has comment: http://stackoverflow.com/comment/33464739
upvote count: 0
has title: How to get the Months for the current year and previous year in java?
has answer: http://stackoverflow.com/a/22068886
favorite count: 0
has answer: http://stackoverflow.com/a/22068574
type: UnansweredQuestion
tagged with: datetime
answer count: 4
score: -5
type: Question
has answer: http://stackoverflow.com/a/22068587
has body: i need to get the current month no and from this till past 1 year month no's to generate a report. For eg: if today is Feb , so From 02 - 2014 to 03-2013 i need to generate. 02 - 2014 01 - 2014 12 - 2013 11 - 2013 . . . 03 - 2013 I need to generate this. Can any one help me on this?
has comment: http://stackoverflow.com/comment/33464479
tagged with: java
downvote count: 5
has answer: http://stackoverflow.com/a/22070601

oracle9i
tags question: http://stackoverflow.com/q/22123698
type: Tag
tag name: oracle9i

http://stackoverflow.com/a/22106710
upvote count: 2
accepted answer of: http://stackoverflow.com/q/22106441
has body: In onCreate, you already operating inside an instance of InterfaceScreen. It's called this. You don't need to create a new instance. Instead of myAnimal.eat(String1); myAnimal.sleep(String2); just say this.eat(String1); this.sleep(String2); or even better eat(String1); sleep(String2); Also, variables typically start with a lowercase letter: string1 and string2. Classes start with an uppercase letter. The NullPointerException was happening because your new instance wasn't getting correct tv1 and tv2 references. In Android, we don't make instances of our Activitys.
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/22106441
type: Answer
score: 2

http://stackoverflow.com/a/22123345
has body: You have for(int i = 0; i&lt;origin.length();i++){ This should be for(int i = 0; i&lt;origin.length()-1;i++){ because in your substring, you are looking at i+1. You might want to consider using origin.charAt(i) instead, this is the usual way to do it and you will not need to adjust your loop bounds. A substring will work fine with the modification to the loop, however. In addition, you might be trying to turn a character like the - in -1 into an integer, maybe try-catch?
answers question: http://stackoverflow.com/q/22123317
accepted answer of: http://stackoverflow.com/q/22123317
has comment: http://stackoverflow.com/comment/33564822
score: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/33564659
type: Answer

http://stackoverflow.com/comment/33559093
score: 0
type: AnswerComment
type: Comment
has text: That gives me the FileNotFoundException error which is why I posted the question. Seems that there is no ways around this :(
comment on: http://stackoverflow.com/a/22120026

http://stackoverflow.com/q/22167955
has comment: http://stackoverflow.com/comment/33644394
has comment: http://stackoverflow.com/comment/33644010
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33644175
has comment: http://stackoverflow.com/comment/33643665
has comment: http://stackoverflow.com/comment/33644560
type: Question
tagged with: java
has body: Ive got an error when i call this android.os.Process.killProcess(android.os.Process.myPid()); My logcat says it is unable to start activity. as my understanding using kill process is to kill task that is running but when i use this it shows that it is starting to call another activity. here is my code: AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(S_2nd_LoginActivity.this); alertDialogBuilder.setTitle("Are you sure you want to cancel?") .setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { android.os.Process.killProcess(android.os.Process.myPid()); } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); here is my logcat: 03-04 18:28:43.805: E/AndroidRuntime(19417): java.lang.RuntimeException: Unable to start activity ComponentInfo{ph.com.example.Project/ph.com.example.Project.MainActivity}: java.lang.NullPointerException 03-04 18:28:43.805: E/AndroidRuntime(19417): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815) 03-04 18:28:43.805: E/AndroidRuntime(19417): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831) 03-04 18:28:43.805: E/AndroidRuntime(19417): at android.app.ActivityThread.access$500(ActivityThread.java:122) 03-04 18:28:43.805: E/AndroidRuntime(19417): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024) 03-04 18:28:43.805: E/AndroidRuntime(19417): at android.os.Handler.dispatchMessage(Handler.java:99) 03-04 18:28:43.805: E/AndroidRuntime(19417): at android.os.Looper.loop(Looper.java:132) 03-04 18:28:43.805: E/AndroidRuntime(19417): at android.app.ActivityThread.main(ActivityThread.java:4123) 03-04 18:28:43.805: E/AndroidRuntime(19417): at java.lang.reflect.Method.invokeNative(Native Method) 03-04 18:28:43…
has comment: http://stackoverflow.com/comment/33644295
has comment: http://stackoverflow.com/comment/33644374
score: 0
has comment: http://stackoverflow.com/comment/33644085
has comment: http://stackoverflow.com/comment/33644101
has answer: http://stackoverflow.com/a/22168635
has title: Error in android.os.Process.killProcess(android.os.Process.myPid());
tagged with: javascript
has comment: http://stackoverflow.com/comment/33644433
has answer: http://stackoverflow.com/a/22168078
has answer: http://stackoverflow.com/a/22168602
answer count: 3
tagged with: android
has comment: http://stackoverflow.com/comment/33644078

http://stackoverflow.com/a/22059245
answers question: http://stackoverflow.com/q/22058712
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/22058712
type: Answer
has body: use the below code to click on load more driver.findElement(By.className("load-more")).click();
has comment: http://stackoverflow.com/comment/33449418
has comment: http://stackoverflow.com/comment/33449497
has comment: http://stackoverflow.com/comment/33449244
score: 0

http://stackoverflow.com/a/22068381
has comment: http://stackoverflow.com/comment/33473879
answers question: http://stackoverflow.com/q/22043489
has comment: http://stackoverflow.com/comment/33479674
type: AcceptedAnswer
has body: EDIT Completely updated based on the dicussion in the comments My first approach was to recursively generate the combinations, and, during the recursion, maintain the information that was required to satisfy all constraints. The intention was to only create valid combinations in the first place. However, according to the comments, the assignment of machines to data centers is optional, and it is hard to detect the "valid" solutions with the recursive approach. Thus, this new approach is slightly different (and much more pragmatic) : It computes all possible combinations of machines (including null), and checks each of these combinations whether it is "valid" - that is, contains each machine only once, and no data center has a machine that it already had before. If it is valid, it is stored in the result list, and the information about the machines that have been used is updated accordingly. The potential drawback is that most of the combinations that are created here are invalid, because it computes the cartesian product of the machine sets. When the number of data centers / machines grows, this will become intractable. If this is a problem, then the computation of combinations will have to be pruned. This would not be so hard, for example, by skipping all combinations that start with { h1, h1 ... } (because this already violates the rules), but would require some additional meditation about how to combine this with the other rules and still keep the implementation understandable. I think that it would also be possible to find a simple and elegant solution with the recursive approach, but ... well... finding a simple solution often turns out to be hard... (The MixedRangeCombinationIterable class is taken from https://github.com/javagl/Combinatorics/blob/master/src/main/java/de/javagl/utils/math/combinatorics/MixedRangeCombinationIterable.java and used here to compute the cartesian product of the machine sets) import java.util.ArrayList; import java.util.Arrays; impo…
has comment: http://stackoverflow.com/comment/33475447
score: 0
has comment: http://stackoverflow.com/comment/33490632
has comment: http://stackoverflow.com/comment/33473628
type: Answer
has comment: http://stackoverflow.com/comment/33473135
accepted answer of: http://stackoverflow.com/q/22043489
has comment: http://stackoverflow.com/comment/33473791
has comment: http://stackoverflow.com/comment/33478089

http://stackoverflow.com/comment/33809260
has text: Sorry for my delay. Once you open (connect) a socket you have several methods from that object. `socket.getRemoteSocketAddress() `and `socket.getLocalAddress()`, they give you exactly what you're looking for. If you need an example, just let me know.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/22150866
score: 0

http://stackoverflow.com/comment/33555064
type: Comment
comment on: http://stackoverflow.com/a/22073691
has text: Yes, in the case of `twoK`, where `K < 32`, you'll have to cast it to an int. I forgot that as I modified the code. And it won't be a good idea to choose K large. Something in the range of 1 to 5 will be usable, I think. So you won't easily run into problems there.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33522009
type: Comment
comment on: http://stackoverflow.com/a/22099370
score: 0
type: AnswerComment
has text: Agree, yes it's true. For a long time i thought that '.contains(String ..)' will result same result with '=='. thank you for taking time answer my question..

http://stackoverflow.com/comment/33422943
has text: and as a consequence of what @PavelHoral noticed, when HashSet calls the real hashCode, it gets a different value for each of your three items, and as per the specs they thus can't be equals (so equals is not called)
score: 1
comment on: http://stackoverflow.com/q/22044660
type: QuestionComment
type: Comment

http://stackoverflow.com/a/22111005
answers question: http://stackoverflow.com/q/22110964
has comment: http://stackoverflow.com/comment/33542352
upvote count: 2
has body: In Java, ^ doesn't mean "power". It is a bitwise XOR operator. therefore 10^6 means 10 XOR 6 instead 10 * 10 * 10 * 10 * 10 * 10 it is hard to guess without seeing your code. However my guess is you are doing somehting like long l = 1000000 * 10000000; If so, here is the problem. literal 1000000 is in fact an int instead of long, and therefore, 1000000 * 10000000 is doing a int multiplication and it got overflow (max of int is something around 2,xxx,xxx,xxx). The "overflowed" value is then cast to a long. Which give you the "strange" result.
has comment: http://stackoverflow.com/comment/33542152
has comment: http://stackoverflow.com/comment/33542182
type: Answer
has comment: http://stackoverflow.com/comment/33542200
score: 2
has comment: http://stackoverflow.com/comment/33542215
has comment: http://stackoverflow.com/comment/33542176
downvote count: 0
has comment: http://stackoverflow.com/comment/33542290

http://stackoverflow.com/a/22096297
has comment: http://stackoverflow.com/comment/33515163
has comment: http://stackoverflow.com/comment/33520474
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/33516016
has comment: http://stackoverflow.com/comment/33515727
has comment: http://stackoverflow.com/comment/33515826
downvote count: 0
has comment: http://stackoverflow.com/comment/33520606
has body: Computational cycles in your database server are a scarce resource. You can have as many server instances running your Java program as you can afford, and as your application scales up (adds users, for example) you can distribute the computationally intensive operation to multiple servers. If you perform the computationally expensive stuff on your MySQL server, you are deciding to do it all on a central machine. Plus, in my experience, it is easier to unit test and maintain Java code than it is to do the same for trigger / stored procedure code. That being said, MySQL's floating-point math operations (log, multiplication) exploit the server's math instruction set and are reasonably efficient.
score: 1
answers question: http://stackoverflow.com/q/22096093
has comment: http://stackoverflow.com/comment/33515364
has comment: http://stackoverflow.com/comment/33525651
has comment: http://stackoverflow.com/comment/33515578

cryptography
tag name: cryptography
tags question: http://stackoverflow.com/q/22129488
type: Tag
tags question: http://stackoverflow.com/q/22034269
tags question: http://stackoverflow.com/q/22109799
tags question: http://stackoverflow.com/q/22011866
tags question: http://stackoverflow.com/q/22132268
tags question: http://stackoverflow.com/q/22156779

http://stackoverflow.com/comment/33493539
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/22083312
has text: Arrays.stream(args).filter(s -> StringUtils.isEmpty(s)).count();
type: Comment

http://stackoverflow.com/a/22091451
has body: replace the code like this public class Albums extends Activity { Button b1; EditText et1; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.album); Button b2 = (Button) findViewById(R.id.addalbum); b1 = (Button) findViewById(R.id.album1); b2.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { startDialog(); } }); } protected void startDialog() { AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this); LayoutInflater inflater = this.getLayoutInflater(); et1 = (EditText) findViewById(R.id.editText1); myAlertDialog.setTitle("Name?"); myAlertDialog.setView(inflater.inflate(R.layout.addalbumsdialog, null)); myAlertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { b1.setText(et1.getText().toString()); } }); myAlertDialog.show(); } }
answers question: http://stackoverflow.com/q/22091326
score: 0
type: Answer

http://stackoverflow.com/q/22144430
has comment: http://stackoverflow.com/comment/33603756
type: Question
has comment: http://stackoverflow.com/comment/33601513
score: 0
has comment: http://stackoverflow.com/comment/33601520
tagged with: java
tagged with: arrays
answer count: 0
type: UnansweredQuestion
has body: I am trying to print the results of the results of my code and it is working when I am simply printing out the results in a straight line but I want the results to be printed in a figure 8 diagram. Below shows the code that effectively prints the results in a straight line: public void printActivities () { // print all the train activity history System.out.println("TRAIN TRACK ACTIVITY(Tracks [0..18])"); for (Enumeration &lt;String&gt; e = theActivities.elements() ; e.hasMoreElements(); ) System.out.println(e.nextElement()); }// end printActivities and the results that this returns is: Train [A1] moving/moved to [5] [..][..][..][..][..][A1][..][..][..][..][..][..][..][..][..][..][..][..][..] Train [A1] moving/moved to [6] [..][..][..][..][..][..][A1][..][..][..][..][..][..][..][..][..][..][..][..] but below shows the code that I have created to print out the figure eight but there are no results being returned. So does anyone have an idea why this is not outputting my results? public void printActivities(){ String tempString=""; // print all the train activity history System.out.println("TRAIN TRACK ACTIVITY(Tracks [0..18])"); for (Enumeration &lt;String&gt; e = theActivities.elements() ; e.hasMoreElements(); ) System.out.println(e.nextElement()); tempString="\t" + trainTrack[5]+ "\n"+ trainTrack[4] + "\t\t" + trainTrack[6] + "\n"+ trainTrack[3] + "\t\t" + trainTrack[7] + "\n"+ trainTrack[2] + "\t\t" + trainTrack[8] + "\n"+ trainTrack[1] + "\t\t" + trainTrack[9] + "\n\t" + trainTrack[0] + "\n"+ trainTrack[10] + "\t\t" + trainTrack[18] + "\n"+ trainTrack[11] + "\t\t" + trainTrack[17] + "\n"+ trainTrack[12] + "\t\t" + trainTrack[16] + "\n"+ trainTrack[13] + "\t\t" + trainTrack[15] + "\n\t" + trainTrack[14]; System.out.println(tempString); }// end printActivities after runing this code I get the following result but with no information returned within the array positions: [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..] [..]
has comment: http://stackoverflow.com/comment/33601664
has title: print function not producing the correct results

http://stackoverflow.com/q/22161720
score: 0
answer count: 1
accepted answer: http://stackoverflow.com/a/22163433
has title: Object Creation during loops
has body: I've run into a bit of a performance issue with Hibernate and I'm stuck. I've got a nested foreach that iterates firstly through a map and then through each key within the map to create an object. for(Map&lt;String, Object&gt; csvRow : csvRows){ Contact contact = new Contact(); contact.setContactId(nextContactId); for(String key : csvRow.keySet()) { contact.setDetails(key, csvRow.get(key)); contactList.addContact(contact); } nextContactId++; } My problem arises in that the above code takes roughly 10 seconds to run. This is with a CSV input of about 2MB, but this service has to handle a file of 200MB (at least) efficiently. The reason I'm stuck is that the code below runs in roughly 1.6 seconds but only creates a single instance of a Contact object (which is fair enough) and I do see why this is occuring. Contact contact = new Contact(); for(Map&lt;String, Object&gt; csvRow : csvRows){ contact.setContactId(nextContactId); for(String key : csvRow.keySet()) { contact.setDetails(key, csvRow.get(key)); contactList.addContact(contact); } nextContactId++; } I have tried the usual things like manually setting the object's id to null during each iteration of processing a key. Just to make things clearer, a contact object is not supposed to represent a complete person, rather it represents a piece of information for a contact. Each contact will have the same contactId, and I have a wrapper object to tie it all together, but that isn't pertinent to my question. My question is thus: How can I keep the performance of the latter while still creating all the objects I need. Also I need to keep the object structure I have because I have no control over the source CSV which may be missing data left right and center, hence the object structure that I'm using. If you need more information, I'm eagerly awaiting your reply. EDIT #1: Using Hibernate 4.2.8, Spring 3.2.6
has answer: http://stackoverflow.com/a/22163433
type: AnsweredQuestion
tagged with: memory-management
tagged with: performance
tagged with: java
type: Question
tagged with: object

http://stackoverflow.com/a/22122947
has body: This is a pretty broad question, so I won't go into too much detail, but roughly: Pre-process the haystacks using something like broad lemmatizer to create "topic word only" versions of the messages by noting which topics all words in it cover. For example, any occurrences of "hamburger", "pizza", "coke", "lunch", "dinner", "restaurant", or "McDonalds" would cause the "topic" word "food" to be collected for that message. Some words may have multiple topics, eg "McDonalds" may be in the topics "food" and "business". Most words won't have any topic. After this process, you'll have haystacks consisting of only "topic" words. Then create a Map&lt;String, Set&lt;Integer&gt;&gt; and populate it with the topic word and the Set of chat message ids that contain it. This is reverse index of topic word to the chat messages that contain it. The runtime code to find all documents that contain all n words is then trivial and super fast - near O(#terms): private Map&lt;String, Set&lt;Integer&gt;&gt; index; // pre-populated Set&lt;Integer&gt; search(String... topics) { Set&lt;Integer&gt; results = null; for (String topic : topics) { Set&lt;Integer&gt; hits = index.get(topic); if (hits == null) return Collections.emptySet(); if (results == null) results = new HashSet&lt;Integer&gt;(hits); else results.retainAll(hits); if (results.isEmpty()) return Collections.emptySet(); // exit early } return results; } This will perform near O(1), and tell you which messages share all search terms. If you just want the number, use the trivial size() of the returned Set.
downvote count: 0
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/22120747

http://stackoverflow.com/a/22088473
score: 0
type: Answer
has body: I spent some time to find the answer and here what i got int temp = 0; temp+=temp++; ie temp = temp + temp++; now what happens here step by stem 1 step temp = exp(0 + 0) 2 step temp value will be incremented to 1 3 step temp will be assigned the value 0 from expression 1 so actually in the expression temp value is incremented but again reset to 0 due to assignment operator here is my code as a proof int i=0,j=0; System.out.println(i+=i++); System.out.println(j+=j++); System.out.println("i= "+i+", j="+j); System.out.println(i=i+i++); System.out.println(j=i+j++); System.out.println("i= "+i+", j="+j); j+=i++; System.out.println("i= "+i+", j="+j); output is 0 0 i= 0, j=0 0 0 i= 0, j=0 i= 1, j=0 so you can see in the last line value of i is 1 that is it got incremented and the value of j is 0 due to assignment operator and yes you should use pre increment to make it work as you expected this is just to show why this unexpected behavior.
answers question: http://stackoverflow.com/q/22087852

http://stackoverflow.com/comment/33397939
type: Comment
comment on: http://stackoverflow.com/a/22030328
type: AnswerComment
has text: @user3341249: Then you're going to have to give us more information about what you've tried (like actual code).
score: 0

http://stackoverflow.com/comment/67193086
has text: Article's link is broken :(
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/22183852
type: Comment

http://stackoverflow.com/a/22117518
answers question: http://stackoverflow.com/q/22117081
type: Answer
score: 3
upvote count: 3
has body: There is no such method, but you can do: String s = "Hello My name is Joel"; int counter = 0; for( int i=0; i&lt;s.length(); i++ ) { if( s.charAt(i) == 'l' ) { counter++; } } (code from Simple way to count character occurrences in a string)
downvote count: 0

http://stackoverflow.com/a/22176113
has body: The correct way to prevent users from utilizing certain types (including built-in types) in Documentum is usually to configure the client. For most clients this is done using display configuration through the DD (Data Dictionary) mechanism. However, for My Documentum Desktop this seems to be somewhat different. I have not used it myself, but take a look at the My Documentum Desktop Installation and Configuration Guide 6.7.2, page 25 -- Object type filters preference set: This sets the root object type that generates the list of object types from which users can select in the ingest dialog box. This also hides specific object types from display in MDD. On page 56 -- Define settings for an object type (Windows): Default_Document_Object_Type=dm_document I guess the former configuration setting will help you in hiding dm_document, and the latter could assist you in making a default type choice for clients.
has comment: http://stackoverflow.com/comment/33735714
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/22151132
answers question: http://stackoverflow.com/q/22151132
score: 1
upvote count: 1

http://stackoverflow.com/comment/33528684
comment on: http://stackoverflow.com/q/22103110
type: Comment
type: QuestionComment
has text: You mean like : System.setProperty("java.library.path","/home/pi/vlc-2.1.3/lib/.libs/"); ? This doesnt work, still the same error.
score: 0

http://stackoverflow.com/comment/33525651
has text: @eis - Understood, everyone's situation can definitely vary. Thanks for the good discussion.
type: Comment
comment on: http://stackoverflow.com/a/22096297
score: 0
type: AnswerComment

http://stackoverflow.com/q/22090672
tagged with: post
type: Question
has body: This is my Java code: @Override public void onClick(View v) { switch (v.getId()) { case R.id.button1: HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://iwindroids.ru/test.php"); try { // Add your data List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(1); //nameValuePairs.add(new BasicNameValuePair("id", "12345")); nameValuePairs.add(new BasicNameValuePair("lal", "AndDev is Cool!")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP Post Request HttpResponse response = httpclient.execute(httppost); } catch (ClientProtocolException e) { // TODO Auto-generated catch block } catch (IOException e) { // TODO Auto-generated catch block } break; default: break; } } When I press button1 writes: Unfortunately, [App name] App has stopped. I wrote in Manifest. &lt;uses-permission android:name="android.permission.INTERNET"/&gt; Android. Eclipse. POST. Http
has comment: http://stackoverflow.com/comment/33505184
has answer: http://stackoverflow.com/a/22096572
has answer: http://stackoverflow.com/a/22091090
has comment: http://stackoverflow.com/comment/33505173
score: 0
answer count: 3
has comment: http://stackoverflow.com/comment/33505223
has title: POST request. Android
linked to: http://stackoverflow.com/q/6343166
type: UnansweredQuestion
tagged with: android
has comment: http://stackoverflow.com/comment/33505182
tagged with: java
has comment: http://stackoverflow.com/comment/33505299
has answer: http://stackoverflow.com/a/22090732
tagged with: eclipse
tagged with: http

http://stackoverflow.com/comment/33617834
type: QuestionComment
comment on: http://stackoverflow.com/q/22153319
score: 0
has text: What problem are you trying to solve, and how does knowing why Java is designed that way help you solve it?
type: Comment

androidhttpclient
tags question: http://stackoverflow.com/q/22071595
tags question: http://stackoverflow.com/q/22096324
type: Tag
tag name: androidhttpclient

http://stackoverflow.com/q/22081314
accepted answer: http://stackoverflow.com/a/22086342
type: AnsweredQuestion
tagged with: web-services
type: Question
tagged with: jakarta-ee
tagged with: java
has title: Accessing SOAPMessage in WebService class issue
score: 0
has answer: http://stackoverflow.com/a/22086342
answer count: 1
has body: I am building a Java web service. My environment is Java EE6, Glassfish 3.1.2 I need to send some files to my web service so I used SOAP attachment method. In my web service class, I need to get all my attachment parts. The below is my code: @WebService //@MTOM public class UploadServiceImpl implements UploadService { @Resource WebServiceContext wsctx; @Override public String upload() { // This below line is CASTING error SOAPMessageContext soapMessageContext = (SOAPMessageContext)wsctx.getMessageContext(); SOAPMessage soapMessage = soapMessageContext.getMessage(); soapMessage.getAttachments(); // ... return "done"; } } I received CASTING error becayse I am casting wsctx.getMessageContext() to SOAPMessageContext. wsctx.getMessageContext() is NOT instance of SOAPMessageContext. My question is: WHY in handlers (SOAPHandler). I am able to cast MessageContext to SOAPMessageContext but in WebService class, I am not able to? Anyone know what is the issue? How can I access SOAPMessage in webservice class? (Annotated by @WebService). Thank you very much!
tagged with: soap

http://stackoverflow.com/a/22038060
has comment: http://stackoverflow.com/comment/33413106
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/22034158
has body: As per the this documentation of ThreadLocalSessionContext which you have configured by thread In the interest of usability, it was decided to have this default impl actually generate a session upon first request and then clean it up after the Transaction associated with that session is committed/rolled-back That means your session will be automatically closed when transaction either committed or rolled-back. As I am assuming you are using spring for managing transactions,then it is never a good thing to set hibernate.current_session_context_class. By default spring will use CurrentSessionContext. Now here you have used thread in current_session_context_class. Then for your own relish I would suggest try{ //... your code } catch(HibernateException ex) { LOG.error(ex); session.getTransaction().rollback(); throw ex; } finally { if(session.isOpen()){ //I don't think this will return true in any case but still for your satisfaction you could do this session.close(); } } Update: From the chat use following configuration in your spring datasource bean 50 500
downvote count: 0
score: 1

http://stackoverflow.com/comment/33410229
type: QuestionComment
comment on: http://stackoverflow.com/q/22037125
score: 0
type: Comment
has text: i am getting new session from hibernateutil class every time.see my code.

http://stackoverflow.com/comment/33606045
has text: check out these http://stackoverflow.com/questions/6621372/android-textview
type: Comment
comment on: http://stackoverflow.com/q/22146923
score: 0
type: QuestionComment

http://stackoverflow.com/q/22033253
has comment: http://stackoverflow.com/comment/33402891
has title: FileOutputStream not working in Android
answer count: 1
has answer: http://stackoverflow.com/a/22033472
tagged with: android
has comment: http://stackoverflow.com/comment/33402844
has comment: http://stackoverflow.com/comment/33403088
tagged with: storage
type: AnsweredQuestion
tagged with: internal
tagged with: java
score: 0
accepted answer: http://stackoverflow.com/a/22033472
tagged with: internal-storage
type: Question
has body: I'm using internal storage for the first time and my openFileOutput is giving me an error. I am not sure how to make this work, but the method below works perfectly fine if the FileOutputStream is removed. Thank you! public void Addition(View view) { int num1 = numberone.getText().toString().trim().length(); int num2 = numbertwo.getText().toString().trim().length(); String numone = numberone.getText().toString(); String numtwo = numbertwo.getText().toString(); if(num1 == 0 || num2 == 0){ TextView value = (TextView)findViewById(R.id.answer); value.setText("Numbers not entered"); } else if(numone.equals("+") || numtwo.equals("+") || numtwo.equals("-") || numone.equals("-")){ TextView value = (TextView)findViewById(R.id.answer); value.setText("Please enter numbers"); } else{ answer = Float.parseFloat(numberone.getText().toString()) + Float.parseFloat(numbertwo.getText().toString());; TextView value = (TextView)findViewById(R.id.answer); value.setText("Your sum is " + answer); FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE); } }
has comment: http://stackoverflow.com/comment/33402929
linked to: http://stackoverflow.com/q/18716865
has comment: http://stackoverflow.com/comment/33403002

http://stackoverflow.com/q/22020475
answer count: 1
tagged with: jpa
downvote count: 0
has answer: http://stackoverflow.com/a/22657626
has comment: http://stackoverflow.com/comment/34517480
has body: I've been reading lots of SO questions and blog posts and documentation about JPA mapping, but nothing seems to clearly address my situation (which surprises me, since I'm sure I'm not the first person to want to map a class hierarchy like this). I have a nice, cleanly-designed object model that I need to map via JPA. It's as follows public abstract class BaseEntity<T extends BaseEntity> { private Integer id; private List<T> children; } public class ConcreteEntity1 extends BaseEntity<ConcreteEntity2> { private String value; } public class ConcreteEntity2 extends BaseEntity{ private String foo; } I can't seem to get this to map at all. The closest I've gotten is like this (I'm using XML mapping now, although I've also tried with annotations): <column name="auto_id" nullable="false"/> <generated-value strategy="IDENTITY"/> <basic name="value" /> <cascade-all /> <basic name="foo" /> The problem with this is that JPA complains about the mapping of children in ConcreteEntity1. It claims that the target entity of children (BaseEntity) is not an entity. Well, that's correct, 'BaseEntity' not an entity. But the actual type of children is not BaseEntity but rather ConcreteEntity2 (as declared by ConcreteEntity1's type parameter). So how can I map an object model like this? I've tried quite a few variations but none worked (they all fail during initialization of the entity manager).
has comment: http://stackoverflow.com/comment/34529686
favorite count: 0
accepted answer: http://stackoverflow.com/a/22657626
tagged with: orm
has title: Is it possible to map (JPA) a Java type hierarchy that uses generics in the abstract superclass?
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
type: Question

http://stackoverflow.com/comment/33610577
has text: @Smutje This post isn't getting committed to the VCS, deployed to production, or maintained by future programmers.
score: 1
comment on: http://stackoverflow.com/q/22149403
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/33482565
type: Comment
comment on: http://stackoverflow.com/a/22077114
score: 0
type: AnswerComment
has text: but I don't have understand where exactly I have to place your piece of code

http://stackoverflow.com/a/22014944
answers question: http://stackoverflow.com/q/22014805
score: 0
type: Answer
has body: Add PrintDataArray() inside your main method public static void main(String args[]) { { ArrayList&lt;Data&gt; data = new ArrayList&lt;Data&gt;(); data.add(new Data("Fred", 21)); PrintDataArray(data); } } private static void PrintDataArray(ArrayList&lt;Data&gt; data) { for(int i=0;i&lt;data.size();++i) { data.get(i).Print(); } } }

http://stackoverflow.com/comment/33405480
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22034430
has text: hi,ItachiUchiha. thank you for your answer. however,unfortunatelly,we already have checked that JRE is installed and not multiple vrsion of JRE. and JRE Version of WebServer and client are same versions...

http://stackoverflow.com/comment/33407641
type: QuestionComment
comment on: http://stackoverflow.com/q/22036043
score: 6
has text: Instead of trying to find some ugly hack to avoid using a `break` statement, explain what your *real* problem is - what problem would you be getting when you would use `break`?
type: Comment

http://stackoverflow.com/q/22109440
has title: Dynamically resize images linked to JLabels in a GridLayout layoutmanager
downvote count: 0
favorite count: 0
upvote count: 2
has body: Current implementation layout: ((EDIT: added Code: )) private JPanel panelCenter; private List&lt;BufferedImage&gt; listCreatedImages; public ChooseCircuitPanel(List&lt;BufferedImage&gt; listCreatedImages) { this.listCreatedImages = listCreatedImages; initiate(); } private void initiate() { setLayout(new BorderLayout(50, 50)); panelCenter = new JPanel(); LayoutManager theLayout = new GridLayout(0, 3, 0, 0); panelCenter.setLayout(theLayout); panelCenter.setBorder(BorderFactory.createLineBorder(Color.BLACK)); for (BufferedImage bufferedImage : listCreatedImages) { ImageIcon theImage = new ImageIcon(bufferedImage); JLabel lblForImage = new JLabel(theImage); lblForImage.setBorder(BorderFactory.createLineBorder(Color.BLACK)); panelCenter.add(lblForImage); } this.add(panelCenter, BorderLayout.CENTER); } Situation: We want to display a race circuit here. A circuit should be displayed by placing standards tiles next to each other. It should be possible to resize the window, and with that, the circuit tiles should also resize. ((EDIT: bit more info: The race circuit data is stored on a server and the desktop application has to translate the data to a visual thing, by placing some standard tiles in the right order. )) ((EDIT: we are not allowed to use any external library. It should be doable by only using Java Swing code.)) I thought about placing the images in a JLabel and placing these JLabels in a panel with GridLayout as layout manager. Using a GridLayout - I thought - it should be rather easy to get to a solution: the components in the GridLayout (= JLabels) already scale and do exactly what I want. Now, it would only be a matter of finding a way to resize the images so they fill the JLabels. As you can see: right now, the images have a fixed size and don't scale at all. I browsed a bit and saw lots of solutions that boil down to using Graphics2D and super.paintComponent, etc. But most of these solutions had nothing to do with a GridLayout. So conclusive question: Is th…
possible better answer: http://stackoverflow.com/a/22110636
has comment: http://stackoverflow.com/comment/33540025
tagged with: swing
linked to: http://stackoverflow.com/q/19209650
has comment: http://stackoverflow.com/comment/33539685
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22110636
tagged with: java
has comment: http://stackoverflow.com/comment/33549770
has comment: http://stackoverflow.com/comment/33549762
type: Question
has comment: http://stackoverflow.com/comment/33541563
tagged with: grid-layout
has answer: http://stackoverflow.com/a/22116517
accepted answer: http://stackoverflow.com/a/22116517
tagged with: resize
tagged with: image
has comment: http://stackoverflow.com/comment/33539746
answer count: 2

http://stackoverflow.com/q/22125600
has answer: http://stackoverflow.com/a/22125622
score: 0
has title: double and '^' Operator, not possible?
has answer: http://stackoverflow.com/a/22125636
tagged with: double
tagged with: android
answer count: 4
tagged with: operators
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/22125636
type: Question
has answer: http://stackoverflow.com/a/22125642
possible better answer: http://stackoverflow.com/a/22125643
has answer: http://stackoverflow.com/a/22125643
tagged with: java
has body: I'm new here(5 days old to be exact) making basic programs in Android and Java. Here's the code I'm working on and I'm stuck at the 'else if' on sendAmount() part of this code. I got an error there that says "The operator ^ is undefined for the argument type(s) double, double". Now my question is, how can I make it work and display the result? private EditText entPrinAmt; private EditText entIntRate; private EditText entTol; private EditText entMonAmt; private TextView txtFactor; private TextView txtFutValue; private TextView txtIntIncome; private TextView txtEffRate; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); entPrinAmt = (EditText) findViewById(R.id.ent_prin_amt); entIntRate = (EditText) findViewById(R.id.ent_int_rate); entTol = (EditText) findViewById(R.id.ent_tol); entMonAmt = (EditText) findViewById(R.id.ent_mon_amt); txtFactor = (TextView) findViewById(R.id.txtFactor); txtFutValue = (TextView) findViewById(R.id.txtFutureVal); txtIntIncome = (TextView) findViewById(R.id.txtIntIncome); txtEffRate = (TextView) findViewById(R.id.txtEffRate); } @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; } public void sendAmount(View view) { DecimalFormat df = new DecimalFormat("#,###,###,###,###,###.##"); DecimalFormat factorFormat = new DecimalFormat("#,###.#####################"); double dPA = Double.parseDouble(entPrinAmt.getText().toString()); double dIR = Double.parseDouble(entIntRate.getText().toString()); double dTL = Double.parseDouble(entTol.getText().toString()); double dMA = Double.parseDouble(entMonAmt.getText().toString()); if (dPA &lt; 0){ Context context = getApplicationContext(); CharSequence txtToast = "Must not be negative!"; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, txtToast, duration); toast.s…

http://stackoverflow.com/a/22123350
downvote count: 0
answers question: http://stackoverflow.com/q/22120747
has body: What you're describing sounds like an excellent use case for the Aho-Corasick string-matching algorithm. This algorithm finds all matches of a set of pattern strings inside of a source string and does so in linear time (plus the time to report the matches). If you have a fixed set of strings to search for, you can do linear preprocessing work up front on the patterns to search for all matches very quickly. There's a Java implementation of Aho-Corasick available here. I haven't tried it out, but it might be a good match. Hope this helps!
type: Answer
score: 3
upvote count: 3

http://stackoverflow.com/comment/33491504
comment on: http://stackoverflow.com/a/22082375
score: 0
type: Comment
type: AnswerComment
has text: Oh, I'm prepared to bet that OP _thinks_ he/she is using getters. The fact that he/she is not using them _correctly_ is kind of my point.

http://stackoverflow.com/comment/33602387
type: Comment
type: QuestionComment
has text: The report from Jenkins should really be produced by a runic Jenkins and not from another users= as you can't be certain what code was used to produce the report
comment on: http://stackoverflow.com/q/22015820
score: 0

http://stackoverflow.com/comment/33383544
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22022165
has text: Well, similar in my way, not strictly equal (hence the `isSimilar` function).
type: AnswerComment

http://stackoverflow.com/comment/33388979
comment on: http://stackoverflow.com/a/22025264
type: AnswerComment
has text: Dear anonymous downvoter, please help me to improve my answer by telling my why you downvoted.
score: 0
type: Comment

http://stackoverflow.com/q/22103769
answer count: 0
tagged with: code-coverage
tagged with: emma
type: Question
has title: not able to generate coverage.emma file
linked to: http://stackoverflow.com/q/52984
tagged with: ant
tagged with: java
score: 0
has comment: http://stackoverflow.com/comment/33542750
tagged with: junit
has comment: http://stackoverflow.com/comment/33535717
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/33542707
has comment: http://stackoverflow.com/comment/33669833
has body: I am performing code coverage using emma for a simple junit case. I am able to compile,instrument,run the junit case from ant successfully. My issue is, the coverage.emma file is not getting generated which I believe is required to generate the coverage report. Below is message I get: report: [report] processing input files ... [report] 1 file(s) read and merged in 10 ms [report] nothing to do: no runtime coverage data found in any of the data files The junit task is below: &lt;!-- Run the Juit cases --&gt; &lt;target name="runJunit"&gt; &lt;junit printsummary="on" showoutput="yes" fork="true"&gt; &lt;test name="com.ea.test.testCode1" /&gt; &lt;classpath&gt; &lt;pathelement location="${dest.dir}" /&gt; &lt;pathelement location="C:\junit4.11\junit-4.11.jar" /&gt; &lt;/classpath&gt; &lt;jvmarg value="-XX:-UseSplitVerifier"/&gt; &lt;jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" /&gt; &lt;jvmarg value="-Demma.coverage.out.merge=false" /&gt; &lt;/junit&gt; &lt;/target&gt;

http://stackoverflow.com/comment/33362168
type: AnswerComment
comment on: http://stackoverflow.com/a/22006427
type: Comment
score: 0
has text: Solution to what? You can do `intField.set(myObject, new Integer(123));` without problem.

http://stackoverflow.com/comment/33397671
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22029621
has text: @GordonLinoff Using backsticks seemed to fix my error! Thanks! and thank you user2310289 for your suggestion too!

eclipse-rcp
tags question: http://stackoverflow.com/q/22120532
tags question: http://stackoverflow.com/q/22021358
tags question: http://stackoverflow.com/q/22060043
type: Tag
tags question: http://stackoverflow.com/q/22159211
tags question: http://stackoverflow.com/q/22032693
tags question: http://stackoverflow.com/q/22073268
tags question: http://stackoverflow.com/q/22156920
tags question: http://stackoverflow.com/q/22074499
tag name: eclipse-rcp
tags question: http://stackoverflow.com/q/22006471

http://stackoverflow.com/a/22086157
answers question: http://stackoverflow.com/q/22086128
downvote count: 0
score: 1
upvote count: 1
has body: You want to loop until n == null. As it stands, you're stopping one short.
type: Answer

http://stackoverflow.com/a/22006427
has body: Because I set the return type of my method as Object, the enum gets casted to a String instead. No it doesn't. With primitive types there are Object wrappers that autobox and unbox, does Enum have something like that? Enum values are objects. You can already put enum values in Object variables. I believe the problem is with this line: if (type.isInstance(Enum.class)) That should be: if (type.isEnum()) The isInstance call won't do what you want since it's asking if the Class object Enum.class is an instanceof the type class. Then, because that if check doesn't work, it's always selecting the second branch that returns the String value as-is, which is why it seems like the enum itself is being cast to a string.
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33357154
has comment: http://stackoverflow.com/comment/33355066
has comment: http://stackoverflow.com/comment/33355294
type: Answer
accepted answer of: http://stackoverflow.com/q/22006190
upvote count: 3
has comment: http://stackoverflow.com/comment/33362168
answers question: http://stackoverflow.com/q/22006190
has comment: http://stackoverflow.com/comment/33354963
has comment: http://stackoverflow.com/comment/33355577
score: 3

http://stackoverflow.com/q/22131782
tagged with: java
possible better answer: http://stackoverflow.com/a/22131817
has answer: http://stackoverflow.com/a/22131817
answer count: 2
favorite count: 0
score: 0
tagged with: android
has answer: http://stackoverflow.com/a/22131806
has comment: http://stackoverflow.com/comment/33580266
upvote count: 1
downvote count: 1
type: Question
type: AnsweredQuestion
tagged with: hashmap
has body: I can't to take value from dataF when I use map.put that say error.if I replace map.put("Nos",dataF); to map.put("Nos",dataF[arrLength]) It's work but It's return [Ljava.lang.string;@b1f37df0 ArrayList&lt;HashMap&lt;String,String[]&gt;&gt; ArrList = new ArrayList&lt;HashMap&lt;String,String[]&gt;&gt;(); Intent intent = getIntent(); String[] dataF = intent.getStringArrayExtra("Money"); ListView list1 = (ListView)findViewById(R.id.listView1); int arrLength = dataF.length; for(int i=0;i&lt;arrLength;i++) { HashMap&lt;String, String[]&gt; map = new HashMap&lt;String, String[]&gt;(); map.put("Nos", dataF[arrLength]); // &lt;&lt; error ArrList.add(map); // &lt;&lt; error } ListAdapter adapters = new SimpleAdapter(resultActivity.this,ArrList, R.layout.activity_column, new String[] {"Nos"},new int[] { R.id.textView1}); list1.setAdapter(adapters);
accepted answer: http://stackoverflow.com/a/22131806
has title: I can't take value from Hashmap

http://stackoverflow.com/q/22040732
tagged with: android
accepted answer: http://stackoverflow.com/a/22040902
type: AnsweredQuestion
has title: Android- How to drag a picture on a canvas
score: 0
upvote count: 1
downvote count: 1
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/22040902
tagged with: draw
answer count: 1
tagged with: android-canvas
favorite count: 0
has body: I need to drag an image like in a videogame. I have a few lines drawed and I need to drag it and see the lines drawed before "out" of the window. I give you two images trying to help to understand it. Image before drag: Then I touch the screen with my finger and I make a move to the top of the screen, so this three lines have to be upper than the initial image, like this: I don't know how to do this "drag efect", can someone help me? This is not an image as a .jpg file, is three lines drawed with "drawLine" on a canvas into an imageView. My onTouchEvent Code and my drawRectangle code: public boolean onTouch(View view, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_UP: { x = event.getX(); y = event.getY(); getFirstFoot(); return true; } case MotionEvent.ACTION_MOVE: { ammountX = event.getX() - startX; ammountY = event.getY() - startY; canvas.save(); canvas.translate(ammountX, ammountY); //canvas.restore(); imageView.invalidate(); return true; } case MotionEvent.ACTION_DOWN: { startX = event.getX(); startY = event.getY(); } } return true; } drawRectagle code: private void drawRectangle(boolean erase) { buttonRed.setVisibility(View.VISIBLE); buttonGree.setVisibility(View.VISIBLE); buttonYellow.setVisibility(View.VISIBLE); Bitmap bitmap2 = BitmapFactory.decodeResource(getResources(), R.drawable.ascensorsininfo); canvas.drawBitmap(bitmap2, x - (bitmap2.getWidth() / 2), y - bitmap2.getHeight(), new Paint()); drawedPoints.add(String.valueOf(x - (bitmap2.getWidth() / 2))); drawedPoints.add(String.valueOf(y - bitmap2.getHeight())); imageView.invalidate(); y -= bitmap2.getHeight(); } Any solution would be apreciated. Thanks!

http://stackoverflow.com/q/22164834
has title: How to layout the button and combobox middle?
has body: I am new to java swing, I wrote a startup program to formart text, but i am confused with the layout, the result is below: I want the combobox and the button are placed middle of the ctrlPanel, and the combobox should not be stretched public class MainFrame extends JFrame { private static final long serialVersionUID = 7553142908344084288L; private static String[] formats = new String[] { "JSON", "XML", "YAML" }; public MainFrame() { super("jValidator"); Panel mainPanel = new Panel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.X_AXIS)); setContentPane(mainPanel); JTextArea fromTextArea = new JTextArea(20, 40); JScrollPane fromTextAreaScrollPanel = new JScrollPane(fromTextArea); fromTextAreaScrollPanel.setPreferredSize(new Dimension(300, 300)); fromTextAreaScrollPanel.setBorder(BorderFactory.createEmptyBorder(15, 5, 15, 5)); mainPanel.add(fromTextAreaScrollPanel); JButton fmtButton = new JButton("Format &gt;&gt;"); JComboBox jComboBox = new JComboBox(formats); jComboBox.setBorder(BorderFactory.createTitledBorder("Text Format")); JPanel ctrPanel = new JPanel(); ctrPanel.setLayout(new BoxLayout(ctrPanel, BoxLayout.Y_AXIS)); ctrPanel.setAlignmentY(Component.CENTER_ALIGNMENT); ctrPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); ctrPanel.add(jComboBox); ctrPanel.add(Box.createRigidArea(new Dimension(50, 15))); ctrPanel.add(fmtButton); mainPanel.add(ctrPanel); JTextArea toTextArea = new JTextArea(20, 40); JScrollPane toTextAreaScrollPanel = new JScrollPane(toTextArea); toTextAreaScrollPanel.setPreferredSize(new Dimension(300, 300)); toTextAreaScrollPanel.setBorder(BorderFactory.createEmptyBorder(15, 5, 15, 5)); mainPanel.add(toTextAreaScrollPanel); setDefaultCloseOperation(EXIT_ON_CLOSE); pack(); setVisible(true); } public static void main(String[] args) { new MainFrame(); } }
type: AnsweredQuestion
score: 1
has comment: http://stackoverflow.com/comment/33638279
accepted answer: http://stackoverflow.com/a/22164996
upvote count: 1
tagged with: swing
type: Question
tagged with: java
has comment: http://stackoverflow.com/comment/33638353
has comment: http://stackoverflow.com/comment/33638271
linked to: http://stackoverflow.com/q/7229226
answer count: 2
downvote count: 0
tagged with: layout-manager
possible better answer: http://stackoverflow.com/a/22165022
has answer: http://stackoverflow.com/a/22164996
favorite count: 0
has answer: http://stackoverflow.com/a/22165022
tagged with: combobox

http://stackoverflow.com/comment/33645712
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/22153377
type: Comment
has text: OK, got it - open one large file. Still, this is the mean for IPC, so I want to know how that can be achieved i..e one process writes, the other one reads, but in a way that we know the other process actually wrote sth before we read from it. This is the synchronization I am talking about

http://stackoverflow.com/comment/33630154
comment on: http://stackoverflow.com/a/22100286
type: AnswerComment
has text: looks like it should work, but i actually ended up just checking an external database to figure out when the stopSelf() should be called
score: 0
type: Comment

http://stackoverflow.com/comment/33454549
comment on: http://stackoverflow.com/a/22041692
score: 0
type: Comment
has text: Will try that and let you know
type: AnswerComment

http://stackoverflow.com/a/22115658
type: Answer
has body: What this code does is the following Create a new variable r=""; then looping for the string in input lenght it adds at the beginning of r the current character of the loop. i=0) r="1" i=1) r="21" i=2) r="321" i=3) r="4321" i=4) r="54321"
upvote count: 3
answers question: http://stackoverflow.com/q/22115576
score: 3
downvote count: 0

http://stackoverflow.com/comment/33608354
score: 0
type: Comment
has text: Thanks for the reply.Is very explicit. But when I adapt the code did you say on mine, the image overlap the rest. I don't know how to solve this...
comment on: http://stackoverflow.com/a/22146266
type: AnswerComment

http://stackoverflow.com/q/22108540
has title: how to properly set size of JButton with image?
has answer: http://stackoverflow.com/a/22110203
tagged with: jframe
type: UnansweredQuestion
tagged with: swing
tagged with: jbutton
type: Question
has answer: http://stackoverflow.com/a/22108912
tagged with: java
answer count: 2
has body: This is what I have now: This is what I want the image to look like: I have two java files, one extends JFrame and part with Jpanel looks basically ShinyButtons panel = new ShinyButtons(); panel.setLocation(10, 10); getContentPane().add(panel); another one extends JPanel with JButtons import javax.swing.*; public class ShinyButtons extends JPanel{ public static byte RED = 0; public static byte ORANGE = 1; public static byte YELLOW = 2; public static byte GREEN = 3; public static byte BLUE = 4; public static byte LIGHT_GRAY = 5; public static byte DARK_GRAY = 6; public static byte ROWS = 8; private byte[][] buttonTable; public ShinyButtons() { buttonTable = new byte[ROWS][ROWS]; resetButtons(); setBorder(BorderFactory.createEmptyBorder()); setSize(552,552); ImageIcon[] icons = {new ImageIcon("RedButton.png"), new ImageIcon("OrangeButton.png"), new ImageIcon("YellowButton.png"), new ImageIcon("GreenButton.png"), new ImageIcon("BlueButton.png"), new ImageIcon("LightGrayButton.png"), new ImageIcon("DarkGrayButton.png")}; for (int row=0; row&lt;8; row++){ for (int col=0; col&lt;8; col++){ JButton buttons = new JButton(); buttons.setSize(69,69); buttons.setIcon(icons[(byte)(Math.random()*7)]); add(buttons); buttons.setLocation(row*69, col*69); buttons.setBorder(BorderFactory.createEmptyBorder()); } } } private void resetButtons() { for (int r=0; r&lt;ROWS; r++) for (int c=0; c&lt;ROWS; c++) buttonTable[r][c] = (byte)(Math.random()*7); } public byte getButton(int r, int c) { return buttonTable[r][c]; } }
tagged with: user-interface
score: 0

http://stackoverflow.com/comment/33564570
score: 1
has text: You should try to debug or print out the contents of origin.substring(i,i+1) before executing parseInt().
comment on: http://stackoverflow.com/q/22123317
type: Comment
type: QuestionComment

http://stackoverflow.com/q/22128813
score: 5
downvote count: 0
answer count: 1
tagged with: string
has title: set a JTextField width in maner to wrap a given text
favorite count: 0
upvote count: 5
accepted answer: http://stackoverflow.com/a/22128845
tagged with: swing
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/22128845
tagged with: jtextfield
type: Question
has body: I have an uneditable and disabled JtextField in which I will put a String obtained after requesting a Database, and I want that this JtextField wraps All my String. I saw the setColumn() and setSize() methods but I don't know first my String length. thank you very much.

http://stackoverflow.com/comment/33537830
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22108097
score: 0
has text: I got it working. Now there are a few logic errors with ^

http://stackoverflow.com/comment/33422920
score: 1
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/22044641
has text: A navigation drawer might be what you are looking for: https://developer.android.com/design/patterns/navigation-drawer.html

http://stackoverflow.com/a/22143995
has comment: http://stackoverflow.com/comment/33614812
has body: Your problem is that you are trying to mix XML configuration and Java Config based configuration. In this particular case that isn't going to work. The bean in the configuration class will be instantiated but that is it, they aren't registered to your <mvc:annotation-driven /> configuration. You will have to add the beans manually to the ConversionService and your RequestMappingHandlerMapping. Either that our switch, at least your DispatcherServlet configuration to Java Config. In XML you can configure additional argument-resolvers by using the <mvc:argument-resolvers /> tag. (This mimics the configuration from the SpringDataWebConfiguration). <mvc:annotation-driven> <mvc:argument-resolvers> </mvc:argument-resolvers> </mvc:annotation-driven> <constructor-arg ref="sortResolver" /> However the SpringDataWebConfiguration does more then only these 2 resolvers it also registers a DomainClassConverter. If you also want to use that you need some additional configuration. <constructor-arg ref="conversionService" /> <mvc:annotation-driven conversion-service="conversionService"> <mvc:argument-resolvers> </mvc:argument-resolvers> </mvc:annotation-driven> <constructor-arg ref="sortResolver" />
score: 20
has comment: http://stackoverflow.com/comment/53662142
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/40042243
has comment: http://stackoverflow.com/comment/40056130
accepted answer of: http://stackoverflow.com/q/22135002
type: Answer
answers question: http://stackoverflow.com/q/22135002
upvote count: 20
downvote count: 0
has comment: http://stackoverflow.com/comment/53073921

http://stackoverflow.com/comment/33455200
type: QuestionComment
type: Comment
score: 3
comment on: http://stackoverflow.com/q/22062974
has text: We don't know your database structure but why not `SELECT COUNT(*) FROM student WHERE email=? AND password=?`. Use a [`PreparedStatement`](http://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html). And **don't store passwords in plaintext in your database**.

http://stackoverflow.com/comment/33632010
type: Comment
score: 0
has text: I've now updated my code to draw circles from the array but have encountered a new problem: see above
comment on: http://stackoverflow.com/a/22160725
type: AnswerComment

http://stackoverflow.com/comment/33643478
has text: It can be :) but much more simpler is using simple loop.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22167753

http://stackoverflow.com/comment/51529865
comment on: http://stackoverflow.com/q/22098754
has text: what in case if my HDFS status is healthy and still i can not able to fix hbase hbck inconsistencies by hbase options?
type: Comment
type: QuestionComment
score: 2

http://stackoverflow.com/comment/33493069
comment on: http://stackoverflow.com/q/22083362
score: 0
type: Comment
type: QuestionComment
has text: I am so sorry about this, I am using axis not axis2.

http://stackoverflow.com/comment/33427267
type: Comment
comment on: http://stackoverflow.com/a/22046065
has text: I mean: public Hero(int x, int y) throws Exception { this.x = x; this.y = y; java.awt.Image pic = javax.imageio.ImageIO.read(Hero.class.getClassLoader().getResourceAsStream("klassid/Pictures/mario.png")); }
type: AnswerComment
score: 0

http://stackoverflow.com/comment/33640206
has text: Think to edit your answer for posting a code sample and validate this one that can help some else. You're welcome.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/22157746

http://stackoverflow.com/a/22141095
has comment: http://stackoverflow.com/comment/33595957
score: 5
has comment: http://stackoverflow.com/comment/33596970
has comment: http://stackoverflow.com/comment/33616894
upvote count: 5
has comment: http://stackoverflow.com/comment/33596075
accepted answer of: http://stackoverflow.com/q/22140955
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33595943
answers question: http://stackoverflow.com/q/22140955
has comment: http://stackoverflow.com/comment/33595749
type: Answer
has body: Correct me again if my assumptions were incorrect, but you would do it as you normally would static Class&lt;?&gt; clazz = MyIf.class; public static void main(String[] args) throws Exception { method(() -&gt; System.out.println("hello")); // lambda } public static void method(MyIf myIf) { System.out.println(clazz.isAssignableFrom(myIf.getClass())); } static interface MyIf { public void execute(); } prints true You don't actually ever get a reference to the lambda expression, the compiler generates a (synthetic?) class and an instance of it is passed to your method.
has comment: http://stackoverflow.com/comment/33595776
has comment: http://stackoverflow.com/comment/33595781

http://stackoverflow.com/comment/33505062
type: AnswerComment
has text: @Aldwoni is your user column in the user table the same name as the user column in the USER_GROUPS table? because the matching is done by the column names.
type: Comment
comment on: http://stackoverflow.com/a/22071538
score: 1

http://stackoverflow.com/a/38810723
answers question: http://stackoverflow.com/q/22142920
type: Answer
has body: From the above example - both the functions are not working same. load() - hibernate will only load proxy of the object with the specified ID. All the properties will not be set in advanced. Once you call the getter methods on the object, the query will be issues. So when you can a getAccount method , select query will be issued and the result object will be saved in cache as it is retrieved by ID. So any subsequent calls via get will not result any select statement. get() - will always retrieve the object from database with full properties populated. For properties defined in collections, depends on lazy initialization configuration. Please note - Any subsequent calls on the same session will return the object from the cache only and hence no queries will be returned. That is what happening with the call to get method in the first time and the second time as the object is ready in cache by calling the acc.getBalance() on the object retrieved by load.
score: 0

http://stackoverflow.com/q/22145515
linked to: http://stackoverflow.com/q/6567870
duplicate of: http://stackoverflow.com/q/6567870
has title: what is SwingUtilities.invokeLater(new Runnable())
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22145624
has answer: http://stackoverflow.com/a/22145755
upvote count: 3
score: 1
downvote count: 2
has body: Can anyone explain me this piece of code in simple words: SwingUtilities.invokeLater( new Runnable(){ public void run(){ chatWindow.append(text); } }); } Please, can anyone give me a detail explanation.
tagged with: swing
type: Question
has answer: http://stackoverflow.com/a/22145571
has answer: http://stackoverflow.com/a/22145556
has answer: http://stackoverflow.com/a/22145811
tagged with: java
has answer: http://stackoverflow.com/a/22145557
answer count: 6
accepted answer: http://stackoverflow.com/a/22145624
possible better answer: http://stackoverflow.com/a/22145811
linked to: http://stackoverflow.com/q/3541373
favorite count: 0

http://stackoverflow.com/a/22157524
has comment: http://stackoverflow.com/comment/33626416
accepted answer of: http://stackoverflow.com/q/22157312
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/33625997
has comment: http://stackoverflow.com/comment/33625670
type: Answer
has comment: http://stackoverflow.com/comment/33625765
has body: The Object parameter of Field#getInt must be an instance of class A. A a = new A(); int y = testnum.getInt(a); Since the name and number fields are not static, you cannot get them from the class; you must get them from a particular instance of the class.
has comment: http://stackoverflow.com/comment/33625973
has comment: http://stackoverflow.com/comment/33626210
upvote count: 3
has comment: http://stackoverflow.com/comment/33625808
answers question: http://stackoverflow.com/q/22157312
score: 3

http://stackoverflow.com/q/22096547
has title: insert into table, if table not exist, create table and then insert
has answer: http://stackoverflow.com/a/22096691
has answer: http://stackoverflow.com/a/22096728
has body: We need a java code which can insert the row in a table, if table not exist, then it will create a new and then insert into that table. Like we are tracking the each request to our server, and then save the same in a table. The table name should be like request_month-name_*year*, which is passed dynamically. The purpose is to keep the table of each month independent of others. The code which we are using is try{ dao.insertTracking(object, year, month); }catch(BadSqlGrammarException e){ dao.createTable(year, month); dao.insertracking(object, year, month); }catch(Exception e){ e.printStackTrace(); } The issue is that the the BadSqlGrammarException can be thrown in many other cases as well. So my question is to how to handle this type of situation efficiently without catching generalized exception and then processing again? Also, We can first check the existence of table, but that would put heavy load on system, since large volume of request are handled each day. Using jdbctemplates and/with mysql.
has answer: http://stackoverflow.com/a/22096758
answer count: 4
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/22265037
accepted answer: http://stackoverflow.com/a/22265037
tagged with: mysql
tagged with: jdbctemplate
type: Question
possible better answer: http://stackoverflow.com/a/22096728
linked to: http://stackoverflow.com/q/8829102
score: 0

http://stackoverflow.com/q/22069525
tagged with: javacard
has answer: http://stackoverflow.com/a/22069615
tagged with: apdu
score: 0
answer count: 1
linked to: http://stackoverflow.com/q/19651128
tagged with: smartcard
type: UnansweredQuestion
has body: I recently bought some Java Cards: GP 2.1.1 JC 2.2.2 JCOP I have created some applets using the emulators. Now I need to transfer these to the card. I am using the open source "gpshell" and "jcManager" to load the applets. The problem is that I cannot load my applet. When I select the default Card Manager applet I get a return "6A82" applet not found. When I run a Select command I receive again "6A82" return. How can I determine the Card Manager AID? If the card is not pre-personalized how can I pre-personalize it? When I run the JCOP INDENTIFY command I get "0" on offset 14 and again "6A82". This means that the card is not fused.
has title: Java Card Communication
tagged with: java
type: Question

http://stackoverflow.com/comment/33584843
has text: okay after following that way of doing it that worked. how can i get my existing java files that i created on dr. java ide to work on eclipse?
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22134051

http://stackoverflow.com/a/22010802
answers question: http://stackoverflow.com/q/22010744
has comment: http://stackoverflow.com/comment/33362434
score: 1
has comment: http://stackoverflow.com/comment/33362584
upvote count: 1
has body: In the first case: Singleton.method(); method have to be static In the second case: Singleton.getInstance().method(); the method is not static. So those are conceptually different
has comment: http://stackoverflow.com/comment/33362659
has comment: http://stackoverflow.com/comment/33362712
downvote count: 0
type: Answer

http://stackoverflow.com/comment/33475133
comment on: http://stackoverflow.com/q/22050158
type: QuestionComment
has text: Then go with the popup dialog
type: Comment
score: 0

http://stackoverflow.com/q/22067933
favorite count: 0
has comment: http://stackoverflow.com/comment/33464397
type: Question
has comment: http://stackoverflow.com/comment/33463831
tagged with: java
has answer: http://stackoverflow.com/a/22085848
tagged with: indexoutofboundsexception
upvote count: 1
has answer: http://stackoverflow.com/a/22068139
answer count: 4
tagged with: for-loop
downvote count: 0
has title: Hangman in Java throws ArrayIndexOutOfBounds
has answer: http://stackoverflow.com/a/22068042
accepted answer: http://stackoverflow.com/a/22085848
tagged with: while-loop
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/22068129
has comment: http://stackoverflow.com/comment/33496402
score: 1
tagged with: string
has answer: http://stackoverflow.com/a/22068129
has body: My programs throws StringIndexOutOfBoundsException at this segment of code: temp1 = temp.replace('-', temp.charAt(p)); I'm trying to get the index of the same letter (after comparing inputted letter and word) and removing the '-' to show that the user has guessed correctly.** **I've been trying for hours to no avail. I think the problem lies in my loops. Thanks for the answers :) if I violated anything, please forgive me. run: ----- Enter a letter: a Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 3 at java.lang.String.charAt(String.java:658) at Hangman.main(Hangman.java:34) Java Result: 1 import java.util.Scanner; public class Hangman { public static void main (String [] args){ Scanner sc = new Scanner(System.in); String word = "Sample"; String temp = null; String temp1 = null; String letter = null; int n; int m=0; int p = 0; for (n = 0; n&lt;word.length(); n++){ temp = word.replaceAll(word, "-"); //replaces the String word with "-" and prints System.out.print(temp); } while (m&lt;=5){ //the player can only guess incorrectly 5 times System.out.println("\nEnter a letter:"); letter = sc.nextLine(); letter.toLowerCase(); if (word.contains(letter) == true){ p = word.indexOf(letter); temp1 = temp.replace('-', temp.charAt(p)); //if the word contains the letter, "-" is replaced by the letter. System.out.print(temp1); } else { System.out.print("\nMissed: "+letter); //if not, Missed: +the given letter m++; //to count for incorrect guesses } System.out.print(temp1); } System.out.println("Game Over."); } }

filewriter
tag name: filewriter
tags question: http://stackoverflow.com/q/22168399
tags question: http://stackoverflow.com/q/22080326
tags question: http://stackoverflow.com/q/22050336
type: Tag

printing
tags question: http://stackoverflow.com/q/22139170
tags question: http://stackoverflow.com/q/22058738
tags question: http://stackoverflow.com/q/22133350
tag name: printing
tags question: http://stackoverflow.com/q/22120122
tags question: http://stackoverflow.com/q/22162075
tags question: http://stackoverflow.com/q/22138436
tags question: http://stackoverflow.com/q/22081772
tags question: http://stackoverflow.com/q/22038608
tags question: http://stackoverflow.com/q/22107417
type: Tag
tags question: http://stackoverflow.com/q/22159803
tags question: http://stackoverflow.com/q/22044294
tags question: http://stackoverflow.com/q/22089344
tags question: http://stackoverflow.com/q/22161755

http://stackoverflow.com/q/22074499
has title: Eclipse RCP which shell to use for popups
favorite count: 0
type: Question
score: 12
answer count: 1
tagged with: popup
has answer: http://stackoverflow.com/a/22075357
tagged with: java
upvote count: 12
downvote count: 0
has body: I am trying to get hold of a shell in Eclipse RCP and bring up popups in my application and had gone through several resources/tutorials to achieve the task but without much luck. Tried: Display.getCurrent().getActiveShell(); or Display.getDefault().getActiveShell(); or PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); or sometimes even Display.getDefault().getShells()[0]; But different things seem to work in different situations. Resources online have different views and most things I find say you shouldn't really use the Display class at all but I am trying to bring up a popup from within an eclipse Job. It's got to the end and failed and the popup needs to be displayed using: Code: Display.getCurrent().syncExec(new Runnable() { @Override public void run() { MessageDialog.openError(Display.getDefault().getActiveShell(), "Publish", e.getMessage()); } }); } The popup is inside a Runnable being executed from a Thread started from an Eclipse Job. It's complex but necessary to provide progress bar updates whilst calling a synchronous method on a server. It doesn't work and I don't know why. Just getting a null from the getActiveShell() call. The real question though isn't 'why doesn't my code work' but was is the definitively correct way to get a shell for a popup in Eclipse RCP framework, and especial in situations where you can't access a workbench?
type: UnansweredQuestion
tagged with: eclipse-rcp

http://stackoverflow.com/comment/33665038
has text: @Cruncher Yup, it won't. In current code, since the `main` method is in the class itself, it would seem that it is able to access, but if you move it outside the class, neither `t1` nor `t2` would be able to access `x`.
type: Comment
comment on: http://stackoverflow.com/a/22164078
score: 1
type: AnswerComment

http://stackoverflow.com/q/22122100
score: 0
has body: hi everyone I'm just curious on how one would write a code for an array that will sort indexes in order to match a previous array's inputs. Example of what i mean: If array 1 had inputs in this order: 1,2,3,4 How the indexed variables would look in array 1 A[0] = 1 A[1] = 2 A[2] = 3 A[3] = 4 Then i ask a user to input a number from the previous array so they can add information to. user input = 2 Now i ask what information do they want to add to that category? They input : apples What i would want to happen: Array 1: A[1] = 2 Array 2: A[1] = apples Explanation in coding: (please disregard if i forgot something) import java.util.Arrays import java.util.Scanner; public static parallelArrays { public static void main (String[] args) { Scanner input = new Scanner (System.in); //arrays and declarations int [] numbers = new int [4]; double [] money = new double [4]; system.out.println("Please enter 4 digits"); for (int i = 0 ; i &lt; numbers.length; i++) { numbers[i] = input.nextInt(); } system.out.println("please choose the number you would want to add more information to"); for (int i : numbers) { System.out.println(i + "; "); } //this is where I'm lost //how should i write the code to get user input that will align with array "numbers" // index? } } i would like to create something that takes in inputs in double form and is able to align them in the order that array "numbers" has indexed its variables. so that i may keep the array indexes corresponding to each other. how would the coding look to get the index of array 2 to sort itself in the correct order so that it will match the index of array 1 in order to keep them sorted in this way? Sorry if this is a trivial question, i really can't find a way to do so. thank you.
tagged with: java
has comment: http://stackoverflow.com/comment/33562300
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/33562265
linked to: http://stackoverflow.com/q/18835047
tagged with: arrays
has comment: http://stackoverflow.com/comment/33562584
tagged with: parallel-arrays
has comment: http://stackoverflow.com/comment/33562316
duplicate of: http://stackoverflow.com/q/18835047
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22122296
has title: how to write a parallel array
favorite count: 0
accepted answer: http://stackoverflow.com/a/22122296
type: Question
answer count: 1

nexus
type: Tag
tags question: http://stackoverflow.com/q/22149683
tag name: nexus

http://stackoverflow.com/comment/55030128
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/27832393
has text: Worked for me (JBoss 6.4 and Spring Boot 1.2.7.RELEASE). I was having the same issue.
type: Comment

http://stackoverflow.com/a/22056150
has comment: http://stackoverflow.com/comment/33444485
has comment: http://stackoverflow.com/comment/33443905
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/33444017
has body: Primitive types are passed by value, that is copied in the stack, while Objects are passed by copy of pointers.
has comment: http://stackoverflow.com/comment/33443828
score: 1
has comment: http://stackoverflow.com/comment/33443855
has comment: http://stackoverflow.com/comment/33444203
has comment: http://stackoverflow.com/comment/33443880
has comment: http://stackoverflow.com/comment/33444054
has comment: http://stackoverflow.com/comment/33443977
has comment: http://stackoverflow.com/comment/33444319
has comment: http://stackoverflow.com/comment/33444055
has comment: http://stackoverflow.com/comment/33444164
answers question: http://stackoverflow.com/q/22056112
upvote count: 1
has comment: http://stackoverflow.com/comment/33443963

http://stackoverflow.com/q/22127945
tagged with: jdbc
accepted answer: http://stackoverflow.com/a/22143757
type: AnsweredQuestion
score: 1
tagged with: java
tagged with: mysql
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/23243811
has title: Sonar runner (ubuntu) execution failed: com.mysql.jdbc.Driver
tagged with: sonarqube
has answer: http://stackoverflow.com/a/22143757
possible better answer: http://stackoverflow.com/a/23243811
answer count: 2
has comment: http://stackoverflow.com/comment/33600135
downvote count: 0
has body: I've recently installed SONAR on a Vagrant box running UBUNTU. Sonar service run fine, but when I try to run the sonar-runner I get an error related to jdbc connector. I configured sonar to run with mysql database by changing the file "sonar-runner.properties": sonar.jdbc.url=jdbc:mysql://127.0.0.1:3306/sonar?seUnicode=true&amp;amp;characterEncoding=utf8 sonar.jdbc.username=sonar sonar.jdbc.password=sonar When trying to start sonar-runner i get the following output: $ sudo sonar-runner start -e SonarQube Runner 2.3 Java 1.6.0_27 Sun Microsystems Inc. (64-bit) Linux 3.2.0-23-generic amd64 INFO: Error stacktraces are turned on. INFO: Runner configuration file: /home/vagrant/bin/sonar-runner/conf/sonar-runner.properties INFO: Project configuration file: NONE INFO: SonarQube Server 4.1.1 13:01:58.363 INFO - Load batch settings 13:01:59.524 INFO - User cache: /root/.sonar/cache 13:01:59.560 INFO - Install plugins 13:02:03.309 INFO - Install JDBC driver 13:02:03.618 INFO - Create JDBC datasource for jdbc:mysql://127.0.0.1:3306/sonar?useUnicode=true&amp;amp;characterEncoding=utf8 INFO: ------------------------------------------------------------------------ INFO: EXECUTION FAILURE INFO: ------------------------------------------------------------------------ Total time: 43.846s Final Memory: 2M/14M INFO: ------------------------------------------------------------------------ ERROR: Error during Sonar runner execution org.sonar.runner.impl.RunnerException: Unable to execute Sonar at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91) at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75) at java.security.AccessController.doPrivileged(Native Method) at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69) at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50) at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102) at org.sonar.runner.api.Runner.execute(Runner.java:90) at org.sonar.runner…
favorite count: 0
has comment: http://stackoverflow.com/comment/33573516

http://stackoverflow.com/comment/33368410
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22014405
has text: @SoftMemes You can only read types which are burnt into the class information, not types which are created at runtime.

ofbiz
tags question: http://stackoverflow.com/q/22010001
tags question: http://stackoverflow.com/q/22040392
tag name: ofbiz
type: Tag

http://stackoverflow.com/q/22035322
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22035402
has comment: http://stackoverflow.com/comment/33406539
possible better answer: http://stackoverflow.com/a/22035487
has body: Sorry, I am beginner in java. I have defined two arrays. one of the types is string and the other is integer. now, i want to shuffle them.Assume id = {12, 45, 78, 23} and name = {"math", "physic", "art", "computer"}. for example after shuffling the arrays will become id = {78,45,23,12} and name = {"physic", "art", "math", "computer"}. i wrote the below code which does not work. how can i fix it? public class RandomNumber { public static void main(String[] args) { long[] numbers = new long[4]; Scanner input = new Scanner(System.in); Random id = new Random(4); String[] name = new String[4]; for (int i=0; i&lt;=numbers.length; i++) { System.out.print("Enter the numbers: "); numbers[i] = input.nextLong(); } for (int i=0; i&lt;=numbers.length; i++) { int randomPosition = id.nextInt(4); long temp = numbers[i]; numbers[i] = randomPosition; numbers[randomPosition] = temp; } for (int i=0; i&lt;name.length; i++) { System.out.println("Enter the name: "); name [i] = input.nextLine(); } for (int i=0; i&lt;name.length; i++) { int randomPosition = id.nextInt(4); String temp = name[i]; name[i] = randomPosition; name [randomPosition] = temp; } for (int i=0; i&lt;numbers.length; i++) { System.out.println(i + " ID = " + numbers[i] + " and name = " + name[i]); } } }
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/22035435
has answer: http://stackoverflow.com/a/22035487
type: Question
linked to: http://stackoverflow.com/q/22035176
has comment: http://stackoverflow.com/comment/33406301
tagged with: arrays
has answer: http://stackoverflow.com/a/22035530
has answer: http://stackoverflow.com/a/22035594
upvote count: 2
tagged with: random
downvote count: 1
has comment: http://stackoverflow.com/comment/33407217
favorite count: 0
has title: shuffle two arrays in java
accepted answer: http://stackoverflow.com/a/22035402
has comment: http://stackoverflow.com/comment/33407159
answer count: 5

http://stackoverflow.com/q/22113578
type: Question
has comment: http://stackoverflow.com/comment/33546956
has comment: http://stackoverflow.com/comment/33546690
tagged with: java
has comment: http://stackoverflow.com/comment/33547045
has comment: http://stackoverflow.com/comment/33547218
has body: I'm trying to solve a problem on codeeval but am running into a problem with using too much memory. In my code there is a loop that runs many many times (~10,000^2) due to a large input that is unavoidable. I noticed that if I run the loop and do nothing on each iteration I use about 6MB of memory in total with my other code. However, if I add a simple method call in the loop that just calls a function that returns false, my memory usage jumps to 20MB. Why is this? Shouldn't the memory allocated for each function call get deallocated after the function call is finished? EDIT: The full code is quite large and irrelevant to post but this snippet is what I described. If I do not include the foo() call, my code as a whole runs using 6MB of memory. If I include the foo() call, my code as a whole runs using 20MB of memory. The foo() method in my actual code does literally the same thing (return false) because I wanted to test out the memory usage. This is for a coding challenge on codeeval so the problem should be solvable in any language they allow so java should be fine. EDIT: I've refactored some of my code so that I could pull out an entire function to show you guys. This still produces the same result described before. The function call that produces the weird behavior is are_friends(). ArrayList&lt;ArrayList&lt;Integer&gt;&gt; graph(String[] word_list) { ArrayList&lt;ArrayList&lt;Integer&gt;&gt; adj_list = new ArrayList&lt;ArrayList&lt;Integer&gt;&gt;(); for (int i = 0; i &lt; word_list.length; i++) { adj_list.add(new ArrayList&lt;Integer&gt;()); } for (int i = 0; i &lt; word_list.length; i++) { for (int j = i + 1; j &lt; word_list.length; j++) { if (are_friends(word_list[i], word_list[j])) { adj_list.get(i).add(j); adj_list.get(j).add(i); } } } return adj_list; } boolean are_friends(String a, String b) { return false; }
has answer: http://stackoverflow.com/a/22113784
score: 5
answer count: 3
has comment: http://stackoverflow.com/comment/33546713
has comment: http://stackoverflow.com/comment/33546676
has comment: http://stackoverflow.com/comment/33547379
favorite count: 0
has comment: http://stackoverflow.com/comment/33548765
has comment: http://stackoverflow.com/comment/33558536
upvote count: 5
has comment: http://stackoverflow.com/comment/33547114
has answer: http://stackoverflow.com/a/22118691
has title: java memory usage from method call
has comment: http://stackoverflow.com/comment/33547016
has comment: http://stackoverflow.com/comment/33547141
has comment: http://stackoverflow.com/comment/33547108
has comment: http://stackoverflow.com/comment/33547057
tagged with: memory-management
has comment: http://stackoverflow.com/comment/33547044
downvote count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/22113843
has comment: http://stackoverflow.com/comment/33557841

http://stackoverflow.com/q/22124538
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/33567531
tagged with: java
has comment: http://stackoverflow.com/comment/33567311
has title: Passing objects from a pool to a runnable class
type: Question
has body: I have an pool of objects in a blockingQueue. Now i want to assign objects from the queue to a thread and use it inside the run method. What is the best way of doing it? Here is a sample code i am using to build the pool: public class ConsumerPool { private static Logger log; //building consumer Pool @SuppressWarnings("finally") public BlockingQueue&lt;OAuthConsumer&gt; buildConsumerPool() { BlockingQueue&lt;OAuthConsumer&gt; consumerObjectsQueue = null; try { //setting the config path PropertyHandler.setConfigPath(propertiesMain); String twitterPath = PropertyHandler.getProperty("twitterPath"); //setting config for twitter PropertyHandler.setConfigPath(twitterPath); //Blocking Linked Queue consumerObjectsQueue = new LinkedBlockingQueue&lt;OAuthConsumer&gt;(); //fetching required tokens for all apps String consumerKeySet = PropertyHandler.getProperty("consumerKey"); String consumerSecretSet = PropertyHandler.getProperty("consumerSecret"); String accessTokenSet = PropertyHandler.getProperty("accessToken"); String tokenSecretSet = PropertyHandler.getProperty("tokenSecret"); String[] splitconsumerKeys = consumerKeySet.split(","); String[] splitconsumerSecret = consumerSecretSet.split("."); String[] splitaccessToken = accessTokenSet.split(","); String[] splittokenSecret = tokenSecretSet.split("."); //creating consumer objects for each app for (int i= 0; i&lt; splitconsumerKeys.length; i++) { log.info("constructing consumer object for twitter api " +i); String consumerKey = splitconsumerKeys[i]; String consumerSecret = splitconsumerSecret[i]; String accessToken = splitaccessToken[i]; String tokenSecret = splittokenSecret[i]; OAuthConsumer consumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret); consumer.setTokenWithSecret(accessToken, tokenSecret); consumerObjectsQueue.put(consumer); log.info("added the consumer object to que pool"); } } catch (Exception e) { e.printStackTrace(); } finally { return consumerObjectsQueue; } } That is used to build the object p…
has comment: http://stackoverflow.com/comment/33567371
has comment: http://stackoverflow.com/comment/33567331
score: 0
has answer: http://stackoverflow.com/a/22125425
accepted answer: http://stackoverflow.com/a/22125425
answer count: 1
tagged with: object-pooling
tagged with: multithreading