java

Running commands over ssh with Java

Scenerio: I'd like to run commands on remote machines from a Java program over ssh (I am using OpenSSH on my development machine). I'd also like to make the ssh connection by passing the password rather than setting up keys as I would with 'expect'. Problem: When trying to do the 'expect' like password login the Process that is create...

Java LDAP - Determine if user in a given group?

We logon users to Active Directory via LDAP using the Java LDAP API. We want to enhance our logon functionality to further check if the user is in a given AD group. Does anyone know how to do this? Current code: import javax.naming.*; import javax.naming.ldap.*; LdapContext ctx = null; Hashtable env = new Hashtable(); env.put(Contex...

How do I convert a Groovy String array to a Java String Array?

I'm trying to call a methond on a Java class from a Groovy class. The Java method has a String array as a parameter, and I have a collection of Strings in my Groovy class. How do I convert the Groovy collection to a Java String array? Java Method: public class SomeJavaClass{ public void helpDoSomething(String[] stuff){ } } Gro...

Why won't my JMenuBar show up?

I'm trying to make a GUI in java, but JMenuBar has been giving me a hard time for two days. Can someone please tell me why it isn't showing up? import java.awt.*; import javax.swing.*; import javax.swing.JPanel; import java.awt.event.*; import java.awt.image.*; import java.io.*; import java.util.Arrays; import javax.imageio.ImageIO...

How to keep the bottom of an SWT Browser widget visible when appending to the HTML content?

I'm viewing HTML in an SWT Browser widget. I am appending logging messages to the end of the content and would like to keep the bottom visible all the time. Currently, whenever I append text to the content, I first set the new text: browser.setText(content); And then I scroll down the Browser widget via JavaScript: browser.execute("w...

.Net guy getting up to speed on Java -- suggested resources?

Hi I've been coding in .NET for several years, and more recently Actionscript. I need to get up to speed now on Java development. I was hoping for some references to good books and blogs that will help me get up to speed in the Java gotcha's I'm likely to encounter. I'd like to know about the framework classes (collections, runtime, ...

Response.End() in Java/JSP

In .net you have the ability to Response.End() in any context you want. Is there similar functionality in Java/JSP? Thanks, Sam ...

Java GUI layout problems

Hi, I'm writing a small Java GUI program, and I'm having some issues with Java not laying things out properly. I haven't done much Java GUI code lately, so I'm having trouble seeing where the problem lies. final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart, false); chartPanel.se...

Solutions for Java User Account Management

I currently work on a Java web application that has relies on a permissions mechanism to manage user content. This of course means that we need to manage users. Our current user management system is an in house system that manage info about users, groups, and user and permissions in an RDBMS. The system works but is a hassle to maintain....

MemoryCacheImageOutputStream To BufferedImage

I have some image constrain code that allows you to output to a MemoryCacheImageOutputStream, but I need to get this back into a BufferedImage, any suggestions? ...

How can I sort the keys of a Map in Java?

This is a very basic question, I'm just not that good with Java. I have a Map and I want to get a list or something of the keys in sorted order so I can iterate over them. ...

Book rec(s) for an ASP.NET/C# developer looking to build in JSP+Tomcat?

I'm a senior-ish C# developer used to ASP.NET & IIS, but a project's come along for which I'll need to use Java/JSP and Tomcat, both of which are new to me. I've got a bit of experience with Java, but none with Tomcat or JSP, so I'm looking for a book ( or books) that'll help me get up and running with JSP and Tomcat quickly. (The proj...

Is platform enforced versioning mechanism most sorely needed feature of java?

As developer, I am often interested in new language feature that can make your life easier. For example, java 5 brought generics and annotations to the language, features that can definitely boost your productivity. However, when I look back at close to a decade working on java platform, I find that the versioning related problems are t...

File permissions in Android

First of all, Hi to everyone, I'm here just to ask something maybe very simple, I'm working with Files, FileOutputStream and FileInputStream, But I just want to get/set a few props from the file, I mean, the owner the file, the permissions read/write, etc. Looking around I found the classes FileDescriptor and FilePermission but I don't ...

Java RandomAccessFile

public void exportUrlsToFile(String file, String urls) throws IOException { String[] urlsArray = urls.split("\\s+");// split on one or more white space characters. // create a fresh file RandomAccessFile raf = new RandomAccessFile(file, "rw"); for (String line : urlsArray) { line = line.trim(); if (line.isEmpty()) {// this ...

Why is J2EE scalable?

I heard from various sources that J2EE is highly scalable, but to me it seems that you could never scale a J2EE application to the level of the google search engine or any other large website. I would like to hear the technical reasons why it is so scalable. ...

Disabling Log4J Output in Java

How can one quickly turn off all Log4J output using a log4j.properties file? ...

Detecting and acting on keyboard direction keys in Java

G'day all, I have a console project where it is intended the user presses the keyboard direction keys (non-numeric keypad) to move an avatar. I am having difficulty coding to check for the press of these keys. In Pascal it was easy enough to use "readkey" and code, for example, for #80 for the down keypress. However, I am stumped how t...

How to remove System.out.println's from codebase

We have a huge (old legacy java) code-base, where many files (around 5k) have System.out.println's. We are planning to remove them for cleanup/performance reasons. How can we write a script that will replace them without introducing any issues in the code? The script cannot blindly delete them as following case can be an issue: if () ...

Does learning java as a first language ruin your programming base for the future?

I am asking this because I read Joel's The Perils of JavaSchools. ...