java

Tool to find duplicate keys and value in properties file

is there a tool that tells me redundant keys and values that are there in my one or many properties file. ...

How to programatically use Spring's JdbcTemplate?

We use Spring's JdbcTemplate which is configured through Spring config as illustrated below. Is there a way to do this without injecting the data source? I'd like to just create the JdbcTemplate instance programatically and "initalize" the datasource using TheOracleDS. Our current config: Java class private JdbcTemplate jdbcTemplat...

Volatile or synchronized for primitive type?

In java, assignment is atomic if the size of the variable is less that or equal to 32 bits but is not if more than 32 bits. What(volatile/synchronized) would be more efficient to use in case of double or long assignment. like, volatile double x = y; synchronized is not applicable with primitive argument. How do i use synchronized i...

Remote Servlet Comms

I have two servlets A & B. On B i intend to have a a method isAvailable() which A will call to check the status. If this method returns true then im going to pass it an object to B. On doing a bit of reading i'm seeing a couple of options non of which im that familar with. JNDI with remote EJB , RMI or simple HTTP (not sure how youd do...

To what extent can optimisation replace Macros, Stack allocation ... ?

There is a lot of discussion about the lack of macros in some languages, and the inefficiencies that can arise. Perhaps the most common example is the guard before a log statement. To what extent can current & future optimisation be relied upon to do the right thing and obviate the need for a macro. In this example and in general? // ...

Convert java syntax to actionscript

I'm porting an existing java library to actionscript and since they are both realy similar, 95% of the work is simply flipping variable and function definition around. public int foo(int bar) {} //converts to public function foo(bar:int):void {} Boring stuff. Is there a tool to automate the transition between java syntax and actionsc...

Comfortable Javadoc API in the browser (web application)

I'm looking for a web application (either an existing web site or a site which I can generate and set it up for myself, or a greasemonkey script), which lets me browse http://java.sun.com/javase/6/docs/api/ (or any earlier version I specify) in a more convenient way, i.e. where I can search for a class name. http://www.jdocs.com/ doesn'...

why PaintComponent event in Java happen everytime I use its Graphics Event?

Consider this code: public class StateChartPanel extends JPanel { private LightContext LC; public StateChartPanel(LightContext lc){ LC=lc; } public void paintComponent( Graphics G ){ super.paintComponent( G ); LC.DrawStateChart((Graphics2D)G); } } StateChartPanel is a panel ...

DId Quicktime 7.6.5 Windows fix QT for Java? Best video for JavaFX?

Greetings, I have read that QuickTime for Java is esentially broken on both Windows 7 and Snow Leopard. I can't tell how broken -- doesn't seem broken, but could just be my setup. I'm trying to determine whether this is a good technology stack, or if I should look elsewhere. Objective: I want to build a specialized desktop video playe...

Is there a better practice for Listeners?

Say I have a swing GUI, and I want to listen MouseEvents. Who do you think should be the Listener class, who should be responsible? What is the best-or preferred way to implement it? Any opinions? I usually go like this: public class MyPanel extends JPanel implements MouseListener{ private JTable table; public void foo(){ ...

Converting Array of Java Strings into LaTeX table

I have an two dimension array that contains strings and want to create a LaTeX table with them. The problem is that they could be longer and there has to be line breakes after 15 characters. The Say it's a 2x2 array with contains {{"String11.......String11", "String21"}, {"String12.......String12.......String12.......", "String22.........

Java (AWT): fitting text in a box

I have an application that extends a Frame. Then, it'll display a few lines of text using: Font f = new Font("Arial", Font.PLAIN, 10); g.setFont(f); g.drawString("Test|great Yes ^.", x, y + 10); Now what happens is that the text doesn't fit in the box around. E.g. I'm expecting the text to fit in [x,y]-[x+width, y+10] (don't care abou...

Create a custom button with SWT

I would like to ask the same thing than this question but using SWT: Is there a way to make a Button with your own button graphic not just with an image inside the button? If not is another way to create a custom button in java? ...

How do determine if an object is locked (synchronized) so not to block in Java?

I have a process A that contains a table in memory with a set of records (recordA, recordB, etc...) Now, this process can launch many threads that affect the records, and sometimes we can have 2 threads trying to access the same record - this situation must be denied. Specifically if a record is LOCKED by one thread I want the other thr...

Java recursion phone number letters

How do you write a java program using a recursive method that takes in an int like "234" and converts this into the corresponding letters on a phone pad (2 = ABC, 3 = DEF, etc), and prints out the permutations of this? e.g.: input = 234 output = ADG ADH ADI AEG AEH AEI AFG AFH AFI BDG BDH BDI BEG BEH BEI BFG BFH BFI CDG CDH CDI CEG CEH...

Java shell expansion similar to wordexp

Is there a way to do shell wildcard expansion in java similar to the way that the C function call wordexp works? It seems a bit platform specific, but there has to be a nice abstraction for this in one of the java system classes, right? I would be happy if I could get ~/, ./, and ../ to resolve to their canonical paths. Thanks! ...

javamail vs sendmail performance during bulk email

Hi all, I'm writing a Java mass emailer application to send out emails to send between 50,000 to 100,000 a day to users. The current plan is to delegate the sending to delegate to sendmail (on the local unix server). From our testing sendmail is sending a maximum of 5 emails per second. Would JavaMail be a faster option? Does anyo...

Hibernate: ORDER BY using Criteria API

Hi guys, When I write a HQL query Query q = session.createQuery("SELECT cat from Cat as cat ORDER BY cat.mother.kind.value"); return q.list(); Everything is fine. However, when I write a Criteria Criteria c = session.createCriteria(Cat.class); c.addOrder(Order.asc("mother.kind.value")); return c.list(); I get an exception org.hibe...

New browser window with information generated by Java applet

I have a Java applet. After user inputs data into the Java applet controls he presses button in Java applet and Java applet performs some calculating and result is a table (for simplicity table can be considered as String[][]). I want to show new browser window and output this table in it as html <table>. How can this be done? Preferre...

ObjectInputStream and ObjectOutputStream

Hi folks! I have written an EchoServer that responds with the String ack if the data have been send accordingly. My client looks like this... In order to receive the ack answer from the server the "echoSocket" puts the received data into in, my ObjectInputStream. Only if I comment these parts out the client works echoSocket =...