Tuesday, March 18, 2014

Programming "Hello World" with Linux in (Java, C#, Ruby and Python)

SPECIFICATION OF MY PC
System type: Microsoft Windows 7 professional, 32-bit Operating system / XUBUNTU 13.10
Motherboard: Gigabyte X58A-UD3R
Processor: Intel Core i7 CPU   960 @ 3.20Ghz
Ram: 4,00GB (3,5GB usable)
Hard drive: 367GB
Video card: Nvidia GeForce GTX 560 Ti
Current resolution: 1680*1050, 59Hz
Cd/dvd/Blueray Drive: Asus BW-12B1LT


This publish includes eleven (11) steps to program "Hello World" with different 
programming languages. Follow the steps and you'll have learned how to program Hello world in different programming languages in no time. In case there is any problems please leave a comment and I'll do my best to help you. Hope it helps.



Step one (1)

Programming with Java. First you download "openjdk-7-jdk" Install it with command "sudo apt-get openjdk-7-jdk"

Step two (2)

Now to start programming you have to first create text file with command "nano HelloWorld.java" here you write the code. I have to highlight REMEMBER NAME THE FILE THE SAME NAME AS THE CLASS! 


 Step three (3)

Write the following text to the text file and save it:

class HelloWorld
{
       public static void main(String[] args)
                    {
                      System.out.println(“Hello World!”);
                    }
}




Step four (4)

After that you have to compile the program and execute it. To do this first make the command "Javac HelloWorld.java" after pressing enter it'll compile the program. After that we can execute it and it should work and execute it with command "java HelloWorld" something like in this picture should happen:




Step five (5)

Programming with C#. In here we also need compiler for C#. We'll have to install app called mono mcs. To install in just type command "sudo apt-get mono-mcs". 

Step six (6)

After installing you do the same as earlier, but just with command "nano HelloWorld.css"
After that as the text file opens you can enter for example this and save it:

public class HelloWorld
{
   public static void Main()
   {
      System.Console.WriteLine("Hello World!");
   }

}



Step seven (7)

In last step of c# we'll have to compile it with command "mcs HelloWorld.cs" and execute it with command "Mono HelloWorld.exe"



Step eight (8)

Programming with Python. First you have to check if you have python interpreter. You can check it with command "whereis python" In this case we've it.



Step nine (9)

To open python just type command "python" and it'll give you starting message and start the program.
After doing this you can just type in command line " print "Hello world!" and it'll print it out.





Step ten (10)

Programming with Ruby. First you have to get the application. You get it by scrollback first from python and then typing "sudo apt-get ruby-full"

Step eleven (11)

After that you can simply do the same trick as in python. Just type ruby and it'll open the program. Type "print ("Hello World!\n") this code will print out the text. As we want the text to be in new line not all connected to each other we used "\n" to use line break.





Links:

http://terokarvinen.com/2014/agenda-for-linux-basics-dat8tf063-23-spring-2014

THANK YOU FOR READING!

HOPE IT HELPED

No comments:

Post a Comment