spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
  Home » JAVA » Page 3
Enable TLSv1.2 in Coldfusion
Try adding this switch to your Java args in the /runtime/bin/jvm.config file (the location of this file can vary with the type of your CF install). -Djavax.net.debug=all Then check the out log (cfusion-out.log in runtime/logs on a standard install) for information on each handshake (outgoing) that it makes. You will likely see some clues there and be able to determine which protocol/level of T

Categories : Java

Websocket concurrent write not working 100% in java
This is due to the following bug in tomcat, https://issues.apache.org/bugzilla/show_bug.cgi?id=57318#c1 updating to apache tomcat 7.0.57 will fix the issue. Updating to an apache tomcat version greater then 7.0.53 may fix the issue but has not been tested yet.

Categories : Java

Joda Time datetime invalid format with Spring
Looks like you're registering two converters which both can handle the same content, so they are competing for the same types. Spring MVC will iterate over all converters to see which one can handle the content. Instead you want a single converter with both modules (Joda and Hibernate4) added. BTW you might want to take a look at the Jadira project, which provides very elegant support in Hiberna

Categories : Java

how to get notified when the window title bar is pressed/clicked
If windowActivated() does not work for you, then as a last resort you can always set your JFrame as undecorated and create your own title bar. It will not look like a native title bar any more, but you will have more control, including the ability to add a mouse listener. myFrame.setUndecorated(true);

Categories : Java

How can I incorporate my return method with this snippet of code? (Java, Eclipse)
It's cleaner if you declare a variable to hold your eventual return value, regardless of what that variable will hold eventually: public static Student getStudentByNumber(int number1, ArrayList<Student> al) { Student studentToReturn = null //return value variable for(Iterator<Student> it = al.iterator(); it.hasNext();) { studentToReturn = it.next(); if(numb

Categories : Java

PowerMock throws NoSuchMethodError (setMockName)
For me, in Eclipse, the fix to this problem was found in Java Build Path. Click on Order and Export tab. Move Web App Libraries to bottom. Note, that when appropriate, this will also allow you to view source of 3rd party libraries when Eclipse tells you that source cannot be found.

Categories : Java

jasper report exclude summary page from PAGE NUMBER
Let me start by saying that this is a somewhat ugly workaround and works only if your summary consists of fixed amount of pages. When you design your report, and put in $V{PAGE_NUMBER} that shows you the amount of pages - you can actually call some Java logic before the output is shown. Specifically you can just subtract 1 and get the result you need.

Categories : Java

Doing payroll program using 2d arrays
your bubble sort should be more like: public static void bubbleSort(String t[][]) { for (int y=0;y<t.length-1;++y) { // surname is col #2 as far as i can see if (t[y][1].compareTo(t[y+1][1])>0) { String temp[]=t[y]; t[y]=t[y+1]; t[y+1]=temp; y=0; // start from beginning } } } assuming all unnecessary date like header and column separators are removed

Categories : Java

How to add a space before the text in a JLabel?
You could consider using an EmptyBorder, for example... JLabel nameLabel= new JLabel("Name"); nameLabel.setBorder(new EmptyBorder(0, 20, 0, 0)); nameLabel.setText("Hello my name is tom."); add(nameLabel, BorderLayout.CENTER); Have a look at How to Use Borders for more details

Categories : Java

Stanford NER 3.4.1 questions
(1) Yes, absolutely. The tokens (class: CoreLabel) returned each store begin and end character offsets for each token. The easiest way to get at the offsets for whole entities is with the classifyToCharacterOffsets() method. See the example below. (2) Yes, but there is some subtlety in interpreting these. That is, a lot of the uncertainty is often over not whether these three words should be a PE

Categories : Java

Dynamic instance-level permissions with Apache Shiro
I'm investigating a similar problem where I have a multi tenancy requirement so I don't know who the tenant is at compile time, something like this type of permission string: global:{tenant}:users:limited,c,r,u,d You might want to take a look at PermissionResolver I found this page quite helpful AuthorizationConfiguration from the shiro docs, the shiro docs are a bit of a scattergun

Categories : Java

How can I get GPS data even on background on Android?
I have a full working sample using the Google Play Services fused location (which is what you should be using). https://github.com/nickfox/GpsTracker/tree/master/phoneClients/android that is built with Android Studio. And I also have a tutorial that explains how it works here: https://www.websmithing.com/2014/04/23/how-the-gpstracker-android-client-works/ And finally, to learn more about the n

Categories : Java

Antisamy Java regex url does not accept pound or hash sign
After further research, the policy file was causing the problem not the regex listed above. If you are experiencing this same issue, be sure to check that the policy is not too restrictive for each HTML element and that the url is properly encoded & escaped.

Categories : Java

copying an array of objects and then modifying the original without affecting the copy
You are creating a shallow copy of your objects. Array.clone() will only work on primitive types. You should create a method in the Class of the objects you are trying to copy that creates and returns a new instance of the class with the same attribute values. Then you can loop through your array getting a copy of each object and add them to a new array then store the new array to your hashmap.

Categories : Java

Adding "double" to List doubleList
You need to initialize your List if List<Double> dbls = wordsDistributionList.get(word); returns null then your list will be null when you try to add a Double. Make sure wordsDistributionList.get(word) does not return null if it does then initialize your list explicitly... Like @ZouZou said try: List<Double> dbls = wordsDistributionList.get(word.toLowerCase()); But if that sti

Categories : Java

Java Swing - JFreeChart app works slowly
The XYSplineRenderer "connects data points with natural cubic splines." Not unexpectedly, its performance scales poorly for thousands points. If the goal is to render smoothed data, it may be advantageous to do the interpolation in the background, as suggested here, and revert to the parent XYLineAndShapeRenderer for rendering only. In addition, scores of curves, each having hundreds of points, m

Categories : Java

Convert String color name to color value (integer)
There's not really a "built-in" standard way to do this (note also that you're specifically looking for English names for colors). You'll have to resort to other solutions. For example: You could just implement it yourself, with a set of names you want to support. A Map, a big ol' if, or even creative use of an enum are all options. You could use something like ColorStringParser from JSAP. You h

Categories : Java

why is distanceTo() not enough to calculate distance?
6371.0 looks like the Earth's radius in km. Multiplying by Math.PI / 180 converts degrees to radians. This is turning a distance in radians to kilometers.

Categories : Java

Using another class in same package but separate file
First, there is a syntax issue in the Advisor.java: you are indexing the class Student as if it were an array Student[lineSafe], but it is not an array. I think you meant to use studentInfo array for that (and make it Student[] studentInfo instead of String[] studentInfo; studentNames should become an array of Strings, too). Don't forget to assign new Student[MAX_STUDENT] to studentInfo to avoid

Categories : Java

Finding out range in Java
You can use http://csvjdbc.sourceforge.net/ and use select query. Or import lines into some database directly ( in memory or true big db) - for cvs processing there are lot of libraries like opencsv and select values via sql query.

Categories : Java

.replyToQueueManagerName and replyToQueueName on different MqEnvironment
I am assuming you are asking how to connect to another queue manager when MQEnvironment is already used for connecting to a queue manager. You can create a connection to a queue manager by providing connection information through a hash table. This piece of code is in C#. Hashtable mqProps = new Hashtable(); mqProps.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);

Categories : Java

converting between List types, java
Short answer is no, you can't solve this with "casting" alone. V is not the same as Vertex<V> so you need a way to extract the V object from each of your Vertex<V> objects.

Categories : Java

JBPM - How to use CMT Command within a process
Container-managed transactions work by simply making sure a transaction is already active when invoking the jBPM engine, in which case the engine will join the existing transaction. At the end of the transaction, the state of all process instances is stored in the database. If they are needed later, the state will be restored from the database again to continue where they left off. It's unclear

Categories : Java

Implemented Facebook Login But Other Buttons Doesn't Work
You are adding a fragment to your activity which is likely over taking the MainActivity. Are you using MainFragment? Either move your buttons into MainFragment or remove the fragment from the activity.

Categories : Java

JavaFX TableView WeakListChangeListener Memory Leak?
There is a Jira bug report for this issue RT-34970. My colleague solved this issue by periodically removing all the columns and adding them back. That caused the TableView to tidy up the visibleLeafColumn object and the heap stayed sensible. Thanks Jewelsea and Tomas for your suggestions. We did try Java 8 which didn't have this memory problem but the performance seemed to degrade over time (12h

Categories : Java

AWS DynamoDB - combining multiple query filters on a single non-key attribute in java
So turns out this is made possible by adding a FilterExpression to the query (introduced recently in this blog post) I had seen this in the DynamoDB documentation but hadn't upgraded to the latest AWS Java SDK :( Using my above example this would look like: Map<String, AttributeValue> expressionAttributeValues = new HashMap<String, AttributeValue>(); expressionAttributeValues.put(":

Categories : Java

Java Programming - Circular Array
What do you really want? A Queue or a circular array ? Circular array : You should have a look there. As you can see, the simpliest (and the best) way is to extend the ArrayList class and override the get() method. Queue : Just use the java.util.Queue interface.

Categories : Java

Java servlet doGet() not refreshing after first call
Getting the same data when repeating the same requests usually is an issue with a cache (let it be in the browser, the server or in a proxy). Several ways of avoiding cache's effect: Disable them (generally not a good idea since it causes a performance impact). Use HTTP headers that signal to the browser that the content should not be cached / that previous cached data is stale. For AJAX, use t

Categories : Java

Why would StringUtils return the incorrect # of matches of a substring?
@kevin it would be great if you could provide us with contents of pagesource. Another thing, if the page has been modified it wont be necessary you get the current page source, pls refer getPageSource Doc If anyhow getPageSource ain't working and you need the text within body tag, you could use: document.getElementsByTagName('body')[0].textContent using JavascriptExecutor, and then try out Strin

Categories : Java

why is this a good implementation of `hashCode()`
Can someone please explain why is this hashCode good? Why is it unique to a specific object? It's not; essentially no hash code function is. It's just supposed to be rare that two objects have the same hash code, not impossible. What does >> vs. >>> means? I thought the >> do x bit shifts to the right which is like multiplying by 2. But what does >>> mean? It's an unsigned right s

Categories : Java

Instead of getting two similar JFrames, I get one whith double component
You are using static instance fields with your MyFrame for your components A component can only reside within a single container, the moment you create your second frame, the static components are removed from the first container before been added to the second. The solution, don't do this, ever... I assume you are using static because you want to access these fields from another class, in that

Categories : Java

Java change server and database setting for security
The least protection you can provide to your configuration file is encrypting it. Make properties class [inside] of project and make .jar files. As I pointed out in the comments, you should never place sensitive data in compiled files. For one, it makes your design quite unflexible: If you decided to change your server password, for instance, you would also have to change your compiled

Categories : Java

Most efficient way to blink a light
Use a Swing javax.swing.Timer, it's repeatable at a regular time interval, provides a level of thread isolation/synchronisation (as it timer event is enqueued in the event queue and execute within the context Event Dispatching Thread one at a time) and prevents any possibility of violating Swings single thread rules. An alternative is to use a SwingWorker and make use of its publish/process metho

Categories : Java

eclipse make java autocomplete to for template instead of the forEach method
I'm not exactly sure what you are looking for, but you can go into Eclipse settings and modify the templates to be what you want. Eclipse -> Preferences -> Java -> Editor -> Templates These templates are the ones that show up when you are typing.

Categories : Java

How to get information from a JTable row when clicking on it with mouse?
There's a few ways to handle this. ArrayList You can declare a final ArrayList to keep track of the students. This allows you to keep track of individual students as they get deleted. The downside is that you can't undo a delete, so you'd have to clear the array and reset the model or it would not represent the database properly. final ArrayList<Student> list = new ArrayList<Studen

Categories : Java

Can Arrays. sort sort enumerations that have been added to a an array.?
If you use Arrays.sort(T[], Comparator), you'll have to take care of null values yourself. Example Arrays.sort(enums, new Comparator<Rank>>() { @Override public int compare(Rank o1, Rank o2) { if (o1 == o2) { return 0; } // Put NULL to the end. if (o1 == null) { return 1; } if (o2 == null) { ret

Categories : Java

For loop to print indices of enum, but not values
All enum elements provide a name() method, which will give you the identifier used to define the element, e.g. Month.JANUARY.name() will be "JANUARY".

Categories : Java

query timeout in mysql via c3p0
No, maxIdleTime has nothing to do with how long a query can run. It defines how long Connections will be allowed to sit idle in the pool before they will expire and be destroyed. c3p0 is plain JDBC. Per the JDBC spec, it offers transparent Connection pooling. Transparent means in this context that the API doesn't change, your code should be basically the same with or without the pool. You are wel

Categories : Java

how to locate a file?
You could use relative paths. Aka MiReader Mr = new MiReader("file.text"); This way the program will look for the file file.text inside the directory you run it from.

Categories : Java


Recently Add
Essbase Java API export database MAXL
String length is getting wrong from two strings in java?
How the connection pool works
How to show data on same page after controller call?
Is there a way to use string names as indexes in java arrays?
adding items to an Hashmap and getting error null.pointer.exception
Java : arraylist shows empty when it used to show null values
how to copy the console output into a file in java?
I can't figure out why a class i made isn't working
How do I sign a java applet if I bought an SSl through Hostgator
Logic error towards the end
Cant store a message on a method in java with exceptions
JSF - c:forEach Not Working On Recursive Method
How do I store the type of a class for use later in Java?
Timer management in Java
Scanner nextLine() occasionally skips input
How to add dates into ArrayList before and after a specified date
JSF with Spring Controllors
How to create two column and with auto number in jasper report to excel?
“Your security settings have blocked a local application from running” Java 8
Too many solutions to coin change maker
Give low level functionality to a JMenuItem "Copy" in a GUI that I am creating
Get HTML and Display it in WebView perfectly
How would I reduce the repetitiveness of this method?
Java fileWriter is not writing all of my output to a file
finding a hash function for long integer array
Programming about finding the triangle
How to reduce the file size of a xml file that is created using java?
JMS Connection Pooling in Message Listener
How can I round down a decimal?
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.