How to get system tasks using Java?
I have question about system tasks. I have to list all tasks which are working in the system. Is there any class which i useful to do that? I've tried to write shell script but it won't be working in system different than Linux. I will be grateful for any help.
In the standard Java classes, there are no such implementation. You are sort of answering the question youself, since you've made a script to do it. It is the same for all systems. To get the system information you need to talk to the system and to do that you need to know what system you are on...
Some system functions are more or less the same in all systems so they can be reached by the Systems-class.
Similar Messages
-
How can i get system variable using java
Hi,
I just want to know how can i get system variables using java code.
for example i want to get the the date for today or i want to get the number of processes that's running.
Thanks alotHi,
I just want to know how can i get system variables
using java code.
for example i want to get the the date for today or i
want to get the number of processes that's running.
Thanks alotSome generic "system variables" are available though Java, usually through the System class.
Date today = new Date();
is instantiated with the current date and time.
Other system values, like environment values, should be passed to java through the command line (-D option) by setting system properties.
Finally, platform specific values like the number of processes running will have to be written in platform specific code and executed by JNI (java native interface).
Java is platform or system agnostic. Common system values, like time, are implemented. Hopefully you won't need platform specific values. -
How to read system evenlog using java program in windows
How to read system evenlog using java program in windows???
is there any java class available to do this ? or any one having sample code for this?
Your friend ZoeWelcome to the Sun forums.
>
How to read system evenlog using java program in windows???>
JNI. (No.)
>
is there any java class available to do this ? or any one having sample code for this?>You will generally get better help around here if you read the documentation, try some sample code and come back with a specific question (hopefully with an SSCCE included).
>
Your friend Zoe>(raised eyebrow) Thank you for sharing that with us.
Note also that one '?' denotes a question, while 2 or more generally denotes a dweeb. -
How to read system eventlog using java program in windows?
How to read system eventlog using java program in windows?
is there any java class available to do this ? or any one having sample code for this?
Your friend ZoeHi,
There is no java class for reading event log in windows, so we can do one thing we can use windows system 32 VBS script to read the system log .
The output of this command can be read using java program....
we can use java exec for executing this system32 vbs script.
use the below program and pass the command "eventquery"
plz refer cscript,wscript
import java.io.*;
public class CmdExec {
public static void main(String argv[]) {
try {
String line;
Process p = Runtime.getRuntime().exec("Command");
BufferedReader input =
new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line);
input.close();
catch (Exception err) {
err.printStackTrace();
This sample program will list all the system log information....
Zoe -
How to get printer IPAddress using java code
Hi all,
Can some one suggest in java
1) how to get printer IPaddress
2) send a printer job to a particular printer either by using printer name or by printer IPaddress ?Hi all,
Can some one suggest in java
1) how to get printer IPaddress
2) send a printer job to a particular printer either by using printer name or by printer IPaddress ? -
How to get MAC address using java code
hi friends
please write me, How can I get MAC Address of local machine using java code.I don't want to use JNI.
Please reply me. Its urgent for me
Thanks in advance
USYou have several ways under *nix
ifconfig -a | grep HWwill output something like
eth0 Lien encap:Ethernet HWaddr 00:11:FF:74:FF:B4combined with Runtime.getRuntime().exec("")and Process.getInputStream()you should be able to read it easilly.
Under Windows (and Linux of course) try jpcap (http://sourceforge.net/projects/jpcap)
You can also use jnative as a generic tool (http://sourceforge.net/projects/jnative)
--Marc (http://jnative.sf.net) -
Anyone know how to get current time using Java?
Hi,
do anyone know how to use system.currentTimeMillis() to get the current time?
I know that system.currentTimeMillis() get the time between current time and midnight, January 1, 1970 UTC. but how to use it to get the current time format?
Thank you very much.Hi,
do anyone know how to use system.currentTimeMillis()
to get the current time?
I know that system.currentTimeMillis() get the time
between current time and midnight, January 1, 1970
UTC. but how to use it to get the current time format?
Thank you very much.
long timeInMillis = System.currentTimeMillis();
Calendar c = Calendar.getInstance();
c.setTime(timeInMillis);
Date d = c.getTime();And format using SimpleDateFormat:
SimpleDateFormat sdf = new SimpleDateFormat("dd-mm-yyyy HH:mm:ss");
String formattedDateString = sdf.format(d); -
How to get system Hostname in java
Hi,
I am a java developer trying to get the hostname of the system from java class. Meaning want the value when i run the $hostname command in linux and my server is Linux server.
I am searching in the System Properties for the hostname but i could not get it
I am running IBM Websphere 5.2 and JDK 1.4.2 in my linux server.
Thanks for input
-APTry
package testing;
import java.net.*;
public class Test
public static void main(String[] args) throws UnknownHostException
System.out.println(InetAddress.getLocalHost().getHostName());
} -
How to measure system parameters using java?
Hi All,
I am having a client which is monitoring the system parameters as CPU,Memory, Disk using cscripts on windows and shell scripts on Linux.
These scripts are executed using exec().
Is it possible to possible using any java's built in classes?
Please help me.
Thanks in advanceIs it possible to possible using any java's built in
classes?There are no built-in Java classes to do low-level hardware/platform-specific things like inspecting the CPU, etc. Wrong tool for the job. -
how to get system id using java ,also MAC address?
I think you have to use JNI and write the native calls on whatever platform(s) you need this.
-
System configuration using java
Hi friends
Can I get System configuration using java code.
If yes plz suggest how.
thanks in advance.. Anjanasome bits and pieces are available see the details in
System.getProperties():
Properties sysProps = System.getProperties();
meration en = sysProps.keys();
while ( en.hasMoreElements() )
//add the key=value pairs
Object keyObj = en.nextElement();
String key = ( String ) keyObj;
Object valueObj = sysProps.getProperty( key );
System.out.println( key + " : " +
+ valueObj.toString());
de]
just an idea??YES, and also you can do
System.getenv();but they also don't give all the info the OP was/is looking for. -
How to get Process Task Retry Count using API (OIM 10g)
Hi ,
I want to get all the process task which are failed after retried 5 times.
For e.g Create user task in AD retried for 5 times but still it is in failed state. I want to get all such process task.
I am stuck at point how to get process task retry count from process definition?
ThanksYou can reference the code in the "Task Timed Retry" scheduled task to get what you are looking for. Here is the decompiled code:
>
package com.thortech.xl.schedule.tasks;
import Thor.API.Operations.tcScheduleTaskOperationsIntf;
import com.thortech.util.logging.Logger;
import com.thortech.xl.dataaccess.tcDataSetException;
import com.thortech.xl.dataobj.tcDataSet;
import com.thortech.xl.scheduler.tasks.SchedulerBaseTask;
import com.thortech.xl.util.logging.LoggerMessages;
import java.sql.Date;
import java.util.Hashtable;
public class tcTskTimedRetry extends SchedulerBaseTask
private static Logger logger = Logger.getLogger("Xellerate.Scheduler.Task");
Date isCurrentDate;
public void init()
logger.debug(LoggerMessages.getMessage("EnteredMethodDebug", "tcTskTimedRetry/init"));
this.isCurrentDate = new Date(System.currentTimeMillis());
logger.debug(LoggerMessages.getMessage("LeftMethodDebug", "tcTskTimedRetry/init"));
public void execute()
logger.debug(LoggerMessages.getMessage("EnteredMethodDebug", "tcTskTimedRetry/execute"));
tcDataSet localtcDataSet1 = new tcDataSet();
tcDataSet localtcDataSet2 = new tcDataSet();
tcDataSet localtcDataSet3 = new tcDataSet();
try
if (isStopped())
return;
localtcDataSet2.setQuery(getDataBase(), "select osi_retry_on from osi where 1=2");
localtcDataSet2.executeQuery();
if (isStopped())
return;
localtcDataSet2.setDate("osi_retry_on", this.isCurrentDate);
localtcDataSet1.setQuery(getDataBase(), "select osi.sch_key, osi.mil_key, osi.orc_key, osi.osi_rowver, sch.sch_rowver, osi.osi_retry_for, osi.osi_retry_on, osi.osi_retry_counter, sch.sch_note from osi osi,sch sch where osi.osi_retry_on <=" + localtcDataSet2.getSqlText("osi_retry_on") + " and osi.sch_key = sch.sch_key" + " and sch.sch_status='R'" + " and osi_retry_counter>0 order by osi.sch_key");
localtcDataSet1.executeQuery();
if (isStopped())
return;
int i = localtcDataSet1.getRowCount();
logger.debug("tcTskTimedRetry:execute:Number of Process tasks retrieved is=" + i);
tcScheduleTaskOperationsIntf localtcScheduleTaskOperationsIntf = (tcScheduleTaskOperationsIntf)getUtility("Thor.API.Operations.tcScheduleTaskOperationsIntf");
tcDataSet localtcDataSet4 = new tcDataSet();
localtcDataSet4.setQuery(getDataBase(), "select osi_retry_for, osi_retry_counter from osi where 1=2");
localtcDataSet4.executeQuery();
Hashtable localHashtable = new Hashtable();
if (isStopped())
return;
for (int j = 0; j < i; j++)
if (isStopped())
return;
localtcDataSet1.goToRow(j);
localtcDataSet3.setQuery(getDataBase(), "select count(*) as counter from osi osi,sch sch where osi.sch_key = sch.sch_key and osi_retry_for=" + localtcDataSet1.getLong("sch_key"));
localtcDataSet3.executeQuery();
if (isStopped())
return;
if (localtcDataSet3.getInt("counter") > 0)
continue;
localHashtable.put("osi_retry_for", String.valueOf(localtcDataSet1.getLong("sch_key")));
localHashtable.put("sch_note", localtcDataSet1.getString("sch_note"));
long l = localtcDataSet1.getLong("osi_retry_counter");
if (isStopped())
return;
try
localtcScheduleTaskOperationsIntf.createScheduleItem(localtcDataSet1.getString("orc_key"), localtcDataSet1.getString("mil_key"), localHashtable, l - 1L);
catch (Exception localException2)
logger.error(LoggerMessages.getMessage("ErrorMethodDebug", "tcTskTimedRetry/execute", localException2.getMessage()), localException2);
catch (tcDataSetException localtcDataSetException)
logger.error(LoggerMessages.getMessage("ErrorMethodDebug", "tcTskTimedRetry/execute", localtcDataSetException.getMessage()), localtcDataSetException);
logger.debug("PJ:tcTskTimedRetry:execute:DataSetexception has occured");
catch (Exception localException1)
logger.error(LoggerMessages.getMessage("ErrorMethodDebug", "tcTskTimedRetry/execute", localException1.getMessage()), localException1);
logger.debug(LoggerMessages.getMessage("LeftMethodDebug", "tcTskTimedRetry/execute"));
public boolean stop()
logger.debug("tcTskTimedRetry:stop:Task being stopped");
return true;
>
-Kevin -
How to invoke Default printer of my system by using java application
I need to invoke default printer of my system by using java application ? could u plz help me out with sample code?
VoodooMagic.getDefaultPrinter().print();
http://www.javaworld.com/javaworld/jw-10-2000/jw-1020-print.html
Look for more at Google. -
How to set proxy authentication using java properties at run time
Hi All,
How to set proxy authentication using java properties on the command line, or in Netbeans (Project => Properties
=> Run => Arguments). Below is a simple URL data extract program which works in absence of firewall:
import java.io.*;
import java.net.*;
public class DnldURLWithoutUsingProxy {
public static void main (String[] args) {
URL u;
InputStream is = null;
DataInputStream dis;
String s;
try {
u = new URL("http://www.yahoo.com.au/index.html");
is = u.openStream(); // throws an IOException
dis = new DataInputStream(new BufferedInputStream(is));
BufferedReader br = new BufferedReader(new InputStreamReader(dis));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);
//Close the input stream
dis.close();
} catch (MalformedURLException mue) {
System.out.println("Ouch - a MalformedURLException happened.");
mue.printStackTrace();
System.exit(1);
} catch (IOException ioe) {
System.out.println("Oops- an IOException happened.");
ioe.printStackTrace();
System.exit(1);
} finally {
try {
is.close();
} catch (IOException ioe) {
}However, it generated the following message when run behind the firewall:
cd C:\Documents and Settings\abc\DnldURL\build\classes
java -cp . DnldURLWithoutUsingProxy
Oops- an IOException happened.
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:320)
at sun.net.www.http.HttpClient.New(HttpClient.java:315)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:510)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:487)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:615) at java.net.URL.openStream(URL.java:913) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
I have also tried the command without much luck either:
java -cp . -Dhttp.proxyHost=wwwproxy -Dhttp.proxyPort=80 DnldURLWithoutUsingProxy
Oops- an IOException happened.
java.io.IOException: Server returned HTTP response code: 407 for URL: http://www.yahoo.com.au/index.html
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245) at java.net.URL.openStream(URL.java:1009) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
All outgoing traffic needs to use the proxy wwwproxy (alias to http://proxypac/proxy.pac) on port 80, where it will prompt for valid authentication before allowing to get through.
There is no problem pinging www.yahoo.com from this system.
I am running jdk1.6.0_03, Netbeans 6.0 on Windows XP platform.
I have tried Greg Sporar's Blog on setting the JVM option in Sun Java System Application Server (GlassFish) and
Java Control Panel - Use browser settings without success.
Thanks,
GeorgeHi All,
How to set proxy authentication using java properties on the command line, or in Netbeans (Project => Properties
=> Run => Arguments). Below is a simple URL data extract program which works in absence of firewall:
import java.io.*;
import java.net.*;
public class DnldURLWithoutUsingProxy {
public static void main (String[] args) {
URL u;
InputStream is = null;
DataInputStream dis;
String s;
try {
u = new URL("http://www.yahoo.com.au/index.html");
is = u.openStream(); // throws an IOException
dis = new DataInputStream(new BufferedInputStream(is));
BufferedReader br = new BufferedReader(new InputStreamReader(dis));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);
//Close the input stream
dis.close();
} catch (MalformedURLException mue) {
System.out.println("Ouch - a MalformedURLException happened.");
mue.printStackTrace();
System.exit(1);
} catch (IOException ioe) {
System.out.println("Oops- an IOException happened.");
ioe.printStackTrace();
System.exit(1);
} finally {
try {
is.close();
} catch (IOException ioe) {
}However, it generated the following message when run behind the firewall:
cd C:\Documents and Settings\abc\DnldURL\build\classes
java -cp . DnldURLWithoutUsingProxy
Oops- an IOException happened.
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:320)
at sun.net.www.http.HttpClient.New(HttpClient.java:315)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:510)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:487)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:615) at java.net.URL.openStream(URL.java:913) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
I have also tried the command without much luck either:
java -cp . -Dhttp.proxyHost=wwwproxy -Dhttp.proxyPort=80 DnldURLWithoutUsingProxy
Oops- an IOException happened.
java.io.IOException: Server returned HTTP response code: 407 for URL: http://www.yahoo.com.au/index.html
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245) at java.net.URL.openStream(URL.java:1009) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
All outgoing traffic needs to use the proxy wwwproxy (alias to http://proxypac/proxy.pac) on port 80, where it will prompt for valid authentication before allowing to get through.
There is no problem pinging www.yahoo.com from this system.
I am running jdk1.6.0_03, Netbeans 6.0 on Windows XP platform.
I have tried Greg Sporar's Blog on setting the JVM option in Sun Java System Application Server (GlassFish) and
Java Control Panel - Use browser settings without success.
Thanks,
George -
Hello Sir,
I am Udhaya. I don't know how to capture system idle time using java. Please any one help me how to get system idle time. Any class is available in java to get idle time?
Thank in advance
Udhayajwenting wrote:
DrLaszloJamf wrote:
jwenting wrote:
the moment you ask the system for its idle time that idle time becomes 0, so just returning a constant value of 0 would always yield the correct answer.But when you don't call this constant method the value it would return is wrong. This is the sort of thing that keeps me up at night.Except of course that when you don't call it it doesn't return it and therefore still behaves properly.
Or were you thinking of philosphical problems like "what does a method do when it's not called?"?Actually I was trying to see if I could get the OP to say boo to a goose.
Maybe you are looking for
-
This just happened 1 or 2 weeks ago. I go to System Preferences > Date & Time, and it doesn't open. The quote below is the error. Please help me. Is this the right thread to ask? Where can I post this or report this? Process: System Preferenc
-
How do I make a photo book in Apeture?
I recently began using Apeture. How do I go about creating a photo book with captions from Apeture. Do I need to export the photos to iphoto for the purchased book?
-
Using Fault Message Type in BPM
Hi, In my BPM Scenario, I am using a synchronous send step in which I am using a fault message type.For giving the container for the fault message in the Properties area of the send step, I want to define a container corresponding to the Fault messag
-
ORA-04062 - very urgent, please help
Error "ORA-04062: timestamp of package "SYS.DBMS_SNAPSHOT_UTL" has been changed" appears while refreshing materialized view with DBMS_MVIEW.REFRESH, the configuration is described below, please, any suggestions what cause the problem? I have the mast
-
AwesomeWM and trader workstation (java application)
Hi guys, is anyone using the Interactive Brokers Trader Workstation (Package: ib-tws) and AwesomeWM? I'm having trouble with some features of Trader Workstation e.g. changing the timeframe of a stock chart. This feature is crucial for me and I did no