java

recent posts related to java, jdbc, spring, etc.

Java - execute a system command pipeline (pipe)

In earlier articles I've described how to execute system commands from Java applications. A long time ago I wrote my first article on this topic (How to execute system commands from Java), and more recently I wrote an updated version of that article titled "Executing system commands from Java using the ProcessBuilder and Process classes".

Given that introduction -- if you're interested in learning how to execute a Unix or Linux system pipeline (pipe) command from a Java application, you're in the right place.

A Java KeyStroke, KeyEvent, Action, InputMap, and ActionMap example

I don't know if this is the "proper" way to handle having multiple keystrokes for one action, but until I find a better approach I thought I'd share this here.

Java textarea cursor/caret position

If you need to get the position of the caret (cursor) in a JTextComponent (++JTextField, JTextArea JEditorPane or JTextPane), this turns out the be easy. Just use the getCaretPosition method of these classes, as shown here:

Java font size - how to change the JTextArea, JTextPane, JEditorPane font size

I'm currently writing a customized text editor in Java, and as part of that, I want to make it easy for the user to increase or decrease the font size in the text editing area (technically a JTextPane). I didn't expect this to be easy, but I've been pleasantly surprised that the following approach seems to work just fine:

Java exec - execute system processes with Java ProcessBuilder and Process (part 1)

I've been thinking about rewriting my old article on how to execute system processes from a Java application for a while now (Running system commands from Java applications), but it's a topic that quickly becomes complicated if you want to do it right, so I kept postponing it until I could give it some quality time in a real-world project.

I've finally had an opportunity to test this in a real-world Java application on a current project, so while I'm still not finished with this, I thought I'd share what I've learned so far.

Java exec - execute system processes with Java ProcessBuilder and Process (part 2)

<< Back to "Java exec with ProcessBuilder and Process, part 1"

A complete Java class that executes a system command

Now that you've seen that snippet of code, here's a complete Java class named ProcessBuilderExample that can execute a Unix/Linux system command:

Java exec - execute system processes with Java ProcessBuilder and Process (part 3)

<< Back to "Java exec with ProcessBuilder and Process, part 2"

Our ThreadedStreamHandler class

Based on an old-but-good article at JavaWorld, I'm developing the following ThreadedStreamHandler class. (It's still a work-in-progress, but as mentioned, commands that don't have to be run using sudo seem to work just fine right now.)

JButton tutorials and examples

Continuing with the organization efforts again today, here is a collection of Java JButton tutorials and examples:

JScrollPane examples and tutorials

Here is a collection of links to our current JScrollPane tutorials and examples:

JDialog tutorials and examples

Still organizing things around here, and here is a list of JDialog tutorials and examples I have created:

Syndicate content