Thursday, April 27, 2017

How to make Apache Tomcat as service in Windows 7 ?



How to make Apache Tomcat as service in Windows 7 ?

Go to the tomcat location c:\apache-tomcat-7.0.77\bin and write command service.bat install as
show in the below picture.





2. You will see the 'Tomcat X' has been started.

Note: X is the version of your Tomcat.






3. Monitor your installed Tomcat service.

c:\apache-tomcat-7.0.77\bin>tomcat7w.exe //MS//Tomcat7




You will see below dialog,






How to set+modify Java option ? or How to set+modify PATH system variable ?

How to set/modify the PATH system variable?


This post applies following OS's :

Windows 7, Windows 8, Windows Vista, Windows XP

Macintosh OS X, 

Oracle Linux, 

Red Hat Linux, 

SUSE Linux, 

Solaris SPARC,




Information for All

  • The PATH is a system variable that your operating system uses to locate needed executables from the command line or Terminal window.

  • The PATH system variable can be set using System Utility in control panel on Windows, or in your shell's startup file on Linux and Solaris.

  • Making changes to the system PATH variable is typically not necessary for computers running Windows or Mac OS X.

Windows

Windows 10 and Windows 8

  1. In Search, find for and then select: System (Control Panel)
  2. Click the Advanced system settings link.
  3. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  4. In the Edit System Variable (or New System Variable) window, specify the value of the PATHenvironment variable. Click OK. Close all remaining windows by clicking OK.
  5. Reopen Command prompt window, and run your java code.
Windows 7

  1. From the desktop, right click the Computer icon.
  2. Choose Properties from the context menu.
  3. Click the Advanced system settings link.
  4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  5. In the Edit System Variable (or New System Variable) window, specify the value of the PATHenvironment variable. Click OK. Close all remaining windows by clicking OK.
  6. Reopen Command prompt window, and run your java code.
Windows Vista

  1. From the desktop, right click the My Computer icon.
  2. Choose Properties from the context menu.
  3. Click the Advanced tab (Advanced system settings link in Vista).
  4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  5. In the Edit System Variable (or New System Variable) window, specify the value of the PATHenvironment variable. Click OK. Close all remaining windows by clicking OK.
  6. Reopen Command prompt window, and run your java code.
Windows XP

  1. Select Start, select Control Panel. double click System, and select the Advanced tab.
  2. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  3. In the Edit System Variable (or New System Variable) window, specify the value of the PATHenvironment variable. Click OK. Close all remaining windows by clicking OK.
  4. Reopen Command prompt window, and run your java code.

Mac OS X

To run a different version of Java, either specify the full path, or use the java_home tool:
% /usr/libexec/java_home -v 1.8.0_73 --exec javac -version

Solaris and Linux

  1. To find out if the path is properly set:
    In a terminal windows, enter:
    % java -version
    This will print the version of the java tool, if it can find it. If the version is old or you get the error java: Command not found, then the path is not properly set.
  2. Determine which java executable is the first one found in your PATH
    In a terminal window, enter:
    % which java
Set the PATH permanently

To set the path permanently, set the path in your startup file.
Note: Instructions for two most popular Shells on Linux and Solaris are listed. If you are using other shells, see the Path Setting Tutorial.
Bash Shell
Edit the startup file (~/.bashrc)
  1. Modify PATH variable
    PATH=/usr/local/jdk1.8.0/bin:$PATH
    export PATH
  2. Save and close the file
  3. Load the startup file
    % . /.profile
  4. Verify that the path is set by repeating the java command
    % java -version
C Shell (csh)
Edit the startup file (~/.cshrc)

  1. Set Path
    set path=(/usr/local/jdk1.8.0/bin $path)
  2. Save and close the file
  3. Load the startup file
    % source ~/.cshrc
  4. Verify that the path is set by repeating the java command
    % java -version

Monday, April 17, 2017

How to run a task in java periodically ?



How to schedule a task in java ?

Few java applications are required to update something after a period of time - and that too automatically or without manual intervention.

To do so, in Java, we can perform below steps to complete this task,


------------------------------ScheduleTask.java---------------------------



public class ScheduledTask extends TimerTask {
public void run() {

System.out.println(" scheduler enabled on " + new Date().getTime());

//you can perform any operation required as per your need here

}
}



--------------------RunScheduledTask.java------------------------------

public class RunScheduledTask{

    public static void main(String args[]){

                Timer time = new Timer(); // Instantiate Timer Object
ScheduleTask st = new ScheduleTask();
time.schedule(st, 0, 86400000);// scheduled for one day

    }
}



Fixing yum command on linux

You may find yourself having to fix more packages. So you can just remove everything you had installed via  pip and reinstall everythin...