Its so frustrating when windows automatically download the windows update files without noticing us. Most of the time we are using a limited wifi network or sharing mobile data to our laptop. But windows 10 has no direct way of turning off automatic updates.
But with a little bit of work we can do it.
First go to Run and type gpedit.msc . This will open Local group policy editor of windows.
Navigate to Computer Configuration then Administrative Templates and go to Windows Components and from there locate Windows Update folder. Inside Windows Update there is a separate setting called Configure Automatic Updates. Right click on it and go to settings. From there choose disabled and apply.
Doing the above method will not disable windows updating feature, Whenever we need we can manually check for updates and install them without losing our limited internet bandwidth.
Saturday, March 25, 2017
Thursday, March 16, 2017
Java Chat Application, Class Chat Client Creation
Creating a chat application using java, creating class Chat Client
Class ChatClient
This class implements the chat client, as described. This involves setting up a basic user interface, handling user interaction, and receiving messages from the server.
import java.net.*; import java.io.*; import java.awt.*; public class ChatClient extends Frame implements Runnable { // public ChatClient (String title, InputStream i, OutputStream o) ... // public void run () ... // public boolean handleEvent (Event e) ... // public static void main (String args[]) throws IOException ... }
The
ChatClient
class extends Frame
; this is typical for a graphical application. We implement the Runnable
interface so that we can start a Thread
that receives messages from the server. The constructor performs the basic setup of the GUI, the run()
method receives messages from the server, the handleEvent()
method handles user interaction, and the main()
method performs the initial network connection.protected DataInputStream i; protected DataOutputStream o; protected TextArea output; protected TextField input; protected Thread listener; public ChatClient (String title, InputStream i, OutputStream o) { super (title); this.i = new DataInputStream (new BufferedInputStream (i)); this.o = new DataOutputStream (new BufferedOutputStream (o)); setLayout (new BorderLayout ()); add ("Center", output = new TextArea ()); output.setEditable (false); add ("South", input = new TextField ()); pack (); show (); input.requestFocus (); listener = new Thread (this); listener.start (); }
The constructor takes three parameters: a title for the window, an input stream, and an output stream. The
ChatClient
communicates over the specified streams; we create buffered data streams i and o to provide efficient higher-level communication facilities over these streams. We then set up our simple user interface, consisting of theTextArea
output and the TextField
input. We layout and show the window, and start a Thread
listener that accepts messages from the server.public void run () { try { while (true) { String line = i.readUTF (); output.appendText (line + "\n"); } } catch (IOException ex) { ex.printStackTrace (); } finally { listener = null; input.hide (); validate (); try { o.close (); } catch (IOException ex) { ex.printStackTrace (); } } }
When the listener thread enters the run method, we sit in an infinite loop reading
String
s from the input stream. When a String
arrives, we append it to the output region and repeat the loop. An IOException
could occur if the connection to the server has been lost. In that event, we print out the exception and perform cleanup. Note that this will be signalled by an EOFException
from thereadUTF()
method.
To clean up, we first assign our listener reference to this
Thread
to null
; this indicates to the rest of the code that the thread has terminated. We then hide the input field and call validate()
so that the interface is laid out again, and close the OutputStream
o to ensure that the connection is closed.
Note that we perform all of the cleanup in a
finally
clause, so this will occur whether an IOException
occurs here or the thread is forcibly stopped. We don't close the window immediately; the assumption is that the user may want to read the session even after the connection has been lost.public boolean handleEvent (Event e) { if ((e.target == input) && (e.id == Event.ACTION_EVENT)) { try { o.writeUTF ((String) e.arg); o.flush (); } catch (IOException ex) { ex.printStackTrace(); listener.stop (); } input.setText (""); return true; } else if ((e.target == this) && (e.id == Event.WINDOW_DESTROY)) { if (listener != null) listener.stop (); hide (); return true; } return super.handleEvent (e); }
In the
handleEvent()
method, we need to check for two significant UI events:
The first is an action event in the
TextField
, which means that the user has hit the Return key. When we catch this event, we write the message to the output stream, then call flush()
to ensure that it is sent immediately. The output stream is a DataOutputStream
, so we can use writeUTF()
to send a String
. If an IOException
occurs the connection must have failed, so we stop the listener thread; this will automatically perform all necessary cleanup.
The second event is the user attempting to close the window. It is up to the programmer to take care of this task; we stop the listener thread and hide the
Frame
.public static void main (String args[]) throws IOException { if (args.length != 2) throw new RuntimeException ("Syntax: ChatClient <host> <port>"); Socket s = new Socket (args[0], Integer.parseInt (args[1])); new ChatClient ("Chat " + args[0] + ":" + args[1], s.getInputStream (), s.getOutputStream ()); }
The
main()
method starts the client; we ensure that the correct number of arguments have been supplied, we open aSocket
to the specified host and port, and we create a ChatClient
connected to the socket's streams. Creating the socket may throw an exception that will exit this method and be displayed.Friday, March 10, 2017
What is Spring Framework?
The Spring Framework is an application frameworkand inversion of control container for the Java platform. The framework's core features can be used by any Java application, but there are extensions for building web applications on top of the Java EE platform.
https://www.youtube.com/watch?v=-weKK-oNuhA
https://www.youtube.com/watch?v=-weKK-oNuhA
Saturday, March 4, 2017
Technology today is so evolving. The purpose of keyboard keys fulfilled by bananas.
https://youtu.be/3LmaCkczLcU
https://youtu.be/3LmaCkczLcU
Tuesday, February 28, 2017
Maven 3
Introduction:
Maven 3 is complete rewrite of maven internal architecture and is almost backward compatible. Maven 3 repository format is same as that of Maven 2, unlike the switch from Maven 1 to Maven 2. Reporting is not part of core Maven and is now part of maven site plugin.
Reasons to migrate to Maven3:
Speed:
Maven documentation says that it could be anywhere from 50% - 400% faster, but it depends on the project though. In one of our simple projects, I could see 25% improvement for both clean install and clean site (no downloading of dependencies involved).
Parallel Builds:
One of the other advantage of Maven3 is parallel builds. Most of us have dual or quad cores these days and so it would be good to take advantage of them. Below are some examples:
Maven Shell:
Maven Shell (mvnsh) seemed to be very promising. The idea is to load JVM, maven and plugins and keep it in memory, thus avoiding start up cost every time maven command is run. But, when I tried it, I kept getting out of memory error (even after increasing my MAVEN_OPTS). At least, this was the cause when I tried it few months back. It could be fixed by now.
Polyglot Maven:
Polyglot maven allows to write POM in other JVM languages - Groovy, Scala, Clojure etc., It is useful for those who don't like the verbose XML POM's. Polyglot maven needs to be downloaded separately though. It comes with translator to convert your current XML POM's. Below are some examples:
Issues:
Maven 3 is complete rewrite of maven internal architecture and is almost backward compatible. Maven 3 repository format is same as that of Maven 2, unlike the switch from Maven 1 to Maven 2. Reporting is not part of core Maven and is now part of maven site plugin.
Reasons to migrate to Maven3:
- Latest and Greatest!
- New development only in Maven 3 - 6 week release cycle
- Maven 2 - Release cycle is unpredictable
- Backward compatible (almost)
- Faster
- Parallel Builds
- Eclipse/OSGi friendly
- Tycho - Helps building Eclipse/OSGi bundles with Maven
- Strict Validation of POM
- Improved error reporting - Link to maven page with description, cause and possible fix.
- Improved Logging
Speed:
Maven documentation says that it could be anywhere from 50% - 400% faster, but it depends on the project though. In one of our simple projects, I could see 25% improvement for both clean install and clean site (no downloading of dependencies involved).
Parallel Builds:
One of the other advantage of Maven3 is parallel builds. Most of us have dual or quad cores these days and so it would be good to take advantage of them. Below are some examples:
- mvn -T 2 clean install (Build project with 2 threads)
- mvn -T 2C clean install (Build project with 2 threads per core)
Maven Shell:
Maven Shell (mvnsh) seemed to be very promising. The idea is to load JVM, maven and plugins and keep it in memory, thus avoiding start up cost every time maven command is run. But, when I tried it, I kept getting out of memory error (even after increasing my MAVEN_OPTS). At least, this was the cause when I tried it few months back. It could be fixed by now.
Polyglot Maven:
Polyglot maven allows to write POM in other JVM languages - Groovy, Scala, Clojure etc., It is useful for those who don't like the verbose XML POM's. Polyglot maven needs to be downloaded separately though. It comes with translator to convert your current XML POM's. Below are some examples:
- translate pom.xml pom.scala
- translate pom.xml pom.groovy
Issues:
- profiles.xml is no longer supported. It is advised to move that to inside settings.xml.
- Reporting now goes under reportPlugins in maven-site plugin configuration.
- mvn dependency:tree may not be correct, since this still uses legacy dependency resolution code.
- Because of stricter POM validation, you will see more errors. These have to be fixed before proceeding further.
Saturday, February 11, 2017
How car brakes work and tips to prevent brake Squeaking
Understanding how something work is useful for us all.
Machines have an incredible way of functioning. So simple yet so complex if not understood the basic theory of how it works.
Following video shows how car brakes work and how to fix squaking.
https://www.youtube.com/watch?v=ZvtjnxpFRbU
Machines have an incredible way of functioning. So simple yet so complex if not understood the basic theory of how it works.
Following video shows how car brakes work and how to fix squaking.
https://www.youtube.com/watch?v=ZvtjnxpFRbU
Monday, February 6, 2017
Tips for a better ITP project
Our project : Ewis Management System
Brief Introductin :
The main purpose of our project was to manage the students attendance, marks, details to be stored in a digital database so that they can be easily accessed and accurately.
Our Contribution as a group was to develop this whole unit as a webbased application and host it so it can be accessed from anywhere.
My part of the project was to handle the administration of the web application. To create, edit, delete entries and to handle the login and registration for new users.
Subscribe to:
Posts (Atom)
Implemting Google Drive File Uploader using OAuth
Implementing Google Drive Text File Uploader using OAuth 2.0 Creating Project and Registering your API with Google In this part we wil...
-
Architecture Models are scope objects in Angular. In traditional MVC, the model encapsulates information to be displayed by a View. Scopi...
-
Cross-Site Request Forgery Protection Cross-site request forgery, also known as one-click attack or session riding and abbreviated as...
-
Implementing Google Drive Text File Uploader using OAuth 2.0 Creating Project and Registering your API with Google In this part we wil...