execute shell command via java

It happened to me that working via an extranet on a citrix environment in a WSAD workspace, that I needed to remove the attribute to at least 200 files in different directories.

Since do it one by one via WSAD is unthinkable, and I didn’t have time to going to the client, loggin into the net in order to have a shell and I dind’t have a shell by my hands, I did it via java.

The environment is Windows machine and here is the source

package tests.runners;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;

public class ShellCommandRunner {
	public static void main(String[] args) throws IOException{
		OutputStream stdin = null;
		BufferedReader br = null;
		String line = null;
		String command = null;

		command = "cmd.exe /C attrib -r /S /D X:\\workspaces\\tuc-workspace\\*.*";

		System.out.println(command);
		Process p = Runtime.getRuntime().exec(command);
		stdin = p.getOutputStream(); //use this to push commands

		//processing stdout
		br = new BufferedReader(new InputStreamReader(p.getInputStream()));
		while((line=br.readLine())!=null) System.out.println(line);

		//processing stderr
		br = new BufferedReader(new InputStreamReader(p.getErrorStream()));
		while((line=br.readLine())!=null) System.err.println(line);

		System.out.println("done!");
	}
}

[WSAD] changing default workspace

What if in Websphere Studio Application Developer you have set a workspace as default and now you want to change it?

Setting a workspace as default make WSAD not asking you for which workspace to use. If you have to reset the option execute WSAD from command line with the -setworkspace parameter.

On windows systems the location probably is the following

C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.1>wsappdev.exe -setworkspace

Maybe this could even work for pure eclipse but I’ve not tested it.