Roy Tang

Programmer, engineer, scientist, critic, gamer, dreamer, and kid-at-heart.

Blog Notes Photos Links Archives About Now

All entries tagged java.

You can subscribe to an RSS feed of this list.

Jun 2014

May 2014

I have an existing AWT Java desktop application. Is there a library or something I can use to have it respond to multitouch gestures (in Windows 7/8)? I see there’s frameworks like MT4J or JavaFX that have multitouch support, but it seems these are separate UI frameworks that I can’t use with my existing app?

I have a working Java SWING-based desktop application, and I’m being asked if it can be run on the Microsoft Surface Pro or Pro 2. As I understand it, these are using stock Windows 8/8.1 and will be able to run any Windows app normally, is this correct?

Are there any caveats or special considerations when running my app on these devices?

Edit: If it matters, the JRE would be distributed together with the application, so installing Java isnt an issue.

Mar 2013

I want to write a servlet that wraps around a set of resources and needs to protect them with basic HTTP auth; the submitted username/pass will be checked against the backend database before serving the file.

Does anyone have any working examples of this? I tried the sample at http://www.coderanch.com/t/352345/Servlets/java/HTTP-basic-authentication-Web-Applications but it kept returning an IllegalStateException in the sendError call.

Aug 2012

I’m being asked to assess whether we can safely upgrade the java version on one of our production-deployed webapps. The codebase is fairly large and we want to avoid having to regression test everything (no automated tests sadly), but we’ve already encountered at least one problem during some manual testing (XmlStringReader.getLocalName now throws an IllegalStateExeption when it just used to return null) and higher-ups are pretty nervous about the upgrade.

The current suggested approach is to do a source compare of the JDK sources for each version and assess those changes to see which ones might have impact, but it seems there’s a lot of changes to go through (and as mentioned the codebase is kinda large). Is it safe and easier to just review the java version changes for each version? Or is there an easier way to conduct this assessment?

Edit: I forgot to mention the version upgrade being considered is a minor version upgrade, i.e. 1.6.10 to 1.6.33

Jan 2012

I’m trying to get a sense of what are the most commonly-used Java web frameworks, with a focus on large, enterprisey projects. I’m interested in which one is most favored by companies/enterprises (which may not be the same as the one most favored by developers or the open source community I guess). I’d also like to be able to cite specific projects used by each framework, preferably big-ticket or well-known ones.

Anyone have any idea about this stuff or can point me in the right direction?

Thanks!

Dec 2011

“rowtype” here is an Oracle PL/SQL-specific type, I don’t think it would be supported by JDBC. A quick search of the oracle forums (google “jdbc rowtype site:oracle.com”) suggests the same. You’re probably better off returning a cursor, or just execute the SQL from JDBC directly.

Posted by under notes at / Tags: #java #oracle #jdbc #plsql / Imported from stackexchange / Syndicated: stackexchange / 2

Jan 2010

I’m looking into screen sharing functionality - i.e. allowing remote users to view your desktop in real time, possibly control it and write annotations (text/drawings) on the shared screen. Something similar to what webex allows in its conferencing software. Preferably a Java-based api, possibly to run from an applet.

Any recommendations on a library/api to use?

Dec 2009

Nov 2009

While testing our setup for user acceptance testing, we got some reports that java applets in our web application would occasionally fail to load. The envt where it was reported was WinXP/IE6, and there were no errors found in the java console.

Obviously we’d like to avoid it. What sort of things should we be checking for here? On our local servers, everything seems fine. There’s some turnaround time when sending questions to the on-site guy, so I’d look to cover as many possible causes as possible.

Some more info: We have multiple applets, in the instance that they fail loading, all of them fail loading. The applet jar files vary in size from 2MB to 8MB. I’m told it seems more likely to happen if the applet isn’t cached yet, i.e. if they’ve been able to load the applets once on a given machine, further runs on that machine go smoothly. I’m wondering if there’s some sort of network transfer error when downloading the applets, but I don’t know how to verify that.

Any advise is welcome!

We have an Applet that can possibly display Chinese text. We are specifying a font for it (Arial), it works fine under both Windows and Mac OSX.

But in Firefox on Linux the Chinese characters are rendered as squares. Is there a way to work around this? Note that we can’t assume the existence of a particular font file on the client.

I have an applet that calls a JDialog that contains a JProgressBar component. I subclass the JDialog to expose a method to update the JProgressBar, something like:

public class ProgressDialog extends javax.swing.JDialog {
    public void setProgress(double progress) {
        jProgressBar1.setValue(jProgressBar1.getMinimum() + (int) (progress * jProgressBar1.getMaximum()));
    }
    ...
}

I use this dialog in the following manner:

public void test() throws Exception {
    progressDialog = new ProgressDialog(null, true);

    try {
        progressDialog.setLocationRelativeTo(null);

        // show the dialog
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                progressDialog.setVisible(true);
            }
        });

        // business logic code that calls progressDialog.setProgress along the way
        doStuff();
        
    } finally {
        progressDialog.setVisible(false);
        progressDialog.dispose();
    }
}

It works fine on Windows/any browser. However, when invoking the above function on Firefox 2/3/3.5 on a Mac, the progressDialog is displayed indefinitely, i.e. it doesn’t close.

I suspected that calling setVisible(true) inside the EventQueue was causing the problem, since it’s a blocking call and might block the queue completely, so I tried changing it to:

        // show the dialog
        new Thread() {
            public void run() {
                progressDialog.setVisible(true);
            }
        }.start();

With this change, the progressDialog now closes correctly, but a new problem emerged - the contents of the dialog (which included the progressbar, an icon and a JLabel used to show a message string) were no longer shown inside the dialog. It was still a problem only on Mac Firefox.

Any ideas? I realize it’s probably some AWT threading issue, but I’ve been at this for a couple of days and can’t find a good solution. Wrapping the doStuff() business logic in a separate new Thread seems to work, but it’s not easy to refactor the actual business logic code into a separate thread, so I’m hoping there’s a simpler solution.

The envt is: Mac OSX 10.5 Java 1.5 Firefox 2/3/3.5

Oct 2009

I have a CRUD maintenance screen with a custom rich text editor control (FCKEditor actually) and the program extracts the formatted text as HTML from the control for saving to the database. However, part of our standards is that leading and trailing whitespace needs to be stripped from the content before saving, so I have to remove extraneous &nbsp; and <br> and such from the beginning and end of the HTML string.

I can opt to either do it on the client side (using Javascript) or on the server side (using Java) Is there an easy way to do this, using regular expressions or something? I’m not sure how complex it needs to be, I need to be able to remove stuff like:

<p><br /> &nbsp;</p>

yet retain it if there’s any kind of meaningful text in between. (Above snippet is from actual HTML data saved by the tester)

Aug 2009

Let’s say I have a Java webapp deployed on some Application Server with clustering across a few nodes.

In the webapp, we maintain a cache of some values retrieved from the database, stored in-memory as static variables. Whenever a user performs an update in a particular screen, we clear the cache so that the cached values will be retrieved again the next time they are needed.

Now the problem: Since each node in the cluster is running on a separate JVM, how can I clear the cache across all nodes? Basically I want to call a static function on each cluster node. Is there some standard J2EE way to do this, or it depends on the Application Server software?

Sep 2008

May 2007

Feb 2006

Oct 2005

Sep 2005

Jun 2005

Apr 2005

Nov 2004