java

Is there any Python-like interactive console for Java ?

I spent a lot of time programming in Java recently, and one thing I miss from scripting languages was the ability to test them in a console. To quickly test a java program, I have to edit a file, then turn it to bytecode and execute it. Even using an IDE, it loses its fun after the 372 th time. I would like to know if there is a prod...

BigDecimal: Can the Java compiler optimize away multiplications by 1?

Does the Java compiler remove multiplications by 1, when talking about BigDecimal? I'm standing in something similar to this: BigDecimal bd = getBigDecimal();//get arbitrary bigDecimal, could be anyone. bd = bd.multiply(new BigDecimal(getOneTwoOrThree()); Where the getOneTwoOrThree method is declared as: /* * Always returns Integ...

What can cause TCP/IP to drop packets without dropping the connection?

I have a web-based application and a client, both written in Java. For what it's worth, the client and server are both on Windows. The client issues HTTP GETs via Apache HttpClient. The server blocks for up to a minute and if no messages have arrived for the client within that minute, the server returns HTTP 204 No Content. Otherwise,...

Evaluate variable before passing to JSP Tag Handler

When trying to use a custom JSP tag library, I have a variable defined in JSP that I would like to be evaluated before being passed to the tag library. However, I cannot seem to get it to work. Here's a simplified version of my JSP: <% int index = 8; %> <foo:myTag myAttribute="something_<%= index %>"/> The doStartTag() method of my T...

Is there a Java 1.5 equivalent to the Predicate<T> methods in .Net?

Specifically, I'm looking for similarly clean notation to the Collection<T>.TrueForAll / Exists, etc. It feels smelly to have to write a foreach loop to inspect the return of a method on each object, so I'm hoping there's a better Java idiom for it. ...

Where can I find and download the Java Speech API?

Could you please tell me from where I can download JVM 1.4 and the Java Speech API? See also: Download and install IBM’s Speech for Java ...

IBM Websphere on Windows- OutOfMemoryError: Failed to create a thread

I have a J2EE application running on an IBM Websphere Application Server on a Windows Operating System. Occasionally I see an OutOfMemoryError Exception with the following information in the javacore file. 1TISIGINFO Dump Event "systhrow" (00040000) Detail "java/lang/OutOfMemoryError":"Failed to create a thread: retVal -1073741830...

Compress and send image over network in java?

Hi. I have a server which waits for a connection from a client then sends an image to that client using the Socket class. Several clients will be connecting over a short time, so I would like to compress the image before sending it. The images are 1000 by 1000 pixel BufferedImages, and my current way of sending them is to iterate over...

How to tune performance of hsqldb/hibernate app

I have an open source Java application that uses Hibernate and HSQLDB for persistence. In all my toy tests, things run fast and everything is good. I have a client who has been running the software for several months continuously and their database has grown significantly over that time, and performance has dropped gradually. It final...

JPA Hibernate One-to-One relationship

I have a one-to-one relationship but hibernatetool complains when generating the schema. Here's an example that shows the problem: @Entity public class Person { @Id public int id; @OneToOne public OtherInfo otherInfo; rest of attributes ... } Person has a one-to-one relationship with OtherInfo: @Entity public cl...

Java: dividing 2 ints makes an int?

In another Bruce Eckels exercise in calculating velocity, v = s / t where s and t are integers. How do I make it so the division cranks out a float? class CalcV { float v; float calcV(int s, int t) { v = s / t; return v; } //end calcV } public class PassObject { public static void main (String[] args ) { int dista...

What is Parse/parsing?

Hi Just wondering what exactly is a Parseing or parsing? especially related to Java. Why are they used? for example: Integer.parseInt, String parse.String etc Thank you ...

SQL Iterators

Does anyone know good source where I can find about implementation of SQL iterator/Operator in java and any other languages? Than you, -Nimesh ...

Can a text widget show overflow with the "..." in the middle of the text instead of the end?

I have a JComboBox which contains an MRU list combo-box and a for a directory tree panel. Together, the two form the left hand panel of my GUI (the MRU is above the tree panel) which is a JSplitPane, so the left panel is resizeable. It has a problem in that the directory text is always longer than the required width to see that directo...

Binding an EditorKit to a specific document model for a JTextPane

I can't seem to figure out a way for an editor kit to work for only one JTextPane. Every time I implement one, it always functions for any JTextPane in the frame. How can I fix this? ...

Apache Felix: What are extension bundles?

Apache Felix has the concept of an "extension bundle". This seems to be a bundle that contributes to the system bundle. There is also a special URL "felix://extensions/" being registered for them. When would I need to use extensions as opposed to regular bundles? Are there examples of bundles that use this approach? Is this a Felix-on...

Spring DatasourceTransaction Manager Problem

final DataSource ds = DataSourceLocator.getInstance() .getDataSource(sg.cmpl.starhub.lprs.Constants.APP_KEY); final DataSourceTransactionManager txManager = new DataSourceTransactionManager(); txManager.setDataSource(ds); final DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setIsolationLevel(TransactionDe...

Why is Java on Server and C# on Client a popular choice?

I have seen a few examples where the architecture is that there is java on the server side and c# on the client - what makes this combination so good? why would .net on both sides not be a better choice (or in fact, java on both sides?) added later: in lots of cases, the java is hosted on a windows server itself, i think via tomcat (not...

warning:[unchecked] unchecked conversion

Hi all, I am getting following warning : warning:[unchecked] unchecked conversion [javac]found:java.util.List [javac] required:java.util.List<edu.fullerton.cs476s09.espressobar.jpa.espressobar_milk> return query.getResultList(); What may the problem and probable solution. I am using following code: @Stateless @Remote(Order.class) //...

Can you pass an int array to a generic method in java?

I'm playing around with some code katas and trying to get a better understanding of java generics at the same time. I've got this little method that prints arrays like I like to see them and I have a couple of helper methods which accept an array of 'things' and an index and returns the array of the 'things' above or below the index (it'...