java

Speed up my Java tcp transfer!

I need to speed up transfers across my gigabit ethernet connection. Right now, I'm doing something almost exactly like this, but I'm only seeing about 40% of that when I run this code below. I also ran this script on all of my (Mac Pro) machines before testing #!/bin/bash sudo sysctl -w net.inet.tcp.win_scale_factor=8 sudo sysctl -w ...

Why say panel and boxlayout twice?

panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); ...

How Configure Hibernate for develop Test

Hi every One, we are 9 programmer work on java Web application use hibernate framework, but we have problem by running(in run mode, debug mode) project each time we want test the project we must wait for Hibernate to create SessionFactory and all Relational Query! what should i do that Hibernate Work faster? ...

Pick up a cache implementation, or roll your own?

I'm doing a Java EE application, and I'm at a point where I've concluded that I need a cache for my objects. My current requirements aren't much more complicated than some kind of key-value storage, possibly something that can handle a tree. It would be tempting to write a simple custom static/singleton class containing one or more maps...

binding to a Set in Spring

If I have a list object I know that I can bind class property fields to form using the code below. <c:forEach items="${items}" var="i" varStatus="itemsRow"> <input name="items[${itemsRow.index}].fieldName" type="text"/> </c:forEach> <form:errors path="items" /> What do I do if the property is a Set object. I have read about initBin...

Adding WARs to Java's classpath

I have two wars, foo.war and bar.war. foo uses classes from bar. I'm trying to start foo, and add to Java's classpath bar.war, but java throws a ClassNotFoundException. If I rename bar.war to bar.jar and edit its directory structure to look like a jar, it works. Java's documentation on the -CP switch does not mention war files: -clas...

Is there a way to wrap some local cache around a URLConnection

I am using a URLConnection class - I want to be able to grab a stream to a given URL even if said URL is unavailable (ie cache the last known cope of the content on a URL, to some local file system dir) - now I have written this code a few times (never happy with it) and was wondering if there is something better out there that might be ...

Java SWT - Text on Transparent Shell?

In Java SWT, is there a way to draw text on a transparent shell so that only the text appears visible? What I would like to do is have the text appear on my desktop without any background window. Using shell.setAlpha() will make the entire shell transparent, including any elements that appear on it (which I am trying to avoid). ...

Generate icon images in Java

I have a set of icon images of various sizes (16x16, 24x24, 32x32) and base colours (red, green, blue, cyan, magenta, yellow). The images are pretty basic geometric patterns + drop shadow, so my gut feeling is that it should be pretty straightforward to replace the files with an icon factory that can generate images given a base colour. ...

Is it possible to use Enter as Tab without inheriting JTextField or mass-adding key listeners?

I've found several pages and SO answers about the enter-as-tab problem in Java, but all propose either overriding methods of JTextField or adding a key listener to every component. But isn't there any other way? Can't I override something of the LookAndFeel or install some global policy? ...

Can I escape braces in a java MessageFormat?

I want to output some braces in a java MessageFormat. For example I know the following does not work: MessageFormat.format(" public {0} get{1}() {return {2};}\n\n", type, upperCamel, lowerCamel); Is there a way of escaping the braces surrounding "return {2}"? ...

Flickr API Java/Clojure

I am trying to get a list of all the photo sets in my account. I gave my application write access i can verify this has write access by creating an photo set but when ever i try to read the list i only get my public lists not my privates. (def flickr (new Flickr api-key shared-sercret (new REST))) (defn get-photo-sets [ ] (let [;p...

how to replace the null character

In java ,i have editfield whcih takes its input ,in it we can enter 3 digits when i enter first and third ,leaving 2 digit empty ,how to remove empty digit thanks ...

JUnit two variables iterating respective value sets, create test functions

Checking function takes two arguments, I want to have a testcase for each element of the cartesian product of the respective domains, but without manually writing all the test cases like in void check(Integer a, Integer b) { ... } @Test public void test_1_2() { check(1, 2); } ... In python I would go with class Tests(unittest.TestC...

how to remove empty space

In j2me ,i have editfield which takes its input ,in it we can enter 3 digits when i enter first and third ,leaving 2nd digit empty , how to remove empty digit thanks ...

Log4j Maxfilesize

Hi, Problem i have with log4j is that when i specify maxfilesize it works properly for the files generated in the src folder of project, but the log files generated in tomcat bin, are not splited into seperate files and then i have a large log file which is not desirable. The following is log4j.xml: <?xml version="1.0" encoding="UTF-...

making frame modal

i have a Jframe with 2 textfields in it. now i want to make that frame a modal window, how can i do that please tell. ...

Why lazy instantiation of the MessageResourcesFactory in Struts 1.2.7?

Hi, Since there is the Double-checked locking issue so we have to use synchronization to guarantee the concurrent access to the following method (org.apache.struts.util.MessageResources class) : LAZY INSTANTIATION public synchronized static MessageResources getMessageResources(String config) { if (defaultFactory == null) { ...

EXT-GWT Portal: How to get all Portlets?

Hi all this is my first Question here! Im just making my first steps with (Ext-) GWT. I´m testing the Ext-GWT libraries and really: These are absolute great! Now my question: Is it possible to make a kind of "clear-Portal" or "hide all portles" for a defined Portal? Or have i always manually clear the portal like in my example code abov...

Is there a way to read the browser's cookie from a java applet?

I have a java applet that needs to do http requests to the server. A quick experiment showed that the session id cookies from the browser is not sent along, so i'll have to set it manually. Currently, I see 2 possible solutions: somehow get hold of the cookie data from within the applet pass the cookie information into the applet's c...