How to set up smartphones and PCs. Informational portal
  • home
  • Programs
  • Learning the java programming language from scratch. JavaRush and Java Development Tools

Learning the java programming language from scratch. JavaRush and Java Development Tools

In this guide, we will cover everything you need to know before starting the study. programming on java. You will learn about the capabilities of the platform, its application, as well as how to start learning Java the right way.

What is the Java programming language?

In 1991, the Green Team, a division of Sun Microsystems, led by James Gosling, created a language for programming consumer electronic devices. At that time it was called Oak ("Oak"). Why " Oak"? Simply because this tree grew outside the window of Gosling's office.

The Green Team demonstrated the use of Oak in an interactive TV. But for digital cable television of those years, this technology was too advanced. At the same time, the Internet was gaining popularity, for which the new programming language was best suited.

After some time, the new language was renamed to Green, and after that - to Java, in honor of coffee from the island of Java. Therefore, the Java logo shows a mug of coffee.

During the development of Java, C/C++ was popular, so Gosling made the syntax of the language similar to C/C++ and implemented the principle for it " write once - run anywhere". In 1995, Sun Microsystems released the first official version of Java. And at the same time, it was announced that Java would be included in the Netscape Navigator browser.

In 2010, Sun Microsystems, along with the Java programming language, was acquired by Oracle Corporation.

Java version history

  1. June 1991 - start of the development project programming language java.
  2. JDK 1.0 - January 1996.
  3. JDK 1.1 - February 1997.
  4. J2SE 1.2 - December 1998.
  5. J2SE 1.3 - May 2000.
  6. J2SE 1.4 - February 2002.
  7. J2SE 5.0 - September 2004.
  8. Java SE 6 - December 2006.
  9. Java SE 7 - July 2011.
  10. Java SE 8 - March 18, 2014.
  11. Java SE 9 - September 21, 2017.

Java programming language features

Java - cross-platform language

Java code written on one platform ( i.e. operating system) can be run unchanged on other platforms.

The Java virtual machine is used to run Java ( Java Virtual Machine, JVM). The JVM processes the byte code, after which the processor processes the code received from the JVM. All virtual machines work similarly, so the same code works the same way on all operating systems, which is what makes Java a cross-platform programming language.

Object-oriented programming language

There are different styles of programming and one of the most popular is object-oriented programming. With this approach, a complex problem is broken down into smaller ones by creating objects. This makes the code reusable.

Object-oriented features are found in many programming languages, including Java, Python, and C++. If you are serious about learning how to program, you should include an object-oriented approach in your learning plan.

Java is fast

Early versions programming language Java has often been criticized for being slow. But today the situation has changed dramatically. New versions of the JVM are much faster, and the processors that interpret them are getting faster.

Java is one of the fastest programming languages ​​today. Well-optimized Java code runs almost as fast as low-level programming languages ​​like C/C++ and much faster than Python, PHP, etc.

Java is a secure platform

Java is:

  • a secure platform for developing and running applications;
  • provides tools for automatic memory management, which reduces the vulnerability of the code;
  • ensures secure data transfer.

Extensive core library

One of the reasons for Java's widespread adoption is its huge standard library. It contains hundreds of classes and methods from various packages that make life easier for developers. For instance,

java.lang is advanced features for strings, arrays, etc.

java.util is a library for working with data structures, regular expressions, dates and times, etc.

kava.io - library for file input/output, exception handling, etc.

Using the Java Platform

Before Learning Java programming from scratch, you need to know that more than 3 billion devices around the world are running on this platform. What exactly can it be used for:

  1. Android Applications - To develop Android applications, the Java programming language is often used in conjunction with the Android SDK ( from English software development kit - software development kit).
  2. Web Applications - Java is used to create web applications using server programs, Struts framework and JSP. Here are some popular web applications written in Java: Google.com, Facebook.com, eBay.com, LinkedIn.com.

It's worth noting that these sites are not necessarily written exclusively in Java, and may use other programming languages ​​as well.

  1. Software Development- Programs such as Eclipse, OpenOffice, Vuze, MATLAB and many others are written in Java.
  2. Big data processing - for processing " big data"You can use the framework Hadoopwritten in Java.
  3. Trading systems- using the platform Oracle Extreme Java Trading Platform, you can write programs for trading.
  4. Embedded devices- Billions of devices such as TVs, SIM cards, Blu-ray players, etc. are powered by Oracle's Java Embedded technology today.

Also programming on Java is used to develop games, scientific applications ( e.g. for natural language processing) and in many other areas.

Java terminology you should know

Java is a set of technologies ( programming language and computer platform) designed to create and run software. However, the term Java is often used to refer to the programming language itself.

Programming language Java is a cross-platform, general-purpose, object-oriented programming language with a wide range of capabilities.

Java 9 is the latest version of Java at the time of this writing.

Java EE , Java Me and Java SE - these names stand for Java Enterprise Edition , Micro Edition and Standard Edition , respectively.

Java EE is aimed at applications that run on servers. Java ME is designed for power-constrained devices such as embedded devices. Java SE is the standard edition of Java for writing regular programs.

If you are new to Java programming, we recommend starting with Java SE .

JVM - Java Virtual Machine (" Java virtual machine") is a program that allows a computer to run programs written in Java.

JRE - Java Runtime Environment (" Java runtime”) includes the JVM, related libraries, and other components needed to run programs. But JRE does not have a compiler, debugger, or other development tools.

JDK - Java Development Kit Java developer) contains the JRE and other development tools such as compilers, debuggers, etc.

How to run Java on your operating system

How to Run Java on Mac OS

Here's what to do for Java programming from scratch and platform installation on Mac OS X or macOS:

  1. Download the latest version of Java ( JDK) with Java SE download pages.
  2. Double click on the downloaded DMG file and follow the instructions of the installer.
  3. To verify the installation, open a terminal and enter the following command:

javac -version

If Java is installed correctly, the version of the program will be displayed ( e.g. javac 1.8.0_60).

The next step is to install the IDE ( integrated development environment) to write and run Java code. We will install the free version of IntelliJ IDEA and run Java on it. Here's what you need to do for this:

  1. Go to IntelliJ download page and download the free Community Edition.
  1. Open the downloaded DMG file and follow the installation instructions. For quick access, you can move IntelliJ IDEA to the Applications folder.
  2. Open IntelliJ IDEA. Select the option “Don’t import settings” (“ Do not import settings"") and click " Ok» . After that, accept the Jetbrains privacy policy by clicking on the "Accept" button.
  3. Now you can customize the interface for yourself. You can also skip this step and leave everything as default. If you are not sure, just skip this step by clicking the "Skip All and Set Defaults" (" Skip everything and set default settings»).


  1. The program will show you a welcome page. Click on the "Create New Project" (" Create a new project»).
  2. In the next window, select " Java"In the left panel and click" New"At the top of the program window to select" JDK» . Here you need to select the place where you installed the JDK, then click Next.


  1. You will have the option to create a project from a template ("Create project from template"). We ignore it and press the button " Next» .
  2. The next installation step programming language Java, enter the name of the project and click the button " Finish» .
  3. In the left pane you will see your project. If the panel is not visible, go to the menu Views > ToolWindows > Project.
  4. Go to Hello > New > Java and set the class name. We named it First .


  1. To run the program you just wrote, go to Run > Run... Click on First ( that is the name of the file we created


How to Run Java on Linux

To run examples from programming lessons from scratch Java on Linux will need the JAVA SE Development Kit ( JDK) and an IDE to develop your projects. Follow the instructions step by step to get started with Java.

Install Java

  1. Open a terminal and type the following command to install Java:

    sudo add-apt-repository ppa:webupd8team/java


    sudo apt update; sudo apt install oracle-java8-installer

  1. Accept the license agreement and terms of use by clicking OK and Yes, respectively.
  2. You have installed Java. To check that the installation was successful, enter the following command in a terminal:

java-version

If the current version is displayed, the installation was successful. If not, check with Oracle help page.

Installing IntelliJ IDEA

  1. Go to .


  1. Download the free Community Edition by clicking the Download button.
  2. After download change directory in terminal to your downloads directory and extract the Java tar file to the /opt folder with the following command:

sudo tar xf .tar.gz -C /opt/

  1. After unpacking, change the directory to the IntelliJ IDEA bin folder:

    cd /opt/ /bin

  2. To start the IDE, enter the following command:
  3. Choose " Don't import settings" (" Do not import settings"") and click "OK". After that, we accept the Jetbrains privacy policyby clicking on the button "Accept» .
  4. Now for passing programming courses Java can customize the interface for you. Create a desktop shortcut for quick access to the program. After that, to launch the IDE, click " Next"At all the following steps.
  5. The program will display a welcome page. Click "Create New Project" (" Create a new project»).
  6. In the next window, select Java in the left pane and make sure Java is selected in the Project SDK row. If not, then select the location where you installed JDK: /usr/lib/jvm/java-8-oracle.


  1. Click “Next” twice and create a project.
  2. In the next step, enter the name of the project and click the button " Finish» . You will now see your project in the left pane. If this panel is not visible, go to the menu Views > ToolWindows > Project.
  3. Add a new Java class. Select src in the left pane with a right click and go to New > Java Class . Set the class name. The class name must not contain spaces.


  1. Write Java code and save the project.
  2. To run the program, go to Run > Run... Click on HelloWorld ( the name of the project) - the program will compile the file and run it.


How to run Java on Windows (XP, 7, 8 and 10)

To learn Java programming fundamentals and running the platform on Windows, you will need a JAVA SE Development Kit (JDK) and an IDE for project development. Follow the step by step instructions below:

Java installation

  • Go to download page Java Standard Edition Development Kit.
  1. In the Java SE Development Kit section at the top of the table, click "Accept License agreement" (" Accept license agreement"). Then click on the link Windows (x64) if you have a 64-bit operating system or Windows (x86) if you have a 32-bit OS.

  1. After downloading, run the installation file and follow the instructions that will appear on the screen. Click " Next". Select all functions by clicking " This feature will be installed on local hard drive" and copy the installation location ( it is highlighted in yellow) in Notepad, then press again " Next».


  1. During the installation process, you will be prompted to install the JRE. Click Next and then Finish to complete the installation.
  2. Now you need to edit the PATH variable. Go to Control Panel > System and Security > System. In the left pane select " Advanced system settings.

  1. Click " Environment Variables". In section " System Variables» find the PATH variable and in the next window click "Edit".

  1. Select all text in the " Variable value" and copy it to a separate text file. This will make it easier to edit and check for errors. See if the copied text contains the line: C : ProgramData Oracle Java javapath ; . If yes, then you can move on to the next step. If not, paste the installation location you copied earlier at the beginning of the variable and add bin at the end of the line like this: C : Program Files (x 86) Java jdk 1.8.0_112 bin ; Please note that your JDK version (jdk 1.8.0_112 ) may be different. Copy the value of the variable and paste it into the PATH box.


  1. Click " OK' to save your changes.
  2. To check if the platform is installed correctly for introduction to programming Java, open command line, by typing cmd in the Windows search bar or through the "Run ..." command ( Windows-R). Enter the java -version command. If the current version of Java is displayed, then the installation was successful. If not, check with Oracle help page.

Installing IntelliJ IDEA

  1. Go to IntelliJ IDEA download page.
  2. Download the free Community Edition by clicking Download.


  1. Once downloaded, run the setup file and follow the instructions that will appear on the screen. Then create a desktop shortcut for the 64-bit version and add associations with the .java extension. Click " Next"And continue with the installation.


  1. Once installed, open IntelliJ IDEA by clicking on the desktop icon.
  2. Select "Don't import settings" (" Do not import settings”) and click OK. After that, we accept the Jetbrains privacy policy by clicking "Accept".
  3. Now you can customize the interface for yourself. You can also skip this step and leave everything as default by clicking the Skip All and Set Defaults button.
  4. The program will display a welcome page. Click "Create New Project" (" Create a new project»).


  1. In the next window, select " Java"In the left panel and click" New"At the top of the program window to select JDK. Here you need to select the location where the JDK was installed during the Java installation, and then click " Next".
  2. IntelliJ IDEA will find the JDK and recognize it. No other options need to be checked, just click " Next» .
  3. On the next screen, enter the project name: HelloWorld and click Finish. If the program says that the directory does not exist, click OK. If you don't see the left pane, go to Views > Tool Windows > Project .
  4. To set the class name, select the src folder in the left pane. Right click on it, go to New > Java and give the class a name. The class name must not contain spaces.


  1. Write Code and Save Java Project programming lesson.
  2. To run the program, go to menu Run > Run... Click on HelloWorld - the program will compile the file and run it.


Your first Java program

To introduce users to a new programming language, use the Hello World program (“Hello world!”). This is a simple program that displays the words Hello, World ! In this section, we will teach you how to write this Java program using IntelliJ IDEA.

  1. Open IntelliJ IDEA.
  2. Go to File > New > Project… > Java ( in the left navigation bar).
  3. Set the project name ( Project Name ) from programming course J a va. We'll name it Hello World and click Finish.
  4. Now we need to create a new Java class.
  5. Select the src folder in the left pane, then go to File > New > Java Class and name the new class HelloWorld .
  6. Copy the following code to the HelloWorld.java file and save it.

public class HelloWorld ( public static void main(String args) (


// prints "Hello, World!"


System.out.println("Hello, World!");

  1. Press the start button ( Run). If everything is in order, you will see on the screen the inscription Hello, World!

How to learn Java?

Official Java Documentation

Oracle, the company that owns Java, publishes quality tutorials. The official documentation covers all Java features and is updated regularly.

Note: The only downside is that the official Java documentation is not always written in the simplest possible language.

If you really want to learn programming in Java, buy a good book. Of course, 1000 pages cannot be read in one day. But a good textbook will help you learn how to program.

Java: The Complete Guide (10th edition)

Great book for those who are just starting to learn Java. The latest edition includes all features of the Java 8 release.

The book covers everything you need to know about Java programming, including syntax, keywords, and programming fundamentals, as well as the Java API library, Java applets, and more.

Java Philosophy (4th edition)

If you are migrating to Java from another programming language, this book is for you. If you are starting from scratch, it is best to read it along with another.

Java 8. Pocket Reference: First Aid for Java Programmers

This book contains clear answers to questions that arise when learning J ava programming from scratch. It briefly covers all the core concepts of Java (including Java 9). Don't want to flip through hundreds of pages looking for the right line? Buy this book.

Instead of a conclusion

If you start learning Java, you can't go wrong - this is a promising programming language full of a wide variety of possibilities.

Before you start learning Java, here are a few tips:

  • Do not read tutorial articles and examples like a novel. The only way to become a good programmer is to write a lot of code.
  • If you are migrating from another programming language (say C# ), you don't need to write C# style code.
  • Find Java communities online. Once you've learned how to write simple Java programs, look for popular Java sites and forums. Try to solve problems that other programmers have. This is a great way to expand your own knowledge. Plus, if you get stuck, you'll know where to ask for help.

We hope this article will encourage you to learn Java and help you get started on your first programs.

Translation of the article “ Learn Java Programming. The Definitive Guide” was prepared by a friendly project team

We'll talk about basic Java syntax for beginners. The syntax of a programming language is a set of rules that govern how it is written and interpreted...

From the author: approximately 3 billion smartphones, 125 million television sets and every single Blu-ray player in the world run on this programming language. This language regularly wins prizes in the ratings of software developers and is the most popular among the largest IT companies. It is a technical phenomenon and works on absolutely any device, which is consistent with its “write once - run everywhere” (WORA - “write once, run anywhere”) principle. Who guessed, raise your hands! Of course, this is the Java language. And today I will reveal all the cards to you and tell you the whole truth about how to become a Java programmer from scratch! Get comfortable!

Some facts about Java

In order not to bore you with long theoretical sermons, I have grouped some information about Java into a list, after reading which you will get an insight into understanding what kind of language it is and what its role is in the wild nature of programming:

Java is a "fancy" and cross-platform programming language. It works on any device with any operating system. All Google and Android applications are written on it. In no other language will you find so much information and learning materials;

the official release date for the language is May 23, 1995. It was originally conceived for interactive cable television, but "didn't grow together." Java was invented by Sun Microsystems, which was acquired by Oracle in 2010;

Many people confuse Java and JavaScript. If you want to engage (websites, web applications), then choose the second option. Java is a back-end, i.e. development of application stuffing;

it is an object-oriented programming language whose code is executed by a special java virtual machine (JVM). In the US, about 9 out of 10 computers have this same JVM installed;

The language takes its name from a brand of coffee, which is why the official emblem features an inspiring cup.

Are you still here or did you run to make yourself a cup of fragrant coffee? Then let's continue talking about how to become a Java programmer.

Installing the software environment

Oddly enough, some people have problems already at the stage of installing the Java software environment. To do this, go to the official website of the developer company - Oracle. You will see a link to the current version at the very top of the site. You need Java SE (Standard Edition) and Java Development Kit - a set of development tools. Please note that there are different distributions for different operating systems.

Let's say we have Windows. We go to the "System Properties" and see what kind of system we have - 32-bit or 64-bit. Download the file that suits us in terms of bit depth. If you choose the wrong distribution, you will get an error when compiling the code. After confirming the Accept License Agreement, click the download button.

What is the Java Developer's Toolkit?

Most of the time a programmer spends in an IDE (IntelliJ IDEA, Eclipse, WebStorm, NetBeans). IDE is an integrated development environment, a special interface for programming. It not only helps when writing code, but also makes it easier to use other programming tools. Some advise those who want to become a Java programmer from scratch to write their first programs in a regular notepad or Notepad++.

Maybe elementary programs should be written in an editor. But in the future, I still strongly recommend using the IDE. It has the functions of code completion, syntax control, jump to method definition, and many others. And intelligent hints will save you from having to remember all the names of functions and their parameters, which is simply physically impossible.

When working on a team, when several people work on the same program at once, it is imperative to use the so-called version control system (Perforce, Git, Subversion, etc.). However, version control systems are very convenient when working alone.

An example algorithm for learning Java

Learning the basics of the Java language. The first step is to develop your logical thinking skills and learn the fundamental concepts of programming language syntax. Armed with a book, article, or tutorial video, learn how to use an IDE or text editor to create simple Java objects that have different behaviors depending on the input.

Analysis of the advanced features of the Java language. In this step, learn the syntax, libraries, and frameworks that will help you build more complex applications with a practical focus. A good programmer not only knows how to use various libraries, but also knows how they are arranged inside. In addition, concepts such as I / O operations, inheritance and abstractions, serialization, generic types, regular expressions should not be an empty phrase for you.

Modern trends and approaches in web development

Learn the algorithm for rapid growth from scratch in website building

Subtleties of programming. Never skimp on the documentation and jargon of Java programming. At this stage, you should already be "mutating" into a mature programmer. Communicate with Java gurus, which you will find in thematic forums and other environments where programmers gather. Show them your code, consult and advise others - "accumulate karma." You can even start your own blog, post snippets of your own code, and see what more experienced programmers have to say about it.

How to start programming?

For those who are going to become a Java programmer from scratch, I will tell you how to write your first program.
So, open any text editor and write:

class HelloWorld ( public static void main(String args) ( System.out.println("Hello World!"); ) )

class HelloWorld(

public static void main(String args )(

System. out . println("Hello World!");

We save the file under the name HelloWorld.java. Please note that Java is case sensitive, so the words "helloworld" and "HelloWorld" are different. If the names of the file and class in the code differ, then the program simply will not start. In addition, it is important that the encoding is ANSI.

Now we have to compile the program using the javac compiler from the JDK. While we have not installed the development environment, we will compile using the cmd command line, calling it from the Start menu. In the window that appears, type cmd and press Enter.

If we saved HelloWorld.java to the Prog folder on drive C, then we enter the command:

cd C :\prog a

and press Enter. Thus, we changed the directory to the one where our program is located. Then we enter.

General information about programming

Programming is the process of creating code in a programming language that is translated into files of various types using a special program - a translator.

8 Cool Youtube Channels to Help You Learn Java

There are two types of compilers: compilers and interpreters. A compiler is a program that translates text written in a programming language into a file. An interpreter is a program capable of translating the text of a program into machine code and simultaneously executing it.

Java Programming(it is a compiling language) has the advantage that the code written in this programming language is translated using the appropriate translator program into the so-called bytecode, and this, in turn, is translated into machine code using the Java virtual machine ( Java Virtual Machine, or simply JVM). Therefore, a program written in Java is executable on any computer with any system, as long as the Java virtual machine is installed on it. Thus, one of the main advantages of the Java language is ensured - the portability of programs created on it to computers of different types.

Programming is of two types: systemic and applied.
System Programming allows us to program in a system, such as Windows, in order to solve global problems.
Application programming aimed at creating application programs, i.e. programs that perform a specific function, such as Microsoft Word, WordPad, Calculator, etc. In this book, we will deal with application programming.

Basics of programming

Introduction. What is JDK?

Introduction. What is JRE?

Introduction. How to install JDK?

Introduction. How to use JDK?

1. Types of programming. First listings.

2. Variables and identifiers

3. Variables and constants in Java

4. Literals in Java

All programming courses

5. Learning about data types

6. Converting data types

7. What are the operators in the Java language

8. Arrays in Java

9. Control structures. General information about cycles

10. Selection constructs in the Java language

11. Java Exit Statements

12. OOP, creating objects

13. Constructors and initialization blocks

14. Methods in Java

15. Inheritance in Java

16. Interfaces

17. Nested classes and questions

18. Exceptions in Java

19. Code documentation

20. Helpful Techniques and Checklists

21. Packages in Java

22. Package java.lang

23. Java.util package and questions

Enter the Faculty of Java Development

24. Get to know JBuilder

25. Set up the program settings

26. Create your own applet in Java

27. Working with the Component Palette in JBuilder 2005

28. The JButton class from the javax package. swing

29. Creating a menu using the java package

30. Components for working with text in Java

31. JSIider slider and indicator in Java

32. Lists in Java

33. Working in JBuilder 2005: JScrollPane component

34. JSplitPane and JTabbedPane Component

35. Forms and dialog boxes in Java

36. Compositions in Java and creating servlets

37. Wizards in JBuilder, as well as questions on the topic

38. A little about HTML

39. Fundamentals of the JavaScript 1.5 programming language

40. JavaScript Language Syntax 1.5

41. The for…in loop and functions in JavaScript

42. Working with objects in JavaScript

43. Built-in JavaScript Objects

44. Subobjects of the document object

45. Math Object

46. ​​Drawings in HTML

47. Tables in HTML

48. Layers in HTML

49. CSS Style Sheets

Useful sites for a java programmer

How to Learn Java Programming - Complete Guide

Good day to all!

This article will describe how to create a 2D game in Java. I warn you right away, you should at least have a basic knowledge of the Java language, since I don’t have time to explain each line in detail. And I beg you, do not just write off the code, but try to understand what each line means, and write with meaning. Also, I use Eclipse, but you can use any IDE.

A task:

I'm planning to make a game that looks like a 3rd person shooter.

Start:

Well, let's get started!

First, let's create a project. Let's call it "Just game". And immediately we create the Display.java class. In it we write:

Now let's see what we did.

we create a frame that will be displayed when we start our game

set the operation that will occur when you click on the cross. EXIT_ON_CLOSE - exit the program

set our frame to the maximum size, remove decorations (minimize, close, reduce/enlarge buttons, etc.), i.e. making the game full screen. If you want the game not to be full screen then use:

Making the frame visible

Just don't forget, all frame settings must be written before you make it visible.

Well, now we press "Run" and try to start our game. If everything is written correctly, you should not have any errors and an empty, gray window should appear.

Gray window... How boring... Let's create something more interesting.

Let's create a new class called "Main". The Main class will be the panel that we will insert into the frame, so it must extend the JPanel. (For those who don't know, extend is written as extends after the class name)

We return to the Display class and after setting the frame, but before setting its visibility, we write:

You ask - "Well, why did we do this?". Imagine a picture. This picture is our final game. Now imagine a frame. With nothing inside, just an empty frame. Nothing can be drawn on it, it is useless. To do this, we inserted an empty sheet into the picture, on which the program can later draw a picture. This concludes our lyrical digression and return to the Main class.

We need to draw, so we need to add the paint method. For this we write:

Well, for starters, we can write a line drawing inside this method. For this we write:

Yeaaaaah, not too much...

Let's draw some picture. For example this one:

First, we need to specify the path to the image. To do this, not in the paint method, we write:

(we first need to throw a picture into our project and name it 2.png)

After that, we delete the line for drawing the line, and instead of it, we write to the paint method:

Let's take a closer look at the drawImage method, as we'll be touching on it often.

drawImage(the picture that we will draw, which we declared earlier, the X coordinate from which the picture will be drawn, the Y coordinate from which the picture will be drawn, paint);

Separately, I want to talk about the paint parameter. It's best to leave it null. I've only come across once when I needed to use paint. This was when I was rendering the text and giving it a font size. But I advise you not to go there and use null.

Now we run the program, and we see:

She's kinda small, isn't she? Let's learn how to increase its size. We add parameters to drawImage() so that it comes out:

It turns out:

Finally. Now we can stretch any picture to full screen. But here's the problem. The paint method is called only once. And how do you update it regularly? There is a very useful thing for this - a timer. Let's create it.

For this we write:

(20 is the frequency with which the timer is updated, this is where to execute the method when the timer is updated
We must enter this immediately after the class definition line, i.e. after:

Also, you need to add the class definition line like this:

After writing this line, your class name should be underlined in red. To fix this, add a method at the very end of the class:

This method will be executed when the timer is updated. In it we have to write repaint(); so that every time the timer is updated, all elements would be erased and redrawn.

Learn Java

To do this, we create the constructor of the Main class and write to it:

After that, you can not run the program, because nothing will change in it. Let's replace the house texture with a normal map texture. You can draw it yourself, or copy my test:

The size of the picture can be any, anyway, its size will be adjusted directly in the program. Oh yeah, computer permissions can be different, so let's add these things to the constructor:

And before the constructor add:

And we go back to the Display.java class and change the frame.add method a little there:

Thus, our frame will be passed to the Main.java class. We pass into this class, and where we have the paint() method, change the drawImage() line to:

Thus, now our game will draw the picture in full screen, regardless of its resolution. We launch:

That's all for today. I leave the code, for those who are confused:

Display.java

Main.java

How to create a java game?

There are a sufficient number of programming languages ​​for writing games. Their difficulty level is different. Experts believe that Java is the most suitable language for writing mobile applications. It is quite simple to learn. Therefore, in order to learn how to make games for mobile phones, you just need to be patient and make a little effort. And in this article we will show you how to write a game in Java.

Creation of mobile phone games

  1. First you need to install the necessary components:
  2. A set of emulators that will be used to test the written modules. This is the J2ME Wireless Toolkit.
  3. The compiler that is used to generate the archives. This is J2SE.
  4. Text editor.
  5. Next, you need to launch the WTK Toolbar application
  6. Create a new project using the File menu, New Project.
  7. Fill in the fields: project name and class. Press Ok. The new project will be located in the WTK program in the apps folder. The directory folders will contain the following:
  8. bin folder - executable files;
  9. res folder - resources;
  10. lib folder - libraries;
  11. src folder - source files.
  12. You need to carefully consider the storyline and graphics.
  13. In accordance with the chosen topic, write a program for a java game.
  14. Be sure to test it, first with an emulator, and then run it on your phone.
  15. To do this, you need to compile the project through the WTK editor, Build item.

    Materials for learning Java

    Press the Run button

  16. If there are no launch problems, you need to pack the application into 2 archives (.jad and .jar) to download to your phone.
  17. To do this, select the Project item. Next package. The archives that appeared in the bin folder must be downloaded to the phone.

Main difficulties

In order to understand how to make a java game, you need to know what difficulties every novice java game programmer has to face. This:

  • Hardware resource capabilities.
  • User satisfaction.
  • Game debugging.

hardware resources. Mobile device processors tend to be underpowered compared to those found in desktops or PDAs. Plus, quite often mobile devices do not have graphics accelerators. In this regard, it is necessary to analyze what the program spends the most time on. But you should not completely surrender to trying to prevent various delays in the game.

When writing programs where performance is the main headache, there is a proven approach: first you need to make it work, then you need to make it work right, and after that, you need to make it work quickly.

User satisfaction. When creating java games for mobile devices, there are factors that can negatively affect the opinion about the game:

  • First, because the screen is small, it's not easy to fit everything on it as it was intended;
  • Small keys are not very convenient to use, sometimes it prevents the player from achieving high results in the game;
  • Very limited audio capabilities.

When creating a game, all this must be taken into account. In order to interest users, it is necessary to create a noteworthy appearance for the game, good sound design and fairly convenient controls.

Debugging. This is the most labor intensive process. For this, it is most convenient to use an emulator, for example, WTK. Another good way to debug is the demo mode of the game. Ideally, in demo mode, all the functionality of the game should be involved. Now if you have a desire to make a mobile phone game, you know how to make a java game

Attention, only TODAY!

In this article I will try to explain the basics of programming in Delphi as simply and clearly as possible.

Java for dummies. Lesson 1. Program Hello World!

First, I'll tell you what Java can do. Firstly, in this language, you can write applets - programs that are embedded in the web page of the site. For example, it can be a game, a business graphics system, and much more. Secondly, you can write full-fledged applications in Java that are not necessarily related to the Web. And servlets are also possible - programs that, unlike applets, are executed not on the client side, but on the server side.

Let's start with the very basics. Let's pay tribute to tradition and write a simple program that displays a greeting on the screen hello world. If you don't have Java, then it can be downloaded from the official site http://www.java.com/en. Then install it.

If Java you have installed, then type in some editor the following text:

Public class HelloWorld {

public static void main ( String args ) {

System . out . print ( "Hello, world!" );

}

}

And be sure to save it under the name Hello World. java- the name of the executable class must match the name of the file. To compile, use the program javac.exe included in the standard package Java. Here's what a compilation batch file might look like this java file:

"c:\Program Files\Java\jdk1.7.0\bin\javac" HellowWorld.java

pause

If there are no errors during compilation:

then, most likely, the compilation was successful and you have it in the same directory where HellowWorld was. java HellowWorld also appeared.class:

Now let's run another batch file that will call the Java interpreter along with our compiled file:

"c:\Program Files\Java\jdk1.7.0\bin\java" HellowWorld

pause

If everything is done correctly, then you should get the following result:

If you got it, then I can congratulate you - you have written your first Java program. In the future, we will learn how to write Java applets, and much more. And now a few words about the program itself. As you can see, it starts with the word public. This is a modifier that means that we are declaring something public: a class, a class method, or a variable. There are other modifiers, for example: private, protected, friendly, final, abstract, static. Some of them can be combined with each other. For example, private means that the variable we want to declare is private to other classes. But we will get to the modifier. Now consider the following class keyword. It means that we are declaring a class. Everything in java is based on classes. One of the classes must be the base class. And the base class must be public. In this example, this is the HelloWord class. For now, he's the only one we have.

Now I will try to explain in simple terms what is Class and what is an object.

Recall the school course of zoology. How is the living world classified? First, the concept of "kingdom" is introduced.

1. The kingdom of unicellular,

2. plant kingdom

3. Animal Kingdom.

Let's take animals. They can be divided into types. For example:

1. Type intestinal.

2. Type flatworms.

3. Shellfish type.

4. Type chordates.

The latter are divided into mammals, reptiles, amphibians, birds, etc. You can delve even further into the classification, but now we will not do this, but will go directly to programming.

In the Java language, you can, like the classification of the living world, classify objects (pieces of program and data). It has classes for this.

Stop stop! - you say, - why classify these objects?

Imagine that you, like some kind of demiurge (creator, god), create life on Earth. First you developed the simplest organic compounds. So, for the sake of experiment, what happens. Then they combined them into complex molecules, from which, like bricks, they assembled the simplest microorganisms. But your ultimate goal is to create intelligent life. Therefore, you did not stop there, but created multicellular organisms. Then they began to improve and develop them. Some species were viable, some became extinct (dinosaurs). And finally, the goal was achieved - Homo Sapiens appeared - a reasonable person.

And now let's descend from heaven to earth and imagine programming as a creation, where you force your program to evolve to a certain state, when it can be used, and then further, gradually increasing and improving functionality.

And now let's imagine that an atom is the simplest command of a program or a unit of information (which, you see, are inseparable from each other, because the program works with something - correctly, with information).

Then the molecule is a subroutine. Or an object.

Here we have created a bunch of objects in our program. It is necessary to classify them somehow, so as not to get confused. That's what Java provides for classes ( class ). With the help of them, we describe a class of objects (a general concept, for example, birds), and then, having the described class, we can create an object - an instance of this class. That is, the class is the very word Birds, and the object is some kind of specific bird, if we continue our analogy.

Further, there are different types of birds. But they all have some common features inherited from the concept of "Birds". So in Java, you can create another class from a class that inherits its properties and methods (features). It is called inheritance.

Different birds have different colors of feathers, the shape of the beak and wings. So for classes, when creating a new class, inherited characteristics can be changed. It is called polymorphism.

So, with the basic concepts of Java figured out. Now let's go through the program.

This is how we declare the class:

public class HelloWorld {

In this case, there is only one class in our program, and this is the base class, that is, the class responsible for starting the program. That is why its name must match the file name, so that the interpreter "knows" where to start the program execution.

The base class (HelloWorld ) has a base method: main. We have declared it as public and static. The first one indicates that this method is public. If this were not so, then the program would simply not start. There are also methods that are not public, but we will talk about them in the next lessons, for now just remember that the base method (which we run when the program starts) must be public. And its name should be main so that the interpreter knows where to start executing the program.

Now what is static. This is a modifier that indicates that the method is static. That is, it works even when an instance of the class (object) has not been created. In general, fields and methods with the static modifier are common to all objects of the class. We will also talk about this later.

Each method may or may not have a return value. If it does, then it's a function. The return type is also set in the method declaration. If not, then put void (as in our example).

Access to the fields and methods of the object goes through a dot. There are also built-in objects, for example, System, which we use in our example:

System . out . print ( Hello world! );

in this case, we refer to the out field, which is also an object intended for data output, and call its print method, which displays text on the screen (as in the good old BASIC, the PRINT command).

(C) Shuravin Alexander

And creating websites are becoming more and more popular and attracting the attention of a huge number of people. Even a person without special education can start developing programs, the main thing is the desire and desire to learn new material and constant practice.

Study Options

Where to start learning to code from scratch? There are several ways to learn new material in this area. Private tutors will show you how to start learning programming from scratch and teach you important aspects of building code. However, this method is quite expensive, so the following training methods are mainly used:

  1. Specialized courses. Their cost is much less than the lessons of a personal tutor. It is worth noting that many employers react positively to the availability of various certificates of completion of training in computer academies. Pay attention to the courses of the world-famous companies Microsoft and Cisco.
  2. Remote free courses. There are a lot of services on the Internet with which you can view lecture courses from Oxford, Harvard and other famous educational institutions in the world. There are also special platforms for training practical programming skills. For more information about distance learning and useful Internet services, read later in the article.
  3. Self-learning. Where to start learning programming from scratch if you don't plan to sign up for courses and spend money? In this case, it is easiest to do self-education. You should start learning by reading the basics, do not delve into theory, immediately start practicing, because only in the process of creating a program will you acquire the necessary skills.

After choosing the training option that suits you, you should decide on the subject area, because programming has a fairly wide range of different branches.

How to choose the right direction?

It directly depends on the type of software that you will create in the future:

If the most important role for you is wages, turn your attention to the job market. Now the most popular are developers who specialize in Java, C#, ASP.NET, C++.

Low and high level languages. Difference and Applications

It is believed that all programming languages ​​are divided into high-level and low-level. Low-level code is easier for a computer to process, but writing it takes a lot of time and requires more domain knowledge. Such languages ​​(for example, assembler) are used to write software for digital circuits and microcontrollers. They are not very convenient for learning programming from scratch. Where to start writing the first programs will be prompted by the useful services and literature from world-famous authors given later in the article.

High-level languages ​​are much easier to use because they use built-in libraries to simplify and visualize code. Most modern software is written using high-level languages.

Programming from scratch: where to start applications?

The process of creating mobile programs allows programmers to work with the latest tools and, as a result, earn a decent amount of money through monetization. First you need to choose the site where you will work:

  1. Google play. Application store for users of the Android operating system. This OS has the largest share of users in the market. Java and C/C++ languages ​​are used to develop applications and games. The most popular applications are instant messengers, social networking clients, cloud storage, and games.
  2. Windows Mobile Store. This store is rapidly gaining popularity along with smartphones from Microsoft. In the CIS countries, most users prefer tablets on the Windows Phone platform. Programming applications for such a store helps to earn more money on monetization, because, unlike Android, almost all programs in the Windows store are distributed on a paid basis.
  3. App Store. Another profitable platform for development (language - Objective-C). The process of creating programs for Apple devices requires a pre-installed development environment called Xcode. The next step is to learn Objective-C programming from scratch. Where to start writing code, David Mark's book “Learning C for Mac. Second Edition".

Java language

Most professional developers recommend that you start learning programming with the Java language. It is easy to learn and at the same time in demand in the market. Use the tips below if you decide to learn programming from scratch. How to start Java development?

Java is a high-level object-oriented programming language that is needed to develop most modern web applications and games. During the compilation process (turning the written code into a language that the device can understand), the code is turned into a sequence of bytes, so the program can be easily tested on any Java virtual machine.

Programming from scratch. Where to start Java and Web coding?

The Java language is widely used in web development. Before you start a full-fledged programming process, you should learn Java, PHP, MySQL, HTML, CSS. A more detailed explanation of these concepts is given below:

  1. Java - used in writing utilities for sites and prescribing the logic of the functionality of web pages.
  2. PHP is a language for creating personal website pages. Has a script structure. The leading language in today's popular dynamic websites. PHP is needed to understand scripting and programming from scratch. Where to begin? From Josh Lockhut's book PHP: The Right Way.
  3. MySQL is a system for managing the basics of data. It is widely used in the creation of websites that require the storage of large amounts of grouped data.
  4. HTML is not a programming language. It is a markup language used to write the base of a web page (building blocks, distributing text and paragraphs, and so on).
  5. CSS - Cascading Style Sheet. Used only in conjunction with HTML to give the markup language style and appearance.

Once you understand the basic concepts behind these milestones, you can start building the professional, dynamic websites that are in high demand today.

Web programming. Relevance and features

The topic of Web-programming is especially relevant today. As mentioned above, to start developing web elements, you need to have a fairly large amount of knowledge about markup languages, scripting, logic and styles.

Now you will not surprise anyone with sites that are created only using HTML and CSS, so web developers who are able to make the site visually beautiful, as well as fill it with all the functionality necessary for users, have become in demand.

This type of development requires the creation of two types of the same program: server and client parts. The programmer must understand the principle of operation of the so-called sockets - data packets that allow you to transfer the necessary information flows over the network between the server and the client.

Creating applications for the Windows operating system

To develop such programs, you will need knowledge of the C# language. A free service from Microsoft called Virtual Academy will allow you to learn all the features of this language and practice writing simple applications.

According to the new Microsoft policy, all applications are laid out in the software store, so you can get access to the monetization of your project.

C family of languages ​​(C, C++, C#). Peculiarities

Programming from scratch - where to start choosing a language? The answer to this question can be obtained by delving into the types of application creation technologies in more detail. The relevance of a particular language should also be taken into account.

The C, C++, C# languages ​​have one thing in common - the presence of the OOP (object-oriented programming) function. This technology greatly simplifies the process of writing program code. Each program object is described in a specific class and has its own parameters, methods and properties. Thus, the programmer does not have to write huge pieces of code each time if the same object needs to be used several times.

Useful Internet services for learning the basic principles of programming and the code structure of any application

At the first stage of learning, almost any web service will offer you to try out its capabilities using Pascal, the simplest of high-level languages. It is used for educational purposes, it is taught in schools and technical schools so that students can understand programming from scratch. How to start Pascal coding? First of all, you need to download the development environment to your PC. This is a small executable file in which you have to write the program code. Use TurboPascal, because it is the most popular environment for learning this programming language.

HourOfCode is a web service from Microsoft. It is designed to clearly show students what a cycle, variable, class, conditions are. The learning process is like a game.

CodeAcademy is a powerful resource for learning almost any coding technology. Devoting just an hour a day, you will not notice how you learn to program and create your own projects.

Udacity is a service that provides its users with free access to lectures by eminent professors and developers.

Gaining initial experience. Freelance

After learning the basic principles of your chosen language, you can safely proceed to your first projects. Start freelancing, because this is how you fill your portfolio and gain experience in communicating with customers. Such skills will come in handy in the future if you want to get a job in a company for an official position as a software developer.

Outcome

Programming from scratch: where to start? For dummies, professors from world-famous universities advise you to practice with the basic structures that form the basis of any programming language. Sign up for specialized courses or self-study by listening to lectures online.

Top Related Articles