Screen Recording with recordMyDesktop in Ubuntu

One of these days you might need to record your desktop in Ubuntu. Today we are going to record the screen in Ubuntu.

We are going to use recordMyDesktop application. First of all install it using below link.

https://apps.ubuntu.com/cat/applications/gtk-recordmydesktop/

Click Available of Software Center to install it. You will get below dialog box

exter

Click Launch Application. Then press Install. After finishing install you can run application either using terminal command

gtk-recordmydesktop

or clicking below icon of side pane of Ubuntu

icon

Now we will get the below window window

dilap

Before we start Screen recording we need few basic configurations to set. First one is to set where to set the saved screen recorded video. To do that press Save As in the window and browse where you need to save the videos.This is the window you get when you click on save as button on recordmydesktop application

Give appropriate name for your video. This name will use to Recorded videos which comes after unless you change it( name 1, name 2, name 3 …)

Basically Now we are good to go. But before that let me explain about the Select Window button. This is Useful when you want to record part of window, like a dialog box. Generally recordMyDesktop will record the full screen. If you want part of window select Select Window button and select the dialog box you want to record.

Now you are good to go. Just click the Record button. Then do the what you want to record. Now lets check how to generate the recorded video.

If you look top task ban of Ubuntu, you can see there is a Red Square button on left of it.

reording

When you want to stop the recording and get the video press that red square button (Stop Button). Then you will get below window.

ebn

Wait till window automatically get close. Then check the place you set to save the video. There you can see your video.

Advertisements

Spring 4 MVC configuring view with controller with java configurations

If you are new to Spring MVC, configuring views with controllers is the first step you have to take into Spring world. There are few ways to configure views, such as xml based, spring boot etc. But today we are going to discuss using java configurations.

As usually we use maven web arch type as our template. ( if you don’t know about maven web arch type template, don’t worry it’s template structure nothing serious.). So if you have installed maven (apt-cache search maven

sudo apt-get install maven)

Then run below command to generate template (FirstDay)

mvn archetype:generate -DgroupId=menuka.hsenid -DartifactId=FirstDay -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

Now open project on Intellij ( or your IDE).

Now we have to add dependencies to the project. Since this is just to we just add spring-webmvc to enable Spring MVC (when you add Spring MVC dependency you don’t need to add basic spring dependency like spring-core, spring-context etc. They automatically added to the project ) and javax.servlet-api to handle servlets.

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>

(I hope you know where to put dependencies, if not, in pom.xml file, within < dependencies> tags)

Just one more step before starting development. We have to declare where our source code reside. Create a folder name java inside main folder. Then File -> Project Structure -> Modules  then select the java folder under Sources tab. Now click Sources button under the Sources tab. Then Apply and Ok. 

Now we need to create to packages one for configuration, other one for Controllers.

I use below two packages hsenid.config and hsenid.web

In config package I use Below three classes

WebConfig


package hsenid.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

@Configuration
@EnableWebMvc
@ComponentScan("hsenid.web")
public class WebConfig extends WebMvcConfigurerAdapter {
@Bean
public ViewResolver viewResolver(){
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/pages/");
resolver.setSuffix(".jsp");
resolver.setExposeContextBeansAsAttributes(true);
return resolver;
}

@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer){
configurer.enable();
}

@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
}

There are several things this class do.

One is addResourceHandlers  method set resource path. Because you can’t use paths like you use them in html. Here we use resources folder (which is under webapp folder ) so you can add your images, js, css etc, files under here. (one thin you must remember is when you referring some file in a jsp you must use webapp folder as root folder. )

Other one is resolving jsp page names using viewResolver. Here we declare if we use a url home it is really name is”/WEB-INF/pages/home.jsp”.  Lets create  other two classes

RootConfig


package hsenid.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

@Configuration
@ComponentScan(basePackages={"hsenid"},
excludeFilters={
@Filter(type= FilterType.ANNOTATION, value=EnableWebMvc.class)
})
public class RootConfig {
}

Here you must add you base package name for basePackages variable.

WebAppInitializer

package hsenid.config;

import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer{
 @Override
 protected String[] getServletMappings(){
 return new String[]{"/"};
 }

 @Override
 protected Class<?>[] getRootConfigClasses(){
 return new Class<?>[]{RootConfig.class};
 }

 @Override
 protected Class<?>[] getServletConfigClasses(){
 return new Class<?>[]{WebConfig.class};
 }

}

Now we are configurations are good to go.

Now we have to create view jsp for connect with controllers.

create below jsp pages in the pages folder in the WEB-INF folder (Because this is the path we set in the configurations).

home.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Home</title>
</head>
<body>
This is home
</body>
</html>

test.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
 <title>Test</title>
</head>
<body>
This is test
</body>
</html>

So lets create a controller in hsenid.web folder.

HomeController


package hsenid.web;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller

public class HomeController {

@RequestMapping("/")
public String home() {
return "home";
}

@RequestMapping("test")
public String test()
{
return "test";
}
}

Now run mvn clean install in terminal (in the location where the pom.xml is) to generate the war file and put the war File in the tomcat webapp folder.

As you can see in the controller, http://localhost:8080/FirstDay/ url is connected with home.jsp and http://localhost:8080/FirstDay/test url is connected with test.jsp.

Well this is simple tutorial to get start with MVC