How do I update node and npm on windows? Install or upgrade Node.js on Windows

Run PowerShell as Administrator

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade

Install Node.js

  1. Open http://nodejs.org in a browser and click Install. Download the .msi package.
  2. After the download has completed, double-click the .msi package. As of this writing, the MSI is node-v0.10.25-x64.msi.
  3. Click Run.
  4. Click Next.
  5. Check I accept the terms in the License Agreement. Click Next.
  6. Click Next.
  7. Click Next.
  8. Click Install.
  9. Enter your Administrator password, if prompted.
  10. Click Finish.

Verify the node installation

Open PowerShell, then run the following commands:

node --version

# Expected output: v0.10.25

npm --version

# Expected output: 1.3.24

Upgrade packages (upgrade only)

If you are upgrading from a previous version of node, then you will want to update all existing global packages.

npm cache clean

npm update -g

What is the default username and password in Tomcat?

In Tomcat 7 you have to add this to tomcat-users.xml (On windows 7 it is located by default installation here: c:\Program Files\Apache Software Foundation\Tomcat 7.0\conf\ )

<<location of Tomcat server>>\Tomcat <<version_no>>\conf\tomcat-users.xml

<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <role rolename="manager-status"/>
  <role rolename="admin-gui"/>
  <role rolename="admin-script"/>
  <user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>
</tomcat-users>

NOTE that there shouldn’t be ANY spaces between roles for admin, as this list should be comma separated.

So, instead of this (as suggested in some answers below) – but it is WRONG:

<user username="admin" password="admin" roles="manager-gui, manager-script, manager-jmx, manager-status, admin-gui, admin-script"/>

It MUST be like this:

  <user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>

 

How to set CATALINA_HOME variable

My Computer –> Advanced System Settings –> Advanced Tab –> Environment Variables

Setting the JAVA_HOME, CATALINA_HOME Environment Variable on Windows

One can do using command prompt:

  1. set JAVA_HOME=C:\ "top level directory of your java install"
  2. set CATALINA_HOME=C:\ "top level directory of your Tomcat install"
  3. set PATH=%PATH%;%JAVA_HOME%\bin;%CATALINA_HOME%\bin

 

C:>echo %path%

C:\Program Files (x86)\Java\jdk1.6.0_27\bin;%CATALINA_HOME%\bin;

C:>echo %classpath%

C:\Program Files (x86)\Java\jdk1.6.0_27\lib\tools.jar;
C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\lib\servlet-api.jar;

C:>echo %CATALINA_HOME%

C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0;

C:>echo %JAVA_HOME%

C:\Program Files (x86)\Java\jdk1.6.0_27;

Add/Delete Certificates in keystore through keytool (Java keystore) Windows/Linux

Adding Certificates in keystore through keytool

keytool -import -file smartcommunitylab.it.smartcommunitylab.it.cer -alias smart -keystore -import

Delete certificate

keytool -delete -keystore stage.jks
Enter alias name: my key — enter your alias name of certificate which you have added
Enter keystore password: — keystore password

listing Certificates
keytool -list -keystore cacerts.jks

————————————————————————–
To add a certificate to the cacerts store

At a command prompt that is set to your JDK’s jdk\jre\lib\security folder, run the following to see what certificates are installed:

keytool -list -keystore cacerts

You’ll be prompted for the store password. The default password is changeit. (If you want to change the password, see the keytool documentation at http://docs.oracle.com/javase/7/docs/technotes/tools/windows/keytool.html.) This example assumes that the certificate with MD5 fingerprint 67:CB:9D:C0:13:24:8A:82:9B:B2:17:1E:D1:1B:EC:D4 is not listed, and that you want to import it (this particular certificate is needed by the Twilio API service).

Obtain the certificate from the list of certificates listed at GeoTrust Root Certificates. Right-click the link for the certificate with serial number 35:DE:F4:CF and save it to the jdk\jre\lib\security folder. For purposes of this example, it was saved to a file named Equifax_Secure_Certificate_Authority.cer.

Import the certificate via the following command:

keytool -keystore cacerts -importcert -alias equifaxsecureca -file Equifax_Secure_Certificate_Authority.cer

When prompted to trust this certificate, if the certificate has MD5 fingerprint 67:CB:9D:C0:13:24:8A:82:9B:B2:17:1E:D1:1B:EC:D4, respond by typing y.

Run the following command to ensure the CA certificate has been successfully imported:

keytool -list -keystore cacerts

Convert java.util.date default format to Timestamp in Java

Example - 1

 java.util.Date date= new java.util.Date();
 Timestamp ts_now = new Timestamp(date.getTime());
Example - 2
 SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd kk:mm:ss z yyyy");
 Date d = sdf.parse("Mon May 27 11:46:15 IST 2013");
 Calendar c = Calendar.getInstance();
 c.setTime(d);
 long time = c.getTimeInMillis();
 long curr = System.currentTimeMillis();
 long diff = curr - time; //Time difference in milliseconds
Example - 3
 String str_date=month+"-"+day+"-"+yr;
 DateFormat formatter = new SimpleDateFormat("MM-dd-yyyy");
 Date date = (Date)formatter.parse(str_date);
 long output=date.getTime()/1000L;
 String str=Long.toString(output);
 long timestamp = Long.parseLong(str) * 1000;
Example - 4
 long startTime = date.getTime() * 1000000;;
 long estimatedTime = System.nanoTime() - startTime;
Example - 5
 You can use DateFormat(java.text.*) to parse the date:
 DateFormat df = new SimpleDateFormat("EEE MMM dd kk:mm:ss z yyyy", Locale.ENGLISH);
 Date d = df.parse("Mon May 27 11:46:15 IST 2013")