Showing posts with label Java Development Company. Show all posts
Showing posts with label Java Development Company. Show all posts

Do Java Programmers Really Take HTML As A Programming Language?

Many java programmers use HTML as their primary development language, but can it be really used as a programming language? Let’s find out.

The survey conducted by experts this year shows that there are about 11% of developers thinks that HTML is their primary development language. Due to this, many other people have started asking themselves – “can HTML really be taken as a programming language, or a tool for JavaScript functions layout?”


Most programmers work in multiple languages, so we can consider that developers who use HTML may write code in JavaScript and prepare their layout in HTML. However, only 13% of those developers who said their primary programming language were HTML accepted that they also use JavaScript- getting confused about how they are developing applications?

Thousands of changes have been made in HTML language since it was first conceived, and today, it has capabilities that can easily let you consider it as a development language. Nowadays, you can find demo apps written in HTML.

You can take an example of Zero Lines JS, a graphical game that requires the player to navigate between approaching enemies with more speed to a piece of suitably-irritating music. It might not be the next Candy Crush Saga or even Watch Dogs, but it would be tough to deny the fact that these applications do exist.

Instances include a tabbed panel that brings content to the front based on selected tab and an image slideshow, all done completely using HTML. Professionals with long years of experience will moan as these instances don’t make HTML a real language and it is nothing more than markup.

Read Also: How To Implement And Use Simplest Storage Service- S3 In Java Web Development

However, we can see that java programmers use HTML5 to create applications and thus, we can tag it as a programming language. There is limited space for discussion, and arguments regarding the subject. Leading java development companies are running more surveys in which they are asking developers what language and tools they are currently using, including the ones who use HTML5 to program.

Why Java Programmers Jump to HTML 5?

There are many reasons why Java Programmers jump to HTML 5, but a few of them which are the main reasons are as under:

  1.  Improvement in Search Ranking
  2. Mobile and Web Apps development are easier
  3. Better Animation effects
  4. Image downloading is fast, specifically for mobile users

An Example of HTML 5 will be known as New Programming Language

  •          Apple does not support Flash in its mobile browser. For this reason, making HTML5 the only possible way to support flash. Nowadays, all new iPads platform depends on HTML5.
  •          Facebook chief technology officer Bret Taylor’s focus for 2011 is mobile and HTML5, or mobile on HTML5.
  •          Google directly supports HTML5 to develop Chrome. Google video service YouTube’s support for HTML5 video since early 2010.
  •          Microsoft specified before a few years that HTML5 is the preferred Web technology and it is just repositioned Silverlight. And now Windows 8 and later OS versions support HTML5 apps as first-class native apps.

So, these are the main causes of how HTML 5 plays a vital role in the big IT Giants products and service development. And that’s why Java Programmers think of HTML 5 as a new Programming Language.

JAVA APPLICATIONS LOG MESSAGE ANALYTICS USING SPLUNK

 

Technology: Splunk is the most used server for collecting data from different sources, indexing the collected data, analyzing the index data, preparing the reports based on indexed data. The source of data may be from any environment and the source may be structured format or unstructured format. Splunk provides some intelligent algorithms to understand the indexed data used in security, IoT machine logs, and application logs and provides the analytics of the data provided.

Splunk Data Sources: Splunk supplies a huge range of plugins to support different resources like for understanding windows event logs it supplies one plugin, for understanding Ubuntu machines logs it provides a various plugin. On the research of logs based Splunk will create the no of times the Operating system is loaded, the average CPU load in period, how many various users logged into the system, it will create the reports and it can also create a controlpanel for live data streaming.

Scalability: Splunk will not depend upon any outside services and it doesn`t necessity any database support, because Splunk internally uses a file system to store the indexed results. If the incoming data is increasing we can add another instance of the Splunk server to index and store the data. Splunk will internally communicate and it will distribute the incoming data and during the searching, it will collect the data from all Splunk servers and display it to the user. If we enable decrease then incoming data is distributed to more than one Splunk server.

Infinite control without losing granularity. Some monitoring products only permit you to keep so many months, weeks, or even days’ worth of data. Anothers decrease the granularity of older events, compressing various data points into one because of volume limits. The same is not true for Splunk. It can actually index hundreds of terabytes per day and hold practically limitless amounts of data.

Customize and extend Splunk with preferred technologies: Immediately change dashboards into HTML5 and create custom user experiences in HTML5 and JavaScript with the Splunk Web Framework. Use Python, Java, Ruby, C#, and PHP SDKs to combine Splunk capacity into developer workflows. Customize and extend Splunk with preferred technologies: Instantly convert dashboards into HTML5 and create custom user experiences in HTML5 and JavaScript with the Splunk Web Framework. Utilize Python, Java, JavaScript, Ruby, C#, and PHP SDKs to combine Splunk capacity into developer workflows.

Developer Tools: Splunk supplies plugins for Visual Studio for .NET-based applications, Eclipse and IntelliJ for Java-based applications, Splunk-logging plugin for Javascript, and it supplies plugin of Topmost of NodeJS, and also we can Splunk-Bunyan-logger plugin for javascript to gather HTTP Events.

The Splunk SDK for Java ships with built-in support for IntelliJ for simple combination. Spring Source organized the Spring Combination Extension for Splunk, making it simple for developers using the famous Java framework Spring to log directly to Splunk from their applications.

HTTP Event Collector (HEC): Splunk Event Collector is the fastest way to send data to Splunk Enterprises server and Splunk Cloud. HTTP Event Collector enables to send data over HTTP and HTTPS protocol directly to Splunk Enterprise and Splunk Cloud from application code. HEC provides the one rest endpoint to accept incoming data, in our application we can write to send data to the rest endpoint. HEC is authorized using tokens so that we don’t need to hard code the username and password details.

HTTP Event Gatherer supplies a new way for developers to send application logging and metrics directly to Splunk Enterprise and Splunk Cloud via HTTP in a highly important and secure manner.

 Enabling HTTP Event Collector:

1.     We can turn on HTTP Event Collector by enabling its endpoint, by default HEC is not enabled.

2.     Generate HEC Token.

3.     On the client end create POST request to include authentication header or key/value pair to include HEC token.

4.     POST data to HEC token receiver.


For Splunk Cloud instance it is not enabled, we can raise a request to Splunk cloud to enable HEC token.

Connecting to Splunk Server using Splunk SDK:

We can add the Splunk jar (http://download.splunk.com/misc/sdk/java/splunk-sdk-java-1.6.2.jar ) to project class path or we can download splunk-sdk from http://download.splunk.com/misc/sdk/java/splunk-sdk-java-1.6.2.zip and we can extract splunk jar from splunk-sdk-java/dist folder.

Below the sample java program to connect to Splunk server and printing the application on it.

importcom.splunk.*;

public class SplunkTest {

public static void main(String[] args) {

// Create a map of arguments and add login parameters

ServiceArgsloginArgs = new ServiceArgs();

loginArgs.setUsername(“admin”);

loginArgs.setPassword(“changeme”);

loginArgs.setHost(“localhost”);

loginArgs.setPort(8089);

// Create a Service instance and log in with the argument map

Service service = Service.connect(loginArgs);

// Print installed apps to the console to verify login

for (Application app : service.getApplications().values()) {

System.out.println(app.getName());

}

}

}

We can either user ServiceArgs or Service constructor to pass host and port details.

importcom.splunk.*;

public class SplunkTest {

public static void main(String[] args) {

// A second way to create a new Service object and log in

Service service = new Service(“localhost”, 8089);

service.login(“admin”, “changeme”);

// Print installed apps to the console to verify login

for (Application app : service.getApplications().values()) {

System.out.println(app.getName());

}

}

}

Using same token across all applications:

Service class creates token after login, it will use this token for all subsequent requests.

importcom.splunk.*;

import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;

public class SplunkTest {

public static void main(String[] args) {

Service service = new Service(“localhost”, 8089);

String credentials = “admin:changeme”;

String basicAuthHeader = Base64.encode(credentials.getBytes());

service.setToken(“Basic ” + basicAuthHeader);

// Print the session token

System.out.println(“Your session token: ” + service.getToken());

// Print installed apps to the console to verify login

for (Application app : service.getApplications().values()) {

System.out.println(app.getName());

}

}

}

For example, if you wish to use the same session token on various customers that are retrieving a single Splunk Enterprise instance, you can log in on one customer, get the session token applying the Service.getToken method, and after pass that token to another customers to use when they log in (use the Service.setToken method).We can also merge to Splunk Enterprise by accessing primary access approve, for example if you have various Splunk Enterprise instances behind a load balancer and wish to use the same session token for all. To build a token using a primary access header, Base64-encode a string with your authorization in the format “username: password” and prepend the authorization method (“Basic”).

Integrating Splunk with Spring Applications:

The Spring Integration adapter for Splunk includes 2 adapters:

·         Inbound Channel Adapter to find data from Splunk.

·         Outbound Channel Adapter to force event data into Splunk.

 

Spring integration gives namespace for splunk, it will acesses the spring integration adapter for splunk internally.

Generating beans for splunk server object.

<?xml version=”1.0″ encoding=”UTF-8″?>

<beans xmlns=”http://www.springframework.org/schema/beans”

xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”

xmlns:int-splunk=”http://www.springframework.org/schema/integration/splunk”

xsi:schemaLocation=”http://www.springframework.org/schema/integration/splunk

http://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd”>

<int-splunk:server id=”splunkServer” host=”somehost” port=”8089″ userName=”user” password=”password” owner=”admin”/>

</beans>

Outbound Channel Adapter: Outbound channel adapter is used to put data into Splunk from channels in Spring Integration. There are 3 kinds of method to put data:

Submit (HTTP REST)

Stream

Tcp

The major dissimilarity using the REST inputs vs plain TCP/UDP inputs is truly in the Splunk event handling pipeline.

With REST, you have to announce your event metadata (index, source, source type…) in the HTTP request at the source. You can’t truly change the log event more after you have made and sent it to Splunk. Typically though, for customers using REST, this is fine because they are well shaping their log events before sending them anyway: no more processing and manipulation is needed.

<int-splunk:outbound-channel-adapter id=”splunkOutboundChannelAdapter” auto-startup=”true” order=”1″ channel=”outputToSplunk” splunk-server-ref=”splunkServer” pool-server-connection=”true” sourceType=”spring-integration” source=”example” ingest=”submit”>

</int-splunk:outbound-channel-adapter>

With TCP inputs, modify the event data in Splunk before it gets indexed (using entrys in props.conf/transforms.conf). The event metadata (index, source, source type…) gets announced on the Splunk side when you start the TCP/UDP input and can also be dynamically created,so essentially you have a lot more control over the indexing of the event data.

<int-splunk:outbound-channel-adapter id=”splunkOutboundChannelAdapter” auto-startup=”true” order=”1″ channel=”outputToSplunk” splunk-server-ref=”splunkServer” ingest=”tcp” tcpPort=”9999″/>

To use outbound channel adapter with stream, you can define the adapter as following:

<int-splunk:outbound-channel-adapter id=”splunkOutboundChannelAdapter” auto-startup=”true” order=”1″ channel=”outputToSplunk” splunk-server-ref=”splunkServer” ingest=”stream”/>

Inbound channel adapter is used to get data out of Splunk and put into Spring Integration’s channel. There are 5 ways to get data out of Splunk:

 

·         Blocking

·         Non blocking

·         Saved search

·         Realtime

·         Export

 

<int-splunk:inbound-channel-adapter id=”splunkInboundChannelAdapter” auto-startup=”true” search=”search spring:example” splunk-server-ref=”splunkServer” channel=”inputFromSplunk” mode=”blocking” initEarliestTime=”-1d”>

<int:poller fixed-rate=”5″ time-unit=”SECONDS”/>

</int-splunk:inbound-channel-adapter>

Where mode is one of the above 5 types.

Using log frameworks to log into splunk servers.

Splunklogging provides the jar provides appenders for most used logger frameworks.

java.util.logging handler for logging to Splunk REST endpoints

java.util.logging handler for logging to Splunk Raw TCP Server Socket

java.util.logging handler for logging to Splunk HEC Endpoint

Log4j appender for logging to Splunk REST endpoints

Log4j appender for logging to Splunk Raw TCP Server Socket

Log4j appender for logging to Splunk HEC Endpoint

Logbackappender for logging to Splunk REST endpoints

Logbackappender for logging to Splunk Raw TCP Server Socket

Logbackappender for logging to Splunk HEC Endpoint

Log4j 2 appender for logging to Splunk HEC Endpoint

Log4j 2 config examples for TCP and UDP logging

For example if we want to use Rest services we can include below configuration in logger.properties.

log4j.appender.splunkrest=com.splunk.logging.log4j.appender.SplunkRestAppender

log4j.appender.splunkrest.user=admin

log4j.appender.splunkrest.pass=somepass

log4j.appender.splunkrest.host=localhost

log4j.appender.splunkrest.port=8089

log4j.appender.splunkrest.delivery=stream

log4j.appender.splunkrest.metaSource=rest

log4j.appender.splunkrest.metaSourcetype=testing

log4j.appender.splunkrest.metaIndex=main

log4j.appender.splunkrest.maxQueueSize=5MB

log4j.appender.splunkrest.dropEventsOnQueueFull=false

So that it will be logged automatically.

Conclusion:  In this article, java developmentcompany India have clarified the uses of Splunk in Java. Splunk is the software to receive the log messages and do index using log messages and supplies the metrics using log messages. It gives the SDK and logging frameworks for connecting to Splunk Enterprises and Splunk Cloud. Spring Integration gives an adapter for connecting Splunk severs also it gives a namespace for generating Splunk-related beans.

Related Aricle:

How to Wrap Text inside the Column in SWT Java-Based Framework?

Java Determines Success


Understanding Pass By Value and Pass By Reference in Java Development

 


The author of this post has written many articles about Java web development. In this article, he will share some important facts about Pass by Value and Pass by Reference. You can learn a lot more about these methods- just understand the details shared by the author in this post.

•          In basic, there are two methods that a computer language can pass an argument to a subroutine. 1) Pass-By-Value and 2) Pass-By-Reference

•          In Java, Objects are passed by reference, and primaries are passed by value.

•          All of us can simply agree that primaries are passed by value; there’s no such thing in Java as a pointer to a primary.

•          Java uses the pass-by-value. There is no pass-by-reference in Java. This Java tutorial is to walk you via the difference between pass by value and pass by reference, then search how Java uses pass by value with samples. Some say that in Java primaries are passed by value and objects are passed by reference. It is not right.

•          But, Objects are not passed by reference. A true statement would be Object references are passed by value.

•          Java does manage objects by reference, and all object variables are references. But, Java doesn’t pass method arguments by reference; it passes them by value.

Pass by Value

•          Real parameter expressions that are passed to a method are estimate and a value is derived. Then this value is stored in a location and then it becomes the formal parameter to the call on method. This structure is called pass-by-value. Not the real reference but Passing a copy of the value.

•          In Java, when you pass a primary type to a method, it is passed by value. So, what happens to the parameter that receives the argument has no effect outside the method.

EXAMPLE OF PASS BY VALUE

public class Example1 {

 

            public static void main(String args[]) {

                        int number = 3;

                        nextPrint(number);

                        System.out.println(“Print number Inside main(): ” + number);

            }

 

            public static void nextPrint(int number) {

                        number++;

                        System.out.println(“Print number Inside nextPrint(): ” + number);

            }

}

Output :

Print number Inside nextPrint(): 4

Print number Inside main(): 3

Above example, Primitives are passed as pass by values to method parameters and

Java Pass by reference both main() method and nextPrint() method should have printed the same value.

Pass by Reference

1.         By name or reference to the real parameter is passed to the method, so that it’s called pass by reference. Passing the address of the object, so that you may examine the real object.

2.         Java is always Pass by Value and not pass by reference.

3.         When you pass an object to a method, the condition changes badly, because objects are passed by successful call-by-reference.

4.         When you generate a variable of a class type, you are only creating a reference to an object.

5.         When you pass this reference to a method, the parameter that gets it will refer to the same object as that referred to by the argument. These successful means that object are passed to methods by use of call-by-reference.

EXAMPLE OF PASS BY REFERENCE.

public class Example2 {

           public static void main(String args[]) {

                   Car car1 = new Car(“Rolls-Royce”);

                   Car car2 = new Car(“BMW”);

                   System.out.println(“Brand of Car Inside main() before: 1) “+ car1.brand + ” 2) ” + car2.brand);

                   brandPrint(car1, car2);

                   System.out.println(“Brand of Car Inside main() after: 1) “+ car1.brand + ” 2) ” + car2.brand);

                   swap(car1, car2);

                   System.out.println(“Brand of Car after swap: 1) “+ car1.brand + ” 2)” + car2.brand);

               }

 

               public static void brandPrint(Car car1, Car car2){

                   car1.brand = “Bugatti”;

                   car2.brand = “Ferrari”;

               }

 

               public static void swap(Car c1, Car c2){

                       Car temp = new Car(“”);

                       temp = c1;

                       c1 = c2;

                       c2 = temp;

               }

 

               private static class Car{

                   private String brand;

 

                   public Car(String brand){

                       this.brand = brand;

                   }

 

               }

}

Output:


Brand of Car Inside main() before: Rolls-Royce

Brand of Car Inside brandPrint(): Bugatti

Brand of Car Inside main() after: Bugatti

1.         Above example, change made in method parameter is reflected globally. The brands of cars are changed in all places, which means one object is used in both methods. Swap() method test may be used for Pass by reference.

2.         You will find that method swap() within from the main() method is passed two objects car1 and car2 those are received by swap() in c1and c2 references respectively. Next inner swap() method c1 and c2 are exchanged. By doing so c1 holds the object earlier referred to by c2 and c2 does the opposite. In this procedure of exchanging formal parameters c1 and c2 there would be no impact on car1 and car2, which states that in Java arguments are passed by value, not by reference.

3.         That’s how Java handles pass-by-value and pass-by-reference mechanisms of passing parameters to methods.

4.         Objects are not swapped because Java uses the pass-by values.

5.         Key point to mention is that “The reference is copied as a value” to a new variable and it is given as a formal parameter to the called method.

6.         If you pass an object as a method parameter in Java it passes “value of reference” or object reference or handles to Object in Java. Here reference expression is fully different from the reference expression used in C and C+ which directly points to the memory address of the variable and is subject to pointer arithmetic. In Java object can only be accessed by its reference as you can’t get the memory address where the object is stored or more precisely there is no method to get the value of an object by passing the memory address.


The author of this post is a java web development professional. He has good exposure to java app development and has built many apps for distinct businesses. If you have any question related to Pass by Value and Pass by reference, then comment on this post. The experts will answer your query and will share proper thoughts about the subject. 

Related Articles:

Webclipse for Java Developers to Create Modern Apps with JavaScript and Java EE Development 

Java Tools Support Windows 10 And Visual Studio Now!