java

How to refresh Jframe to create ainimation?

I have a simple animation program which moves some basic shapes on the Jframe. However, the program does not really move the shapes, but creates more instead. In other words, I need to force the Jframe to clean up the previous object. How to do so? ...

How to read data from a file in Eclipse Plug-in?

I'm currently developing a Eclipse plug-in. When called, my plug-in will read the active (currently opened) source file's data and will do some formatting on the source code and then it will update the results to the same active source file. Now my questions are: How to read the data from the active source file? Do I need to get the f...

Generate Java class from JSON?

Hi. I want utility that generates classes from JSON. For example we got "firstName": "John", "lastName": "Smith", "address": { "streetAddress": "21 2nd Street", "city": "New York" } We pass this to our util and on exit we have something like this: class Address { JSONObject mInternalJSONObject; Addr...

Not Able to give previleges...Openoffice error

This is the code i had written to save the data into the openoffice database. but its giving error.i m not understanding y it is appearing. package coop.data; import java.sql.*; /** * * @author spk */ public class Connectionsetting { private static Connection con; private static Statement sm; private static ResultSet r...

How to bind ServletRequest params to domain objects?

I want to bind parameters of a ServletRequest to arbitrary domain objects. Params are available as a map of type Map<String, String[]> // String = key, String[] = values They should be converted and bound to the fields of the target object. Id like to have a method like this: // definition: public void bind(Map<String, String[]>, T...

What should be the correct/better approach for locking a record in table?

Actually, the problem is like this:- i am having a table, say Payments. I have provided few GUI for searching, viewing and editing the record. Now if the user is trying to edit a record perform some particular action, which takes say 1 minute to process. Then another user should not be able to perform that particular operation on the sam...

mysql's current_timestamp for java derby

Hi all, In MySQL I can easily set the default value of a timestamp field to be the current time fieldname timestamp not null default current_timestamp Does anyone know how to do the same thing in java derby? ...

xml string to file

Hi All, I want a xml string to be converted to file,for which i am doing in the below way, String xmlFile=responseXMLName; log.info("xml file :" +xmlFile); fr = new FileWriter(new File(xmlFile)); Writer br= new BufferedWriter(fr); log.info("respose string"+responseXMLString); br.write(responseXMLString); br.close(); i want to pass x...

Why I have to declare each and every class in my hibernate.cfg.xml when using annotations?

Why it isn't enough to set the @Entity annotation? Am I missing the point here (performance?)? Thanks. ...

Java: convert int to InetAddress

I have an int which contains an IP address in network byte order, which I would like to convert to an InetAddress object. I see that there is an InetAddress constructor that takes a byte[], is it necessary to convert the int to a byte[] first, or is there another way? ...

when to use assertion vs Exception

most of the time i will use exception to check for condition in my code, i wonder when is appropriate time to use assertion for instance, Group group=null; try{ group = service().getGroup("abc"); }catch(Exception e){ //i dont log error because i know whenever error occur mean group not found } if(group !=null) { //do something } ...

Java String formatting

I have a property-file with strings inside, formatted in this way: audit.log.events.purged=The audit events were purged. {0} events were purged, {1} assets were deleted. Is there a way to bind some values inside those {0} and {1}, using some standard APIs, or should I create some code for parsing those Strings? ...

Creating a post request including a multipart file upload

I am writing a simple snippet which sends a simple post request. Currently I am building the request like so: // Construct data String data = URLEncoder.encode("param1", "UTF-8") + "=" + URLEncoder.encode("val1", "UTF-8"); data += "&" + URLEncoder.encode("param2", "UTF-8") + "=" + URLEncoder.encode("val2", "UTF-8"); //...

which way is better "null != object" or " object != null"?

Possible Duplicate: Why does one often see null != variable instead of variable != null in C#? Is there any advantage on using "null != object" over "object != null"? ...

Printing a java scriptlet variable as if it is a JavaScript variable

hello i need to output a java variable inside a javascript call inside a tag inside a jsp ! for example: <% String param = "hello";%> <dmf:checkbox name="checkbox" onclick = "selectAll(<%=param%>)" /> the javascript generated is: selectAll(<%=param%>),this); but I actually want something like selectAllCheckBoxes(Hello),this);...

Thread safety in JSF

Assume that we have Spring bean UserController with singleton scope. All my further reasoning is based on my assumption that "singleton" scope is almost similar to application scope i.e. we have only one instance for all users. If this is wrong assumption then tell me about it, please. So, we have a web-form with several fields. Two ...

problem persisting xml in Mysql using hibernate

Hi, I am trying to persist a string object in Mysql(5.0.67) using hibernate. My entity is as follows: @Entity @Table(name = "info", schema = "DB") public class info { @Column(name = "InfoXml") private String InfoXml; } The problem is when I persist the xml with value: String InfoXml = "<?xml version="1.0" encoding="UTF-8" standalon...

jboss 4.2.2 worker thread initialization failure

im having jboss as server and java as client. there are some 200 client will access server daily. this error coming every now and then on jboss log. any one tell me some idea. ERROR [org.jboss.remoting.transport.socket.ServerThread] Worker thread initialization failure java.net.SocketTimeoutException: Read timed out at java.net.Sock...

How to view a log file in Eclipse editor just like it looks in console window?

I have a txt log file. How to make it look in Eclipse editor just as if it was the console output [ eg links underlined ]. It is a bit sad plugins called "Log viewer" do not highlight links as Console Window does. That's the worst thing about such plugins. ...

NetBeans Platform Application: How to create test environment for first automated end-to-end test through GUI?

How to write first end-to-end automated test for NetBeans Platform Application on Java (not just capture & replay) which suppose run the application and test if click on the Main Menu -> File -> Exit menu item will close it? Given: installed jdk1.6.0_17 and apache-maven-2.2.1 Then: mvn archetype:generate -DarchetypeGroupId=org.codehau...