Showing posts with label hello world. Show all posts
Showing posts with label hello world. Show all posts

Thursday, June 27, 2013

Hello World program in JAVA

 

Today on 6Tags i am going to write about starting  journey as Java programmer.Java is one of the most popular programming language in the world.Check out wikipedia for its history.I'm going to write about how to write a simple hello world program in java.Lets start our journey as a java programmer.


requirements:

1. Windows 7/8

2. Latest versions of JDK DOWNLOAD

3.A working human brain


Download and install latest version of JDK, i working with JDK1.7_03.
Now you have to set the path for cmd to know where the java resides.For this got to:
c:/program files/java/["your java version"]/bin 



 copy the address ,

right click on my computer

choose properties

go to Advance system setting

in Advanced tab choose  Environment Variables

Click on path

variable name=path

variable value= [paste the location you copied]






You are on the Half way now,
now choose a editor NOTEPAD,ECLIPSE,NETBEANS ,many options are out there, i'll go with NOTEPAD.
open NOTEPAD
copy the program and save it as helloworld.java. Here it is

class HelloWorld
{
    public static void main(String[] args)
    {
        System.out.println("Hello World!");
    }
}
Program is quite simple we created a class helloworld, then a function to print the hello world.
Now for some eay work, make a folder in c drive , my folder is dr and save the helloworld.java there.
Make sure your file is not helloworld.java.txt.

Now open CMD
go the directory where you saved your  java program.for me it cd c:\dr
type JAVAC helloworld.java,this will create a byte code that will be system independent and a helloworld class file will be created in folder.
If it shows no error then type
JAVA HelloWorld  (this is the class name , it is case sensitive,and there is no extension).
And EUREKA you are now a java programmer.


Now one thing very important,I am not a java programmer i just wrote my helloworld yesterday faced a small problem, that can be huge for a newcomer . My source code was like this
class manish
{
    public static void main(String[] args)
    {
        System.out.println("Hello World!");
    }
}
And i saved it as mac.java.
Now when i run the program javac mac.java run successfully but java mac showed a error like this 
COULD NOT FIND OR LOAD MAIN CLASS MAC, i goolged stack overflow and other discussion forum suggested other commands ,nothing happend then suddenly it strike it is talking about class so i changed my command from java mac to java manish, and bang !!..:) Beaware of these silly mistakes.


Wednesday, May 1, 2013

HELLO WORLD IN "JQUERY"


Jquery is javascript library which contain thousand lines of Javascript codes,to make some regular work easier.You can DOWNLOAD latest version of it from here.It is embedded it HTML code using <Script arc="">. You can use it by downloading in same folder in which your HTML codes are.Otherwise you can use CDS(content delivery system such as google).Here is our helloworld.html using JQUERY.

<html>
<head>
<title>hello world</title>
</head>
<body>
<script src="jquery-1.9.1.js"></script>          <!---download and attach latest JQuery -->
<script type="text/javascript">                        <!---start script tag--->
$(document).ready(function() {                       <!----$(document).ready(function(){ }); is function that will    load after all the document will ready to diaplay--->
    alert("hello world");                                     <!---this will show a alert box with "hello world"-->
});
</script>
</body>
</html>




Follow my blog with Bloglovin

Tuesday, April 30, 2013

HELLO WORLD IN "JAVASCRIPT"


Javascript is client side scripting used to design dynamic webpages. Unlike PHP which require a server to execute it run on browser itself.Javascript can be used with html to produce dynamic web pages. It can be inserted into <head> tag or <body> tag.Javascript also follow Object Oriented Programming .Here is our helloworld.html using javascript.Open notepad paste the code and save it as hello.html.

<html>
<head>
<title>helloworld with JS
</title>
</head>
<body>
<script type="text/javascript">
document.write("hello world");
</script>
</body>
</html>  

Explaining the code:

<script type="text/javascript"> tells the browser that next lines are JavaScript be ready.
document.write() document is the class and write() is the function that is used to display the object on the page.
</script> tell the browser that javscript ended.

HELLO WORLD IN "PHP"


PHP stand for Hypertext Preprocessor a group of people call it "Personal Home Page". It is server side scripting language,i.e. browser can't run a PHP code directly. It require a server before it goes to browser. PHP follow OOPs (object oriented programming like C++).PHP is used to create dynamic web pages.A dynamic web pages are those which can interact with the visitor.You can use HTML with PHP.
To run a PHP code you will need:

1. A code Editor (notepad,notepad++ etc)
2. A server with PHP (wamp,xamp,easyphp come with all the package i.e php,apache,mysql,phpmyadmin etc)
Extension Of a PHP code is .php

here it is helloworld.php

<?php
 echo("hello world");
?>

that's it..
ya that's it..
Now paste this code in C:\wamp\www for wamp and in htdocs for xamp and run the server .
Open browser , type localhost and you'll find your file there,just open it.

Explaining the code :
A PHP code start with <?php , note there is no space  and end end with ?>  echo("string"); work the same as  "printf " in C and "cout" in c++ does.

HELLO WORLD IN "HTML"


HTML stands for Hyper Text Markup Language.Always remember it is a markup language not programming language.Markup language is used to mark up web pages i.e. it provide proper structure to the web element.HTML 5 is the latest trend on the web with several new feature added.Cascading Style Sheets(CSS) is used for styling purpose the element of html. To run a HTML code, all you need is

1. A Code editor (notepad,notepad++,context,dreamweaver,aptana studio many light weight code editor are available for free, last two is used by professionals to develop websites)
2.A Browser (firefox,IE,chrome,safari,opera etc)

Extension of a HTML file is .htm or .html
this is the code for helloworld.html

Paste the following code in notepad and save as helloworld.html

<html> <!--starting the code with html tag-->
<head> <!--starting head tag-->
<title> <!--starting title tag-->
Hello World
</title> <!--closing title tag-->
</head>  <!--closing head tag-->
<body>    <!--starting body tag-->
<h1>HELLO WORLD</h1> <!--staring heading tag and heading within then closing tag-->
</body>  <!--closing body tag-->
</html> <!--closing html tag-->

Now simply open the file.

Explaining the code:-
HTML is all about TAGS. i.e. <html>,<body>,<h1> all are tags.
there are two types of Tags :
1. single tags
2.Pair Tags

single tags are <br /> <hr /> <link />
moat are pair tags. like <html></html> both are pair.
Every HTML code start with <HTML> and </HTML>(i'll explain DOCTYPE later).All the codes are written within these 2 tags.Next is <HEAD> tag which contain <TITLE> tag which hold the title of the webpage and shows on the title bar of the web page.<head> tag also contain javascripts,css links etc.Next is <BODY> tag.All the element that will be displayed on the page will go through this tag.<H1> is used for heading.

HELLO WORLD IN "C++"



C++ is just super class c, all programs that run in a C compiler will run in C++ compiler but vice versa is not true.I personally felt C++ is more easy than C,there is no prior knowledge of C is necessary.But remember C is mother of all programming language ,so it is always a plus point .C++ is Object Oriented Language which make it easier to program.You design a class and create object of that class. A class contain variables and functions. Object contain the property of the class to which it belong.Here is the first program in C++.
Extension of a C program is c and of C++ program is .cpp.
Here is HELLOWORLD.CPP

#include<iostream.h>
#include<conio.h>
void main()
{
cout<<"hello world";
getch();
}

IOSTREAM.H is new header file introduced in C++ which contain object like COUT,CIN etc
COUT work similar to printf i.e to display characters on the screen. Rest of the code is same as C program.

Monday, April 29, 2013

HELLO WORLD IN "C"



C is mother of all programming languages.It is easy to learn,understand and code.It was developed by Dennis Ritchie.C is one of the most used programming language of all time.So lets start our journey in C with hello world program.It is just a tradition we  start with this program in every programming languages.
I will assume throughout the blog that user has idea about how to compile  a c program.It is not rocket science you need a compiler like Turbo c++,Borland C++ for windows and GCC for linux.Here it is our first program:

#include<stdio.h> 
#include<conio.h>
void main()
{
printf("hello world");
getch();
}

Now explaining the code
# is called Preprocessor is used to include Header file in the program , will be used in every program.
INCLUDE is used to include the functions of   Header file that is included.
STDIO.H is a header file, header file is a collection of predefined functions that make us easy to code.STDIO.H stand for Standard Input Output because it contain the function like scanf,printf that is used for input and output and .H extension is because it is a header file.
CONIO.H is also a header file that contain getch(); function which is used to hold the screen.
VOID is prototype of main() that means the program will return nothing.
MAIN() it is the main function which contain the program ,it will used in every program of c and c++.
{}   program go through in this bracket.
PRINTF() this function is used to print on the screen.
; is terminator that means it tell computer that line is over,now move to next line.
GETCH() this function is a part of CONIO.H header file used to hold the screen.

I can understand You won't be able to get it all at first time, just practice and see other program, you will get the idea hoe easy it is.