close

A period back, I considered necessary to breakthrough out all processes running on my mechanism from java standard for several slow role. What d you do in specified a scenario? I proved to write out whatever standard and was pretty booming. Java can't skip near rules activity and therefore invoking a runtime is merely treatment to get all activity and here it is:


import java.io.*;
class ListProcess {

public unchanging blankness biggest(String[] args) throws IOException {

The Essential Middle School, 4th Edition
Thomas Aquinas: Disputed Questions on the Virtues
Tales in Colour and Other Stories
The Social Sources of Financial Power: Domestic Legitimacy
NIV Life Application Study Bible, Personal Size
Die Philosophie der Freiheit.
Keep Your Voice Healthy: A Guide to the Intelligent Use
Ethnic Politics in Burma: States of Conflict (Routledge
Frege - Arg Philosophers (RPD) (Arguments of the
Picture the Middle Ages: The Middle Ages Resource Book
Literatura, mímesis y antropología.
DK Eyewitness Books: Olympics
Student Workbook for Aufmann/Lockwood's Essential
After Pomp and Circumstance: High School Reunion as an
Home/Land/Security: What We Learn about Arab Communities
100 Magic Miles of the Great Barrier Reef : The Whitsunday
The Art of Persuasion in Greece
Business Ethics and Corporate Goverance
Saint Lucia: Portrait of an Island
Advanced Torts: Cases and Materials (American Casebooks)
Custom Folding Knives
Theology of Post-Reformation Lutheranism: A Study of
The rise and fall of the Confederate government
Night and Day

Runtime runtime = Runtime.getRuntime();

String cmds[] = {"cmd", "/c", "tasklist"};

Process proc = runtime.exec(cmds);

Another Bullshit Night in Suck City: A Memoir (Library
American gods
The Fountainhead
Portrait in Death
ESV Study Bible (TruTone, Classic Black)
Leaves of Grass (Signet Classical Books)
Black Beauty (Illus Pocket Classics)
The Merry Adventures of Robin Hood
30 Days to Taming Your Tongue: What You Say (And Don't
Robin Hood
Roaring Rockets (Amazing Machines)
Fly Away Home
The Thorn Birds (Penguin Joint Venture Readers)
The Professional Chef
Shadow Divers (Unabridged)
The Wives Of Henry The Eighth And The Parts They Played In
Drama of the Gifted Child: The Search For the True Self
Rainbow Valley
The Book Of The National Parks (1919)
Wife for Hire
Competing on Analytics (text only) 1st (First) edition by
The Pathfinder: Or The Inland Sea
Word Problems Grade 1 byTsukamoto
Dragonquest: Volume 2 of the Dragonriders of Pern

InputStream inputstream = proc.getInputStream();

InputStreamReader inputstreamreader = new InputStreamReader(inputstream);

BufferedReader bufferedreader = new BufferedReader(inputstreamreader);

String line;

while ((line = bufferedreader.readLine()) != invalid) {

System.out.println(line);

}

}
}

Mind you, the secret message is longhand exclusively for Windows Machine :). And one string tuning in this written communication will schedule you lonesome island running route.


String cmds[] = {"cmd", "/c", "jps"}; this is zero but running jps.exe wallet in bin (jdk6 forward).

Its not all through with. Writing Runtime opinion is not the realistic answer as in that is pocket-sized of platform dependencies. So, I have contracted to dash off the opinion for exploit List of Java Process. Again, I have restrained by OpenJDK secret message for jps(search on jps.java folder :) ) and I got quite a few undercurrent how to do it and here it goes:


import java.util.*;
import sun.jvmstat.monitor.*;
public group ListJavaProcess {

public adynamic empty space crucial(String[] args) throws Exception {

/* Checking for area Host, one can do for faraway machine as all right */

MonitoredHost local = MonitoredHost.getMonitoredHost("localhost");

/* Take all alive VM's on Host, LocalHost present */

Set vmlist = new HashSet(local.activeVms());

for (Object id : vmlist) {

/* 1234 - Specifies the Java Virtual Machine identified by lvmid 1234 on an unknown host.

This thread is transformed into the unqualified approach //1234, which essential be single-minded against

a HostIdentifier. */

MonitoredVm vm = local.getMonitoredVm(new VmIdentifier("//" id));

/* purloin thinking of socio-economic class file and jar wallet some */

String processname = MonitoredVmUtil.mainClass(vm, correct);

System.out.println(id " ---> " processname);

}

}
}

I have scripted groovy magnitude of aside as it is all together a sun import rather than java or javax importation. This introduction resides in tools.jar, so even moving uncomplicated javac and java will not donkey work. So, moving the program will go here:

E:Program FilesJavajdk1.6.0_10bin>javac -classpath "E:Program FilesJavajdk1.6.0_10libtools.jar" ListJavaProcess.java

E:Program FilesJavajdk1.6.0_10bin>java -classpath .;"E:Program FilesJavajdk1.6.0_10libtools.jar" ListJavaProcess 3700 ---> ListJavaProcess

Right now singular one island practice is running. Now in the 2nd code, you can frisk beside both of the java process, but near autochthonal procedure in the above opinion you can't do anything apart from looking at it :)

No hypothesis how to do this in JDK 1.5 or back(runtime is off pedagogy one route). Would respect to learn it some otherwise case.

arrow
arrow
    全站熱搜

    zazaci 發表在 痞客邦 留言(0) 人氣()