FAQ Database Discussion Community


Spring Resttemplate login fails

java,spring,spring-mvc,spring-security,csrf
after an update to spring-4.1.6 i'am not able to login to my rest services any more. I looked on different sides, but couldn't solve the problem... so i ask for help. Here is my my web.xml: <?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <!-- The definition of the...

Get current latitude and longitude android

java,android,gps,geolocation,location
Requirement: 1.Sometimes(not everytime) I am getting latitude and longitude 0.0. 2.I want to know how to get the location update after user has enabled the gps from the settings. Here is my code public class GPSTracker extends Service implements LocationListener { private final Context mContext; // flag for GPS status...

Getting a mouse position with JavaFX and Event

java,javafx
I'm trying to get the position of a mouse click in my JavaFX application. I have an EventHandler as so: EventHandler<Event> mouseHandler = new EventHandler<Event>() { @Override public void handle(Event event) { String eType = event.getEventType().toString(); if(eType.equals("MOUSE_PRESSED")){ //mouse position } } }; which is called on mouse press, release and...

Using Class names as identifiers

java
If I did String String = "String" then I can use the methods in variable String. If I wanted to use the static methods in class String, how do I do that?

Error while setting targetConnectionFactory in UserCredentialsConnectionFactoryAdapter Spring 4

java,spring,jms,spring-boot,spring-jms
We are receiving a compilation error in the following code, while trying to set the targetConnectionFactory. According to the example given in Spring 4 documentation for UserCredentialsConnectionFactoryAdapter, the setTargetConnectionFactory() method takes the object of JndiObjectFactoryBean as an argument. But, looks like the JndiObjectFactoryBean hasn't implemented the 'ConnectionFactory' interface, which is...

Classes Extending Object

java
If every class extends Object, then how does the explicit "extends" keyword to another class work? Does this mean that the current class doesn't extend Object anymore or does it mean it extends two classes?

Serializing a java bean into a cookie: Is it bad?

java,json,cookies
In the organization that i work for, there was a serious debate about the following. Scenario: There is a POJO with 6 different properties all are of type Strings. These values need to be persisted as cookies so that it can be picked back when someone does a booking on...

Java.util.logger new file every day

java,logging
I am using java.util.logging framework to implement logging in my JSF application. I have successfully done implementing this, but however I have a new requirement to rotate the logs and create a new log file for each day. I am not able to figure out how this can be implemented....

Javadoc: Do parameter and return need an explicit type description

java,types,javadoc
When Javadoc'ing, I don't know whether you should explicitly say whether the parameters are of type String or int. For example /** * This method does something * @param foo an object of type Foo * @param abc the number of doors, of type int * @return the number of...

Swing regular expression for phone number validation

java,regex
I want to validate phone number field in swing, so I am writing code to allow user to enter only digits, comma, spaces. For this I am using regular expression, when user enter characters or other than the pattern text field will consume. My code is not working. Can anyone...

Form submit portlet with Spring MVC

java,jsp,spring-mvc,liferay,portlet
I'm trying to achieve a Liferay portlet of submit form using spring MVC. The model: package com.model; public class Person { String firstName; String middleName; public String getFirstName() { return this.firstName; } public String getMiddleName() { return this.middleName; } public void setFirstName(String firstName) { this.firstName=firstName; } public void setMiddleName(String middleName)...

What is the meaning of this code in Java? [on hold]

java
I was going through some of the questions online and I came across this code. I couldn't understand the meaning of this particular line of code. Please can anyone explain me the meaning of this line of code. So, there are two classes Student class and Course class. Each class...

SOAP Client, Following an example

java,soap,saaj
I need to consume a SOAP Server named "Mouser" for my company. However I have a problem when I try to send a message. The documentation of my request is : POST /service/searchapi.asmx HTTP/1.1 Host: www.mouser.fr Content-Type: application/soap+xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Header> <MouserHeader...

Numeric literals in Java - octal? [duplicate]

java,literals,octal
This question already has an answer here: How does a leading zero change a numeric literal in Java? 3 answers Here is some code in java on datatypes: class Test { public static void main(String args[]) { int i = -0777; System.out.println(i); } } The output of the above...

Implementing enum-based singleton

java,enums,singleton
J. Bloch in his Effective Java suggests we use an enum-based singleton implementation. For instance: public enum Application { INSTANCE; //methods, fields } This implementation is nice in the case of serialization because enums provide us with the capability of serialization by default (and we don't have to be afraid...

Mysterious claim of a missing { in eclipse

java,eclipse
I have a case of a mysterious missing curly brace that I don't see any use for. Eclipse says, "Syntax error on token ";", { expected after this token". Either I am missing something very silly or there is something new I have to learn about Java. This is the...

How to do custom rounding of numbers in Java?

java,rounding
Suppose I want to round numbers that have mantissa greater than 0.3 'up' and those below 'down'. How can I do it in Java? The only thing that came to my mind was Math.round(), but I can't seem to make it follow a certain rule....

Get network interfaces on remote machine

java,network-programming
I know in java we can do NetworkInterface.getNetworkInterfaces() to get all available network interfaces on local machine. Can we do similar thing where I can pass host name to get the NICs(with IPs) which are up and running?

Bulkheading strategies for Akka actors

java,asynchronous,akka,blocking,future
I have a scenario where an important actor needs to make a call to a slow (15 - 20 seconds) remote system: // Non-actor code equivalent public Result makeSlowNetworkCall(Request request) { Result result = slowServiceClient.soooooSlow(request); // Could be up to 15 - 20 SECONDS (mehhhh) return result; } The Akka...

Java - Enforce TextField Format - UX - 00:00:00;00

java,regex,user-interface
Please see below image of the UI of my current application Currently, I am enforcing Data Format of the text fields in the back end. If the RegEx does match (00:00:00;00), it will throw an error. My question is from a UX perspective, is it possible to make the input...

Unfortunately, (My app) has stopped. Eclipse Android [duplicate]

java,android,eclipse,adt
This question already has an answer here: What is a Null Pointer Exception, and how do I fix it? 12 answers I'm a beginner in android developing and I'm trying to build a simple app but I'm getting this error in the emulator.(Unfortunately,(App) has unexpectedly stopped). LogCat http://i.stack.imgur.com/VZhuL.png package...

List view not returning to original state after clearing search

java,android,xml,android-activity,android-listfragment
I'm trying to get my list to show all my items again whenever I cancel a search from my search view but for some strange reason, the list gets stuck with the results only from the previous search. Does anyone know what is wrong with my code and how to...

LinkedHashMap vs ArrayList with Bluetooth Scanning and ListView

java,listview,arraylist,linkedhashmap
I have a little bit of a confusion when it comes to what is considered the better implementation. One the one hand, LinkedHashMap provides the following benefits: Prevents duplicate items (I need to be able to prevent a scanned Bluetooth device to not repeatedly enter the list.) Provides easy access...

Why is my Spring Boot autowired JPA Repository failing JUnit test?

java,spring,junit,spring-boot
My JUnit test is failing with the following error: "java.lang.IllegalArgumentException: Could not find field [userRepository] of type [null] on target [[email protected]]" Here is the Test class: @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = App.class) @WebAppConfiguration @IntegrationTest public class UserResourceTest { @Autowired private UserRepository userRepository; private MockMvc restUserMockMvc; @Before public void setup() { UserResource userResource...

A beginner questions about printf, java

java,string,printf
I'm learning Java by myself and through tutorials online. Just wondering in a printf statement, what does the different %s, %d, %15, %7, %12.2(and so on...) mean? Couldn't find any explanation anywhere online, so I'm turning to you. ...

error: cannot find symbol class AsyncCallWS Android

java,android,web-services
I'm trying to rewrite the application in this, in Android Studio link, which is written in Eclipse. There are two problems, first problem is there is this line in the project : import com.example.webserviceactivity.R; I couldn't write this one on Android Studio. The second problem is, in this part of...

Get the value of the last inserted record

java,jdbc
I am trying to get the stop_name of the last inserted row in the table with preparedStatement. How can I get the last inserted one? I appreciate any help. behavoiur table: CREATE TABLE IF NOT EXISTS behaviour( behaviour_id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, mac VARCHAR(30) NOT NULL, stop_name VARCHAR(30)...

possibly lossy conversion from int to byte

java,javax.comm
I am trying to write hexadecimal data into my serial port using java, but now I cant convert the hexadecimal data into the byte array. Here is the code which shows the error message: static byte[] bytearray = {0x02, 0x08, 0x16, 0x0, 0x00, 0x33, 0xC6, 0x1B}; This is the code...

Assigning text file data to java variable

java
I'm pretty sure that I'm really close to getting this working. I have a text file that contains the output of batch file. I want to assign the computer name from within the text file to JLabel selectedComputerFromAD. Currently the text file output looks like this: "CN=COUD111235,OU=Workstations,OU=Mis,OU=Accounts,DC=FL,DC=NET" I need to...

What does '<< ' mean ? And what this code mean?

java
I don't understand what is this doCalculatePi means or does, in the following example: public static double doCalculatePi(final int sliceNr) { final int from = sliceNr * 10; final int to = from + 10; final int c = (to << 1) + 1; double acc = 0; for (int...

Using world coordinates

java,libgdx
I am currently using pixels as units for placing objects within my world, however this can get tedious because I only ever place objects every 16 pixels. For example, I would like to be able to place an object at position 2 and have the object rendered at the pixel...

Can I install 2 or more Android SDK when using Eclipse

java,android,eclipse,sdk,versions
I am new to android developments. I am setting up my android development environment using Eclipse. I have a test smart phone with Android version 4.2.2. The automatic installation installed the latest Android SDK version, which is 5.1.1. My questions are: 1. Do I have to install the SDK version...

Get the min and max value of several items with Comparable

java
I am trying to get the records with min distance, min speed and max speed in the result of my query. Currently I am getting the shortest distance but I am facing problem to get the min and max speed and I am asking myself whether it is possible to...

type conversion if flex

java,actionscript-3,flex
I am using Flerry as Java-Flex bridge for my Flex Desktop Application. How to convert List in Java to ArrayCollection in Flex Flex Code:- [Bindable]public var screenList:ArrayCollection; <flerry:NativeObject id="windowControllerObj" source="ls.window.EnumAllWindowNames" singleton="true" fault="windowControllerObj_faultHandler(event)"> <flerry:NativeMethod id="getWindowNames" name="getAllWindowNames" result="windowControllerObj_resultHandler(event)" fault="getWindowNames_faultHandler(event)"/>...

Design suggestion: Changing the class behaviour

java,design,object-oriented-analysis
Below I am trying to explain the problem with an example. We have a Caller.java Caller.java : which calls the series of Actors to perform certain steps in sequence. Actor.java : Abstract class containing action() method ActorOne.java : Implements the action() method ActorTwo.java : Implements the action() method ActorThree.java :...

Selenium catch popup on close browser

java,selenium,browser
I'm trying to test that when I close my window a popup shows with a warning message. I've tried both driver.close() and driver.quit() after making sure I'm on the proper window but this just terminates the process since my popup doesn't show. I could test it by using the awt...

Generic method only compiles with one argument

java,generics
The below code will not compile, it says that the method is not applicable for the arguments. The interesting thing is that if I remove one of the arguments (doesn't matter which) then it compiles fine. public class Test1 { static Collection<? extends Shape> someColl = new ArrayList<Shape>(); public static...

Java Scanner not reading newLine after wrong input in datatype verification while loop

java,while-loop,java.util.scanner
I've looked at similar questions and tried to follow the answers that solved the issues that others have had but putting the sc.next() or sc.nextLine() after the while loop causes it to go into an infinite loop. The problem is if a user enters incorrect input (nothing or a number)...

Postgresql Update JDBC

java,postgresql,jdbc
I want to update table: id integer NOT NULL, "first" character varying(255), "last" character varying(255), age integer, CONSTRAINT registration_pkey PRIMARY KEY (id) using method: void updateTable(String tableName, String columnName, String value, String columnName2, String value2) { try { String sql = "UPDATE " + tableName + " SET " +...

ffmpeg problems (mpeg1video -> ?)

java,ffmpeg
I'm trying to convert various video files from .mpeg to .ogg theora videos. This command works fine when I test it in its own program, but fails to run properly inside the program it was intended for. I don't understand what's breaking here. Adding a -vcodec flag causes other errors....

Interpreting hex dump of java class file

java,class,hex
I understand the structure of a java .class file, but when I want to interpret the raw hex data I get a bit lost. This is a hex dump of a class file, excluding the header and constant pool. I understand the header to be the magic number, minor_version and...

How to set fixed size to PriorityQueue in Java? [duplicate]

java,priority-queue
This question already has an answer here: Is there a PriorityQueue implementation with fixed capacity and custom comparator? 7 answers I have a simple question. I am implementing PriorityQueue in my project. My question is can i set a fixed size for PriorityQueue is Java ?...

@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) doesn't work

java,jpa,glassfish,ejb-3.0
I need to delete a list of employees ignoring any integrity constraints (i.e. successfully delete the entity that doesn't related to any others yet or skip the entity that related to others) using JPA 2.0 and EJB3.0 on glassfish3.0: I iterated on the list and call entity manager in a...

Change the “about this” window on mac app

java,osx,deployment
On Macs, there's a default menu at the top for basic application handling functions: I've made an application using Java for my Grade 10 final project, (and I'm quite convinced that it's better than Microsoft Paint) and I decided to package it. Using Eclipse, I exported it as a Mac...

How to call MySQL view in Struts2 or Hibernate

java,mysql,hibernate,java-ee,struts2
I have a view in MySQL database CREATE VIEW CustInfo AS SELECT a.custName, a.custMobile, b.profession, b.companyName, b.annualIncome FROM customer a INNER JOIN cust_proffessional_info b ON a.cust_id=b.cust_id Is there any way that i can call this view using Struts2 or in Hibernate. I have tried to search it but could not...

Create and initialize a singleton with Guice [duplicate]

java,guice
This question already has an answer here: Guice: How to get instance of Singleton without injector or using Constructor Injection 1 answer I have a the following classes StorageProxy.java (Interface) StorageProxyImpl1.java (Implementation1 of StorageProxy Interface) public class StorageProxyImpl1 extends StorageProxy{ public void init(String key){ .... } } public class...

@RestController throws HTTP Status 406

java,spring,rest,maven
I am working on a basic Hello World program using Spring and Restful webservices. But when I try to call my service I am getting below error message: HTTP Status 406 - description - The resource identified by this request is only capable of generating responses with characteristics not acceptable...

count items in a column vaadin

java,vaadin
Good day everyone! How do I get the number of items that a column contains? I want to hide the "Workgroup" column if it's empty, I just don't know how. Table tblTeachings = new Table(); tblTeachings.addContainerProperty("#", Integer.class,0); tblTeachings.addContainerProperty("Course",String.class,""); tblTeachings.addContainerProperty("Teaching name",String.class,""); tblTeachings.addContainerProperty("Start date",String.class,""); tblTeachings.addContainerProperty("End Date",String.class,""); tblTeachings.addContainerProperty("Activity...

Return value -Java API design VS. C API

java,api
I used C a lot before and now use Java. I have a question of API design in JAVA. In C, I always use int as a meaningful return value, and put multiple objects(some of which will be changed) in arguments. e.g, int foo(int x, int y, int *result) {...

Why ever use CachedGauage in Dropwizard Metrics?

java,metrics,dropwizard,codahale-metrics
I see there is the CachedGauge in the DropWizard Metrics (formerly Coda Hale Metrics) lib. I'm wondering why anyone would ever use this?!? My understanding of the value of a metric is that it is real-time, accurate and relevant. If a metric is reporting a stale/cached value, of what purpose...

why java API prevents us to call add and remove together?

java,list,collections,listiterator
As per Java API- IllegalStateException - if neither next nor previous have been called, or remove or add have been called after the last call to next or previous remove()- Removes from the list the last element that was returned by next() or previous() (optional operation). This call can only...

Android SQLite: Fast insert/update

java,android,sqlite
In my Android application I am using compiled statements to be able to insert rows quickly: insert = db.compileStatement( "INSERT INTO foo (id, aaa, bbb, ccc) " + "VALUES (?,?,?,?)"); This works correctly and quite fast. However when there is already foo with id, I am receiving following exception: column...

Android String if-statement

java,android,string
I have a if-statement in the start of my app if (ready.equals("yes")){ ... } and later on my code I have ready="yes"; but the if statement is never called, why? The ready="yes"; is called from a background thread, is that why? public void DownloadFromUrl(final String fileName) { //this is the...

App Not Downloading Newest Version Of File [Java]

java,caching,download
Okay, I've been trying to figure this out for a few hours and it's starting to kill me. I wrote a primitive version checker for an app I work on every once and awhile. It's just a simple for fun project. The version checker has been a pain though. It...

byte array to string and inverse : recoverded byte array is NOT match to original byte array in Java

java,string,bytearray
I converted a byte array to string as follow, in Java: String str_bytearray = new String(bytearray_original); and then, I recovered original byte array using string, as follow: byte[] bytearray_recovered = str_bytearray.getBytes(); but I wondered when I compared bytearray_original and bytearray_recovered. the result is as follow: [48, 89, 48, 19, 6,...

Why do I get different results on variable value?

java
I'm kind of confused about the outputs. This is the first program. class A { private int price; private String name; public int getPrice() { return price; } public String getName() { return name; } } class B { public static void main(String[] args) { A a = new A();...

Iterating over a map and putting its values in java

java,guava
I have created the data structure that is google based guava table and it is shown below final Table<String, String, List<String>> values = HashBasedTable.create(); values.put("ton bon", "currency", Lists.newArrayList("ccdd", "rode1", "cwey", "Certy")); values.put("ton bon", "racy", Lists.newArrayList("wqadd", "werde", "ihtr", "ytre")); Below is the way in which i am iterating over this collection...

Comparasion of Integer.equals() and Objects.equals()

java,testing,equals
Here are my test for two equals methods: Random generator = new Random(); long startTime = System.nanoTime(); for(int i = 0; i<1000; i++) { Integer int11 = generator.nextInt(1000); Integer int22 = generator.nextInt(1000); int11.equals(int22); } long endTime = System.nanoTime(); long duration = (endTime - startTime); System.out.println(duration + " ns"); Random generator1...

do calculation inside JSONArray in Java

java,arrays,json
I have a simple issue but cannot solve it as I am not very good at algorithm! I have an JSONArray in this form: [{"values":[{"time":1434976493,"value":"50"}, {"time":1434976494,"value":"100"}],"counter":"counter1"}, {"values":[{"time":1434976493,"value":"200"}, {"time":1434976494,"value":"300"}],"counter":"counter2"}, {"values":[{"time":1434976493,"value":"400"}, {"time":1434976494,"value":"600"}],"counter":"total"}] What I want to do is to get the integer value for counter 1 and counter 2 and then divide...

Reading and modifying the text from the text file in Java

java
I am have a project that need to modify some text in the text file. Like BB,BO,BR,BZ,CL,VE-BR I need make it become BB,BO,BZ,CL,VE. and HU, LT, LV, UA, PT-PT/AR become HU, LT, LV, UA,/AR. I have tried to type some code, however the code fail to loop and also,in this...

Instantiate web service

java,jaxb,wsdl
I have clasess BankImpl, BankService, BankClient, BankServer and Bank interface. I want to instantiate that bank service so I can use it with my other webservices but dont know the correct way of doing it. I have something like this now: Service service = Service.create(wsdlLocation, new QName("http://bla/bla/bank", "BankService")); Bank bank...

Persist Object's value after copying in Java

java,object
My sample code - private final DataObj dataObj = getDataObjs(); private final DataObj dataObj1 = new DataObjImpl(); dataObj1 = dataObj; //I need the value of dataObj1 to be the same even if the value of dataObj is modified anywhere further down in a class. My problem is that if the...

Relationship between a package statement and the directory of a .java file?

java,package
Consider a package hierarchy folder1/hi. folder1 contains B.java and hi contains A.java. B.java: package hi.a12.pkg; public class B { } A.java: package a12.pkg; public class A {B b; } Now B.java compiles successfully, but A.java does not. Since both should produce class files in same location. Hence they should be...

how to call Java method which returns any List from R Language? [on hold]

java,r,rjava
How to call java method which returns list from R Language.

Is there standard implementation for thread block/resume in java SE?

java,multithreading,wait
I need to block execution of a thread until resumed from another thread. So I wrote my own implementation using wait() method. Which seems to be working, but it is far from simple. Is there any ready to use solution? Preferably in java SE 6? Or do I have to...

Dynamic creation of objects vs storing them as fields

java,performance,object
I have this loop which runs about 1,000,000 times. while ((line = br.readLine()) != null) { if(!(line.isEmpty())){ data = new JSONObject(line); name = (String)data.get("name"); surname = (String)data.get("surname"); ar.put(name, surname); //an array } } What are the advantages (if any) in terms of efficiency of having it like that were data,name...

Finding embeded xpaths in a String

java,regex
I have a string where I have the user should be able to specify xpaths that will be evaluated at runtime. I was thinking about having a the following way to specify it. String = "Hi my name is (/message/user) how can i help you with (/message/message) "; How can...

Exception in thread “main” java.util.InputMismatchException: For input string: “1234567891011”

java
input:- 1 3 4 7 9 6 -1 output:- 4 6 What I am doing is print the even numbers from the list, one per line. The list ends when -1 is encountered. Below is the my code: Scanner sc=new Scanner(System.in); for (int i = 0; i <100000000; i++) {...

implement a method that takes 3 boolean args

java
I'm studying "Programming in Java An Interdisciplinary Approach by Sedgewick and Wayne". The following question is giving me a bit of a challenge to implement. Write a static method odd() that takes three boolean inputs and returns true if an odd number of inputs are true, and false otherwise. private...

REST Jersey server JAX-RS 500 Internal Server Error

java,rest,jersey,jax-rs
I'm calling this method and getting a 500 back from it. In the debugger I'm able to step though it all the way to the return statement at the end. No problem, r is populated as expected after Response.build() is called, the status says 200 OK. But that's not what...

Using user input value to display a specific object from an array list

java,arraylist
I am trying to create a program where the user inputs animal pertinent values, which then create animal Objects, which are then saved into an array list. The area I am having trouble with is shown below. After the Array list is populated, I cannot figure out how to use...

Android Implicit Intent for Viewing a Video File

java,android,android-intent,uri,avd
In my Android app, I have a button that when clicked, launches the external application of my choice to play a video (I gather that this is called an "implicit intent"). Here is the relevant Java code from my onCreate method. Button button = (Button) findViewById(R.id.button); button.setOnClickListener ( new Button.OnClickListener()...

viewResolver with more folders inside of WEB-INF/jsp is not working in spring

java,spring,jsp,spring-mvc
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <!-- avoid '???' --> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp"/> </bean> if i create other subfolders under jsp , for instance /WEB-INF/jsp/reports , /WEB-INF/jsp/insertions how should i configure now the viewResolver to can resolve these new sub folders??...

How to block writes to standard output in java (System.out.println())

java,logging,stdout
In Java, how to block code from writing to system out? My app calls a 3rd party library that spams logs by issuing numerous System.out.println() calls. I don't have legal rights to decompile and patch the library. I'm running Websphere 8.5.x Considered using System.setOut(PrintStream out), but that will effect the...

Getting particular view from expandable listview

java,android,listview,android-fragments,expandablelistview
In my list view I have an textview in expandable group and I want to open the dialog when textview is clicked to fill the information through edittext and update textview. Problem: how could I get the groupview textview item in my fragment oncreateview() method....

How to check if an ExecutionResult is empty in Neo4j

java,neo4j
I am executing a query in neo4j using java. I don't know how to check if the execution result is empty. Here is my code. String firstquery=" start n=node(*) match(b)-[relatedto]->(n) where b.value=\""+applicationName+"\" return n"; ExecutionResult execResult = execEngine.execute(firstquery); System.out.println("executing query"); String results = execResult.dumpToString(); System.out.println(results); Iterator<Node> n_column1 = execResult.columnAs( "n"...

Creating GUI with OpenGL

java,opengl
I am trying to write a Java programm using LWJGL 3 and so far I've made it to creating a window, rendering to it and getting basic input. But I've ran into a problem with creating GUI and namely text fields that my programm requires. I found information that there...

Logging operations in lightadmin

java,spring,logging,lightadmin
I have a Java web application which use Spring and Hibernate and I plan to use lightadmin to provide an administration interface. However, I found very little information about the logging part of lightadmin : if I have such an adminsitration interface, I would like that any operation made to...

FileNotFoundException when writing to raw file

java,android
I'm trying to write in file "numbers.txt". It's located in raw folder. I'm using this function to write in file: public void writeToFile(String data) { try { Uri url = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.numbers); String Path = url.toString(); File f = new File(Path); OutputStreamWriter outputStreamWriter = new...

Get element starting with letter from List

java,android,list,indexof
I have a list and I want to get the position of the string which starts with specific letter. I am trying this code, but it isn't working. List<String> sp = Arrays.asList(splited); int i2 = sp.indexOf("^w.*$"); ...

PropertyNotFoundException in jsp

java,jsp
Am getting this error in my application javax.el.PropertyNotFoundException: Property 'survey_id' not found on type com.moh.forms.MOH731 javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:229) javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:206) javax.el.BeanELResolver.property(BeanELResolver.java:317) javax.el.BeanELResolver.getValue(BeanELResolver.java:85) This is my MOH731.java @Id @GeneratedValue(strategy = GenerationType.AUTO) private int survey_id; public MOH731 (int survey_id, String uname)...

IllegalStateException: Iterator already obtained [duplicate]

java,file,loops,path
This question already has an answer here: java.lang.IllegalStateException: Iterator already obtained 1 answer so I wrote a little Java program to test a little stack language I made vie various test file, but for some reason it won't work. Here is the code: import org.apache.commons.io.FilenameUtils; import java.io.IOException; import java.nio.file.*;...

Broken pipe error when executing Android method more than once?

java,android,illegalstateexception,broken-pipe
I'm trying to execute the following method to spoof the MAC address of an android device. The method runs every time the user clicks a button: public void changeMac(View v) throws IOException { editText = (EditText)findViewById(R.id.newMacText); String mac = editText.getText().toString(); Log.d("my log", "" + mac); String[] cmds = {"ip link...

How can implement long running process in spring hibernate?

java,spring,hibernate
as we know the struts interceptor execute and wait will take care of long running process by not getting the request to timeout and destroy it sends wait and at last the desired response i want to implement the same for long running process in spring and hibernate. Thanks....

setOnClickListener error Null object

java,android
I saw many questions like mine and I try to fix my codes but failed... this is my code: public class MainActivity extends ActionBarActivity { EditText usernameEditText; EditText passwordEditText; public Button saveme; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); usernameEditText = (EditText) findViewById(R.id.username); passwordEditText = (EditText) findViewById(R.id.pass); saveme = (Button)...

custom arraylist get distinct

java,android
is there any way to get the distinct values of a custom arraylist? public class mystatistic extends BaseActivity { public String objectid; public String playerid; public String playername; public String enemyid; public String enemyname; public String question; public mystatistik(String objectid, String playerid, String playername, String enemyid, String enemyname, String question)...

Java Scripting API — Property from JavaScript object is always null

javascript,java,scriptengine
Below is the code I am running in my Java compiler: ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("JavaScript"); engine.put("person", "{name: 'Bob', favoriteColor: 'red'}"); System.out.println(engine.get("person.name")); I would expect this to evaluate to "Bob", but instead it gives me null. If I try printing just the user object, it properly...

OpenJPA OneToMany and composite key in parent and child table

java,jpa,jpa-2.0,openjpa
I have tables with composited primary key. Server(key=ServerId) ServerId|Name 1 |server1 2 |server2 ParentObj(key=ServerId+Code) ServerId|Code |Title 1 |code1|value1 1 |code2|value2 2 |code1|Value2b ChildObj(key=ServerId+Code+Name) ServerId|Code |Name |Value 1 |code1|prop1|val1 1 |code1|prop2|val2 1 |code2|prop1|val1b 2 |code1|prop3|val3 This is Java beans I have. @Entity @Table(name="ParentObj") @Access(AccessType.FIELD) @IdClass(value=ParentObj.PK.class) @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER) @XmlRootElement public class ParentObj {...

Android set clickable text to go one fragment to another fragment

java,android,android-fragments,spannablestring
I need to do something like this. Suppose I have 2 fragments A and B.There is a text which can be clickable in fragment A and when user click this text , he can go to fragment B. This example helped me to do it but I think it does...

Give port number and passed parameters in WSO2

java,api,wso2,wso2-am,api-manager
I am trying to learn WSO2 but have been stuck at a minor step which i believe should be quite easy to do. While creating a new api i need to give the production endpoint. What i want to give is the url along with the port as well. So...

Mock class inside REST controller with Mockito

java,testing,junit,spring-boot,mockito
I have a spring-boot application which exposes a REST interface via a controller. This is an example of my controller: @RestController public class Controller { @Autowired private Processor processor; @RequestMapping("/magic") public void handleRequest() { // process the POST request processor.process(); } } I am trying to write unit tests for...

BitmapFont class does not have getBound(String) method

java,android,libgdx
Previously I used getBound method for BitmapFont class in libgdx, but now, I am unable to use it. I cannot find the changes in latest version. Any help is appreciated. Thank you...

Join files using Apache Spark / Spark SQL

java,apache-spark,apache-spark-sql
I am trying to use Apache Spark for comparing two different files based on some common field, and get the values from both files and write it as output file. I am using Spark SQL for joining both files (after storing the RDD as table). Is this the correct approach?...

WebDriver can't get dropdown menu element (Java)

java,selenium,webdriver,junit4
I write a script on Java for Selenium WebDriver, and I have a problem with selected from dropdown menu. Here's my locator: new Select(driver.findElement(By.id("FormElement_select_68_input_input"))).selectByVisibleText("Image"); Here's an error: http://prntscr.com/7jul03 Here's HTML code: http://prntscr.com/7jvou6 Need to select "Image" from this menu, but have an error. Before I had the error like this,...

Get document on some condition in elastic search java API

java,elasticsearch,elasticsearch-plugin
As I know we can parse document in elastic search, And when we search for a keyword, It will return the document using this code of java API:- org.elasticsearch.action.search.SearchResponse searchHits = node.client() .prepareSearch() .setIndices("indices") .setQuery(qb) .setFrom(0).setSize(1000) .addHighlightedField("file.filename") .addHighlightedField("content") .addHighlightedField("meta.title") .setHighlighterPreTags("<span class='badge badge-info'>") .setHighlighterPostTags("</span>") .addFields("*", "_source")...

java Swing: how to keep one component left aligned with another component centered with respect to parent

java,swing,layout,jpanel,layout-manager
Say I have two components, A and B, in a JPanel. I want Component A to stay left aligned, while Component B does its best to stay in the middle of the panel. I mocked up the following demo (sorry for the quality, I made it in paint): What I...

Why there isn't library of design patterns?

java,oop,design-patterns
I'm new to design pattern subject. If design pattern are so great, why can't someone build a library of them so I don't have to create them in each application?...

How to change the working directory of a bundled Java program

java,netbeans,bundle,executable
I wrote a program in Java and packaged it up as a Mac App using Netbeans. It has the typical Java, MacOS, Resources, and Plugins folders and works just fine. The problem is that my program has a save feature which, whenever used, saves files to the computer's User directory...

GenericApplicationContext cannot be cast to WebApplicationContext : Spring Web Flow

java,spring,spring-mvc,classcastexception,spring-webflow-2
I'm trying to set up Spring Web Flow using only Java annotations in a Spring environment that also uses only Java annotations. However when I attempt to access my flow I get the following exception SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/forms] threw exception [Request processing failed;...

Java dice roll with unexpected random number

java,if-statement
I've written a simple Java program to display the results of 20 dice rolls on the console. The results I'm getting are listed below: 3 1 [email protected] 1 5 4 1 [email protected] 1 [email protected] [email protected] 1 6 [email protected] 1 [email protected] [email protected] 1 2 3 3 When I ran it for...