Java for Desktop & Internet Applications Assignment Writing Help

Java for Desktop and Internet Applications

This document covers up the advantages and disadvantages of using java for various applications. This document includes a discussion of the principles, characteristics and features of programming in Java, a description of program threads and how these can be implemented in Java, a description of the Java inter-faces to MySQL and description of how the data may be retrieved from the database and displayed in a standard Web Browser, a description of how Java may be used to implement desktop applications, a description of Java applets and their applications, a critical evaluation of the environmental flexibility of programming in Java.

 Programming in java

Java was first released to the public as the version 1.02. It comprised of 250 classes then. The use of applets  was very difficult at that time. Then version 1.1 was released that contained 500 classes. It was much friendlier and became popular soon. Then java 2 was released that was much powerful that any of its earlier version. It comprised of 2300 classes and appeared in three flavors, micro edition (J2ME), enterprise edition (J2EE) and Standard Edition (J2SE). The latest version of java is java 5 that includes java 1.5 and above. It comprised of 3500 classes at its release but the number is growing by the day. As more and more plug ins are being developed in java. It gave a new dimension to GUI programming with its easy syntax and easy to understand design. ( You can java and pyhthon my assignment help from our Australia experts)

  • Principles: – java is based on the Object Oriented Programming Structure (OOPS) principle. This principle says that “everything in this world is an object, and each object could be defined by some class”. Java uses this principle in its each and every program and hence there can’t be a java program without a class. A class in a definition of anything that could be seen in real world. An object is an instance of a class. Java takes advantage of following principles that make it suitable for being used as a language for real world:-

o   Inheritance: – java implements the concepts of inheritance to replicate the hierarchal structure of the real world.

o   Abstraction: – java implements the concepts of abstraction to show only the useful information to the user and hiding the background information.

o    Encapsulation:- Java packs methods into classes and classes into packages, that must be imported to access the underlying resource.

  • Characteristics features of java:- java has following features that makes it better than other languages:-

o   Portability:- java can be executed over a very small device to a very large device, the only requirement is the device must have JVM.

o   Platform Independent:- java can be installed and used over almost all platforms whether it be windows, Linux , Mac OS or it could be a smaller mobile phone OS. As far as machines are concerned, java could be installed over a small mobile to huge servers.

o   Robust: – Java has the strong memory allocation and automatic garbage collection mechanism. It provides the powerful exception handling and type checking mechanism as compare to other programming languages.

o   Distributed: – The widely used protocols like HTTP and FTP are developed in java. Internet programmers can call functions on these protocols and can get access the files from any remote machine on the internet rather than writing codes on their local system.

o   Dynamic: – While executing the java program the user can get the required files dynamically from a local drive or from a computer thousands of miles away from the user just by connecting with the Internet.

o   Secure: – Java does not use memory pointers explicitly. All the programs in java are run under an area known as the sand box.

 

Java Threads

Threading is a facility to allow multiple activities to coexist within a single process. Most modern operating systems support threads, and the concept of threads has been around in various forms for many years. Java is the first mainstream programming language to explicitly include threading within the language itself, rather than treating threading as a facility of the underlying operating system. Every Java program has at least one thread — the main thread. When a Java program starts, the JVM creates the main thread and calls the program’s main () method within that thread. The JVM also creates other threads such as threads associated with garbage collection, object finalization, and other JVM housekeeping tasks. Other facilities create threads too, such as the AWT (Abstract Windowing Toolkit) or Swing UI toolkits, servlet containers, application servers, and RMI (Remote Method Invocation). Threads are sometimes referred to as lightweight processes. Like processes, threads are independent, concurrent paths of execution through a program, and each thread has its own stack, its own program counter, and its own local variables. However, threads within a process are less insulated from each other than separate processes are. They share memory, file handles, and other per-process state. A process can support multiple threads, which appear to execute simultaneously and asynchronously to each other. Multiple threads within a process share the same memory address space, which means they have access to the same variables and objects, and they allocate objects from the same heap. Although threads are somewhat dependant on each other, they can be used to generate highly effective applications.

Some common advantages of threads are:-

  • Create a faster and more responsive user Interface:- since a separate thread could be created for taking the inputs from user and giving output, the user interface is faster as the processing and calculations are done in a separate thread.
  • Take advantage of multiprocessor systems:- separate threads could execute on separate processors that allows the easier utilization of multiprocessors as it involves less transfer of data among processors, since threads are independent.
  • Simplify modeling: – with multiple threads of execution, those tasks that are to executed concurrently can be easily modeled and designed.
  • Perform asynchronous or background processing: – with the facility of multiple threads, several processes could be run in background.

 

 

Implementing java threads: –

Java threads could be implemented via two methods:-

  1. a)Extend the thread class.
  2. b)Implement the Runnable interface.

In the first method we create a class that extends the Thread class. Since it is extending thread class it automatically has a start() method. We then instantiate the defined class and call the start() method to execute the thread.

In the second method, while defining the class that implement runnable, we need to instantiate Thread class, i.e. create an object of thread class in it. Then there is a run () method that allows the thread to execute.

 

Java connectivity with MySQL

 As per MySQL assignment help experts,A java program connects to a database using JAVA DATABASE CONNECTIVITY or JDBC. This is a technology that is widely used for this purpose. JDBC is consists of four Components: The JDBC API, JDBC Driver Manager, The JDBC Test Suite and JDBC-ODBC Bridge. 

 JDBC URL’s

URL stands for “Uniform Resource Locator”. URLs are used to identify a resource using a unique name. Same goes for database URLs in JDBC. JDBC requires that all database connection strings should be represented by URLs. The URLs used in JDBC have following structure:

               jdbc:subprotocol:subname

In HTTP a URL  begins with the protocol name i.e. http:, similarly in JDBC driver URLs, the URL  begins with protocol name i.e. jdbc:. Next subprotocol represents the database you want to connect to e.g. mysql, oracle, odbc etc. While subname provides additional information on how and where to connect.

JDBC Driver

Only URL will not provide access to the database. Java also requires a JDBC driver reference to connect to MYSQL. The name of the Driver is a requirement and is not optional. We  can tell JVM about what driver/s to use by using one of the following methods:

  • To load the the driver/s at JVM startup, specify the driver/s in jdbc.drivers system property like this:

java -Djdbc.drivers=com.mysql.jdbc.Driver YourJavaProgram

  • To explicitly load the driver, use Class.forName() method in your code like this:

Class.forName(“com.mysql.jdbc.Driver”).newInstance();

 

To create a connection to a database, you will have to use java.sql.DriverManager‘s getConnection() method. This method takes as an argument the database URL (that we discussed earlier) you want to connect to. It then internally finds the appropriate driver which has been loaded in the JVM and then delegates the work of creating the connection to that driver.

Java applets

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled browser to view a page that contains an applet, the applet’s code is transferred to your system and executed by the browser’s Java Virtual Machine (JVM). It is delivered to the users in form of bytecode. Java applets are executed in a sandbox by most web browsers, preventing them from accessing local data like clipboard or file system. The code of the applet is downloaded from a web server and the browser either embeds the applet into a web page or opens a new window showing the applet’s user interface.

 There are two steps involved in creating an applet program:-

  1. a)Define an applet class:- A Java applet extends the class java.applet.Applet, or in the case of a Swing applet, javax.swing.JApplet. The class must override methods from the applet class to set up a user interface inside itself (Applet is a descendant of Panel which is a descendant of Container. As applet inherits from container, it has largely the same user interface possibilities as an ordinary Java application, including regions with user specific visualization.
  2. b)Embed in a webpage:- a java applet is embedded inside a webpage by the use of the  This tag declares the source of the applet and that applet’s byte code is supplied with the webpage.

References:-

  1. Scheildt, herbert (2004), complete java reference manual, tata macgraw hills.
  2. http://www.java.sun.com the online java manual.
  3. Eckel, Bruce (2002) , thinking in java, Prentice hall.

Submit Your Assignment for Free Quote

Our Professional Australia based experts will evaluate your assignment or Case Study Assignment Help within 15 to 60 minutes, and we will provide you our guaranteed best price.