Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Monday 30 November 2015

Install and Run Tomcat windows

I am explaining every step to run tomcat in window and how to setup your projects and running Servlets.

1. Install JDK before installing tomcat.

  a) I installed JDK1.6.0 onC:\Java\jdk1.6.0

NOTE: Do not installed JDK under C:\Program Files. I just faced problem after setting my
environment variable on Window Xp.

2. Download the latest version of tomcat.
tomcat.apache.org , i downloaded Apache Tomcat 7.0.65.I rename downloaded folder to "apache-tomcat" and placed it at E:\apache-tomcat.Go to "Start" --> "My Computer" --> Right click--> "Property"--> Click "Advance Tab" --> "Environment Variables" --> Opens a window where you have to create new Environment Variables As Written Below
/* Under User Variable click New */
Variable Name CATALINA_HOME
Variable Value E:\apache-tomcat , Press ok
Variable Name JAVA_HOME
Variable Value C:\Java\jdk1.6.0, Press ok
Variable Name JAVA_HOME
Variable Value C:\Java\jdk1.6.0, Press ok
Variable Name PATH
Variable Value C:\Java\jdk1.6.0\bin, Press ok
// Under System Variable click New
Variable Name CALSSPATH
Variable Value C:\Java\jdk1.6.0\bin;E:\apache-tomcat\lib\servlet-api.jar, Press ok
3. Now We have to edit configuration files E:\apache-tomcat\conf folder
Open file context.xml find line/xml tag <Context>
and replace by <Context reloadable="true">
<servlet>...</servlet> inside this tag find
<param-value>false</param-value> 
and replace with <param-value>true</param-value>
Open file tomcat-users.xml and placed below code inside<tomcat-users>...</tomcat-users>
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="boy108zon" password="boy108zon" roles="manager-gui,admin-gui"/>
4.Restart your computer. After above steps configuration. Lets create a new project.

1. I created a folder called store in E:\apache-tomcat\webapps\
2. Create Structure under
store(Project Folder) ---> WEB-INF(DIR) --> classes(DIR) , web.xml (FILE)
classes(DIR)-->HelloWorld.java (File)
3. Placed below xml code in web.xml created as above
  <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
   <web-app>
    <servlet>
     <servlet-name>HelloWorld</servlet-name>
     <servlet-class>HelloWorld</servlet-class>
    </servlet>
    <servlet-mapping>
     <servlet-name>HelloWorld</servlet-name>
     <url-pattern>/</url-pattern>
    </servlet-mapping>
  </web-app>
4. Open http://localhost:8080/ You can see Tomcat Statup Page , you can click on Mange App it will ask you to enter username and password , As you putted OR placed in tomcat-users.xml.
 
Here you can see list of Application running or deploy. if you further check our created application also visible to this list , you can Start , Stop , Reload , Undeploy your application here. Click on start so that our created application can be start.
 
5. That's all , Now open http://localhost:8080/store/ and you will see your HelloWorld Running.

Monday 11 May 2015

Minify your javascript files offline with uglifyjs

You can compress or minify your Javascript / jQuery code by visiting to resources which is available but if you want to use it on your localhost so you can use it and run like below on windows.
1. Installed Node.js
2. Set envirnment variable
NODE_PATH
C:\Program Files\nodejs\UglifyJS\bin\uglify;C:\Program Files\nodejs\node.exe;
3. Download uglify master from gits and put in folder
C:\Program Files\nodejs\uglifyjs
4. run command
Run npm -g install uglify-js
final if you want to minify js
5. Run uglifyjs -o app.min.js app.js
Note: app.min.js is your name and app.js is your source js which you want to compress OR minify.