Reg how to a Run a java program 24/7
i have a requirement to display the content of the folder 24/7,365 days
regarding this i have written a program but it seems not much efficient regarding its work can any one help me ;
Thread t = new Thread(new ScheduledTask());
t.setDaemon(true);
t.start();
Thread.sleep(90000);
is it possible to run the Daemon Thread continuosly
Any suggestions please welcome
Regards
praveen
praveenmca09 wrote:
i have a requirement to display the content of the folder 24/7,365 days
regarding this i have written a program but it seems not much efficient regarding its work can any one help me ;
Thread t = new Thread(new ScheduledTask());
t.setDaemon(true);
t.start();
Thread.sleep(90000);Remove setDaemon(true) - if you want the thread to keep the JVM from exiting, then it should not be a daemon. Also remove the Thread.sleep( 90000 ) - it's not necessary.
Similar Messages
-
How do i run a java program an another directory?
How do I run a java program that's in a different directory?
I have been doing this in the command line:
java "C:\Document and Settings\freeOn\Desktop\Java\Test\test"
and I get
Exception in thread "main" java.lang.NoClassDefFoundError:
C:\Document and Settings\freeOn\Desktop\Java\Test\test
I just thought there might be a quick way to do this and not
have to cd to the following dir evertime i want to run an app in
console.
The test.java file is this:
import java.io.*;
public class test {
public static void main(String args[]) {
System.out.println("Testing.....");Ok I looked in the java help and found the classpath, this makes it alittle easier.
java -cp C:\DOCUME~1\freeOn\Desktop\Java\Test\ test
At least i can run this in the run dialog which makes it easier thanks for you help kota balaji -
How can i run my java program with out java language
Hai to every one ..Iam new to java language ...am using windows xp operating system , i did not installed java language in my system .. how can i run a java program with out installing java language... Which files is requied to run java program..?
any one can help me??Hai to every one ..Iam new to java language ...am
using windows xp operating system , i did not
installed java language in my system .. how can i run
a java program with out installing java language...
you ... can ... not ... do ... this
Which files is requied to run java program..?
any one can help me??a JVM. Download it from sun's website.
[url http://java.sun.com/javase/downloads/index.jsp]Download JavaSE here -
How can i run my java program in background process?
hi all,
i am working on desktop monitoring so when i start my program on client machine that is visible to all but i want this program client not visible to all instead of this can be run in background process . so, nobody can see that.
so, how i can do this ?
pls pls help me
thanks in advanced to helper
regards
maulik & riteshthis will run the java program in the background.It'll just use the Windows Java Console instead of the command-line console. It has nothing to do with running as a background process.
Edit: though this might be exactly what the OP wants: not "background process" but "no DOS console". -
How can I run a java program on Linux?
I have JBuilder's IDE installed on my Linux partition and it works. However I don't know how to compile and test a program without it. Also I tried to install Limewire on Linux and although I've installed the Java SDK on the system. Once before I installed JBuilder and then JBuilder (I guess) installed it again. However it told me it couldn't find the Java Virtual Machine. Isn't this installed with the JDK? I am able to run programs through JBuilder so I can't see why I'd have a problem. Any answers to the above issues would be greatly appreciated.
Go here and work out how to make a simple app to compile and run on the command line: http://java.sun.com/docs/books/tutorial/getStarted/cupojava/unix.html#2b
(You should find the JDK from a directory under the jbuilder directory so use that and not the /usr/local/jdk1.4 in the example.)
Then find the classes or source code of your project and do the same thing to it. -
How to remotly run a Java Program on machine B from machine A.
Hi all,
I would like to start a JVM/java program from machine A onto machine B (windows plateform). Machine B could be running at another location so where in the lan/intranet.
OR
I would like to be able to start the process(GUI application) on machine B using code running on machine A.
Has anybody ever done somthing like this? Any help will be greatly appreciated.
Kind regards,
Suleman.
[email protected]Machine B would have to be "listening" for program requests from Machine A.
So, on machine B you could have
a) corba server
b) rmi server
c) program listening on a socket for messages
d) servlet running on a web server
regards,
Owen -
How can I run this java program? Please help.
I have jmf installed, sunone running , the file may be in the wrong directory.
It is in some directory nowhere near the java lang dir.
When I try to compile or build i cant. I'm off on a basic thing.
here is the code.
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Receiver;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.ShortMessage;
import javax.sound.midi.SysexMessage;
public class MidiNote
/** Flag for debugging messages.
If true, some messages are dumped to the console
during operation.
private static boolean DEBUG = false;
public static void main(String[] args)
try {
// TODO: make settable via command line
int nChannel = 0;
int nKey = 0; // MIDI key number
int nVelocity = 0;
* Time between note on and note off event in
* milliseconds. Note that on most systems, the
* best resolution you can expect are 10 ms.
int nDuration = 0;
int nArgumentIndexOffset = 0;
String strDeviceName = null;
if (args.length == 4)
strDeviceName = args[0];
nArgumentIndexOffset = 1;
else if (args.length == 3)
nArgumentIndexOffset = 0;
else
printUsageAndExit();
nKey = Integer.parseInt(args[0 + nArgumentIndexOffset]);
nKey = Math.min(127, Math.max(0, nKey));
nVelocity = Integer.parseInt(args[1 + nArgumentIndexOffset]);
nVelocity = Math.min(127, Math.max(0, nVelocity));
nDuration = Integer.parseInt(args[2 + nArgumentIndexOffset]);
nDuration = Math.max(0, nDuration);
MidiDevice outputDevice = null;
Receiver receiver = null;
if (strDeviceName != null)
MidiDevice.Info info = getMidiDeviceInfo(strDeviceName, true);
if (info == null)
out("no device info found for name " + strDeviceName);
System.exit(1);
try
outputDevice = MidiSystem.getMidiDevice(info);
outputDevice.open();
catch (MidiUnavailableException e)
if (DEBUG) { out(e); }
if (outputDevice == null)
out("wasn't able to retrieve MidiDevice");
System.exit(1);
try
receiver = outputDevice.getReceiver();
catch (MidiUnavailableException e)
if (DEBUG) { out(e); }
else
/* We retrieve a Receiver for the default
MidiDevice.
try
receiver = MidiSystem.getReceiver();
catch (MidiUnavailableException e)
if (DEBUG) { out(e); }
if (receiver == null)
out("wasn't able to retrieve Receiver");
System.exit(1);
/* Here, we prepare the MIDI messages to send.
Obviously, one is for turning the key on and
one for turning it off.
MidiMessage onMessage = null;
MidiMessage offMessage = null;
try
onMessage = new ShortMessage();
offMessage = new ShortMessage();
((ShortMessage) onMessage).setMessage(ShortMessage.NOTE_ON, nChannel, nKey, nVelocity);
((ShortMessage) offMessage).setMessage(ShortMessage.NOTE_OFF, nChannel, nKey);
/* test for SysEx messages */
//byte[] data = { (byte) 0xF0, (byte) 0xF7, (byte) 0x99, 0x40, 0x7F, 0x40, 0x00 };
//onMessage = new SysexMessage();
//offMessage = new SysexMessage();
//onMessage.setMessage(data, data.length);
//offMessage = (SysexMessage) onMessage.clone();
catch (InvalidMidiDataException e)
if (DEBUG) { out(e); }
* Turn the note on
receiver.send(onMessage, -1);
* Wait for the specified amount of time
* (the duration of the note).
try
Thread.sleep(nDuration);
catch (InterruptedException e)
if (DEBUG) { out(e); }
* Turn the note off.
receiver.send(offMessage, -1);
* Clean up.
receiver.close();
if (outputDevice != null)
outputDevice.close();
} catch (Throwable t) {
out(t);
System.exit(0);
private static void printUsageAndExit()
out("MidiNote: usage:");
out(" java MidiNote [<device name>] <note number> <velocity> <duration>");
out(" <device name>\toutput to named device");
out(" -D\tenables debugging output");
System.exit(1);
private static void listDevicesAndExit(boolean forInput, boolean forOutput) {
if (forInput && !forOutput) {
out("Available MIDI IN Devices:");
else if (!forInput && forOutput) {
out("Available MIDI OUT Devices:");
} else {
out("Available MIDI Devices:");
MidiDevice.Info[] aInfos = MidiSystem.getMidiDeviceInfo();
for (int i = 0; i < aInfos.length; i++) {
try {
MidiDevice device = MidiSystem.getMidiDevice(aInfos);
boolean bAllowsInput = (device.getMaxTransmitters() != 0);
boolean bAllowsOutput = (device.getMaxReceivers() != 0);
if ((bAllowsInput && forInput) || (bAllowsOutput && forOutput)) {
out(""+i+" "
+(bAllowsInput?"IN ":" ")
+(bAllowsOutput?"OUT ":" ")
+aInfos[i].getName()+", "
+aInfos[i].getVendor()+", "
+aInfos[i].getVersion()+", "
+aInfos[i].getDescription());
catch (MidiUnavailableException e) {
// device is obviously not available...
if (aInfos.length == 0) {
out("[No devices available]");
System.exit(0);
e
* This method tries to return a MidiDevice.Info whose name
* matches the passed name. If no matching MidiDevice.Info is
* found, null is returned.
* If forOutput is true, then only output devices are searched,
* otherwise only input devices.
private static MidiDevice.Info getMidiDeviceInfo(String strDeviceName, boolean forOutput) {
MidiDevice.Info[] aInfos = MidiSystem.getMidiDeviceInfo();
for (int i = 0; i < aInfos.length; i++) {
if (aInfos[i].getName().equals(strDeviceName)) {
try {
MidiDevice device = MidiSystem.getMidiDevice(aInfos[i]);
boolean bAllowsInput = (device.getMaxTransmitters() != 0);
boolean bAllowsOutput = (device.getMaxReceivers() != 0);
if ((bAllowsOutput && forOutput) || (bAllowsInput && !forOutput)) {
return aInfos[i];
} catch (MidiUnavailableException mue) {}
return null;
private static void out(String strMessage)
System.out.println(strMessage);
private static void out(Throwable t)
t.printStackTrace();Please post your code using code tags.
When I try to compile or build i cant.What is your question? Exactly what error message do you get? -
URGENT: How to run a Java program from a different directory?
Hi.
How do I run a Java program from a directory that the file is not located in? So lets say im in c:\Java. But the file is in c:\Java\abc\efg\.
What would be the command to run the Java file from c:\Java.
I can't remember it and I need it asap.
Cheers.If the class you are trying to run is MyApp.class, try
c:\Java\>java -cp abc\efg MyAppThe actual classpath you specify will depend on whether or not MyApp.class is in a package (I've assumed it isn't) and whether or not any 3rd party jars are involbed (I've assumed not).
Edited by: pbrockway2 on Apr 1, 2008 6:42 PM
The command arguments read as "Run the MyApp class using as a classpath abc\efg relative to here (c:\Java)". -
Running a Java program at startup in Linux
Hello
How do I run a Java program at startup in Linux? I know in Windows I can put a .bat file in C:\Windows\Start Menu\Programs\StartUp\ directory, but in Linux I have no idea how it is done.
Thank you,
MihaiThis is really a Linux question, not Java.
And then it depends on the version of Linux you are using.
Maybe this will help, otherwise you should try on a forum for your version of Linux. -
Running a java program in a directory other than the current directory
How do I run a java program that's located in a directory other than the current directory?
There is a file Test.java in /dir1/subdir1. If my current directory is anywhere other than that directory, say /dir2/subdir2, I can compile Test.java by using:
javac -classpath /dir1/subdir1 /dir1/subdir1/Test.java
But when I try to run it with:
java -classpath /dir1/subdir1 /dir1/subdir1/Test
I get a java.lang.NoClassDefFoundError: \dir1\subdir1\Test
Any thoughts?You need to specify just the name of the class you want to run. So java -classpath /dir1/subdir1 Test
-
How to run a java program without Java Compiler
I have a small project and I want share it with my friends but my friend'pc have not
Java compiler.
for example, I writen a application like YM, then 2cp can sent,receive messege. My cumputer run as Server, and my frien PC run as client.
How can my friend run it? or how to create an icon in dektop tu run a java program..??..
(sorry about my English but U still understand what i mean (:-:)) )To run a program you don't need a Java compiler. Just the Java Runtime Engine. That can be downloaded from the Sun website and comes with an installer.
You could then turn your application into an executable jar file and start it somehow like jar myYM.
There is also software that packs a Java program into an executable file. I've never used that but one that comes to my mind is JexePack. It's for free if you can live with a copyright message popping up every time you start the program.
http://www.duckware.com/jexepack/index.html -
How to run a java program in another folder
Hello!
I want to run for example the java class file in the path ./sourcecode/javafile.class. It works fine if I do the following:
cd sourcecode
java javafile
but it cannot work if I do:
java sourcecode/java
The error it outputs is NoClassDefFoundError.
Can someone tell me how to run a java program in another folder
thanks a lot.You need to specify the classpath using the -cp flag when running. so instead of
"java sourcecode/javafile"
Try
"java -cp sourcecode javafile" -
How can i run the java bean sample program download from OTN
hello to all
i have a p[roblem. i have downloaded the sample progam from oracle web site which is a java code that connect with the oracle and shows a form. how can i run the from.
can any body help me pleaSEEE
thanks
kamran ahmedHi Darryl.Burke
So your telling, we cannot run our Java Program when system shutdowns...In my application, when user has schedule for next days and he shutdown his PC. On the next day when System Started i should able to get back my schedule on the Specified time(I'm TimerTask class in Java)... How can i achieve this using Java? can u tell me clearly.. -
How to set path to run a Java program?
my pc os is win2000 service pack 3.
cpu is celoron 667mhz
256 pc133 sdram
i have done the setting b4 run a java program but no any effect.
setting as below:
set path=c:\j2sdk1.4.1_01\bin
set classpath=c:\j2sdk1.4.1_01\lib
my java file is store in C:\Java, file name is HelloWorld.java, so when i type:
C:\>
C:\>Java\javac HelloWorld.java
(the screen show me : java\javac not internal or external........")
and i try again as follow:
C:>
C:>\Java>javac HelloWorld.java
(the screen show : Exception in thread "main" java.lang.NoClassDefFoundError:HelloWorld/java)
i cant do anymore, who can help me?you need to put the CLASSPATH to dir: c:\j2sdk1.4.1_01
and also to the directory you are working
For example, you are working in "C:\Myclasses". You need to put:
set CLASSPATH = C:\j2sk1.4.1_01;C:\Myclasses;
if you don't put your working directory, java doesn't find your classes
Try it and luck! -
How to run a java program in command prompt
hi i want to run a java program from in command prompt from another directory
i want to run a file named First in C:\Program Files\Java\jdk1.6.0_07\bin
so when i give the command
java "C:\Program Files\Java\jdk1.6.0_07\bin\First"
it doesnt works it shows
C:\>java "C:\Program Files\Java\jdk1.6.0_07\bin\First"
Exception in thread "main" java.lang.NoClassDefFoundError: C:\Program Files\Java
\jdk1/6/0_07\bin\First
Caused by: java.lang.ClassNotFoundException: C:\Program Files\Java\jdk1.6.0_07\b
in\First
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: C:\Program Files\Java\jdk1.6.0_07\bin\First. Pro
gram will exit.but it prints
C:\>java -cp "C:\Program Files\Java\jdk1.6.0_07\bin\" First
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -jre-no-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
C:\>
Maybe you are looking for
-
Iphones and windows 8.1
Since upgrading from windows 8 to windows 8.1 I'm no longer able to charge or back up my phone from my laptop. Any suggestions ??
-
Power Consumption of Power Injector
Hi, Hope you can assist me. My customer requested me to calculate the power consumption required for the installation of one unit of AP 1510 using the following power injector, part no: Power Injector (AIR-PWRINJ1500). He would like to know the cost
-
Reassign activities in Email Interaction manager
Hello Mates, i need to delete an agent in Cisco Email Interaction Manager. This fails with this message. Any ideas how to delete the user? the user that your trying to delete has some open activities or cases or suggestions in feedback mode. Please r
-
Time comparison in UCCX scripting
Hi, Need help in UCCX 8.5 scripting with opening and clsoing hours. I need to check for any incoming call if current system time is between 8 am to 5 pm then call should route to CSQ otherwise it should route to voice mail. Regards, Dinesh Joshi
-
After syncing iphone 4s all previous music gone
Hi - I recently uploaded some CDs to my itunes library and the synced my iphone 4s. Now, all the music that WAS in my library is gone from my computer and from my iphone. I searched my PC - none of them are there, not in the recycle bin either. And t