July 19, 2009 at 11:05 am (Java, Linux)
Tags: code, command, command line, console, exec, input stream, Java, jstack, Linux, output, pid, process, runtime, sample, stack trace, thread dump
Of course; I was trying to get a thread dump using jstack here. You would need to change the command that Runtime.exec() executes to your liking.
Process threadDump=Runtime.getRuntime().exec("jstack -l "+pid);
BufferedReader br=new BufferedReader(new InputStreamReader(threadDump.getInputStream()));
while(true)
{
String line=br.readLine();
if(line==null)
break;
else {
//Do whatever you want
}
Leave a Comment
July 19, 2009 at 11:00 am (Java, Linux)
Tags: *nix, application, code, command, echo, exec, get, id, input stream, Java, Linux, pid, process, runtime, sample, shell, unix
Use the following sample code to get the pid(process id) on *nix variants, after running it as a command from Java using Runtime.exec() .
The command variable, in my case, was running another Java application.
try {
Process process=Runtime.getRuntime().exec(new String [] {"sh","-c",command+" & echo $!"} );
BufferedReader br=new BufferedReader(new InputStreamReader(process.getInputStream()));
String ps=br.readLine();
int pid=Integer.valueOf(ps);
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
1 Comment
August 12, 2008 at 4:56 pm (Java, Linux, Oracle)
Tags: 10g R2, connection, database, OCI8
Hello folks,
Recently, I had another problem connecting to an Oracle 10g R2 database with the Oracle Call Interface. Well, this was not about the driver actually. Having passed 2 weeks from my first problem, this time I was deploying the servlet, Tomcat 6 and Oracle 10g R2 to a OpenSUSE 10.3 machine. It still was stopping at this line:
connection = DriverManager.getConnection(url, username, password);
Read the rest of this entry »
Leave a Comment
August 12, 2008 at 4:23 pm (Java, Oracle)
Tags: Driver, invalid login, JDBC, OCI8, ORA-01017
Hi,
Approximately 2 weeks ago, I encountered a strange problem while connecting to an Oracle database from my servlet on Tomcat Application Server. What was strange about it was that it was fully tested and working when it was residing on my laptop; however when I deployed the application to the PC at work, it started to give errors at this line:
connection = DriverManager.getConnection(url, username, password);
Read the rest of this entry »
Leave a Comment