Sample multithreading program using Callable Interface

Sample multithreading program using Callable Interface

Step 1: Create “MainThread.java” and paste the below code, package runnableandcallable; import java.util.ArrayList; import java.util.Collection; import java.util.List; import runnableandcallable.CallingThread; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class MainThread{ private static ExecutorService service = Executors.newFixedThreadPool(10); //connection pool @SuppressWarnings("unchecked") public static void main(String[] args) throws InterruptedException { List<CallingThread> threads = new ArrayList<CallingThread>(); //ArrayList to store the threads with CallingThread Type CallingThread ct = null; for(int i=1;i<=5;i++){ // 5 threads are created ct = new CallingThread(i); //calling CallingThread constructor of the CallingThread class….

Read More Read More

655 total views, no views today

Auto Refresh in All Browsers

Auto Refresh in All Browsers

If you use, <% response.addHeader(“Refresh”,”4;account.jsp”); %> in jsp page, the page will be redirected to account.jsp from the current page after 4 seconds. Note: The above operation would happen in all browsers except internet explorer and eclipse internal browser. To Perform Auto Refresh in all browsers: <%String autoRefresh=”accounts.jsp” %> <meta http-equiv=”refresh” content=”5;URL=<%=(autoRefresh)%>” /> Now After 5 seconds page will be refreshed and redirected to accounts.jsp in all browsers including internet explorer and eclipse internal browser. Note: Use http-equiv=”refresh” rather than…

Read More Read More

509 total views, 2 views today

Passing Console output from java to jsp

Passing Console output from java to jsp

Step 1: Create Hello.java and paste the below code,   package com.agn; public class Hello { /** * @param args */ public String returning(){ String go = "hello Naveen"; return go; } public static void main(String[] args) { Hello h = new Hello(); System.out.println(h.returning()); } }   Step 2: Create fethingfromjava.jsp and paste the below code,   <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title>…

Read More Read More

2,871 total views, no views today

Converting Numbers to Words in Java

Converting Numbers to Words in Java

Step 1: Download the program and save it as Naveen.java package pack; import java.util.ArrayList; import java.util.List; public class Naveen { public static void main(String[] args) { String[] zerotonineteen={" zero"," one"," two"," three"," four"," five", " six"," seven"," eight"," nine"," ten"," eleven", " twelve", " thirteen", " fourteen", " fifteen", " sixteen", " seventeen", " eighteen", " nineteen"}; String[] tens ={"",""," twenty"," thirty"," forty"," fifty"," sixty"," seventy"," eighty"," ninety"}; String[] remainings = {" hundred", " thousand", " million", " billion", "…

Read More Read More

512 total views, no views today

Perl System values to variables

Perl System values to variables

In perl you can easily assign the system (“some commands”) values to variables using the  Capture::Tiny Module. Step 1: Download the Capture::Tiny Module from cpan. http://search.cpan.org/~dagolden/Capture-Tiny-0.20/lib/Capture/Tiny.pm Step 2: Extract the downloaded file and go into that and run perl Makefile.PL make  make run make install  commands to install. Step 3:  Example program. use strict; use warnings; BEGIN {required Capture::Tiny; } my $out = Capture::Tiny::Capture {system (“commands”);}; print “$out”;     Thanks for reading this post…!! please leave a command to…

Read More Read More

479 total views, 1 views today

[Solved]sudo:must be setuid root

[Solved]sudo:must be setuid root

Solution: Just run these commands in the terminal, chmod 4111 /usr/bin/sudo chmod 0440 /etc/sudoers If its not working fine, then simply restart and come back again by “recovery mode” and choose root and try the above commands again. after the above commands run sudo reboot Then go with normal mode, now you wont get the error.   Thanks for reading this post………..!!! Please leave a command to improve this site…………….!!!   591 total views, no views today

591 total views, no views today

Passing Checkbox values from one jsp to another

Passing Checkbox values from one jsp to another

1.jsp:   <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <form method="post" action="2.jsp"> My Favourite Colors are <input type="checkbox" name="cb1" value="blue">Blue <input type="checkbox" name="cb1" value="green">Green <input type="checkbox" name="cb1" value="Yellow">Yellow <input type="checkbox" name="cb1" value="Red">Red <input type="checkbox" name="cb1" value="white">White <input type="submit"> </form> </body> </html>   2.jsp:   <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type"…

Read More Read More

686 total views, 1 views today

‘ant’ is not recognized as an internal or external command, operable program or batch file.

‘ant’ is not recognized as an internal or external command, operable program or batch file.

Root cause: Ant path has not been set. So windows could not recognize ant command. Solution: Set the ant path in cmd like this, Note: Jdk must be installed. Thanks for reading this post………..!!! 3,206 total views, 3 views today

3,206 total views, 3 views today

[Solved] ‘mvn’ is not recognized as an internal or external command, operable program or batch file.

[Solved] ‘mvn’ is not recognized as an internal or external command, operable program or batch file.

Root cause: Maven path has not been set. So windows can not recognize mvn command. Solution: [sociallocker] Set the maven path in cmd like this,   [/sociallocker] Recommended Maven Books: 4,054 total views, 2 views today

4,054 total views, 2 views today