java

LdapContext, how to do select count(*)

I am using an LdapContext in java to query an LDAP server (I think the server is Sun server version 5.2). I use the LdapContext.search(String name, String filter, SearchControls cons) method for the regular querys, but I don't know how to run a query equivalent to sql's "select count(*)". Any idea? Performance is important so I don't wan...

How to run Unix shell script from java code?

It is quite simple to run a Unix command from java. Runtime.getRuntime().exec(myCommand); But is it possible to run a Unix shell script from java code? If yes, would it be a good practice to run a shell script from within java code? ...

Problem migrating Spring Web App from tomcat 5.5 to tomcat 6.0

I have a spring web application which has been working fine on tomcat 5.5. I've attempted to deploy the same web app to a tomcat 6 container and come up against some issues. The main two problems I've had are relating to configuring the container for jstl and getting the spring security login to work properly. I believe I've solved the...

Java: Accounting for taskbars/menubars/etc when placing a window on the desktop?

When my program starts, the main window places itself where it was when it was last closed. I want to modify this behavior some so if the window is off-screen (or partially off-screen) it moves itself to fully on screen. I've got this working perfectly. Here's the code: int x = gameConfig.windowX; int y = gameConfig.windowY; int...

Default constructors and inheritance in Java

Hello, I have a question about default constructors and inheritance in Java. Generally, if you write a class and do not include any constructor, Java provides automatically for you a default constructor (one without parameters), which initializes all instance variables of the class (if there are any) with some default values (0, null,...

Does anyone know how to successfully integrate Seam and Spring MVC?

As the title says. Is there a way to integrate the two? ...

Examples where is Java more elegant than C#?

It's been a couple of years since I last worked with Java. Can you tell me what problems can be solved more elegantly in Java? I am aware of the following benefits of Java: Java 'runs everywhere', Java has support for units and measures (supposedly) better latency in Java J2EE (I don't think there is an equivalent in .Net) different a...

please recommend a swing book about custom JComponent creation

Please recommend a Swing book that covers creating custom JComponents. ...

Should I use Java applets or Flash to make webpage-embeddable physics simulations?

I want to start working on some simple physics simulations that I can embed onto my website. I have a lot of experience with web programming with languages like PHP and javascript, a fair amount of experience with python and some experience with C++. Should I use Java applets, Flash or something else? Also, could you please recommend a...

Moving focus from JTextArea using tab key

Hi guys, As stated, I want to change the default TAB behaviour within a JTextArea (so that it acts like a JTextField or similar component) Here's the event action private void diagInputKeyPressed(java.awt.event.KeyEvent evt) { if(evt.KEY_PRESSED == java.awt.event.KeyEvent.VK_TAB) { actionInput.transferFocus(); } } ...

[Java] How to open user system preffered editor for given file?

Hi, I'm trying to figure out how to open system preferred editor for given file. Say, we have a file manager, written in Java. User goes to folder and see list of files. And, for example, there are file "Icon.jpg". User double clicks on the filename and file opens in system's preferred editor (i.e. Gimp). The main issue is - how to do ...

How do you get Java sockets working with public IPs?

I have had no trouble getting the sockets working with localips, but once I made the code change to use public ips, I've consistently gotten java.net.ConnectException. I am using the port 8084, which as far as I know, is not used elsewhere In the command prompt, netstat -a | grep 8084 shows: File STDIN: TCP user-9114eb19a8:8084 ...

How to call upon a gameOver method in a Java game when sprite "falls off" the screen?

I am developing a simple platform game in Java using BlueJ. Over the next few weeks I will be posting a few questions asking for help with this project as am not very proficient at programming. So I hope I don't become annoying and I would be very grateful if you can kindly help me. In my game I have a gameOver method which ends the ga...

Learning a legacy Java system

Hi All, I've been tasked with maintaining and refactoring a legacy Java system. I currently do C# and .NET, although I'm familiar with Java. The legacy system uses RMI, a client/server architecture and was designed for the 1.4 JVM. It's using for the UI (as far as I can tell), Swing and AWT. My question is this: What is the best way ...

Compilation error on Zxing

Since I don't own a G1 for development purposes, I am doing my best with the emulator. This said, I am trying to scan a JPEG image or a PNG image in my sdCard, with the ZXing (Zebra Zrossing) library. I tried to change the code in the Android project, so it would scan from an image in the sdCard, instead from the camera, without any luc...

Why some method in Java modify the original value and some do not?

The method Concat() does not modify the original value. It returns a new value. like this: String str = "good"; str.concat("ness"); System.out.println(str); //"good" But some method modify the original value. Why? In Groovy: def languages = ["Java", "Groovy", "JRuby"] languages.reverse() ===> [JRuby, Groovy, Java] println language...

web.xml <transport-guarantee> not able to work in certain environment.

I have added this transport-guarantee tag in the web.xml meaning that certain pages can only be accessed by https. But however this has an issue with environment that has web server and load balancer. Apparently it does not redirect to the application with ssl port. Seens like a firewall restriction. Any advise anyone? ...

What is difference between autoReconnect & autoReconnectForPools in MySql connector/J ?

In the configuration reference for MySql's connector J driver, a caveat emptor is issued on the use of the autoReconnect property. I followed the instructions and increased my server's *wait_timeout*. Since I am using DBCP (I am considering moving to c3po after reading several posts on Stackoverflow shooting down DBCP ), is it ok to use ...

Python or java which language will exposed a self taught programmer to more computer science concept?

Of the two which one would exposed someone just learning to program to more computer science concept/problems? ...

Java POI - anyone been able to extract numbers from formula cells?

I've been using Java POI for some time now, but have encountered a new problem, and I'm wondering if anyone has found a solution. When you read a spreadsheet, you need to know the type of cell in order to use the proper read method. So you get the cell type, then call the appropriate read method to get the cell's contents. This works ...