In Java, when you do
int b;
b = b + 1.0;
You get a possible loss of precision error. But why is it that if you do
int b;
b += 1.0;
There isn't any error?
Hi all!
I was wondering about how to clean multiple JTextField in a Java applicatio, without setting the text with an empty string for each field.
Any suggestions?
Why does JPA require a no-arg constructor for domain objects ?
I am using eclipselink and just got this exception during deployment.
Exception [EclipseLink-63] (Eclipse Persistence Services-1.1.0.r3639-SNAPSHOT):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The instance creation method
[com.me.model.UserVO.<Default Constructor>], with no parameters,
does not exist, or is not accessible.
Internal Exception: java.lang.NoSuchMethodException:
com.me.model.UserVO.<init>()
Descriptor: RelationalDescriptor(com.me.model.UserVO -->
[DatabaseTable(user)])
So I have a java hashmap like below:
hMap.put("1", "One");
hMap.put("2", "Two");
hMap.put("3", "Two");
I would like to remove ALL items where the value is "Two"
If I do something like:
hmap.values().remove("Two");
Only the first one is deleted, I want to remove them all, how can this be done?
I'm writing java application that is using both SQLite and MySQL using JDBC.
Are there any differences in SQL for those databases? Can I use same queries for both SQLite and MySQL, or is there any db specific stuff, that doesn't work on the other one?
As far I've worked only with MySQL, so I don't really know much about SQLite.
In my Java application I have to custom-paint a control and for that I need to use the same font colors as JButton. (Enabled an disabled) I don't want to to hard-code them, because the user can change the Substance skin at runtime.
I'm aware of the ColorSchemes but I'm not sure how to proceed once I have the color scheme of the current skin. Also the Substance documentation says something about creating your own color scheme, but I just can't figure out the way to retrieve a certain color.
Hello, I want to host a web application on a private JVM they offer 32, 64, 128, 256 MB plans.
My web application uses Spring. And I store some objects for every logged in user session.
My question is: How can I profile my web app to see how much heap size it needs so I can choose a plan?, How can I simulate hundreds of users logged in at the same time?
I'm developing the application using Netbeans 6.7 Java 1.6 Tomcat 6.0.18
Thank you.
Hi, I am a C++ / Java programmer and the main paradigm I happen to use in everyday programming is OOP. In some thread I read a comment that Type classes are more intuitive in nature than OOP. Can someone explain the concept of type classes in simple words so that an OOP guy like me can understand it?
I'm loading pixels from an image which is 32 w by 32 height. The format I'm loading them in is ARGB via java. When I bind this to the video card, I can expect that the video card might use somewhere around 32*32*4 bytes, or 4K.
Similarly, 1024 w, 1024 h would be 1024*1024*4 = 4MB.
Is my understanding correct? Now I understand where all the memory goes!
Hi,
How can i find decimal(dot) in a given number in java.
I am getting input from user, he may give integer or float value.
I need to find he entered integer or float , is it possible?
if yes could u tell me please.
--
Thanks
JFileChooser looks nothing like the native widget. I seem to remember reading some hack to get it look like the native widget but searching for it know i can't seem to find it again i came across posts that suggest using java.awt.FileChooser but that class does not seem to be in the distribution. How can i make JFileChooser make look like the native widget?
according to http://java.sun.com/javase/6/webnotes/trouble/TSG-VM/html/clopts.html it should be possible to enable -XX:+HeapDumpOnOutOfMemoryError using JConsole in runtime. How?
I assume its somewhere under MBeans tab and the com.sun.management - HotSpotDiagnostic - Operations - setVMOptions ?
Hi,
Can someone explain to me the usage of Integer, Boolean etc in place of their primitive types in JAVA?
I can't seem to grasp the advantages their are providing. They seem to create unnecessary problems of handling null values.
Thanks!
In Java, how can I construct a Type object for Map<String, String>?
System.out.println(Map<String, String>.class);
doesn't compile. One workaround I can think of is
private Map<String, String> dummy() { throw new Error(); }
Type mapStringString = Class.forName("ThisClass").getMethod("dummy", null).getGenericReturnType();
Is this the correct way?
Hello
Please suggest me a good open source web crawler written in C++,JAVA or PHP.
i just need to crawl/index some specific websites for specific contents(images,text,videos).
i know that their are already a lot of question & answers about this topic on this website
but i am a little confused after reading all of them.
So i am sorry if i am repeating the same question again.
-Thanks in advance
It is possible to use Java class files which includes annotations that are not present at runtime?
Example: I want to write a class with the JPA @Embeddable annotation, which would be present at compile time (maven scope: "provided"). But the annoatation definition could be absent at runtime, if the class is used outside a JPA application.
Hi,
ok it is 'easy' to make jna wrapper solution for mapping exported functions within dll using jna:
long f1(int x), just int
long f2(char* y), just char[]
but how to deal with long f3(char** z) ?
I need f3's result(long) as well as z value on java side.
Please don't say cpp code should be rewritten to avoid this:-)
I'm trying to create a REST based web service with data encapsulated using JSON. My problem is when I pass the string version of JSON in the URI it turns to something like this: %7B%22coal%22:100,%22ele%22:1500.1%7D.
I'm wondering if there are any functions Java for converting between the escaped and unescaped versions so I can parse the string.
For a machine with multiple NIC cards, is there a convenient method in Java that tells whether a given IP address is the current machine or not. e.g.
boolean IsThisMyIpAddress("192.168.220.25");
In Java, is there a way to force a JVM instance to run on a single CPU/Core.
Additionally is there a way for given thread to figure out what CPU it is running on?
I am currently picking up Grails and Roo to expand my skills and to have a bit of fun.
The vast majority of training materials appear aimed at new developers or Java developers.
Does anyone know of any guides, resources or have any tips and anecdotes for translating existing development experience with .Net (C#/ASP.Net/Asp.Net MVC)?
Suppose I'm running several servers serving basic requests on my local network (say a home network, where all machines generally have an IP in the form K.K.K.x, where x is variable). Is there an easy way to discover all such servers? I would need to find each IP on the network running a particular java server application.
I have a vector of float arrays i.e. Vector . I want to convert this to one float array i.e. move every element in every float[] within the vector to a new float[]. Am a bit puzzled on using the Java built in method vector.toArray() to do this. Any ideas pls?
I want to build a sip client based on SIP Communicator - the Java VoIP and Instant Messaging client. Basically I need to plug in some how and redirect VoIP to and from my application. Where is a good place to start?
If this seems a bit vague, I do apologize.
Hello,
How can I write DAO method which will return as a result only first entry from the database. For instance lets say I'm looking at Users table and I want to retrieve only the first entry, I'd declare method like:
public User getFirstUser(){
//method logic
}
EDIT:
User has primary key id if that matters at all.
I apologize if this question is too simple/stupid/whatever I'm beginner with Java so I'm trying new things. thank you