Posts

Showing posts from October, 2009

To start and stop tomcat server using Java

The command to execute in dos prompt - For Tomcat 5.5 To Start: net start tomcat5 To Stop: net stop tomcat5 public class TestTomcatService { public static void main(String[] args) throws IOException { TestTomcatService obj = new TestTomcatService(); obj.startService(); obj.stopService(); } public void startService() { try { String[] command = new String[3]; command[0] = "cmd"; command[1] = "/C"; command[2] = "net start tomcat5"; Process p = Runtime.getRuntime().exec(command); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); // read the output from the command String s = null; System.out.println("Here is the standard output of the command:\n"); while ((s = stdInput.readLine()) != null) { System.out.println(s); } // read any errors from the attempted command System.out.println(...

Find difference in days in Java

To calculate the difference between two dates, we will be using Calendar (java.util.*) public static long daysDifference(Calendar startDate, Calendar endDate) { Calendar date = (Calendar) startDate.clone(); long daysBetween = 0; while (date.before(endDate)) { date.add(Calendar.DAY_OF_MONTH, 1); daysBetween++; } return daysBetween; } The while loop will be executed until the startDate is less than the endDate. The long value daysBetween will return the days difference.

How to Succeed

1. Don't talk negatively about people behind their backs. 2. If you gossip, people won't confide in you. Mind your own business. 3. Try to work for someone who'll challenge your powers. 4. You'll learn more in a year than 4 years of college. 5. Successful bosses have good communication skills. They learn from people, including their employees. 6. Work in such a way that makes your boss look good. It's not flattery 7. On downsizing, the first to go are those with few friends. Bosses prefer competent people whom they respect. 8. Dress for the job you want, not the one you have. Let your dress reflect professionalism. 9. Workout to get in good physical shape. Unless exceptionally skilled, the unhealthy are at a comparative disadvantage. 10. Personal integrity is crucial. tell nothing but the truth. Bosses can forgive mistakes but if you lie, you're gone 11. Be on time. Try to arrive few minutes early. It saves you from stress. You'll be much relaxed & work ...

Mobile Charge - Saving Tips

If you're expecting a call and your battery icon starts blinking, the first thing you should do is find a charger. But if that's not an option, here are ten things you can do to hang on. We'll skip the usual tips about the 'memory effect' and which battery type is better NiCd or Li-Ion because you don't really have a choice in that. Close Background Applications If you're using a Smartphone, close applications that you don't need. Applications that stay active in the background use up a bit of CPU, which uses up battery. Make sure you 'exit' the applications from the menu, not by pressing the 'End' key, as that merely puts the application in the background. In Series 60 Smartphones (mostly Nokias), hold down the 'Menu' key to get a list of all applications running in the background to close them. In Windows Mobile 5 phones, open the 'Memory' application and check the 'Running programs' tab to close them. Turn D...