Java hello world
Java hello world
«Hello World!» for Microsoft Windows
It’s time to write your first application! The following instructions are for users of Windows Vista, Windows 7, and Windows 8. Instructions for other platforms are in «Hello World!» for Solaris OS, Linux, and Mac OS X and «Hello World!» for the NetBeans IDE.
A Checklist 
To write your first program, you’ll need:
The Java SE Development Kit 8 (JDK 8)
In this example, we’ll use Notepad, a simple editor included with the Windows platforms. You can easily adapt these instructions if you use a different text editor.
These two items are all you’ll need to write your first application.
Creating Your First Application
Create a source file
A source file contains code, written in the Java programming language, that you and other programmers can understand. You can use any text editor to create and edit source files.
The Java programming language compiler ( javac ) takes your source file and translates its text into instructions that the Java virtual machine can understand. The instructions contained within this file are known as bytecodes.
The Java application launcher tool ( java ) uses the Java virtual machine to run your application.
Create a Source File
To create a source file, you have two options:
Or, you can use the following (longer) instructions.
First, start your editor. You can launch the Notepad editor from the Start menu by selecting Programs > Accessories > Notepad. In a new document, type in the following code:
Be Careful When You Type
Note: Type all code, commands, and file names exactly as shown. Both the compiler ( javac ) and launcher ( java ) are case-sensitive, so you must capitalize consistently.
The Save As dialog just before you click Save.
Now click Save, and exit Notepad.
The prompt shows your current directory. When you bring up the prompt, your current directory is usually your home directory for Windows XP (as shown in the preceding figure.
To compile your source file, change your current directory to the directory where your file is located. For example, if your source directory is myapplication on the C drive, type the following command at the prompt and press Enter:
If you enter dir at the prompt, you should see your source file, as follows:
Now you are ready to compile. At the prompt, type the following command and press Enter.
If you encounter problems with the instructions in this step, consult the Common Problems (and Their Solutions).
Run the Program
In the same directory, enter the following command at the prompt:
You should see the following on your screen:
Congratulations! Your program works!
If you encounter problems with the instructions in this step, consult the Common Problems (and Their Solutions).
Lesson: The «Hello World!» Application
The sections listed below provide detailed instructions for compiling and running a simple «Hello World!» application. The first section provides information on getting started with the NetBeans IDE, an integrated development environment that greatly simplifies the software development process. The NetBeans IDE runs on all of the platforms listed below. The remaining sections provide platform-specific instructions for getting started without an integrated development environment. If you run into problems, be sure to consult the common problems section; it provides solutions for many issues encountered by new users.
«Hello World!» for the NetBeans IDE These instructions are for users of the NetBeans IDE. The NetBeans IDE runs on the Java platform, which means that you can use it with any operating system for which there is a JDK 7 available. These operating systems include Microsoft Windows, Solaris OS, Linux, and Mac OS X. We recommend using the NetBeans IDE instead of the command line whenever possible.
«Hello World!» for Microsoft Windows These command-line instructions are for users of Windows XP Professional, Windows XP Home, Windows Server 2003, Windows 2000 Professional, and Windows Vista.
«Hello World!» for Solaris OS, Linux, and Mac OS X These command-line instructions are for users of Solaris OS, Linux, and Mac OS X. Common Problems (and Their Solutions) Consult this page if you have problems compiling or running your application.
«Hello World!» for the NetBeans IDE
It’s time to write your first application! These detailed instructions are for users of the NetBeans IDE. The NetBeans IDE runs on the Java platform, which means that you can use it with any operating system for which there is a JDK available. These operating systems include Microsoft Windows, Solaris OS, Linux, and Mac OS X.
A Checklist 
To write your first program, you’ll need:
The Java SE Development Kit (JDK 7 has been selected in this example)
Creating Your First Application
Create an IDE project
When you create an IDE project, you create an environment in which to build and run your applications. Using IDE projects eliminates configuration issues normally associated with developing on the command line. You can build or run your application by choosing a single menu item within the IDE.
Add code to the generated source file
A source file contains code, written in the Java programming language, that you and other programmers can understand. As part of creating an IDE project, a skeleton source file will be automatically generated. You will then modify the source file to add the «Hello World!» message.
The IDE invokes the Java application launcher tool ( java ), which uses the Java virtual machine to run your application.
Create an IDE Project
To create an IDE project:
Launch the NetBeans IDE.
On Microsoft Windows systems, you can use the NetBeans IDE item in the Start menu.
On Mac OS X systems, click the NetBeans IDE application icon.
NetBeans IDE with the File | New Project menu item selected.
In the New Project wizard, expand the Java category and select Java Application as shown in the following figure:
NetBeans IDE, New Project wizard, Choose Project page.
In the Name and Location page of the wizard, do the following (as shown in the figure below):
NetBeans IDE, New Project wizard, Name and Location page.
The project is created and opened in the IDE. You should see the following components:
The Projects window, which contains a tree view of the components of the project, including source files, libraries that your code depends on, and so on.
The Source Editor window with a file called HelloWorldApp.java open.
The Navigator window, which you can use to quickly navigate between elements within the selected class.
NetBeans IDE with the HelloWorldApp project open.
Add JDK 8 to the Platform List (if necessary)
It may be necessary to add JDK 8 to the IDE’s list of available platforms. To do this, choose Tools | Java Platforms as shown in the following figure:
Selecting the Java Platform Manager from the Tools Menu
If you don’t see JDK 8 (which might appear as 1.8 or 1.8.0) in the list of installed platforms, click Add Platform, navigate to your JDK 8 install directory, and click Finish. You should now see this newly added platform:
The Java Platform Manager
To specify this JDK for the current project only, select Hello World App in the Projects pane, choose File | Project Properties (Hello World App), click Libraries, then select JDK 1.8 in the Java Platform pulldown menu. You should see a screen similar to the following:
The IDE is now configured for JDK 8.
Add Code to the Generated Source File
When you created this project, you left the Create Main Class checkcbox selected in the New Project wizard. The IDE has therefore created a skeleton class for you. You can add the «Hello World!» message to the skeleton code by replacing the line:
Optionally, you can replace these four lines of generated code:
These four lines are a code comment and do not affect how the program runs. Later sections of this tutorial explain the use and format of code comments.
Be Careful When You Type
Note: Type all code, commands, and file names exactly as shown. Both the compiler ( javac ) and launcher ( java ) are case-sensitive, so you must capitalize consistently.
Save your changes by choosing File | Save.
The file should look something like the following:
To compile your source file, choose Run | Build Project (Hello World App) from the IDE’s main menu.
The Output window opens and displays output similar to what you see in the following figure:
Output window showing results of building the HelloWorld project.
When you build the project, the bytecode file HelloWorldApp.class is generated. You can see where the new file is generated by opening the Files window and expanding the Hello World App/build/classes/helloworldapp node as shown in the following figure.
Now that you have built the project, you can run your program.
Run the Program
From the IDE’s menu bar, choose Run | Run Main Project.
The next figure shows what you should now see.
The program prints «Hello World!» to the Output window (along with other output from the build script).
Congratulations! Your program works!
Continuing the Tutorial with the NetBeans IDE
The next few pages of the tutorial will explain the code in this simple application. After that, the lessons go deeper into core language features and provide many more examples. Although the rest of the tutorial does not give specific instructions about using the NetBeans IDE, you can easily use the IDE to write and run the sample code. The following are some tips on using the IDE and explanations of some IDE behavior that you are likely to see:
Once you have created a project in the IDE, you can add files to the project using the New File wizard. Choose File | New File, and then select a template in the wizard, such as the Empty Java File template.
You can compile and run an individual file (as opposed to a whole project) using the IDE’s Compile File (F9) and Run File (Shift-F6) commands. If you use the Run Main Project command, the IDE will run the file that the IDE associates as the main class of the main project. Therefore, if you create an additional class in your HelloWorldApp project and then try to run that file with the Run Main Project command, the IDE will run the HelloWorldApp file instead.
You might want to create separate IDE projects for sample applications that include more than one source file.
As you are typing in the IDE, a code completion box might periodically appear. You can either ignore the code completion box and keep typing, or you can select one of the suggested expressions. If you would prefer not to have the code completion box automatically appear, you can turn off the feature. Choose Tools | Options | Editor, click the Code Completion tab and clear the Auto Popup Completion Window check box.
If you want to rename the node for a source file in the Projects window, choose Refactor from IDE’s main menu. The IDE prompts you with the Rename dialog box to lead you through the options of renaming the class and the updating of code that refers to that class. Make the changes and click Refactor to apply the changes. This sequence of clicks might seem unnecessary if you have just a single class in your project, but it is very useful when your changes affect other parts of your code in larger projects.
For a more thorough guide to the features of the NetBeans IDE, see the NetBeans Documentation page.
«Hello World!» for Solaris OS, Linux, and Mac OS X
It’s time to write your first application! These detailed instructions are for users of Solaris OS, Linux, and Mac OS X. Instructions for other platforms are in «Hello World!» for Microsoft Windows and «Hello World!» for the NetBeans IDE.
A Checklist 
To write your first program, you’ll need:
The Java SE Development Kit 8 (JDK 8)
These two items are all you’ll need to write your first application.
Creating Your First Application
Create a source file
A source file contains code, written in the Java programming language, that you and other programmers can understand. You can use any text editor to create and edit source files.
The Java application launcher tool ( java ) uses the Java virtual machine to run your application.
Create a Source File
To create a source file, you have two options:
You can save the file HelloWorldApp.java on your computer and avoid a lot of typing. Then, you can go straight to Compile the Source File.
Or, you can use the following (longer) instructions.
First, open a shell, or «terminal,» window.
A new terminal window.
When you first bring up the prompt, your current directory will usually be your home directory. You can change your current directory to your home directory at any time by typing cd at the prompt and then pressing Return.
To change your current directory to this new directory, you then enter:
Now you can start creating your source file.
When you start Pico, it’ll display a new, blank buffer. This is the area in which you will type your code.
Type the following code into the new buffer:
Be Careful When You Type
Note: Type all code, commands, and file names exactly as shown. Both the compiler ( javac ) and launcher ( java ) are case-sensitive, so you must capitalize consistently.
You can type Ctrl-X to exit Pico.
If you enter ls at the prompt, you should see your file.
Now are ready to compile the source file. At the prompt, type the following command and press Return.
If you encounter problems with the instructions in this step, consult the Common Problems (and Their Solutions).
Run the Program
In the same directory, enter at the prompt:
The next figure shows what you should now see.
The output prints «Hello World!» to the screen.
Congratulations! Your program works!
If you encounter problems with the instructions in this step, consult the Common Problems (and Their Solutions).
Java hello world
Π ΡΡΠΎΠΌ ΡΡΠΎΠΊΠ΅ ΠΌΡ ΡΠΎΠ·Π΄Π°Π΄ΠΈΠΌ Π½Π°ΡΡ ΠΏΠ΅ΡΠ²ΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π½Π° ΡΠ·ΡΠΊΠ΅ Java.
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Π½Π° ΡΠ·ΡΠΊΠ΅ Java ΡΠΎΡΡΠΎΠΈΡ ΠΈΠ· ΡΡΠ΅Ρ
ΡΠ»Π΅Π΄ΡΡΡΠΈΡ
ΡΠ°Π³ΠΎΠ²:
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΈΡΡ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΡΠ°ΠΉΠ»Π°
ΠΡΠ°ΠΊ, ΠΎΡΠΊΡΡΠ²Π°Π΅ΠΌ ΡΠ΅ΠΊΡΡΠΎΠ²ΡΠΉ ΡΠ΅Π΄Π°ΠΊΡΠΎΡ ΠΈ ΠΏΠΈΡΠ΅ΠΌ Π² Π½Π΅ΠΌ ΠΊΠΎΠ΄ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Hello World, ΡΠ΅Π»Ρ ΠΊΠΎΡΠΎΡΠΎΠΉ β Π²ΡΠ²ΠΎΠ΄ Π½Π° ΡΠΊΡΠ°Π½ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΡ Hello World!
ΠΡΠ»ΠΈ Π²Ρ ΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΠ΅ΡΡ Notepad++ ΡΠΎ Π½ΡΠΆΠ½ΠΎ Π²ΡΠ±ΡΠ°ΡΡ Π’ΠΈΠΏ ΡΠ°ΠΉΠ»Π°:Java source file (*.java)
ΠΡΠ΄ΡΡΠ΅ Π²Π½ΠΈΠΌΠ°ΡΠ΅Π»ΡΠ½Ρ! ΡΠ°ΠΉΠ» Π΄ΠΎΠ»ΠΆΠ΅Π½ Π½Π°Π·ΡΠ²Π°ΡΡΡΡ Π² ΡΠΎΡΠ½ΠΎΡΡΠΈ ΡΠ°ΠΊ, ΠΊΠ°ΠΊ Π½Π°Π·ΡΠ²Π°Π΅ΡΡΡ Π½Π°Ρ ΠΊΠ»Π°ΡΡ β HelloWorld. Π’Π°ΠΊ ΠΆΠ΅ Π²Π°ΠΆΠ½ΠΎ ΡΡΠΈΡΡΠ²Π°ΡΡ ΡΠ΅Π³ΠΈΡΡΡ Π±ΡΠΊΠ². HelloWorld ΠΈ helloworld Π² Π΄Π°Π½Π½ΠΎΠΌ ΡΠ»ΡΡΠ°Π΅ ΡΡΠΎ ΡΠ°Π·Π½ΡΠ΅ ΡΠ»ΠΎΠ²Π°!
ΠΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΡ ΠΈΡΡ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΡΠ°ΠΉΠ»Π°
ΠΡΡ ΠΎΠ΄Π½ΡΠΉ ΡΠ°ΠΉΠ» Ρ ΠΊΠΎΠ΄ΠΎΠΌ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ ΡΠΎΠ·Π΄Π°Π½, ΡΠ΅ΠΏΠ΅ΡΡ ΠΏΠ΅ΡΠ΅ΠΉΠ΄Π΅ΠΌ ΠΊ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ. ΠΠ»Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ Java ΠΏΡΠ΅Π΄Π½Π°Π·Π½Π°ΡΠ΅Π½ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡ javac, ΠΊΠΎΡΠΎΡΡΠΉ Π²Ρ ΠΎΠ΄ΠΈΡ Π² ΡΠΎΡΡΠ°Π² ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½Π½ΠΎΠ³ΠΎ Π½Π°ΠΌΠΈ Π² ΠΏΠ΅ΡΠ²ΠΎΠΌ ΡΡΠΎΠΊΠ΅ ΠΏΠ°ΠΊΠ΅ΡΠ° JDK.
ΠΠ»Ρ ΡΠΎΠ³ΠΎ, ΡΡΠΎΠ±Ρ ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡ ΠΈΡΡ ΠΎΠ΄Π½ΡΠΉ ΡΠ°ΠΉΠ», ΠΎΡΠΊΡΡΠ²Π°Π΅ΠΌ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΡΡ ΡΡΡΠΎΠΊΡ. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ Π² ΠΌΠ΅Π½Ρ Windows ΠΡΡΠΊ Π² ΡΡΡΠΎΠΊΠ΅ ΠΏΠΎΠΈΡΠΊΠ° Π²Π²ΠΎΠ΄ΠΈΠΌ ΠΊΠΎΠΌΠ°Π½Π΄Ρ cmd ΠΈ ΠΆΠΌΠ΅ΠΌ Enter. ΠΠΎΡΠ»Π΅ ΡΡΠΎΠ³ΠΎ ΠΎΡΠΊΡΠΎΠ΅ΡΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠ΅ ΠΎΠΊΠ½ΠΎ.
Π’Π΅ΠΏΠ΅ΡΡ Π² Π½Π΅ΠΌ Π½ΡΠΆΠ½ΠΎ ΠΈΠ·ΠΌΠ΅Π½ΠΈΡΡ ΡΠ΅ΠΊΡΡΠΈΠΉ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ Π½Π° ΡΠΎΡ, Π² ΠΊΠΎΡΠΎΡΠΎΠΌ Π½Π°Ρ ΠΎΠ΄ΠΈΡΡΡ Π½Π°Ρ ΠΈΡΡ ΠΎΠ΄Π½ΡΠΉ ΡΠ°ΠΉΠ» (Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ C:\studyjava\). ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ Π²Π²ΠΎΠ΄ΠΈΠΌ ΡΠ»Π΅Π΄ΡΡΡΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ:
ΠΠΎΡΠ»Π΅ ΡΠΎΠ³ΠΎ, ΠΊΠ°ΠΊ Π΄ΠΈΡΠ΅ΠΊΡΠΎΡΠΈΡ ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»Π°ΡΡ, Π²Π²ΠΎΠ΄ΠΈΠΌ ΠΊΠΎΠΌΠ°Π½Π΄Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ
ΠΠΎΡΠ»Π΅ ΡΡΠΎΠ³ΠΎ, ΠΎΠΊΠ½ΠΎ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠΈ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π²ΡΠ³Π»ΡΠ΄Π΅ΡΡ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ (ΡΠΈΡ 2.2):
Π’ΠΎ Π΅ΡΡΡ, ΠΌΡ Π½Π΅ ΠΏΠΎΠ»ΡΡΠΈΠΌ Π½ΠΈΠΊΠ°ΠΊΠΎΠ³ΠΎ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠΆΠ΄Π΅Π½ΠΈΡ, ΠΎ ΡΠΎΠΌ, ΡΡΠΎ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°Π»Π°ΡΡ ΡΡΠΏΠ΅ΡΠ½ΠΎ. ΠΠ΄Π½Π°ΠΊΠΎ, Π² ΠΏΠ°ΠΏΠΊΠ΅ Ρ Π½Π°ΡΠΈΠΌ ΠΈΡΡ ΠΎΠ΄Π½ΡΠΌ ΡΠ°ΠΉΠ»ΠΎΠΌ, Π΄ΠΎΠ»ΠΆΠ΅Π½ ΠΏΠΎΡΠ²ΠΈΡΡΡΡ ΡΠ°ΠΉΠ» HelloWorld.class. ΠΡΠΎ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ
ΠΡΠ° ΠΊΠΎΠΌΠ°Π½Π΄Π° Π²ΡΠ²ΠΎΠ΄ΠΈΡ Π½Π° ΡΠΊΡΠ°Π½ ΡΠΏΠΈΡΠΎΠΊ Π²ΡΠ΅Ρ ΡΠ°ΠΉΠ»ΠΎΠ², Π½Π°Ρ ΠΎΠ΄ΡΡΠΈΡ ΡΡ Π² Π²ΡΠ±ΡΠ°Π½Π½ΠΎΠΉ Π΄ΠΈΡΠ΅ΠΊΡΠΎΡΠΈΠΈ (ΡΠΈΡ 2.3).
ΠΡΠ»ΠΈ ΡΠ°ΠΉΠ» HelloWorld.class ΠΏΡΠΈΡΡΡΡΡΠ²ΡΠ΅Ρ Π² ΡΡΠΎΠΌ ΡΠΏΠΈΡΠΊΠ΅, ΡΠΎ ΡΡΠΎ Π·Π½Π°ΡΠΈΡ, ΡΡΠΎ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°Π»Π°ΡΡ ΡΡΠΏΠ΅ΡΠ½ΠΎ.
ΠΡΠ»ΠΈ Π² ΠΊΠΎΠ΄Π΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π΅ΡΡΡ ΠΎΡΠΈΠ±ΠΊΠ°, ΡΠΎ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡ Java ΠΏΡΠΈ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ Π½Π°ΠΌ ΠΎΠ± ΡΡΠΎΠΌ ΡΠΎΠΎΠ±ΡΠΈΡ.
ΠΡΠΎΠ²Π΅Π΄Π΅ΠΌ ΡΠΊΡΠΏΠ΅ΡΠΈΠΌΠ΅Π½Ρ: ΠΡΠΊΡΠΎΠ΅ΠΌ Π² ΡΠ΅ΠΊΡΡΠΎΠ²ΠΎΠΌ ΡΠ΅Π΄Π°ΠΊΡΠΎΡΠ΅ Π½Π°Ρ ΡΠ°ΠΉΠ» HelloWorld.java ΠΈ ΡΠ΄Π°Π»ΠΈΠΌ ΠΏΠΎΡΠ»Π΅Π΄Π½ΡΡ Π·Π°ΠΊΡΡΠ²Π°ΡΡΡΡΡΡ ΡΠΈΠ³ΡΡΠ½ΡΡ ΡΠΊΠΎΠ±ΠΊΡ Β«>Β». Π‘ΠΎΡ ΡΠ°Π½ΠΈΠΌ ΡΠ°ΠΉΠ» ΠΈ ΠΏΠΎΠΏΡΠΎΠ±ΡΠ΅ΠΌ Π΅Π³ΠΎ Π΅ΡΠ΅ ΡΠ°Π· ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡ. Π ΠΈΡΠΎΠ³Π΅ ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ ΠΎΠ± ΠΎΡΠΈΠ±ΠΊΠ΅ (ΡΠΈΡ 2.4).
Π§ΡΠΎΠ±Ρ ΠΈΡΠΏΡΠ°Π²ΠΈΡΡ ΠΎΡΠΈΠ±ΠΊΡ, Π½ΡΠΆΠ½ΠΎ Π²Π½ΠΎΠ²Ρ ΠΎΡΠΊΡΡΡΡ ΡΠ°ΠΉΠ» Π΄Π»Ρ ΡΠ΅Π΄Π°ΠΊΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ, ΡΡΡΡΠ°Π½ΠΈΡΡ ΠΎΡΠΈΠ±ΠΊΡ, ΡΠΎΡ ΡΠ°Π½ΠΈΡΡ ΡΠ°ΠΉΠ» ΠΈ Π΅ΡΠ΅ ΡΠ°Π· Π΅Π³ΠΎ ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡ.
ΠΠ°ΠΏΡΡΠΊ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ
ΠΠ΅ΡΠ΅Ρ ΠΎΠ΄ΠΈΠΌ ΠΊ ΠΏΠΎΡΠ»Π΅Π΄Π½Π΅ΠΉ ΡΡΠ°Π΄ΠΈΠΈ β Π·Π°ΠΏΡΡΠΊΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ.
ΠΠ²ΠΎΠ΄ΠΈΠΌ Π² ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΌ ΠΎΠΊΠ½Π΅:
ΠΈ Π΅ΡΠ»ΠΈ Π²ΡΠ΅ ΠΏΠ΅ΡΠ΅Π΄ ΡΡΠΈΠΌ Π±ΡΠ»ΠΎ ΡΠ΄Π΅Π»Π°Π½ΠΎ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎ, ΡΠΎ ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ β Π²ΡΠ²ΠΎΠ΄ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΡ Β«Hello World!Β» (ΡΠΈΡ 2.5).
ΠΡΠ΅ ΡΠ°Π· ΠΎΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅ Π½Π° ΡΡΠ²ΡΡΠ²ΠΈΡΠ΅Π»ΡΠ½ΠΎΡΡΡ ΠΊ ΡΠ΅Π³ΠΈΡΡΡΡ Π² Java. ΠΡΠ»ΠΈ Π²Ρ Π½Π°ΠΏΠΈΡΠ΅ΡΠ΅ helloworld Π²ΠΌΠ΅ΡΡΠΎ HelloWorld, ΡΠΎ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° Π·Π°ΠΏΡΡΠ΅Π½Π° Π½Π΅ Π±ΡΠ΄Π΅Ρ, ΠΏΠΎΡΠΎΠΌΡ ΡΡΠΎ Java ΠΏΠΎΠΏΡΠΎΡΡΡ Π½Π΅ Π½Π°ΠΉΠ΄Π΅Ρ ΡΠ°ΠΉΠ» Ρ ΡΠ°ΠΊΠΈΠΌ ΠΈΠΌΠ΅Π½Π΅ΠΌ.
Π ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ Π΄ΠΎΠΌΠ°ΡΠ½Π΅Π³ΠΎ Π·Π°Π΄Π°Π½ΠΈΡ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΠΏΠΎΡΠΊΡΠΏΠ΅ΡΠΈΠΌΠ΅Π½ΡΠΈΡΠΎΠ²Π°ΡΡ ΠΈ Π²ΡΠ²ΠΎΠ΄ΠΈΡΡ Π½Π° ΡΠΊΡΠ°Π½ ΠΊΠ°ΠΊΠΎΠ΅-Π»ΠΈΠ±ΠΎ ΡΠ²ΠΎΠ΅ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ Π²ΠΌΠ΅ΡΡΠΎ Hello World!.
Java IDL: The «Hello World» Example
POA model, transient server
This document is a high-level overview of how to create a complete CORBA (Common Object Request Broker Architecture) application using IDL (Interface Definiton Language) to define interfaces and the Java IDL compiler to generate stubs and skeletons. For more information on the development process, and a more detailed tutorial on creating a CORBA application using IDL, see Getting Started with Java IDL: The Hello World Tutorial. You can also create CORBA application by defining the interfaces in the Java programming language. For more information and a tutorial on this development process, see the Java RMI-IIOP documentation.
In this release of Java SE, the server-side implementation generated by the idlj compiler is the Portable Servant Inheritance Model, also known as the POA model. The POA, or Portable Object Adapter, is discussed in more detail in Portable Object Adapter. This document presents a sample application created using the default behavior of the idlj compiler, which uses a POA server-side model.
CORBA supports at least two different server-side mappings for implementing an IDL interface:
Using the Inheritance Model, you implement the IDL interface using an implementation class that also extends the compiler-generated skeleton.
Inheritance models include:
NOTE: ImplBase is deprecated in favor of the POA model, but is provided to allow compatibility with servers written in J2SE 1.3 and prior. We do not recommend creating new servers using this nonstandard model.
Using the Delegation Model, you implement the IDL interface using two classes:
The Delegation model is also known as the Tie model, or the Tie Delegation model. It inherits from either the POA or ImplBase compiler-generated skeleton, so the models will be described as POA/Tie or ImplBase/Tie models in this document.
This tutorial presents the POA Inheritance model for server-side implementation. For tutorials using the other server-side implementations, see the following documents:
The Tie Model is a delegation model. Use the idlj compiler to first generate server-side bindings. Then, run the idlj compiler a second time with the with the -fallTie option to generate Tie model server-side bindings. For the interface Hello, HelloPOATie.java is one of the generated files. The constructor to HelloPOATie takes a delegate or a delegate and a poa. You must provide the implementation for delegate and/or the poa, but the delegate does not have to inherit from any other class, only the interface HelloOperations. For more information, refer to the IDL to Java Language Mapping Specification.
The ImplBase server-side model is an Inheritance Model, as is the POA model. Use the idlj compiler with the -oldImplBase flag to generate server-side bindings that are compatible with versions of Java IDL prior to J2SE 1.4. Given an interface Hello defined in Hello.idl, the file _HelloImplBase.java is generated. You must provide the implementation for Hello and it must inherit from _HelloImplBase.
Note that using the -oldImplBase flag is non-standard: these APIs are being deprecated. You would use this flag ONLY for compatibility with existing servers written in J2SE 1.3 or earlier. In that case, you would need to modify an existing MAKEFILE to add the -oldImplBase flag to the idlj compiler, otherwise POA-based server-side mappings will be generated.
This document contains:
To create this example, create a directory named hello/ where you develop sample applications and create the files in this directory, or download the example code and unzip it into your sample applications directory.
Defining the Interface ( Hello.idl )
The first step to creating a CORBA application is to specify all of your objects and their interfaces using the OMG’s Interface Definition Language (IDL). IDL has a syntax similar to C++ and can be used to define modules, interfaces, data structures, and more. The IDL can be mapped to a variety of programming languages. The IDL mapping for Java is summarized in IDL to Java Language Mapping Summary.
The following code is written in the OMG IDL, and describes a CORBA object whose sayHello() operation returns a string and whose shutdown() method shuts down the ORB. To learn more about OMG IDL Syntax and Semantics, read Chapter 3 of the CORBA 2.3.1 Specification.
Hello.idl
NOTE: When writing code in OMG IDL, do not use an interface name as the name of a module. Doing so runs the risk of getting inconsistent results when compiling with tools from different vendors, thereby jeopardizing the code’s portability. For example, code containing the same names could be compiled with the IDL to Java compiler from Sun Microsystems and get one result. The same code compiled with another vendor’s IDL to Java compiler could produce a different result.
To complete the application, you simply provide the server ( HelloServer.java ) and client ( HelloClient.java ) implementations.
Implementing the Server ( HelloServer.java )
The example server consists of two classes, the servant and the server. The servant, HelloImpl, is the implementation of the Hello IDL interface; each Hello instance is implemented by a HelloImpl instance. The servant is a subclass of HelloPOA, which is generated by the idlj compiler from the example IDL. The servant contains one method for each IDL operation, in this example, the sayHello() and shutdown() methods. Servant methods are just like ordinary Java methods; the extra code to deal with the ORB, with marshaling arguments and results, and so on, is provided by the skeleton.
The HelloServer class has the server’s main() method, which:
This example provides an example of a transient object server. For an example of the «Hello World» program with a persistent object server, see Example 2: Hello World with Persistent State. For more discussion of CORBA servers, see Developing Servers.
For more discussion of the code, see the detailed tutorial topic Getting Started with Java IDL: Developing a Hello World Server.
HelloServer.java
Implementing the Client Application ( HelloClient.java )
The example application client that follows:
HelloClient.java
Building and Running Hello World
Despite its simple design, the Hello World program lets you learn and experiment with all the tasks required to develop almost any CORBA program that uses static invocation. Static invocation, which uses a client stub for the invocation and a server skeleton for the service being invoked, is used when the interface of the object is known at compile time. If the interface is not known at compile time, dynamic invocation must be used.
This example requires a naming service, which is a CORBA service that allows CORBA objects to be named by means of binding a name to an object reference. The name binding may be stored in the naming service, and a client may supply the name to obtain the desired object reference. The two options for Naming Services shipped with this release of Java SE include orbd (Solaris, Linux, or Mac OS X or Windows), a daemon process containing a Bootstrap Service, a Transient Naming Service, a Persistent Naming Service, and a Server Manager, and tnameserv (Solaris, Linux, or Mac OS X or Windows), a transient naming service that is provided for backward compatibility. This example uses orbd.
When running this example, remember that, when using Solaris software, you must become root to start a process on a port under 1024. For this reason, we recommend that you use a port number greater than or equal to 1024. The -ORBInitialPort option is used to override the default port number in this example. The following instructions assume you can use port 1050 for the Java IDL Object Request Broker Daemon, orbd. You can substitute a different port if necessary. When running these examples on a Windows machine, subtitute a backslash (\) in path names.
To run this client-server application on your development machine:
You must use the -fall option with the idlj compiler to generate both client and server-side bindings. This command line will generate the default server-side bindings, which assumes the POA Inheritance server-side model. For more information on the idlj options, see the man page for idlj (Solaris, Linux, or Mac OS X or Windows).
The idlj compiler generates a number of files. The actual number of files generated depends on the options selected when the IDL file is compiled. The generated files provide standard functionality, so you can ignore them until it is time to deploy and run your program. The files generated by the idlj compiler for Hello.idl, with the -fall command line option, are:
This class is the client stub, providing CORBA functionality for the client. It extends org.omg.CORBA.portable.ObjectImpl and implements the Hello.java interface.
This interface contains the Java version of our IDL interface. The Hello.java interface extends org.omg.CORBA.Object, providing standard CORBA object functionality. It also extends the HelloOperations interface and org.omg.CORBA.portable.IDLEntity.
This class provides auxiliary functionality, notably the narrow() method required to cast CORBA object references to their proper types.The Helper class is responsible for reading and writing the data type to CORBA streams, and inserting and extracting the data type from Anys. The Holder class delegates to the methods in the Helper class for reading and writing.
This final class holds a public instance member of type Hello. Whenever the IDL type is an out or an inout parameter, the Holder class is used. It provides operations for org.omg.CORBA.portable.OutputStream and org.omg.CORBA.portable.InputStream arguments, which CORBA allows, but which do not map easily to Java’s semantics. The Holder class delegates to the methods in the Helper class for reading and writing. It implements org.omg.CORBA.portable.Streamable.
This interface contains the methods sayHello() and shutdown(). The IDL-to-Java mapping puts all of the operations defined on the IDL interface into this file, which is shared by both the stubs and skeletons.
To start orbd from a Solaris, Linux, or Mac OS X command shell, enter:
From an MS-DOS system prompt (Windows), enter:
Note that 1050 is the port on which you want the name server to run. The -ORBInitialPort argument is a required command-line argument. Note that when using Solaris software, you must become root to start a process on a port under 1024. For this reason, we recommend that you use a port number greater than or equal to 1024.
For an example of how to run this program on two machines, see Running the Hello World Program on 2 machines.
To start the Hello server from a Solaris, Linux, or Mac OS X command shell, enter:
From an MS-DOS system prompt (Windows), enter:
You will see HelloServer ready and waiting. when the server is started.
For this example, you can omit -ORBInitialHost localhost since the name server is running on the same host as the Hello server. If the name server is running on a different host, use -ORBInitialHost nameserverhost to specify the host on which the IDL name server is running.
Specify the name server (orbd) port as done in the previous step, for example, -ORBInitialPort 1050.
When the client is running, you will see a response such as the following on your terminal: Obtained a handle on server object: IOR: (binary code) Hello World! HelloServer exiting.
For this example, you can omit -ORBInitialHost localhost since the name server is running on the same host as the Hello client. If the name server is running on a different host, use -ORBInitialHost nameserverhost to specify the host on which the IDL name server is running.
Specify the name server (orbd) port as done in the previous step, for example, -ORBInitialPort 1050.
When you have finished this tutorial, be sure to shut down or kill the name server (orbd). To do this from a DOS prompt, select the window that is running the server and enter Ctrl+C to shut it down. To do this from a shell on Solaris, Linux, or Mac OS X, find the process, and kill it. The server will continue to wait for invocations until it is explicitly stopped.
Create your first Java application
In this tutorial, you will learn how to create, run, and package a simple Java application that prints Hello, World! to the system output. Along the way, you will get familiar with IntelliJ IDEA features for boosting your productivity as a developer: coding assistance and supplementary tools.
Watch the screencast and follow the step-by-step instructions below:
Prepare a project
Create a new Java project
In IntelliJ IDEA, a project helps you organize your source code, tests, libraries that you use, build instructions, and your personal settings in a single unit.
Launch IntelliJ IDEA.
In the New Project wizard, select New Project from the list on the left.
Name the project (for example HelloWorld ) and change the default location if necessary.
We’re not going to work with version control systems in this tutorial, so leave the Create Git repository option disabled.
To develop Java applications in IntelliJ IDEA, you need the Java SDK ( JDK ).
If the necessary JDK is already defined in IntelliJ IDEA, select it from the JDK list.
If the JDK is installed on your computer, but not defined in the IDE, select Add JDK and specify the path to the JDK home directory (for example, /Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk ).
After that, the IDE will create and load the new project for you.
Create a package and a class
Packages are used for grouping together classes that belong to the same category or provide similar functionality, for structuring and organizing large applications with hundreds of classes.
IntelliJ IDEA creates the com.example.helloworld package and the HelloWorld class.
Together with the file, IntelliJ IDEA has automatically generated some contents for your class. In this case, the IDE has inserted the package statement and the class declaration.
This is done by means of file templates. Depending on the type of the file that you create, the IDE inserts initial code and formatting that is expected to be in all files of that type. For more information on how to use and configure templates, refer to File templates.
The Project tool window Alt+1 displays the structure of your application and helps you browse the project.
In Java, there’s a naming convention that you should follow when you name packages and classes.
Write the code
Add the main() method using live templates
Type main and select the template that inserts the main() method declaration.
Live templates are code snippets that you can insert into your code. main is one of such snippets. Usually, live templates contain blocks of code that you use most often. Using them can save you some time as you don’t have to type the same code over and over again.
For more information on where to find predefined live templates and how to create your own, refer to Live templates.
Call the println() method using code completion
After the main() method declaration, IntelliJ IDEA automatically places the caret at the next line. Let’s call a method that prints some text to the standard system output.
Type Sy and select the System class from the list of code completion suggestions (it’s from the standard java.lang package).
Press Ctrl+. to insert the selection with a trailing comma.
IntelliJ IDEA shows you the types of parameters that can be used in the current context. This information is for your reference.
For information on different completion modes, refer to Code completion.
Call the println() method using a live template
You can call the println() method much quicker using the sout live template.
After the main() method declaration, IntelliJ IDEA automatically places the caret at the next line. Let’s call a method that prints some text to the standard system output.
Build and run the application
Valid Java classes can be compiled into bytecode. You can compile and run classes with the main() method right from the editor using the green arrow icon in the gutter.
Click in the gutter and select Run ‘HelloWorld.main()’ in the popup. The IDE starts compiling your code.
When the compilation is complete, the Run tool window opens at the bottom of the screen.
If your code is not correct, and the IDE can’t compile it, the Run tool window will display the corresponding exit code.
Once javac finishes compilation, it places the compiled bytecode to the out directory, which is highlighted with yellow in the Project tool window.
After that, the JVM runs the bytecode.
Automatically created run configurations are temporary, but you can modify and save them.
IntelliJ IDEA automatically analyzes the file that is currently opened in the editor and searches for different types of problems: from syntax errors to typos. The Inspections widget at the top-right corner of the editor allows you to quickly see all the detected problems and look at each problem in detail. For more information, refer to Current file.
Package the application in a JAR
Create an artifact configuration for the JAR
To the right of the Main Class field, click and select HelloWorld (com.example.helloworld) in the dialog that opens.
IntelliJ IDEA creates the artifact configuration and shows its settings in the right-hand part of the Project Structure dialog.
Apply the changes and close the dialog.
Build the JAR artifact
If you now look at the out/artifacts folder, you’ll find your JAR there.
Run the packaged application
To make sure that the JAR artifact is created correctly, you can run it.
Use Find Action Ctrl+Shift+A to search for actions and settings across the entire IDE.
Create a run configuration for the packaged application
To run a Java application packaged in a JAR, IntelliJ IDEA allows you to create a dedicated run configuration.
In the Path to JAR field, click and specify the path to the JAR file on your computer.
Doing this means that the HelloWorld.jar is built automatically every time you execute this run configuration.
Run configurations allow you to define how you want to run your application, with which arguments and options. You can have multiple run configurations for the same application, each with its own settings.
Execute the run configuration
On the toolbar, select the HelloWorldJar configuration and click to the right of the run configuration selector. Alternatively, press Shift+F10 if you prefer shortcuts.
As before, the Run tool window opens and shows you the application output.
The process has exited successfully, which means that the application is packaged correctly.
Π Π°Π±ΠΎΡΠ° Ρ Java Π² ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠ΅
ΠΠ°ΠΆΠ΄Π°Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° ΠΎΠ±ΡΡΠ½ΠΎ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡΡΡ Π² ΠΎΡΠ΄Π΅Π»ΡΠ½ΠΎΠΌ ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π΅. Π― ΠΏΡΠΈΠ΄Π΅ΡΠΆΠΈΠ²Π°ΡΡΡ ΠΏΡΠ°Π²ΠΈΠ»Π° ΡΠΎΠ·Π΄Π°Π²Π°ΡΡ Π² ΡΡΠΎΠΌ ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π΅ ΠΏΠΎ ΠΊΡΠ°ΠΉΠ½Π΅ΠΉ ΠΌΠ΅ΡΠ΅ Π΄Π²Π΅ ΠΏΠ°ΠΏΠΊΠΈ: src ΠΈ bin. Π ΠΏΠ΅ΡΠ²ΠΎΠΉ ΡΠΎΠ΄Π΅ΡΠΆΠ°ΡΡΡ ΠΈΡΡ ΠΎΠ΄Π½ΡΠ΅ ΠΊΠΎΠ΄Ρ, Π²ΠΎ Π²ΡΠΎΡΠΎΠΉ β ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ. Π Π΄Π°Π½Π½ΡΡ ΠΏΠ°ΠΏΠΊΠ°Ρ Π±ΡΠ΄Π΅Ρ ΡΡΡΡΠΊΡΡΡΠ° ΠΊΠ°ΡΠ°Π»ΠΎΠ³ΠΎΠ², Π·Π°Π²ΠΈΡΡΡΠ°Ρ ΠΎΡ ΠΏΠ°ΠΊΠ΅ΡΠΎΠ².
ΠΠ΄ΠΈΠ½ ΡΠ°ΠΉΠ»
ΠΠΎΠΆΠ½ΠΎ ΡΠ΄Π΅Π»Π°ΡΡ ΠΈ Π±Π΅Π· Π»ΠΈΡΠ½ΠΈΡ
ΠΏΠ°ΠΏΠΎΠΊ.
ΠΠ΅ΡΠ΅ΠΌ ΡΠ°ΠΌ ΡΠ°ΠΉΠ» HelloWorld.java.
ΠΠ΅ΡΠ΅Ρ
ΠΎΠ΄ΠΈΠΌ Π² ΠΊΠ°ΡΠ°Π»ΠΎΠ³, Π³Π΄Π΅ Π»Π΅ΠΆΠΈΡ Π΄Π°Π½Π½ΡΠΉ ΡΠ°ΠΉΠ», ΠΈ Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΠΌ ΠΊΠΎΠΌΠ°Π½Π΄Ρ.
Π Π΄Π°Π½Π½ΠΎΠΉ ΠΏΠ°ΠΏΠΊΠ΅ ΠΏΠΎΡΠ²ΠΈΡΡΡ ΡΠ°ΠΉΠ» HelloWorld.class. ΠΠ½Π°ΡΠΈΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°Π½Π°. Π§ΡΠΎΠ±Ρ Π·Π°ΠΏΡΡΡΠΈΡΡ
ΠΡΠ΄Π΅Π»ΡΠ΅ΠΌ Π±ΠΈΠ½Π°ΡΠ½ΡΠ΅ ΡΠ°ΠΉΠ»Ρ ΠΎΡ ΠΈΡΡ ΠΎΠ΄Π½ΠΈΠΊΠΎΠ²
Π’Π΅ΠΏΠ΅ΡΡ ΡΠ΄Π΅Π»Π°Π΅ΠΌ ΡΠΎΠΆΠ΅ ΡΠ°ΠΌΠΎΠ΅, Π½ΠΎ Ρ ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π°ΠΌΠΈ. Π‘ΠΎΠ·Π΄Π°Π΄ΠΈΠΌ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ HelloWorld ΠΈ Π² Π½Π΅ΠΌ Π΄Π²Π΅ ΠΏΠ°ΠΏΠΊΠΈ src ΠΈ bin.
ΠΠΎΠΌΠΏΠΈΠ»ΠΈΡΡΠ΅ΠΌ
ΠΠ΄Π΅ΡΡ ΠΌΡ ΡΠΊΠ°Π·Π°Π»ΠΈ, ΡΡΠΎ Π±ΠΈΠ½Π°ΡΠ½ΡΠ΅ ΡΠ°ΠΉΠ»Ρ Π±ΡΠ΄ΡΡ ΡΠΎΡ
ΡΠ°Π½ΡΡΡΡΡ Π² ΠΎΡΠ΄Π΅Π»ΡΠ½ΡΡ ΠΏΠ°ΠΏΠΊΡ bin ΠΈ Π½Π΅ ΠΏΡΡΠ°ΡΡΡΡ Ρ ΠΈΡΡ
ΠΎΠ΄Π½ΠΈΠΊΠ°ΠΌΠΈ.
ΠΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌ ΠΏΠ°ΠΊΠ΅ΡΡ
Π ΡΠΎ, Π²Π΄ΡΡΠ³, ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° ΠΏΠ΅ΡΠ΅ΡΡΠ°Π½Π΅Ρ Π±ΡΡΡ ΠΏΡΠΎΡΡΠΎ HelloWorld-ΠΎΠΌ. ΠΠ°ΠΊΠ΅ΡΠ°ΠΌ Π»ΡΡΡΠ΅ Π΄Π°Π²Π°ΡΡ ΠΏΠΎΠ½ΡΡΠ½ΠΎΠ΅ ΠΈ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΠΎΠ΅ ΠΈΠΌΡ. ΠΡΠΎ ΠΏΠΎΠ·Π²ΠΎΠ»ΠΈΡ Π΄ΠΎΠ±Π°Π²ΠΈΡΡ Π΄Π°Π½Π½ΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π² Π΄ΡΡΠ³ΠΎΠΉ ΠΏΡΠΎΠ΅ΠΊΡ Π±Π΅Π· ΠΊΠΎΠ½ΡΠ»ΠΈΠΊΡΠ° ΠΈΠΌΠ΅Π½. ΠΡΠΎΡΠΈΡΠ°Π² Π½Π΅ΠΊΠΎΡΠΎΡΡΠ΅ ΡΡΠ°ΡΡΠΈ, ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΠ΄ΡΠΌΠ°ΡΡ, ΡΡΠΎ Π΄Π»Ρ ΠΈΠΌΠ΅Π½ΠΈ ΠΏΠ°ΠΊΠ΅ΡΠ° ΠΎΠ±ΡΠ·Π°ΡΠ΅Π»ΡΠ½ΠΎ Π½ΡΠΆΠ΅Π½ Π΄ΠΎΠΌΠ΅Π½. ΠΡΠΎ Π½Π΅ ΡΠ°ΠΊ. ΠΠΎΠΌΠ΅Π½Ρ β ΡΡΠΎ ΡΠ΄ΠΎΠ±Π½ΡΠΉ ΡΠΏΠΎΡΠΎΠ± Π΄ΠΎΠ±ΠΈΡΡΡΡ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΠΎΡΡΠΈ. ΠΡΠ»ΠΈ ΡΠ²ΠΎΠ΅Π³ΠΎ Π΄ΠΎΠΌΠ΅Π½Π° Π½Π΅Ρ, Π²ΠΎΡΠΏΠΎΠ»ΡΠ·ΡΠΉΡΠ΅ΡΡ Π°ΠΊΠΊΠ°ΡΠ½ΡΠΎΠΌ Π½Π° ΡΠ°ΠΉΡΠ΅ (Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ, ru.habrahabr.mylogin). ΠΠ½ Π±ΡΠ΄Π΅Ρ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΡΠΌ. Π£ΡΡΠΈΡΠ΅, ΡΡΠΎ ΠΈΠΌΠ΅Π½Π° ΠΏΠ°ΠΊΠ΅ΡΠΎΠ² Π΄ΠΎΠ»ΠΆΠ½Ρ Π±ΡΡΡ Π² Π½ΠΈΠΆΠ½Π΅ΠΌ ΡΠ΅Π³ΠΈΡΡΡΠ΅. Π ΠΈΠ·Π±Π΅Π³Π°ΠΉΡΠ΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ ΡΠΏΠ΅ΡΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ². ΠΡΠΎΠ±Π»Π΅ΠΌΡ Π²ΠΎΠ·Π½ΠΈΠΊΠ°ΡΡ ΠΈΠ·-Π·Π° ΡΠ°Π·Π½ΡΡ ΠΏΠ»Π°ΡΡΠΎΡΠΌ ΠΈ ΡΠ°ΠΉΠ»ΠΎΠ²ΡΡ ΡΠΈΡΡΠ΅ΠΌ.
ΠΠΎΠΌΠ΅ΡΡΠΈΠΌ Π½Π°Ρ ΠΊΠ»Π°ΡΡ Π² ΠΏΠ°ΠΊΠ΅Ρ Ρ ΠΈΠΌΠ΅Π½Π΅ΠΌ com.qwertovsky.helloworld. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ Π΄ΠΎΠ±Π°Π²ΠΈΠΌ Π² Π½Π°ΡΠ°Π»ΠΎ ΡΠ°ΠΉΠ»Π° ΡΡΡΠΎΡΠΊΡ
Π ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π΅ src ΡΠΎΠ·Π΄Π°Π΄ΠΈΠΌ Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠ΅ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ΠΈ, ΡΡΠΎΠ±Ρ ΠΏΡΡΡ ΠΊ ΡΠ°ΠΉΠ»Ρ Π²ΡΠ³Π»ΡΠ΄Π΅Π» ΡΠ°ΠΊ: src/com/qwertovsky/helloworld/HelloWorld.java.
ΠΠΎΠΌΠΏΠΈΠ»ΠΈΡΡΠ΅ΠΌ
Π ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π΅ bin Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈ ΡΠΎΠ·Π΄Π°ΡΡΡΡ ΡΡΡΡΠΊΡΡΡΠ° ΠΊΠ°ΡΠ°Π»ΠΎΠ³ΠΎΠ² ΠΊΠ°ΠΊ ΠΈ Π² src.
ΠΡΠ»ΠΈ Π² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ΅ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΡΠ°ΠΉΠ»ΠΎΠ²
HelloWorld.java
Calculator.java
Adder.java
ΠΡΠ»ΠΈ ΡΠ΄ΠΈΠ²Π»ΡΠ΅Ρ ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ
ΠΡΠ»Π°Π΄ΡΠΈΠΊ Π·Π°ΠΏΡΡΠΊΠ°Π΅Ρ ΡΠ²ΠΎΠΉ Π²Π½ΡΡΡΠ΅Π½Π½ΠΈΠΉ ΡΠ΅ΡΠΌΠΈΠ½Π°Π» Π΄Π»Ρ Π²Π²ΠΎΠ΄Π° ΠΊΠΎΠΌΠ°Π½Π΄. Π‘ΠΏΡΠ°Π²ΠΊΡ ΠΏΠΎ ΠΏΠΎΡΠ»Π΅Π΄Π½ΠΈΠΌ ΠΌΠΎΠΆΠ½ΠΎ Π²ΡΠ²Π΅ΡΡΠΈ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ help.
Π£ΠΊΠ°Π·ΡΠ²Π°Π΅ΠΌ ΡΠΎΡΠΊΡ ΠΏΡΠ΅ΡΡΠ²Π°Π½ΠΈΡ Π½Π° 9 ΡΡΡΠΎΠΊΠ΅ Π² ΠΊΠ»Π°ΡΡΠ΅ Calculator
ΠΠ°ΠΏΡΡΠΊΠ°Π΅ΠΌ Π½Π° Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅.
Π§ΡΠΎΠ±Ρ ΡΠΎΠΎΡΠΈΠ΅Π½ΡΠΈΡΠΎΠ²Π°ΡΡΡΡ ΠΌΠΎΠΆΠ½ΠΎ Π²ΡΠ²Π΅ΡΡΠΈ ΠΊΡΡΠΎΠΊ ΠΈΡΡ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΊΠΎΠ΄Π°, Π³Π΄Π΅ Π² Π΄Π°Π½Π½ΡΠΉ ΠΌΠΎΠΌΠ΅Π½Ρ Π½Π°Ρ ΠΎΠ΄ΠΈΡΡΡ ΠΊΡΡΡΡΠΎΡ.
Π£Π·Π½Π°Π΅ΠΌ, ΡΡΠΎ ΠΈΠ· ΡΠ΅Π±Ρ ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»ΡΠ΅Ρ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½Π°Ρ Π°.
ΠΡΠΏΠΎΠ»Π½ΠΈΠΌ ΠΊΠΎΠ΄ Π² ΡΠ΅ΠΊΡΡΠ΅ΠΉ ΡΡΡΠΎΠΊΠ΅ ΠΈ ΡΠ²ΠΈΠ΄ΠΈΠΌ, ΡΡΠΎ sum ΡΡΠ°Π»Π° ΡΠ°Π²Π½ΡΡΡΡΡ 2.
ΠΠΎΠ΄Π½ΠΈΠΌΠ΅ΠΌΡΡ ΠΈΠ· ΠΊΠ»Π°ΡΡΠ° Adder Π² Π²ΡΠ·Π²Π°Π²ΡΠΈΠΉ Π΅Π³ΠΎ ΠΊΠ»Π°ΡΡ Calculator.
Π£Π΄Π°Π»ΡΠ΅ΠΌ ΡΠΎΡΠΊΡ ΠΏΡΠ΅ΡΡΠ²Π°Π½ΠΈΡ
ΠΠΎΠΆΠ½ΠΎ ΠΈΠ·Π±Π΅ΠΆΠ°ΡΡ Π·Π°Ρ ΠΎΠ΄Π° Π² ΠΌΠ΅ΡΠΎΠ΄Ρ, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ next.
ΠΡΠΎΠ²Π΅ΡΡΠ΅ΠΌ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΡ ΠΈ Π·Π°Π²Π΅ΡΡΠ°Π΅ΠΌ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅.
Π₯ΠΎΡΠΎΡΠΎ Π±Ρ ΠΏΡΠΎΡΠ΅ΡΡΠΈΡΠΎΠ²Π°ΡΡ
ΠΠ°ΠΏΡΡΠΊΠ°Π΅ΠΌ. Π ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ ΡΠ°Π·Π΄Π΅Π»ΠΈΡΠ΅Π»Ρ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΡ ΠΏΡΡΠ΅ΠΉ Π² classpath Π² Windows ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ ‘;’, Π² Linux β ‘:’. Π ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ Cygwin Π½Π΅ ΡΠ°Π±ΠΎΡΠ°ΡΡ ΠΎΠ±Π° ΡΠ°Π·Π΄Π΅Π»ΠΈΡΠ΅Π»Ρ. ΠΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ, Π΄ΠΎΠ»ΠΆΠ΅Π½ ΡΠ°Π±ΠΎΡΠ°ΡΡ ‘;’, Π½ΠΎ ΠΎΠ½ Π²ΠΎΡΠΏΡΠΈΠ½ΠΈΠΌΠ°Π΅ΡΡΡ ΠΊΠ°ΠΊ ΡΠ°Π·Π΄Π΅Π»ΠΈΡΠ΅Π»Ρ ΠΊΠΎΠΌΠ°Π½Π΄.
Π‘ΠΎΠ·Π΄Π°Π΄ΠΈΠΌ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΡ
ΠΠ»Π°ΡΡ Calculator ΠΎΠΊΠ°Π·Π°Π»ΡΡ ΠΏΠΎΠ»Π΅Π·Π½ΡΠΌ ΠΈ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ Π²ΠΎ ΠΌΠ½ΠΎΠ³ΠΈΡ ΠΏΡΠΎΠ΅ΠΊΡΠ°Ρ . ΠΠ΅ΡΠ΅Π½Π΅ΡΠ΅ΠΌ Π²ΡΡ, ΡΡΠΎ ΠΊΠ°ΡΠ°Π΅ΡΡΡ ΠΊΠ»Π°ΡΡΠ° Calculator Π² ΠΎΡΠ΄Π΅Π»ΡΠ½ΡΠΉ ΠΏΡΠΎΠ΅ΠΊΡ.
ΠΠ·ΠΌΠ΅Π½ΠΈΡΠ΅ ΡΠ°ΠΊΠΆΠ΅ Π½Π°Π·Π°Π²Π°Π½ΠΈΡ ΠΏΠ°ΠΊΠ΅ΡΠΎΠ² Π² ΠΈΡΡ ΠΎΠ΄Π½ΡΡ ΡΠ΅ΠΊΡΡΠ°Ρ . Π HelloWorld.java Π½ΡΠΆΠ½ΠΎ Π±ΡΠ΄Π΅Ρ Π΄ΠΎΠ±Π°Π²ΠΈΡΡ ΡΡΡΠΎΠΊΡ
ΠΠ°Π΄ΠΎ ΡΠ·Π½Π°ΡΡ, ΡΡΠΎ Ρ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ Π²Π½ΡΡΡΠΈ
ΠΠΎΠΆΠ½ΠΎ ΡΠ°ΡΠΏΠ°ΠΊΠΎΠ²Π°ΡΡ Π°ΡΡ
ΠΈΠ² zip-ΡΠ°ΡΠΏΠ°ΠΊΠΎΠ²ΡΠΈΠΊΠΎΠΌ ΠΈ ΠΏΠΎΡΠΌΠΎΡΡΠ΅ΡΡ, ΠΊΠ°ΠΊΠΈΠ΅ ΠΊΠ»Π°ΡΡΡ Π΅ΡΡΡ Π² Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠ΅.
ΠΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ ΠΎ Π»ΡΠ±ΠΎΠΌ ΠΊΠ»Π°ΡΡΠ΅ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΠ»ΡΡΠΈΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ Π΄ΠΈΠ·Π°ΡΡΠ΅ΠΌΠ±Π»Π΅ΡΠ° javap.
ΠΡΡΡΠ΅ ΡΠ½Π°Π±Π΄ΠΈΡΡ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΡ Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΡΠΈΠ΅ΠΉ
ΠΠ·ΠΌΠ΅Π½ΠΈΠΌ Π΄Π»Ρ ΡΡΠΎΠ³ΠΎ ΠΊΠ»Π°ΡΡ ΠΊΠ°Π»ΡΠΊΡΠ»ΡΡΠΎΡΠ°.
ΠΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΡΠΈΡ ΠΌΠΎΠΆΠ½ΠΎ ΡΠΎΠ·Π΄Π°ΡΡ ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΉ ΠΊΠΎΠΌΠ°Π½Π΄ΠΎΠΉ. ΠΡΠΈ ΠΎΡΠΈΠ±ΠΊΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° Π²ΡΠ΄Π°ΡΡ ΡΠΏΠΈΡΠΎΠΊ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΡΡ ΠΎΠΏΡΠΈΠΉ.
Π ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠ΅ ΠΏΠΎΠ»ΡΡΠΈΡΡΡΡ ΡΠ»Π΅Π΄ΡΡΡΠ΅Π΅
ΠΠΎΠΆΠ½ΠΎ ΠΏΠΎΠ΄ΠΏΠΈΡΠ°ΡΡ jar-Π°ΡΡ ΠΈΠ²
ΠΡΠ»ΠΈ ΡΡΠ΅Π±ΡΠ΅ΡΡΡ ΠΏΠΎΠ΄ΠΏΠΈΡΠ°ΡΡ ΡΠ²ΠΎΡ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΡ ΡΠΈΡΡΠΎΠ²ΠΎΠΉ ΠΏΠΎΠ΄ΠΏΠΈΡΡΡ, Π½Π° ΠΏΠΎΠΌΠΎΡΡ ΠΏΡΠΈΠ΄ΡΡ keytool ΠΈ jarsigner.
ΠΠ΅Π½Π΅ΡΠΈΡΡΠ΅ΠΌ ΠΏΠΎΠ΄ΠΏΠΈΡΡ.
ΠΠ΅Π½Π΅ΡΠΈΡΡΠ΅ΠΌ Certificate Signing Request (CSR)
Π‘ΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅ ΠΏΠΎΠ»ΡΡΠ΅Π½Π½ΠΎΠ³ΠΎ ΡΠ°ΠΉΠ»Π° ΠΎΡΠΏΡΠ°Π²Π»ΡΠ΅ΠΌ Π² ΡΠ΅Π½ΡΡ ΡΠ΅ΡΡΠΈΡΠΈΠΊΠ°ΡΠΈΠΈ. ΠΡ ΡΠ΅Π½ΡΡΠ° ΡΠ΅ΡΡΠΈΡΠΈΠΊΠ°ΡΠΈΠΈ ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΠ΅ΡΡΠΈΡΠΈΠΊΠ°Ρ. Π‘ΠΎΡ ΡΠ°Π½ΡΠ΅ΠΌ Π΅Π³ΠΎ Π² ΡΠ°ΠΉΠ»Π΅ (Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ, qwertokey.cer) ΠΈ ΠΈΠΌΠΏΠΎΡΡΠΈΡΡΠ΅ΠΌ Π² Ρ ΡΠ°Π½ΠΈΠ»ΠΈΡΠ΅
Π€Π°ΠΉΠ» qwertokey.cer ΠΎΡΠΏΡΠ°Π²Π»ΡΠ΅ΠΌ Π²ΡΠ΅ΠΌ, ΠΊΡΠΎ Ρ ΠΎΡΠ΅Ρ ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ Π°ΡΡ ΠΈΠ². ΠΡΠΎΠ²Π΅ΡΡΠ΅ΡΡΡ ΠΎΠ½ ΡΠ°ΠΊ
ΠΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ
ΠΡΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° HelloWorld, ΠΊΠΎΡΠΎΡΠ°Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅Ρ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΡΠ½ΡΠΉ ΠΊΠ»Π°ΡΡ Calculator. Π§ΡΠΎΠ±Ρ ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡ ΠΈ Π·Π°ΠΏΡΡΡΠΈΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ, Π½ΡΠΆΠ½ΠΎ ΠΏΡΠΈΡΠΎΠ΅Π΄ΠΈΠ½ΠΈΡΡ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΡ.
ΠΠΎΠΌΠΏΠΈΠ»ΠΈΡΡΠ΅ΠΌ
Π‘ΠΎΠ±ΠΈΡΠ°Π΅ΠΌ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ
ΠΡΠΎ ΠΌΠΎΠΆΠ½ΠΎ ΡΠ΄Π΅Π»Π°ΡΡ ΠΏΠΎ-ΡΠ°Π·Π½ΠΎΠΌΡ.
ΠΠ΅ΡΠ²ΡΠΉ ΡΠΏΠΎΡΠΎΠ±
ΠΠ΄Π΅ΡΡ Π΅ΡΡΡ ΡΠΎΠ½ΠΊΠΎΡΡΠΈ.
Π ΡΡΡΠΎΠΊΠ΅
Π½Π΅ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π±ΡΡΡ ΠΏΡΠΎΠ±Π΅Π»ΠΎΠ² Π² ΠΊΠΎΠ½ΡΠ΅.
ΠΡΠΎΡΠ°Ρ ΡΠΎΠ½ΠΊΠΎΡΡΡ ΠΎΠΏΠΈΡΠ°Π½Π° Π² [3]: Π² ΡΡΠΎΠΉ ΠΆΠ΅ ΡΡΡΠΎΠΊΠ΅ Π΄ΠΎΠ»ΠΆΠ΅Π½ ΡΡΠΎΡΡΡ ΠΏΠ΅ΡΠ΅Π½ΠΎΡ Π½Π° ΡΠ»Π΅Π΄ΡΡΡΡΡ ΡΡΡΠΎΠΊΡ. ΠΡΠΎ Π΅ΡΠ»ΠΈ ΠΌΠ°Π½ΠΈΡΠ΅ΡΡ ΠΏΠΎΠΌΠ΅ΡΠ°Π΅ΡΡΡ Π² Π°ΡΡ
ΠΈΠ² ΡΡΠΎΡΠΎΠ½Π½ΠΈΠΌ Π°ΡΡ
ΠΈΠ²Π°ΡΠΎΡΠΎΠΌ.
ΠΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° jar Π½Π΅ Π²ΠΊΠ»ΡΡΠΈΡ Π² ΠΌΠ°Π½ΠΈΡΠ΅ΡΡ ΠΏΠΎΡΠ»Π΅Π΄Π½ΡΡ ΡΡΡΠΎΠΊΡ ΠΈΠ· ΠΌΠ°Π½ΠΈΡΠ΅ΡΡΠ°, Π΅ΡΠ»ΠΈ Π² ΠΊΠΎΠ½ΡΠ΅ Π½Π΅ ΡΡΠΎΠΈΡ ΠΏΠ΅ΡΠ΅Π½ΠΎΡ ΡΡΡΠΎΠΊΠΈ.
ΠΡΡ ΠΌΠΎΠΌΠ΅Π½Ρ: Π² ΠΌΠ°Π½ΠΈΡΠ΅ΡΡΠ΅ Π½Π΅ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π±ΡΡΡ ΠΏΡΡΡΡΡ
ΡΡΡΠΎΠΊ ΠΌΠ΅ΠΆΠ΄Ρ ΡΡΡΠΎΠΊΠ°ΠΌΠΈ. ΠΡΠ΄Π΅Ρ Π²ΡΠ΄Π°Π½Π° ΠΎΡΠΈΠ±ΠΊΠ° Β«java.io.IOException: invalid manifest formatΒ».
ΠΡΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠΈ ΠΊΠΎΠΌΠ°Π½Π΄Ρ echo Π½Π°Π΄ΠΎ ΡΠ»Π΅Π΄ΠΈΡΡ ΡΠΎΠ»ΡΠΊΠΎ Π·Π° ΠΏΡΠΎΠ±Π΅Π»ΠΎΠΌ Π² ΠΊΠΎΠ½ΡΠ΅ ΡΡΡΠΎΠΊΠΈ Ρ main-class.
ΠΡΠΎΡΠΎΠΉ ΡΠΏΠΎΡΠΎΠ±
Π Π΄Π°Π½Π½ΠΎΠΌ ΡΠΏΠΎΡΠΎΠ±Π΅ ΠΈΠ·Π±Π΅Π³Π°Π΅ΠΌ ΠΎΡΠΈΠ±ΠΊΠΈ Ρ ΠΏΡΠΎΠ±Π΅Π»ΠΎΠΌ Π² main-class.
Π’ΡΠ΅ΡΠΈΠΉ ΡΠΏΠΎΡΠΎΠ±
ΠΠΊΠ»ΡΡΠΈΠ»ΠΈ ΠΊΠΎΠ΄ Π½ΡΠΆΠ½ΠΎΠΉ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ Π² ΠΈΡΠΏΠΎΠ»Π½ΡΠ΅ΠΌΡΠΉ ΡΠ°ΠΉΠ».
ΠΠ°ΠΏΡΡΠΊ ΠΈΡΠΏΠΎΠ»Π½ΡΠ΅ΠΌΠΎΠ³ΠΎ jar-ΡΠ°ΠΉΠ»Π°
Π€Π°ΠΉΠ» calculator.jar ΠΈΡΠΏΠΎΠ»Π½ΡΠ΅ΠΌΡΠΌ Π½Π΅ ΡΠ²Π»ΡΠ΅ΡΡΡ. Π Π²ΠΎΡ helloworld.jar ΠΌΠΎΠΆΠ½ΠΎ Π·Π°ΠΏΡΡΡΠΈΡΡ.
ΠΡΠ»ΠΈ Π°ΡΡ
ΠΈΠ² Π±ΡΠ» ΡΠΎΠ·Π΄Π°Π½ ΠΏΠ΅ΡΠ²ΡΠΌΠΈ Π΄Π²ΡΠΌΡ ΡΠΏΠΎΡΠΎΠ±Π°ΠΌΠΈ, ΡΠΎ ΡΡΠ΄ΠΎΠΌ Ρ Π½ΠΈΠΌ Π² ΠΎΠ΄Π½ΠΎΠΌ ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π΅ Π΄ΠΎΠ»ΠΆΠ½Π° Π½Π°Ρ
ΠΎΠ΄ΠΈΡΡΡ ΠΏΠ°ΠΏΠΊΠ° lib Ρ ΡΠ°ΠΉΠ»ΠΎΠΌ calculator.jar. Π’Π°ΠΊΠΈΠ΅ ΠΎΠ³ΡΠ°Π½ΠΈΡΠ΅Π½ΠΈΡ ΠΈΠ·-Π·Π° ΡΠΎΠ³ΠΎ, ΡΡΠΎ Π² ΠΌΠ°Π½ΠΈΡΠ΅ΡΡΠ΅ Π² class-path ΡΠΊΠ°Π·Π°Π½ ΠΏΡΡΡ ΠΎΡΠ½ΠΎΡΠΈΡΠ΅Π»ΡΠ½ΠΎ ΠΈΡΠΏΠΎΠ»Π½ΡΠ΅ΠΌΠΎΠ³ΠΎ ΡΠ°ΠΉΠ»Π°.
ΠΡΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠΈ ΡΡΠ΅ΡΡΠ΅Π³ΠΎ ΡΠΏΠΎΡΠΎΠ±Π° Π½ΡΠΆΠ½ΡΠ΅ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ Π²ΠΊΠ»ΡΡΠ°ΡΡΡΡ Π² ΠΈΡΠΏΠΎΠ»Π½ΡΠ΅ΠΌΡΠΉ ΡΠ°ΠΉΠ». ΠΠ΅ΡΠΆΠ°ΡΡ ΡΡΠ΄ΠΎΠΌ Π½ΡΠΆΠ½ΡΠ΅ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ Π½Π΅ ΡΡΠ΅Π±ΡΠ΅ΡΡΡ. ΠΠ°ΠΏΡΡΠΊΠ°Π΅ΡΡΡ Π°Π½Π°Π»ΠΎΠ³ΠΈΡΠ½ΠΎ.
ΠΠ°ΠΊ Π±ΡΡΡ Ρ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡΠΌΠΈ JavaEE
ΠΠ½Π°Π»ΠΎΠ³ΠΈΡΠ½ΠΎ. Π’ΠΎΠ»ΡΠΊΠΎ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ Π΄Π»Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ Π½ΡΠΆΠ½ΠΎ Π±ΡΠ°ΡΡ Ρ ΡΠ΅ΡΠ²Π΅ΡΠ° ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ, ΠΊΠΎΡΠΎΡΡΠΉ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ. ΠΡΠ»ΠΈ Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡ JBoss, ΡΠΎ Π΄Π»Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ ΡΠ΅ΡΠ²Π»Π΅ΡΠ° ΠΌΠ½Π΅ Π½ΡΠΆΠ½ΠΎ Π±ΡΠ΄Π΅Ρ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ ΠΏΡΠΈΠΌΠ΅ΡΠ½ΠΎ ΡΠ»Π΅Π΄ΡΡΡΠ΅Π΅
Π‘ΡΡΡΠΊΡΡΡΠ° Π°ΡΡ ΠΈΠ²Π° JavaEE-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Π΄ΠΎΠ»ΠΆΠ½Π° ΡΠΎΠΎΡΠ²Π΅ΡΡΡΠ²ΠΎΠ²Π°ΡΡ ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Π½ΠΎΠΌΡ ΡΠΎΡΠΌΠ°ΡΡ. ΠΠ°ΠΏΡΠΈΠΌΠ΅Ρ
Π‘ΠΏΠΎΡΠΎΠ±Ρ Π·Π°ΠΏΡΡΠΊΠ° ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Π½Π° ΡΠ°ΠΌΠΎΠΌ ΡΠ΅ΡΠ²Π΅ΡΠ΅ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠΈ Π΄Π»Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΡΠ΅ΡΠ²Π΅ΡΠ° ΡΠ°Π·Π»ΠΈΡΠ½Ρ.
ΠΠ°Π΄Π΅ΡΡΡ, Π΄Π°Π½Π½Π°Ρ ΡΡΠ°ΡΡΡ ΡΡΠ°Π½Π΅Ρ Π΄Π»Ρ ΠΊΠΎΠ³ΠΎ-Π½ΠΈΠ±ΡΠ΄Ρ ΡΠΏΠ°ΡΠ³Π°Π»ΠΊΠΎΠΉ Π΄Π»Ρ ΡΠ°Π±ΠΎΡΡ Ρ Java Π² ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠ΅. ΠΠ°Π½Π½ΡΠ΅ Π½Π°Π²ΡΠΊΠΈ ΠΏΠΎΠΌΠΎΠ³ΡΡ ΠΏΠΎΠ½ΡΡΡ ΡΠΎΠ΄Π΅ΡΠΆΠ°Π½ΠΈΠ΅ ΠΈ ΡΠΌΡΡΠ» Ant-ΡΠΊΡΠΈΠΏΡΠΎΠ² ΠΈ ΠΎΡΠ²Π΅ΡΠΈΡΡ Π½Π° ΡΠΎΠ±Π΅ΡΠ΅Π΄ΠΎΠ²Π°Π½ΠΈΠΈ Π½Π° Π±ΠΎΠ»Π΅Π΅ ΠΊΠ°Π²Π΅ΡΠ·Π½ΡΠ΅ Π²ΠΎΠΏΡΠΎΡΡ, ΡΠ΅ΠΌ Β«ΠΠ°ΠΊΠ°Ρ IDE ΠΠ°ΠΌ Π±ΠΎΠ»ΡΡΠ΅ Π½ΡΠ°Π²ΠΈΡΡΡ?Β».
Java Hello World Program
Java is one of the most popular and widely used programming languages and platforms. Java is fast, reliable, and secure. Java is used in every nook and corner from desktop to web applications, scientific supercomputers to gaming consoles, cell phones to the Internet.
Java is easy to learn, and its syntax is simple and easy to understand. It is based on C++ (so easier for programmers who know C++).
The process of Java programming can be simplified in three steps:
The below-given program is the most simple program of Java printing βHello Worldβ to the screen. Let us try to understand every bit of code step by step.
Time Complexity: O(1)
Space Complexity: O(1)
The βHello World!β program consists of three primary components: the HelloWorld class definition, the main method, and source code comments. The following explanation will provide you with a basic understanding of the code:
1. Class definition
This line uses the keyword class to declare that a new class is being defined.
2. HelloWorld
It is an identifier that is the name of the class. The entire class definition, including all of its members, will be between the opening curly brace β<β and the closing curly brace β>β.
3. main method:
In the Java programming language, every application must contain a main method. The main function(method) is the entry point of your Java application, and itβs mandatory in a Java program. whose signature in Java is:
Like in C/C++, the main method is the entry point for your application and will subsequently invoke all the other methods required by your program.
The next line of code is shown here. Notice that it occurs inside the main() method.
This line outputs the string βHello, Worldβ followed by a new line on the screen. Output is accomplished by the built-in println( ) method. The System is a predefined class that provides access to the system, and out is the variable of type output stream connected to the console.
Comments
They can either be multiline or single-line comments.
This is a single-line comment. This type of comment must begin with // as in C/C++. For multiline comments, they must begin from /* and end with */.
Important Points
Compiling the program
In Windows
In Linux
Java Core Π΄Π»Ρ ΡΠ°ΠΌΡΡ ΠΌΠ°Π»Π΅Π½ΡΠΊΠΈΡ . Π§Π°ΡΡΡ 1. ΠΠΎΠ΄Π³ΠΎΡΠΎΠ²ΠΊΠ° ΠΈ ΠΏΠ΅ΡΠ²Π°Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ°
ΠΡΡΡΠΏΠ»Π΅Π½ΠΈΠ΅. ΠΡΠ°ΡΠΊΠ°Ρ ΠΈΡΡΠΎΡΠΈΡ ΠΈ ΠΎΡΠΎΠ±Π΅Π½Π½ΠΎΡΡΠΈ ΡΠ·ΡΠΊΠ°
ΠΠ°ΠΊ-ΡΠΎ Π΄Π°Π²Π½ΠΎ ΠΌΡ Ρ ΠΌΠΎΠΈΠΌ ΡΠΎΠ²Π°ΡΠΈΡΠ΅ΠΌ ΠΈ ΠΊΠΎΠ»Π»Π΅Π³ΠΎΠΉ ΠΠ³ΠΎΡΠΎΠΌ Π³ΠΎΡΠΎΠ²ΠΈΠ»ΠΈ ΠΎΠ±ΡΡΠ°ΡΡΠΈΠΉ ΠΊΡΡΡ ΠΏΠΎ Java Core. ΠΠΎ ΠΊΠ°ΠΊ-ΡΠΎ Π½Π΅ ΡΡΠΎΡΠ»ΠΎΡΡ ΠΈ ΡΡΠΎ Π΄Π΅Π»ΠΎ Π½Π΅ Π±ΡΠ»ΠΎ Π΄ΠΎΠ²Π΅Π΄Π΅Π½ΠΎ Π΄ΠΎ ΠΊΠ°ΠΊΠΎΠ³ΠΎ-Π»ΠΈΠ±ΠΎ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΎΠ³ΠΎ ΠΊΠΎΠ½ΡΠ°. Π Π²ΠΎΡ, ΡΠΏΡΡΡΡ Π²ΡΠ΅ΠΌΡ, Ρ ΡΠ΅ΡΠΈΠ», ΡΡΠΎ Π½Π΅ ΡΡΠΎΠΈΡ ΠΏΡΠΎΠΏΠ°Π΄Π°ΡΡ Π΄ΠΎΠ±ΡΡ ΠΈ ΠΏΠΎ-ΡΡΠΎΠΌΡ Π·Π°ΠΏΡΡΠΊΠ°Ρ ΡΠ΅ΡΠΈΡ ΡΡΠ°ΡΠ΅ΠΉ ΠΏΡΠΎ Java Core Π΄Π»Ρ ΡΠ°ΠΌΡΡ ΠΌΠ°Π»Π΅Π½ΡΠΊΠΈΡ .
ΠΠ°ΡΠ°Π»ΠΎ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ ΡΠ·ΡΠΊΠ° Π±ΡΠ»ΠΎ ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΎ Π΅ΡΠ΅ Π² 1991 Π³ΠΎΠ΄Ρ ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠ΅ΠΉ Sun Microsystems, Inc. ΠΠ½Π°ΡΠ°Π»Π΅ ΡΠ·ΡΠΊ Π±ΡΠ» Π½Π°Π·Π²Π°Π½ Oak (ΠΡΠ±), Π½ΠΎ Π² 1995 ΠΎΠ½ Π±ΡΠ» ΠΏΠ΅ΡΠ΅ΠΈΠΌΠ΅Π½ΠΎΠ²Π°Π½ Π² Java. ΠΡΠ±Π»ΠΈΡΠ½ΠΎ Π·Π°ΡΠ²ΠΈΠ»ΠΈ ΠΎ ΡΠΎΠ·Π΄Π°Π½ΠΈΠΈ ΡΠ·ΡΠΊΠ° Π² 1995 Π³ΠΎΠ΄Ρ. ΠΡΠΈΡΠΈΠ½ΠΎΠΉ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ Π±ΡΠ»Π° ΠΏΠΎΡΡΠ΅Π±Π½ΠΎΡΡΡ Π² Π½Π΅Π·Π°Π²ΠΈΡΡΡΠ΅ΠΌ ΠΎΡ ΠΏΠ»Π°ΡΡΠΎΡΠΌΡ ΠΈ Π°ΡΡ ΠΈΡΠ΅ΠΊΡΡΡΡ ΠΏΡΠΎΡΠ΅ΡΡΠΎΡΠ° ΡΠ·ΡΠΊΠ΅, ΠΊΠΎΡΠΎΡΡΠΉ ΠΌΠΎΠΆΠ½ΠΎ Π±ΡΠ»ΠΎ Π±Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π΄Π»Ρ Π½Π°ΠΏΠΈΡΠ°Π½ΠΈΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌ Π΄Π»Ρ Π±ΡΡΠΎΠ²ΠΎΠΉ ΡΠ»Π΅ΠΊΡΡΠΎΡΠ΅Ρ Π½ΠΈΠΊΠΈ. ΠΠΎ ΠΏΠΎΡΠΊΠΎΠ»ΡΠΊΡ Π² ΡΠ°ΠΊΠΈΡ ΡΡΡΡΠΎΠΉΡΡΠ²Π°Ρ ΠΏΡΠΈΠΌΠ΅Π½ΡΠ»ΠΈΡΡ ΡΠ°Π·Π»ΠΈΡΠ½ΡΠ΅ ΠΏΡΠΎΡΠ΅ΡΡΠΎΡΡ, ΡΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ ΠΏΠΎΠΏΡΠ»ΡΡΠ½ΡΡ Π½Π° ΡΠΎ Π²ΡΠ΅ΠΌΡ ΡΠ·ΡΠΊΠΎΠ² Π‘/Π‘++ ΠΈ ΠΏΡΠΎΡΠΈΡ Π±ΡΠ»ΠΎ Π·Π°ΡΡΡΠ΄Π½Π΅Π½ΠΎ, ΠΏΠΎΡΠΊΠΎΠ»ΡΠΊΡ Π½Π°ΠΏΠΈΡΠ°Π½Π½ΡΠ΅ Π½Π° Π½ΠΈΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π΄ΠΎΠ»ΠΆΠ½Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡΡΡ ΠΎΡΠ΄Π΅Π»ΡΠ½ΠΎ Π΄Π»Ρ ΠΊΠΎΠ½ΠΊΡΠ΅ΡΠ½ΠΎΠΉ ΠΏΠ»Π°ΡΡΠΎΡΠΌΡ.
ΠΠ»Ρ ΡΠΎΠ³ΠΎ ΡΡΠΎΠ±Ρ ΡΠΊΠ°ΡΠ°ΡΡ ΠΈ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ JDK ΠΎΡΠΊΡΡΠ²Π°Π΅ΠΌ Π±ΡΠ°ΡΠ·Π΅Ρ, ΠΈ Π² ΡΡΡΠΎΠΊΠ΅ ΠΏΠΎΠΈΡΠΊΠ° Google Π²Π²ΠΎΠ΄ΠΈΠΌ βdownload JDKβ ΠΈΠ»ΠΈ ΠΏΠ΅ΡΠ΅Ρ ΠΎΠ΄ΠΈΠΌ ΠΏΠΎ ΡΡΠΎΠΉ ΡΡΡΠ»ΠΊΠ΅.
Π‘ΠΊΡΠΎΠ»ΠΈΠΌ Π½ΠΈΠΆΠ΅ ΠΈ Π½Π°Ρ ΠΎΠ΄ΠΈΠΌ ΡΠ°Π±Π»ΠΈΡΡ Ρ Π²Π°ΡΠΈΠ°Π½ΡΠ°ΠΌΠΈ ΡΠΊΠ°ΡΠΈΠ²Π°Π½ΠΈΡ JDK. Π Π·Π°Π²ΠΈΡΠΈΠΌΠΎΡΡΠΈ ΠΎΡ Π½Π°ΡΠ΅ΠΉ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½ΠΎΠΉ ΡΠΈΡΡΠ΅ΠΌΡ Π²ΡΠ±ΠΈΡΠ°Π΅ΠΌ ΡΠ°ΠΉΠ» Π΄Π»Ρ ΡΠΊΠ°ΡΠΈΠ²Π°Π½ΠΈΡ.
ΠΡΠΎΡΠ΅ΡΡ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ Π΄Π»Ρ ΠΠ‘ Windows ΠΈΠΌΠ΅Π΅Ρ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΡΡΠ°ΠΏΠΎΠ². ΠΠ΅ ΡΡΠΎΠΈΡ ΠΏΡΠ³Π°ΡΡΡΡ, Π²ΡΠ΅ ΠΎΡΠ΅Π½Ρ ΠΏΡΠΎΡΡΠΎ ΠΈ Π΄Π΅Π»Π°Π΅ΡΡΡ Π² Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΠΊΠ»ΠΈΠΊΠΎΠ². ΠΠΎΡ Π·Π΄Π΅ΡΡ ΠΏΠΎΠ΄ΡΠΎΠ±Π½ΠΎ ΠΎΠΏΠΈΡΠ°Π½ ΠΏΡΠΎΡΠ΅ΡΡ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ. Π‘Π°ΠΌΠΎΠ΅ Π²Π°ΠΆΠ½ΠΎΠ΅ Π΄Π»Ρ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Π΅ΠΉ Windows ΡΡΠΎ Π΄ΠΎΠ±Π°Π²ΠΈΡΡ ΡΠΈΡΡΠ΅ΠΌΠ½ΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ JAVA_HOME. Π ΡΡΠΎΠΉ ΠΆΠ΅ ΡΡΠ°ΡΡΠ΅ Π΄ΠΎΡΡΠ°ΡΠΎΡΠ½ΠΎ ΠΏΠΎΠ΄ΡΠΎΠ±Π½ΠΎ ΡΠ°ΡΠΏΠΈΡΠ°Π½ΠΎ ΠΊΠ°ΠΊ ΡΡΠΎ ΡΠ΄Π΅Π»Π°ΡΡ (Π΅ΡΡΡ Π΄Π°ΠΆΠ΅ ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ).
Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ° IDE
Π’Π΅ΠΏΠ΅ΡΡ Π½Π°ΠΌ Π½ΡΠΆΠ½ΠΎ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ ΡΡΠ΅Π΄Ρ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ, ΠΎΠ½Π° ΠΆΠ΅ IDE (Integrated development environment). Π§ΡΠΎ ΡΠΎΠ±ΠΎΠΉ ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»ΡΠ΅Ρ ΡΡΠ΅Π΄Π° ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ? ΠΠ° ΡΠ°ΠΌΠΎΠΌ Π΄Π΅Π»Π΅ ΠΎΠ½Π° Π²ΡΠ³Π»ΡΠ΄ΠΈΡ ΠΊΠ°ΠΊ ΡΠ΅ΠΊΡΡΠΎΠ²ΡΠΉ ΡΠ΅Π΄Π°ΠΊΡΠΎΡ, Π² ΠΊΠΎΡΠΎΡΠΎΠΌ ΠΌΡ ΠΌΠΎΠΆΠ΅ΠΌ Π²Π²ΠΎΠ΄ΠΈΡΡ ΠΈ ΡΠ΅Π΄Π°ΠΊΡΠΈΡΠΎΠ²Π°ΡΡ ΡΠ΅ΠΊΡΡ. ΠΠΎ ΠΏΠΎΠΌΠΈΠΌΠΎ ΡΡΠΎΠ³ΠΎ, ΡΡΠΎΡ ΡΠ΅ΠΊΡΡΠΎΠ²ΡΠΉ ΡΠ΅Π΄Π°ΠΊΡΠΎΡ ΡΠΌΠ΅Π΅Ρ Π΄Π΅Π»Π°ΡΡ ΠΏΡΠΎΠ²Π΅ΡΠΊΡ ΡΠΈΠ½ΡΠ°ΠΊΡΠΈΡΠ° ΡΠ·ΡΠΊΠ° Π½Π° ΠΊΠΎΡΠΎΡΠΎΠΌ Π²Ρ ΠΏΠΈΡΠ΅ΡΠ΅. ΠΠ΅Π»Π°Π΅ΡΡΡ ΡΡΠΎ Π΄Π»Ρ ΡΠΎΠ³ΠΎ ΡΡΠΎΠ±Ρ Π½Π° ΡΠ°Π½Π½Π΅ΠΌ ΡΡΠ°ΠΏΠ΅ ΠΏΠΎΠ΄ΡΠΊΠ°Π·Π°ΡΡ Π²Π°ΠΌ ΠΎ ΡΠΎΠΌ, ΡΡΠΎ Π²Ρ Π΄ΠΎΠΏΡΡΡΠΈΠ»ΠΈ ΠΎΡΠΈΠ±ΠΊΡ Π² ΡΠ²ΠΎΠ΅ΠΌ ΠΊΠΎΠ΄Π΅.
ΠΡΠΎΠΌΠ΅ ΡΡΠΎΠ³ΠΎ, ΡΡΠ΅Π΄Π° ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅Ρ ΠΎΡΠ»Π°Π΄ΡΠΈΠΊΠΈ ΠΊΠΎΡΠΎΡΡΠ΅ ΠΏΠΎΠΌΠΎΠ³Π°ΡΡ ΠΏΡΠ°Π²ΠΈΡΡ ΠΈ ΠΎΡΠ»Π°ΠΆΠΈΠ²Π°ΡΡ Π²Π°Ρ ΠΊΠΎΠ΄ Π² ΡΠ»ΡΡΠ°Π΅ ΠΎΡΠΈΠ±ΠΊΠΈ. Π‘ΠΊΠ°ΠΆΠ΅ΠΌ ΡΠ°ΠΊ, ΡΡΠΎ Π±ΡΠ»ΠΈ ΠΎΠΏΠΈΡΠ°Π½Ρ ΠΎΡΠ½ΠΎΠ²Π½ΡΠ΅ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΠΈ IDE. Π‘ΠΎΠ²ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅ IDE ΠΏΡΠ΅Π΄ΠΎΡΡΠ°Π²Π»ΡΡΡ ΠΎΠ³ΡΠΎΠΌΠ½ΠΎΠ΅ ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠΎΠ², ΠΊΠΎΡΠΎΡΡΠ΅ ΠΌΠΎΠ³ΡΡ ΠΏΠΎΠΌΠΎΡΡ Π² Π½Π°ΠΏΠΈΡΠ°Π½ΠΈΠΈ, ΠΎΡΠ»Π°Π΄ΠΊΠ΅, Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΎΠΉ Π³Π΅Π½Π΅ΡΠ°ΡΠΈΠΈ ΠΊΠΎΠ΄Π° ΠΈ ΡΠ΅ΡΠΈΡΡ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²ΠΎ Π΄ΡΡΠ³ΠΈΡ ΠΏΡΠΎΠ±Π»Π΅ΠΌ.
ΠΠ»Ρ Π½Π°ΡΠ°Π»Π° Π½Π°ΠΌ Π½ΡΠΆΠ½ΠΎ Π²ΡΠ±ΡΠ°ΡΡ ΠΈ ΡΡΠ΅Π΄Ρ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ. ΠΡ Π΄ΠΎΠ²ΠΎΠ»ΡΠ½ΠΎ ΡΠ°ΠΊΠΈ ΠΌΠ½ΠΎΠ³ΠΎ, ΠΈ ΡΠ°ΠΌΡΠΌΠΈ ΠΏΠΎΠΏΡΠ»ΡΡΠ½ΡΠΌΠΈ ΠΈΠ· Π½ΠΈΡ ΡΠ²Π»ΡΡΡΡΡ: IntelliJ IDEA, NetBeans, Eclipse. ΠΠ»Ρ ΡΠ΅Π±Ρ Ρ Π²ΡΠ±ΠΈΡΠ°Ρ IntelliJ IDEA. ΠΠ½Π° ΡΠ²Π»ΡΠ΅ΡΡΡ ΡΠ°ΠΌΠΎΠΉ ΡΠ΄ΠΎΠ±Π½ΠΎΠΉ Π½Π° ΠΌΠΎΠΉ Π²Π·Π³Π»ΡΠ΄, ΠΈ Ρ ΠΎΡΡ ΠΎΠ½Π° ΠΈ ΠΏΠ»Π°ΡΠ½Π°Ρ, Π½Π° ΠΎΡΠΈΡΠΈΠ°Π»ΡΠ½ΠΎΠΌ ΡΠ°ΠΉΡΠ΅ ΠΌΠΎΠΆΠ½ΠΎ Π½Π°ΠΉΡΠΈ Π±Π΅ΡΠΏΠ»Π°ΡΠ½ΡΡ Π²Π΅ΡΡΠΈΡ ΠΊΠΎΡΠΎΡΠ°Ρ Π½Π°Π·ΡΠ²Π°Π΅ΡΡΡ Community. ΠΡΠΎΠΉ Π²Π΅ΡΡΠΈΠΈ Π±ΡΠ΄Π΅Ρ Π²ΠΏΠΎΠ»Π½Π΅ Π΄ΠΎΡΡΠ°ΡΠΎΡΠ½ΠΎ Π΄Π»Ρ ΠΈΠ·ΡΡΠ΅Π½ΠΈΡ ΠΎΡΠ½ΠΎΠ² Java. ΠΠΎΠΎΠ±ΡΠ΅ΠΌ Π±ΡΠ΄Π΅ΠΌ ΡΠ°Π±ΠΎΡΠ°ΡΡ Π² IntelliJ IDEA.
ΠΡΠ°ΠΊ, ΠΎΡΠΊΡΡΠ²Π°Π΅ΠΌ Π±ΡΠ°ΡΠ·Π΅Ρ, Π² ΠΏΠΎΠΈΡΠΊΠΎΠ²ΠΎΠΉ ΡΡΡΠΎΠΊΠ΅ Π²Π²ΠΎΠ΄ΠΈΠΌ «Download IntelliJ IDEA Community» ΠΈΠ»ΠΈ ΠΏΠ΅ΡΠ΅Ρ ΠΎΠ΄ΠΈΠΌ ΠΏΠΎ ΡΡΠΎΠΉ ΡΡΡΠ»ΠΊΠ΅. ΠΡΠ±ΠΈΡΠ°Π΅ΠΌ Π²Π΅ΡΡΠΈΡ ΠΠ‘ ΠΈ ΠΊΠ°ΡΠ°Π΅ΠΌ Π²Π΅ΡΡΠΈΡ Community.
Π ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠ΅ IntelliJ IDEA Π½Π΅Ρ Π½ΠΈΡΠ΅Π³ΠΎ Π²ΠΎΠ΅Π½Π½ΠΎΠ³ΠΎ. ΠΠ° ΠΊΡΠ°ΠΉΠ½ΠΈΠΉ ΡΠ»ΡΡΠ°ΠΉ Π½Π° ΡΡΡΠ±Π΅ Π΅ΡΡΡ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²ΠΎ Π²ΠΈΠ΄Π΅ΠΎ ΠΎ ΡΠΎΠΌ, ΠΊΠ°ΠΊ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ ΡΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ.
ΠΠ΅ΡΠ²Π°Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ°
Π’Π΅ΠΏΠ΅ΡΡ ΠΌΡ Π³ΠΎΡΠΎΠ²Ρ ΡΠΎΠ·Π΄Π°ΡΡ Π½Π°ΡΡ ΠΏΠ΅ΡΠ²ΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ. Π ΠΎΠΊΠΎΡΠΊΠ΅ Π·Π°ΠΏΡΡΡΠΈΠ²ΡΠΈΠΉΡΡ IDE Π½Π°ΠΆΠΈΠΌΠ°Π΅ΠΌ New Project.
Π Π½ΠΎΠ²ΠΎΠΌ ΠΎΠΊΠΎΡΠΊΠ΅ Π² Π»Π΅Π²ΠΎΠΉ ΠΏΠ°Π½Π΅Π»ΠΈ Π²ΡΠ±ΠΈΡΠ°Π΅ΠΌ Java.
ΠΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅! Π Π²Π΅ΡΡ Π½Π΅ΠΌ ΠΎΠΊΠΎΡΠΊΠ΅, ΡΠΏΡΠ°Π²Π°, Π²ΠΎΠ·Π»Π΅ Π½Π°Π΄ΠΏΠΈΡΠΈ «Project SDK:» Π΄ΠΎΠ»ΠΆΠ½Π° Π½Π°Ρ ΠΎΠ΄ΠΈΡΡΡ Π²Π΅ΡΡΠΈΡ Java, ΠΊΠΎΡΠΎΡΡΡ Π²Ρ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΠ»ΠΈ Π²ΠΌΠ΅ΡΡΠ΅ Ρ JDK. ΠΡΠ»ΠΈ ΡΠ°ΠΌ ΠΏΡΡΡΠΎ, ΡΠΎ Π²Π°ΠΌ Π½ΡΠΆΠ½ΠΎ Π±ΡΠ΄Π΅Ρ ΡΠΊΠ°Π·Π°ΡΡ ΠΏΡΡΡ ΠΊ Π²Π°ΡΠ΅ΠΌΡ JDK Π²ΡΡΡΠ½ΡΡ. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ Π² Π²ΡΠΏΠ°Π΄Π°ΡΡΠ΅ΠΌ ΡΠΏΠΈΡΠΊΠ΅ Π½Π°ΠΆΠΌΠΈΡΠ΅ «Add JDK. « ΠΈ ΡΠΊΠ°ΠΆΠΈΡΠ΅ ΠΏΡΡΡ ΠΊ Π²Π°ΡΠ΅ΠΌΡ JDK, ΠΊΠΎΡΠΎΡΡΠΉ Π±ΡΠ» ΠΏΡΠ΅Π΄Π²Π°ΡΠΈΡΠ΅Π»ΡΠ½ΠΎ ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½.
Π’Π΅ΠΏΠ΅ΡΡ ΠΌΠΎΠΆΠ΅ΠΌ Π½Π°ΠΆΠ°ΡΡ Π½Π° ΠΊΠ½ΠΎΠΏΠΊΡ Next. Π ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΌ ΠΎΠΊΠΎΡΠΊΠ΅, Π²Π²Π΅ΡΡ Ρ, ΠΏΠΎΡΡΠ°Π²ΡΡΠ΅ Π³Π°Π»ΠΎΡΠΊΡ βCreate project from templateβ ΠΈ Π²ΡΠ±Π΅ΡΠΈΡΠ΅ βCommand Line Appβ. Π ΡΠ½ΠΎΠ²Π° Π½Π°ΠΆΠΈΠΌΠ°Π΅ΠΌ Next.
ΠΠ°Π»ΡΡΠ΅ Π½Π°ΠΌ Π½ΡΠΆΠ½ΠΎ ΡΠΊΠ°Π·Π°ΡΡ ΠΈΠΌΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ. Π£ ΠΌΠ΅Π½Ρ ΡΡΠΎ Π±ΡΠ΄Π΅Ρ Hello World, ΠΆΠ΅Π»Π°ΡΠ΅Π»ΡΠ½ΠΎ ΡΡΠΎΠ±Ρ ΠΈΠΌΡ ΠΏΡΠΎΠ΅ΠΊΡΠ° Π±ΡΠ»ΠΎ Π²Π²Π΅Π΄Π΅Π½ΠΎ Π»Π°ΡΠΈΠ½ΠΈΡΠ΅ΠΉ, ΠΈ Π½Π° Π°Π½Π³Π»ΠΈΠΉΡΠΊΠΎΠΌ ΡΠ·ΡΠΊΠ΅.
ΠΡΠΈΠΌΠ΅ΡΠ°Π½ΠΈΠ΅. ΠΡΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ, ΠΈΠΌΠ΅Π½Π° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌ, ΠΏΡΠΈΠ½ΡΡΠΎ ΠΏΠΈΡΠ°ΡΡ Π½Π° Π°Π½Π³Π»ΠΈΠΉΡΠΊΠΎΠΌ ΡΠ·ΡΠΊΠ΅, ΠΈ ΠΆΠ΅Π»Π°ΡΠ΅Π»ΡΠ½ΠΎ ΠΏΡΠΈΠ΄Π΅ΡΠΆΠΈΠ²Π°ΡΡΡΡ ΡΠ°ΠΊΠΎΠ³ΠΎ ΡΡΠΈΠ»Ρ, ΡΡΠΎ ΡΠ²Π»ΡΠ΅ΡΡΡ Ρ ΠΎΡΠΎΡΠΈΠΌ ΡΠΎΠ½ΠΎΠΌ Π² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΠΈ.
ΠΠΎΡΠ»Π΅ ΡΠΊΠ°Π·ΡΠ²Π°Π΅ΠΌ ΠΏΡΡΡ ΠΊ ΠΏΡΠΎΠ΅ΠΊΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ.
ΠΠΎΡΠ»Π΅ ΡΡΠΎΠ³ΠΎ Π²Ρ ΡΠ²ΠΈΠ΄ΠΈΡΠ΅ Π³Π»Π°Π²Π½ΠΎΠ΅ ΠΎΠΊΠ½ΠΎ IDE, Π² ΠΊΠΎΡΠΎΡΠΎΠΌ ΡΠΆΠ΅ Π±ΡΠ΄Π΅Ρ ΡΠΎΠ·Π΄Π°Π½Π° Π²Π°ΡΠ° ΠΏΠ΅ΡΠ²Π°Ρ, ΠΏΠΎΡΡΠΈ Π³ΠΎΡΠΎΠ²Π°Ρ ΠΊΠΎΠ½ΡΠΎΠ»ΡΠ½Π°Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ°.
ΠΡΠΎ ΠΎΠΊΠ½ΠΎ, ΡΠΎ ΡΡΠΎ Π²Ρ Π±ΡΠ΄Π΅ΡΠ΅ Π²ΠΈΠ΄Π΅ΡΡ 80-90%, Π° ΠΈΠ½ΠΎΠ³Π΄Π° ΠΈ 100% Π²ΡΠ΅ΠΌΠ΅Π½ΠΈ, ΡΠ°Π±ΠΎΡΠ°Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡΠΎΠΌ.
ΠΠ»Ρ ΡΠΎΠ³ΠΎ ΡΡΠΎΠ±Ρ Π·Π°ΠΊΠΎΠ½ΡΠΈΡΡ Π²Π°ΡΠ΅ ΠΏΠ΅ΡΠ²ΠΎΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅, ΠΎΡΡΠ°Π½Π΅ΡΡΡ Π΄ΠΎΠ±Π°Π²ΠΈΡΡ ΡΡΡΠΎΡΠΊΡ ΠΊΠΎΠ΄Π° System.out.print(«Hello world!»); ΠΊΠ°ΠΊ ΠΏΠΎΠΊΠ°Π·Π°Π½ΠΎ Π½Π° ΡΠΊΡΠΈΠ½ΡΠΎΡΠ΅.
Π Π°Π·Π±ΠΈΡΠ°Π΅ΠΌ ΠΏΠ΅ΡΠ²ΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ
Π ΡΠ²ΠΎΠ΅ΠΌ ΠΏΠ΅ΡΠ²ΠΎΠΌ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΈ Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΡΠ²ΠΈΠ΄Π΅ΡΡ ΠΌΠ½ΠΎΠ³ΠΎ Π½Π΅ΠΏΠΎΠ½ΡΡΠ½ΡΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ² ΠΈ ΡΠ»ΠΎΠ², Π½ΠΎ Π½Π° Π΄Π°Π½Π½ΠΎΠΌ ΡΡΠ°ΠΏΠ΅ Π²Ρ Π΄ΠΎΠ»ΠΆΠ½Ρ Π²ΠΎΡΠΏΡΠΈΠ½ΡΡΡ ΠΈΡ ΠΊΠ°ΠΊ Π΄Π°Π½Π½ΠΎΡΡΡ, ΠΏΠΎΠ·ΠΆΠ΅, Π² ΡΠ»Π΅Π΄ΡΡΡΠΈΡ ΡΠ°ΡΡΡΡ , Ρ ΡΠ°ΡΡΠΊΠ°ΠΆΡ ΠΎ ΠΊΠ°ΠΆΠ΄ΠΎΠΌ ΠΈΠ· Π½ΠΈΡ , ΠΈ Π·Π°ΡΠ΅ΠΌ ΠΎΠ½ΠΈ Π½ΡΠΆΠ½Ρ. ΠΠ° Π΄Π°Π½Π½ΠΎΠΌ ΡΡΠ°ΠΏΠ΅ Π²Π°ΠΌ Π½ΡΠΆΠ½ΠΎ ΠΏΠΎΠ½ΡΡΡ ΡΡΠΎ ΡΡΠΎ ΡΡΠ°Π½Π΄Π°ΡΡΠ½ΡΠ΅ ΡΠΎΡΡΠ°Π²Π»ΡΡΡΠΈΠ΅ Π»ΡΠ±ΠΎΠ³ΠΎ Java-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ, ΠΈ Π² ΠΏΠΎΡΠ»Π΅Π΄ΡΡΡΠΈΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡΡ ΡΡΠΈ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΡ Π±ΡΠ΄ΡΡ ΠΈΠ·ΠΌΠ΅Π½ΡΡΡΡΡ ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡΠ½ΠΎ.
ΠΡΠΎΠΉΠ΄Π΅ΠΌΡΡ ΠΏΠΎ ΠΏΠΎΡΡΠ΄ΠΊΡ:
Π€ΠΈΠ³ΡΡΠ½ΡΠ΅ ΡΠΊΠΎΠ±ΠΊΠΈ <> Ρ ΠΌΠ΅ΡΠΎΠ΄Π° main ΠΎΠ±ΠΎΠ·Π½Π°ΡΠ°Ρ Π½Π°ΡΠ°Π»ΠΎ ΠΈ ΠΊΠΎΠ½Π΅Ρ ΡΠ΅Π»Π° ΠΌΠ΅ΡΠΎΠ΄Π°, Π²Π΅ΡΡ ΠΊΠΎΠ΄ ΠΌΠ΅ΡΠΎΠ΄Π° Π΄ΠΎΠ»ΠΆΠ΅Π½ ΡΠ°ΡΠΏΠΎΠ»Π°Π³Π°ΡΡΡΡ ΠΌΠ΅ΠΆΠ΄Ρ ΡΡΠΈΠΌΠΈ ΡΠΊΠΎΠ±ΠΊΠ°ΠΌΠΈ. ΠΠ½Π°Π»ΠΎΠ³ΠΈΡΠ½ΡΠ΅ ΡΠΊΠΎΠ±ΠΊΠΈ Π΅ΡΡΡ ΠΈ Ρ ΠΊΠ»Π°ΡΡΠ° Main.
Π‘Π»Π΅Π΄ΡΡΡΠ°Ρ ΡΡΡΠΎΠΊΠ° ΡΠ²Π»ΡΠ΅ΡΡΡ // write your code here ΠΎΠ΄Π½ΠΎΡΡΡΠΎΡΠ½ΡΠΌ ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠ΅ΠΌ.
ΠΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠ΅ΠΌ ΡΠ²Π»ΡΠ΅ΡΡΡ ΡΠ΅ΠΊΡΡ ΠΊΠΎΡΠΎΡΡΠΉ ΠΈΠ³Π½ΠΎΡΠΈΡΡΠ΅ΡΡΡ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡΠΎΠΌ. ΠΠΎ-ΡΡΠΎΠΌΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠ΅Π² Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΠΎΡΡΠ°Π²Π»ΡΡΡ Π² ΠΊΠΎΠ΄Π΅ ΠΏΠΎΠ΄ΡΠΊΠ°Π·ΠΊΠΈ Π΄Π»Ρ ΡΠ΅Π±Ρ ΠΈ Π΄ΡΡΠ³ΠΈΡ , ΠΊΡΠΎ Π±ΡΠ΄Π΅Ρ ΡΠΈΡΠ°ΡΡ Π²Π°Ρ ΠΊΠΎΠ΄, ΠΈΠ»ΠΈ ΠΆΠ΅ Π΄Π»Ρ Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π²Π°ΡΠ΅Π³ΠΎ ΠΊΠΎΠ΄Π°. Π‘ΡΡΠ΅ΡΡΠ²ΡΠ΅Ρ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ Π²ΠΈΠ΄ΠΎΠ² ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠ΅Π², ΠΎΡΠ½ΠΎΠ²Π½ΡΠΌΠΈ ΠΈΠ· Π½ΠΈΡ ΡΠ²Π»ΡΡΡΡΡ ΠΎΠ΄Π½ΠΎΡΡΡΠΎΡΠ½ΡΠΉ, ΠΈ ΠΌΠ½ΠΎΠ³ΠΎΡΡΡΠΎΡΠ½ΡΠΉ.
ΠΠ½ΠΎΠ³ΠΎΡΡΡΠΎΡΠ½ΡΠΉ ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠΉ Π±ΡΠ΄Π΅Ρ Π²ΡΠ³Π»ΡΠ΄Π΅ΡΡ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ:
ΠΡ ΠΏΡΠΎΡΡΠΎ ΡΠ°ΡΠΏΠΎΠ»Π°Π³Π°Π΅ΠΌ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΡΡΡΠΎΠΊ ΠΌΠ΅ΠΆΠ΄Ρ ΡΠΈΠΌΠ²ΠΎΠ»Π°ΠΌΠΈ /* ΠΈ */
ΠΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅ ΡΡΠΎ Π² ΠΊΠΎΠ½ΡΠ΅ ΡΡΠΎΠΈΡ ΡΠΎΡΠΊΠ° Ρ Π·Π°ΠΏΡΡΠΎΠΉ, Π² ΡΠ·ΡΠΊΠ΅ Java ΠΊΠΎΠΌΠ°Π½Π΄Ρ Π΄ΠΎΠ»ΠΆΠ½Ρ Π·Π°ΠΊΠ°Π½ΡΠΈΠ²Π°ΡΡΡΡ ΡΠΎΡΠΊΠΎΠΉ Ρ Π·Π°ΠΏΡΡΠΎΠΉ.
ΠΠ° ΡΡΠΎΠΌ ΡΡΠ°ΡΡΡ ΠΏΠΎΠ΄Ρ ΠΎΠ΄ΠΈΡ ΠΊ ΠΊΠΎΠ½ΡΡ. ΠΠ²ΡΠΎΡΠΎΠΌ ΠΊΠΎΠ½ΠΊΡΠ΅ΡΠ½ΠΎ ΡΡΠΎΠ³ΠΎ ΠΌΠ°ΡΠ΅ΡΠΈΠ°Π»Π° ΡΠ²Π»ΡΠ΅ΡΡΡ ΠΠ³ΠΎΡ ΠΈ Π²ΡΠ΅ ΡΠΌΠ΅Π½ΡΡΠΈΡΠ΅Π»ΡΠ½ΠΎ Π»Π°ΡΠΊΠ°ΡΠ΅Π»ΡΠ½ΡΠ΅ ΡΠΎΡΠΌΡ ΡΠ»ΠΎΠ² ΡΠΎΡ ΡΠ°Π½ΠΈΠ»ΠΈΡΡ Π² ΠΏΠ΅ΡΠ²ΠΎΠ·Π΄Π°Π½Π½ΠΎΠΌ Π²ΠΈΠ΄Π΅.
Π ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΉ ΡΡΠ°ΡΡΠ΅ ΠΌΡ ΠΏΠΎΠ³ΠΎΠ²ΠΎΡΠΈΠΌ ΠΎ ΡΠΈΠΏΠ°Ρ Π΄Π°Π½Π½ΡΡ Π² Java.
Hello World in Java (Windows)
This document instructs you on how to set up a Java programming environment for your Windows computer. It also provides a step-by-step guide for creating and compiling a Java program in IntelliJ and executing it from the command line.
You will need a 64-bit version of Windows 8 or 10.
0. Install the Java Programming Environment |
The installer installs and configures a Java programming environment, including OpenJDK 11 and IntelliJ IDEA Community Edition 2022.1.
If you have previously used IntelliJ 2022.1, run this installer only if you want a clean re-install. The installer overwrites any existing IntelliJ 2022.1 settings with our novice-friendly settings.
1. Open a Project in IntelliJ |
You will develop your Java programs in an application called IntelliJ IDEA Community Edition.
IntelliJ organizes Java programs into projects. In our context, each project corresponds to one programming assignment. A typical project contains Java programs, associated data files, and course-specific settings (such as compiler options, style rules, and textbook libraries).
[ sample project for COS 126 (Princeton) ]
[ sample project for COS 226 (Princeton) ]
[ sample project for Computer Science: Programming with a Purpose (Coursera) ]
[ sample project for Algorithms, Part I or II (Coursera) ]
The project folders contain course-specific information. Be sure to download the one corresponding to your institution and course.
Do not click New Project; this option is intended for advanced programmers. Also, always use Open with a project folder, not an individual file.
2. Create a Program in IntelliJ |
Now you are ready to write your first Java program. IntelliJ features many specialized programming tools including line numbering, syntax highlighting, bracket matching, auto indenting, auto formatting, auto importing, variable renaming, and continuous code inspection.
IntelliJ is configured to automatically save changes that you make to your files upon various events (such as compiling, executing, closing a file or project, or quitting the IDE). We still recommend using File β Save All (Ctrl + S) frequently for its code reformatting functionality.
3. Compile and Execute the Program (from IntelliJ) |
If the compilation fails, a Recompile panel will open up (at bottom), highlighting the compile-time errors or warnings. Check your program carefully for typos, using the error messages as a guide.
You should see the output of the program (in white), along with a message that the program finished normally (with exit code 0).
Use the LIFT menu to compile and execute your program from IntelliJ. The Build and Run menus support additional options for advanced programmers.
Also be sure that the main editor window is active before using the LIFT menu (e.g., by clicking the code you want to compile or execute).
4. Compile and Execute the Program (from the command line) |
The command line is a simple and powerful mechanism for controlling your programs (e.g., command-line arguments, file redirection, and piping). IntelliJ supplies an embedded terminal for easy access to the command line.
/Desktop/hello is the current working directory, where
is shorthand for your home directory.
Typically, you should compile from IntelliJ (because IntelliJ highlights the lines on which any compile-time errors or warnings occur) and execute from the command line (because the command line makes it is easy to specify command-line arguments and use file redirection).
5. Textbook Libraries (from the command line) |
To make our textbook libraries accessible to Java from the command line, you will use our wrapper scripts.
To get your command prompt back, close the standard drawing window.
When you execute the program, a standard drawing window will appear with an animation of 20 colliding disks. To get your command prompt back, close the standard drawing window.
Frequently Asked Questions |
PMD is licensed under a BSD-style license.
The course-specific project folders perform additional customizations:
To manually configure the Project SDK,
To create a new project from scratch, you can use the Create New Project option from the Welcome screen. But, we do not recommend this approach for novice programmers. Can I use a version of IntelliJ that is more recent than 2022.1.2? Yes, though if it is 2022.2 (or above), you will need to migrate your user preferences. How I can I restore the original IntelliJ settings (instead of the abbreviated novice-friendly ones)?
How to write, compile and run a hello world Java program for beginners
To start, all you need is a fresh computer without any Java software installed, a text-based editor and a good internet connection.
NOTES: This beginner tutorial is targeted for Windows environment.
1. Download and install Java Development Kit
Check the option βAccept License Agreementβ, and choose an appropriate version for your computer from the list. Here we choose the version for Windows x64:
You would see the JDK is installed in the following directory, for example: C:\Program Files\Java\jdk1.7.0_21. The following screenshot describes the JDKβs directory structure:
Now letβs test if Java runtime is installed correctly. Open a command prompt window and type:
You would see the following result:
Now try to type the following command:
You would see the following error:
2. Set up environment variables
Then click Advanced system settings:
The System Properties dialog appears, select Advanced tab and click Environment Variables. :
The Environment Variable dialog appears, click on the New⦠button under the System variables section.
That opens up the New System Variable dialog. Type the following information:
Now back to the Environment Variables dialog, look for a variable called Path under the System Variables list, and click Editβ¦:
In the Edit System Variable dialog, append the following to the end of the field Variable value:
;%JAVA_HOME%\bin
Note that there is a semicolon at the beginning to separate this value from other ones. Click OK three times to close all the dialogs.
Now we have to quit the current command prompt and open a new one to see the changes takes effect. Type the following command again in the re-opened command prompt window:
You would see the following output:
Congratulations! You have completed the setup for essential Java development environment on your computer. Itβs now ready to write your first Java program.
3. Code a Java hello world program
Donβt worry if you donβt understand everything in this simple Java code. The following picture explains it nicely:
Every Java program starts from the main() method. This program simply prints βHello worldβ to screen.
4. Compile your first Java program
cd C:\Java
And type the following command:
javac HelloWorld.java
So remember a Java program will be compiled into bytecode form (.class file).
5. Run your first Java program
java HelloWorld
It just prints out βHello world!β to the screen and quits. Congratulations! You have successfully run your first Java program!
6. What we have learnt so far
You can also watch the video version of this tutorial:
Next, I recommend you to read this article: Understand Classes and Objects in Java
Related Java Hello World Tutorials:
About the Author:
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.
Add comment
Comments
I downloaded the Java Installer form the link you’ve provided in this site. It was java 18.0.2. and it never asked me to set those clumsy Path and System variable settings for javac.
MANY THANKS FOR THIS.
I was just about to uninstall java, because it didn’t worked in spite of following several tutorials available online. Then! I tumbled upon your tutorial and everything changed. Thanks Again Nam Ha!
Java Hello World: A Guide for Beginners
Welcome to the Java programming language. The first task any beginner should take on is the βHello, World!β script. In this task, you have to print a message to the console. This is another way of saying make a line of text appear on the screen.
This guide walks you through an example βHello, World!β program and explain how it works. Along the way, youβll learn the building blocks that make up a Java program.
Find Your Bootcamp Match
Select your interest
First name
Last name
Phone number
By continuing you agree to our Terms of Service and Privacy Policy, and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.
Prerequisites
Before we begin, make sure you have installed Java on your computer. You should have a text editor, like Atom or Sublime Text, as well. Text editing tools are used to view and edit programs in a Java project.
Java Hello World
Letβs introduce your program to the world by writing a program that shows βHello, World!β on the console. This is what the typical HelloWorld program looks like:
Create a file called HelloWorld.java on your computer. Then, copy the text that you see above in that file. In Java, the names of a class must match up to the name of a file. Your file must be called HelloWorld because our class is called HelloWorld.
This is a feature of Java that helps keep programs consistent. As you write more advanced code, having classes in files with the same name makes it easier to navigate through those classes and find the code you are looking for.
Our code prints βHello, World!β to the command line console:
Java Hello World: A Deep Dive
Thatβs all you need to show a message to the console. In total, our program is six lines of code. As a beginner, youβre probably wondering what they mean.
Weβll start with the first line. On the first line, we define a class:
For a program to work in Java, it must be enclosed within a class. We have called our class HelloWorld. All the code within the curly braces is part of the class. Whereas languages like Python use spaces to indicate what code is part of a class, Java uses curly braces.
On the next line, we write a comment:
// Show a message to the screen
Comments are text that are readable by a programmer who is viewing or editing a file. The Java compiler, which runs your code, will not execute any comments. The compiler knows that comments are for human use, and not instructions for a machine.
Next, we define a main method:
public static void main(String[] args) < >
This line of code is a bit more complicated than the others, but itβs actually quite simple.
Every class must have a main method. This is where Java starts running a program. If your program did not have a main method, Java would not know where to begin executing your code.
Weβre going to skip over the βpublic static voidβ part for now. Those are more advanced topics youβll learn later. For now, you should know that most main methods in beginner programs use these keywords.
The String[] args method lets you pass arguments into a method. Weβre going to skip over this concept because you do not need to know how it works when you first start.
Like our class, our main() method ends in a set of curly braces. In those curly braces, we have a statement that prints a message to the console:
The System.out.println() method displays a message to the console. We donβt have to do any work other than tell this method what should be displayed.
In our program, we ask the method to print the statement βHello, World!β to the console. This statement appears in curly brackets so our program knows our message is part of the method.
Moving On From βHello, World!β
You have successfully written your first program in Java. You should give yourself a pat on the back. It is a big deal that you have written anything in code.
The βHello, World!β program may be simple but thatβs not a problem. You do not need to expect too much from yourself when you first begin. There will always be opportunities to master hard topics further down the line. The basics come first.
«Career Karma entered my life when I needed it most and quickly helped me match with a bootcamp. Two months after graduating, I found my dream job that aligned with my values and goals in life!»
Venus, Software Engineer at Rockbot
Find Your Bootcamp Match
What weβve learned is that every program must contain a class. This class should share the same name as the file in which it appears. Every program must contain a method called main(). This tells Java what code should run.
Files can contain comments. Comments are pieces of text that are readable by humans but are not executed by a computer.
Now youβre ready to move on to the next step of learning the Java language!
3 Hello World, JavaFX Style
The best way to teach you what it is like to create and build a JavaFX application is with a βHello Worldβ application. An added benefit of this tutorial is that it enables you to test that your JavaFX technology is properly installed.
The tool used in this tutorial is NetBeans IDE 7.4. Before you begin, ensure that the version of NetBeans IDE that you are using supports JavaFX 8. See the Certified System Configurations section of the Java SE 8 downloads page for details.
Construct the Application
NetBeans opens the HelloWorld.java file and populates it with the code for a basic Hello World application, as shown in Example 3-1.
Example 3-1 Hello World
Here are the important things to know about the basic structure of a JavaFX application:
The main class for a JavaFX application extends the javafx.application.Application class. The start() method is the main entry point for all JavaFX applications.
A JavaFX application defines the user interface container by means of a stage and a scene. The JavaFX Stage class is the top-level JavaFX container. The JavaFX Scene class is the container for all content. Example 3-1 creates the stage and scene and makes the scene visible in a given pixel size.
In JavaFX, the content of the scene is represented as a hierarchical scene graph of nodes. In this example, the root node is a StackPane object, which is a resizable layout node. This means that the root node’s size tracks the scene’s size and changes when the stage is resized by a user.
The root node contains one child node, a button control with text, plus an event handler to print a message when the button is pressed.
The main() method is not required for JavaFX applications when the JAR file for the application is created with the JavaFX Packager tool, which embeds the JavaFX Launcher in the JAR file. However, it is useful to include the main() method so you can run JAR files that were created without the JavaFX Launcher, such as when using an IDE in which the JavaFX tools are not fully integrated. Also, Swing applications that embed JavaFX code require the main() method.
Figure 3-1 shows the scene graph for the Hello World application. For more information on scene graphs see Working with the JavaFX Scene Graph.
Figure 3-1 Hello World Scene Graph
Description of «Figure 3-1 Hello World Scene Graph»
Run the Application
Click the Say Hello World button.
Verify that the text βHello World!β is printed to the NetBeans output window.
Figure 3-2 shows the Hello World application, JavaFX style.
Figure 3-2 Hello World, JavaFX style
Description of «Figure 3-2 Hello World, JavaFX style»
Where to Go Next
This concludes the basic Hello World tutorial, but continue reading for more lessons on developing JavaFX applications:
Creating a Form in JavaFX teaches the basics of screen layout, how to add controls to a layout, and how to create input events.
Fancy Forms with JavaFX CSS provides simple style tricks for enhancing your application, including adding a background image and styling buttons and text.
Using FXML to Create a User Interface shows an alternate method for creating the login user interface. FXML is an XML-based language that provides the structure for building a user interface separate from the application logic of your code.
Animation and Visual Effects in JavaFX shows how to bring an application to life by adding timeline animation and blend effects.
Java IDL: The «Hello World» Example
POA model, transient server
This document is a high-level overview of how to create a complete CORBA (Common Object Request Broker Architecture) application using IDL (Interface Definiton Language) to define interfaces and the Java IDL compiler to generate stubs and skeletons. For more information on the development process, and a more detailed tutorial on creating a CORBA application using IDL, see Getting Started with Java IDL: The Hello World Tutorial. You can also create CORBA application by defining the interfaces in the Java programming language. For more information and a tutorial on this development process, see the Java RMI-IIOP documentation.
In this release of Java SE, the server-side implementation generated by the idlj compiler is the Portable Servant Inheritance Model, also known as the POA model. The POA, or Portable Object Adapter, is discussed in more detail in Portable Object Adapter. This document presents a sample application created using the default behavior of the idlj compiler, which uses a POA server-side model.
CORBA supports at least two different server-side mappings for implementing an IDL interface:
Using the Inheritance Model, you implement the IDL interface using an implementation class that also extends the compiler-generated skeleton.
Inheritance models include:
NOTE: ImplBase is deprecated in favor of the POA model, but is provided to allow compatibility with servers written in J2SE 1.3 and prior. We do not recommend creating new servers using this nonstandard model.
Using the Delegation Model, you implement the IDL interface using two classes:
The Delegation model is also known as the Tie model, or the Tie Delegation model. It inherits from either the POA or ImplBase compiler-generated skeleton, so the models will be described as POA/Tie or ImplBase/Tie models in this document.
This tutorial presents the POA Inheritance model for server-side implementation. For tutorials using the other server-side implementations, see the following documents:
The Tie Model is a delegation model. Use the idlj compiler to first generate server-side bindings. Then, run the idlj compiler a second time with the with the -fallTie option to generate Tie model server-side bindings. For the interface Hello, HelloPOATie.java is one of the generated files. The constructor to HelloPOATie takes a delegate or a delegate and a poa. You must provide the implementation for delegate and/or the poa, but the delegate does not have to inherit from any other class, only the interface HelloOperations. For more information, refer to the IDL to Java Language Mapping Specification.
The ImplBase server-side model is an Inheritance Model, as is the POA model. Use the idlj compiler with the -oldImplBase flag to generate server-side bindings that are compatible with versions of Java IDL prior to J2SE 1.4. Given an interface Hello defined in Hello.idl, the file _HelloImplBase.java is generated. You must provide the implementation for Hello and it must inherit from _HelloImplBase.
Note that using the -oldImplBase flag is non-standard: these APIs are being deprecated. You would use this flag ONLY for compatibility with existing servers written in J2SE 1.3 or earlier. In that case, you would need to modify an existing MAKEFILE to add the -oldImplBase flag to the idlj compiler, otherwise POA-based server-side mappings will be generated.
This document contains:
To create this example, create a directory named hello/ where you develop sample applications and create the files in this directory, or download the example code and unzip it into your sample applications directory.
Defining the Interface ( Hello.idl )
The first step to creating a CORBA application is to specify all of your objects and their interfaces using the OMG’s Interface Definition Language (IDL). IDL has a syntax similar to C++ and can be used to define modules, interfaces, data structures, and more. The IDL can be mapped to a variety of programming languages. The IDL mapping for Java is summarized in IDL to Java Language Mapping Summary.
The following code is written in the OMG IDL, and describes a CORBA object whose sayHello() operation returns a string and whose shutdown() method shuts down the ORB. To learn more about OMG IDL Syntax and Semantics, read Chapter 3 of the CORBA 2.3.1 Specification.
Hello.idl
NOTE: When writing code in OMG IDL, do not use an interface name as the name of a module. Doing so runs the risk of getting inconsistent results when compiling with tools from different vendors, thereby jeopardizing the code’s portability. For example, code containing the same names could be compiled with the IDL to Java compiler from Sun Microsystems and get one result. The same code compiled with another vendor’s IDL to Java compiler could produce a different result.
To complete the application, you simply provide the server ( HelloServer.java ) and client ( HelloClient.java ) implementations.
Implementing the Server ( HelloServer.java )
The example server consists of two classes, the servant and the server. The servant, HelloImpl, is the implementation of the Hello IDL interface; each Hello instance is implemented by a HelloImpl instance. The servant is a subclass of HelloPOA, which is generated by the idlj compiler from the example IDL. The servant contains one method for each IDL operation, in this example, the sayHello() and shutdown() methods. Servant methods are just like ordinary Java methods; the extra code to deal with the ORB, with marshaling arguments and results, and so on, is provided by the skeleton.
The HelloServer class has the server’s main() method, which:
This example provides an example of a transient object server. For an example of the «Hello World» program with a persistent object server, see Example 2: Hello World with Persistent State. For more discussion of CORBA servers, see Developing Servers.
For more discussion of the code, see the detailed tutorial topic Getting Started with Java IDL: Developing a Hello World Server.
HelloServer.java
Implementing the Client Application ( HelloClient.java )
The example application client that follows:
HelloClient.java
Building and Running Hello World
Despite its simple design, the Hello World program lets you learn and experiment with all the tasks required to develop almost any CORBA program that uses static invocation. Static invocation, which uses a client stub for the invocation and a server skeleton for the service being invoked, is used when the interface of the object is known at compile time. If the interface is not known at compile time, dynamic invocation must be used.
This example requires a naming service, which is a CORBA service that allows CORBA objects to be named by means of binding a name to an object reference. The name binding may be stored in the naming service, and a client may supply the name to obtain the desired object reference. The two options for Naming Services shipped with this release of Java SE include orbd, a daemon process containing a Bootstrap Service, a Transient Naming Service, a Persistent Naming Service, and a Server Manager, and tnameserv, a transient naming service that is provided for backward compatibility. This example uses orbd.
When running this example, remember that, when using Solaris software, you must become root to start a process on a port under 1024. For this reason, we recommend that you use a port number greater than or equal to 1024. The -ORBInitialPort option is used to override the default port number in this example. The following instructions assume you can use port 1050 for the Java IDL Object Request Broker Daemon, orbd. You can substitute a different port if necessary. When running these examples on a Windows machine, subtitute a backslash (\) in path names.
To run this client-server application on your development machine:
You must use the -fall option with the idlj compiler to generate both client and server-side bindings. This command line will generate the default server-side bindings, which assumes the POA Inheritance server-side model. For more information on the idlj options, see IDL-to-Java compiler options.
The idlj compiler generates a number of files. The actual number of files generated depends on the options selected when the IDL file is compiled. The generated files provide standard functionality, so you can ignore them until it is time to deploy and run your program. The files generated by the idlj compiler for Hello.idl, with the -fall command line option, are:
This class is the client stub, providing CORBA functionality for the client. It extends org.omg.CORBA.portable.ObjectImpl and implements the Hello.java interface.
This interface contains the Java version of our IDL interface. The Hello.java interface extends org.omg.CORBA.Object, providing standard CORBA object functionality. It also extends the HelloOperations interface and org.omg.CORBA.portable.IDLEntity.
This class provides auxiliary functionality, notably the narrow() method required to cast CORBA object references to their proper types.The Helper class is responsible for reading and writing the data type to CORBA streams, and inserting and extracting the data type from Anys. The Holder class delegates to the methods in the Helper class for reading and writing.
This final class holds a public instance member of type Hello. Whenever the IDL type is an out or an inout parameter, the Holder class is used. It provides operations for org.omg.CORBA.portable.OutputStream and org.omg.CORBA.portable.InputStream arguments, which CORBA allows, but which do not map easily to Java’s semantics. The Holder class delegates to the methods in the Helper class for reading and writing. It implements org.omg.CORBA.portable.Streamable.
This interface contains the methods sayHello() and shutdown(). The IDL-to-Java mapping puts all of the operations defined on the IDL interface into this file, which is shared by both the stubs and skeletons.
To start orbd from a UNIX command shell, enter:
From an MS-DOS system prompt (Windows), enter:
Note that 1050 is the port on which you want the name server to run. The -ORBInitialPort argument is a required command-line argument. Note that when using Solaris software, you must become root to start a process on a port under 1024. For this reason, we recommend that you use a port number greater than or equal to 1024.
For an example of how to run this program on two machines, see Running the Hello World Program on 2 machines.
To start the Hello server from a UNIX command shell, enter:
From an MS-DOS system prompt (Windows), enter:
You will see HelloServer ready and waiting. when the server is started.
For this example, you can omit -ORBInitialHost localhost since the name server is running on the same host as the Hello server. If the name server is running on a different host, use -ORBInitialHost nameserverhost to specify the host on which the IDL name server is running.
Specify the name server (orbd) port as done in the previous step, for example, -ORBInitialPort 1050.
When the client is running, you will see a response such as the following on your terminal: Obtained a handle on server object: IOR: (binary code) Hello World! HelloServer exiting.
For this example, you can omit -ORBInitialHost localhost since the name server is running on the same host as the Hello client. If the name server is running on a different host, use -ORBInitialHost nameserverhost to specify the host on which the IDL name server is running.
Specify the name server (orbd) port as done in the previous step, for example, -ORBInitialPort 1050.
When you have finished this tutorial, be sure to shut down or kill the name server (orbd). To do this from a DOS prompt, select the window that is running the server and enter Ctrl+C to shut it down. To do this from a Unix shell, find the process, and kill it. The server will continue to wait for invocations until it is explicitly stopped.
Java Tutorial/Hello World!
Congratulations! You are now ready (hopefully) to begin programming in Java. Since this is the norm for first programs, your first program in Java will be the infamous «Hello World!». All this program does is display the text «Hello World!» on your screen. Your screen will usually be the console window.
Now let’s see the program:
Contents
Hello World Java Program [ edit | edit source ]
Compiling the Program [ edit | edit source ]
Compiling the program will produce the file HelloWorld.class, the JVM version of your program. This code is machine independent.
Your first impression of this program is probably «This is really long just to display a line of text.» While this may be true compared to other programming languages, this program shows a lot about the Java programming language, way beyond simply displaying a line of text.
Running the Program [ edit | edit source ]
To run the compiled version of the HelloWorld program, on the command line simply type:
Do not add the «.class» extention to the name; the Java interpreter will already be able to locate the file based on the class name you provided, and adding the extention incorrectly will simply confuse it.
Line-by-line analysis [ edit | edit source ]
Let us examine the program line by line. The first line
declares a class called HelloWorld. (Almost) everything in Java is contained in something called a class. Classes are the basis of Object-Oriented Programming (OOP) which we will discuss in a later lesson.
does pretty much what you think it does: it writes «Hello World!» to your screen. println means to print the string (text) provided and then add a line break (like the enter key).
The remaining lines are to close the method and the class.
Excercises [ edit | edit source ]
Play with the Hello World program, and:
Java: ΠΊΡΠ°ΡΠΊΠΎΠ΅ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²ΠΎ Π΄Π»Ρ Π½Π°ΡΠΈΠ½Π°ΡΡΠΈΡ . ΠΠΈΡΠ΅ΠΌ ΠΏΡΠΎΡΡΠΎΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π±Π΅Π· ΠΎΠΏΡΡΠ° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ
Java β ΠΎΠ΄ΠΈΠ½ ΠΈΠ· ΡΠ°ΠΌΡΡ Π²ΠΎΡΡΡΠ΅Π±ΠΎΠ²Π°Π½Π½ΡΡ ΡΠ·ΡΠΊΠΎΠ² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π² ΠΌΠΈΡΠ΅ ΠΈ ΠΎΠ΄ΠΈΠ½ ΠΈΠ· Π΄Π²ΡΡ ΠΎΡΠΈΡΠΈΠ°Π»ΡΠ½ΡΡ ΡΠ·ΡΠΊΠΎΠ² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌΡΡ Π² ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠ΅ Android (Π΄ΡΡΠ³ΠΎΠΉ β Kotlin). Π Π°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠΈ, Π·Π½Π°ΠΊΠΎΠΌΡΠ΅ Ρ Java, Π²Π΅ΡΡΠΌΠ° Π²ΠΎΡΡΡΠ΅Π±ΠΎΠ²Π°Π½Ρ ΠΈ ΡΠΏΠΎΡΠΎΠ±Π½Ρ ΡΠΎΠ·Π΄Π°Π²Π°ΡΡ ΡΠΈΡΠΎΠΊΠΈΠΉ ΡΠΏΠ΅ΠΊΡΡ ΡΠ°Π·Π»ΠΈΡΠ½ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ, ΠΈΠ³Ρ ΠΈ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠΎΠ². Π‘ ΠΏΠΎΠΌΠΎΡΡΡ ΡΡΠΎΠΉ ΠΊΡΠ°ΡΠΊΠΎΠΉ ΡΡΠ°ΡΡΠΈ ΠΏΠΎ Java Π΄Π»Ρ Π½Π°ΡΠΈΠ½Π°ΡΡΠΈΡ Π²Ρ ΡΠΌΠΎΠΆΠ΅ΡΠ΅ ΡΠ΄Π΅Π»Π°ΡΡ ΡΠ²ΠΎΠΈ ΠΏΠ΅ΡΠ²ΡΠ΅ ΡΠ°Π³ΠΈ ΠΊ ΡΠΎΠΌΡ, ΡΡΠΎΠ±Ρ ΡΡΠ°ΡΡ ΠΎΠ΄Π½ΠΈΠΌ ΠΈΠ· ΡΠ°ΠΊΠΈΡ ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠΎΠ². ΠΡ ΡΠ°ΡΡΠΌΠΎΡΡΠΈΠΌ Π²ΡΠ΅, ΡΡΠΎ Π²Π°ΠΌ Π½ΡΠΆΠ½ΠΎ Π·Π½Π°ΡΡ, ΡΡΠΎΠ±Ρ Π½Π°ΡΠ°ΡΡ ΡΠ°Π±ΠΎΡΡ, ΠΈ ΠΏΠΎΠΌΠΎΠΆΠ΅ΠΌ Π²Π°ΠΌ ΡΠΎΠ·Π΄Π°ΡΡ ΡΠ²ΠΎΠ΅ ΠΏΠ΅ΡΠ²ΠΎΠ΅ ΠΏΡΠΎΡΡΠΎΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅.
Π§ΡΠΎ ΡΠ°ΠΊΠΎΠ΅ Java?
Java-ΡΡΠΎ ΠΎΠ±ΡΠ΅ΠΊΡΠ½ΠΎ-ΠΎΡΠΈΠ΅Π½ΡΠΈΡΠΎΠ²Π°Π½Π½ΡΠΉ ΡΠ·ΡΠΊ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ, ΡΠ°Π·ΡΠ°Π±ΠΎΡΠ°Π½Π½ΡΠΉ ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠ΅ΠΉ Sun Microsystems Π² 1990-Ρ Π³ΠΎΠ΄Π°Ρ (ΠΏΠΎΠ·ΠΆΠ΅ ΠΊΡΠΏΠ»Π΅Π½Π½ΠΎΠΉ Oracle).
ΠΠΎΠ½ΡΡΠΈΠ΅ Β«ΠΎΠ±ΡΠ΅ΠΊΡΠ½ΠΎ-ΠΎΡΠΈΠ΅Π½ΡΠΈΡΠΎΠ²Π°Π½Π½ΡΠΉΒ» ΠΎΡΠ½ΠΎΡΠΈΡΡΡ ΠΊ ΡΠΏΠΎΡΠΎΠ±Ρ Π½Π°ΠΏΠΈΡΠ°Π½ΠΈΡ ΡΡΡΡΠΊΡΡΡΠ½ΠΎΠ³ΠΎ ΠΊΠΎΠ΄Π° Java, Π° ΠΈΠΌΠ΅Π½Π½ΠΎ: ΡΠ°Π·Π΄Π΅Π»Π΅Π½ΠΈΠ΅ ΠΊΠΎΠ΄Π° Π½Π° ΡΠ°ΠΊ Π½Π°Π·ΡΠ²Π°Π΅ΠΌΡΠ΅ Β«ΠΊΠ»Π°ΡΡΡΒ», ΠΊΠΎΡΠΎΡΡΠ΅ Π·Π°ΠΏΡΡΠΊΠ°ΡΡΡΡ Π²ΠΌΠ΅ΡΡΠ΅, ΡΡΠΎΠ±Ρ ΠΎΠ±Π΅ΡΠΏΠ΅ΡΠΈΡΡ ΡΠΎΠ³Π»Π°ΡΠΎΠ²Π°Π½Π½ΠΎΠ΅ ΠΏΠΎΡΠΎΠΆΠ΄Π΅Π½ΠΈΠ΅ ΠΎΠ±ΡΠ΅ΠΊΡΠΎΠ². ΠΡ ΠΎΠ±ΡΡΠ΄ΠΈΠΌ ΡΡΠΎ ΠΏΠΎΠ·ΠΆΠ΅, Π½ΠΎ Π΄ΠΎΡΡΠ°ΡΠΎΡΠ½ΠΎ ΡΠΊΠ°Π·Π°ΡΡ, ΡΡΠΎ ΡΡΠΎ ΠΏΡΠΈΠ²ΠΎΠ΄ΠΈΡ ΠΊ ΡΠ½ΠΈΠ²Π΅ΡΡΠ°Π»ΡΠ½ΠΎΠΌΡ ΠΈ ΠΎΡΠ³Π°Π½ΠΈΠ·ΠΎΠ²Π°Π½Π½ΠΎΠΌΡ ΠΊΠΎΠ΄Ρ, ΠΊΠΎΡΠΎΡΡΠΉ Π»Π΅Π³ΠΊΠΎ ΡΠ΅Π΄Π°ΠΊΡΠΈΡΠΎΠ²Π°ΡΡ ΠΈ ΠΏΠ΅ΡΠ΅ΠΏΡΠΎΡΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡ.
Java Π½Π°Ρ ΠΎΠ΄ΠΈΡΡΡ ΠΏΠΎΠ΄ Π²Π»ΠΈΡΠ½ΠΈΠ΅ΠΌ C ΠΈ C++, ΠΏΠΎΡΡΠΎΠΌΡ ΠΎΠ½Π° ΠΈΠΌΠ΅Π΅Ρ ΠΌΠ½ΠΎΠ³ΠΎ ΠΎΠ±ΡΠ΅Π³ΠΎ Ρ ΡΡΠΈΠΌΠΈ ΡΠ·ΡΠΊΠ°ΠΌΠΈ (ΠΈ C#). ΠΠ΄Π½ΠΈΠΌ ΠΈΠ· Π±ΠΎΠ»ΡΡΠΈΡ ΠΏΡΠ΅ΠΈΠΌΡΡΠ΅ΡΡΠ² Java ΡΠ²Π»ΡΠ΅ΡΡΡ ΡΠΎ, ΡΡΠΎ ΠΎΠ½ Β«ΠΏΠ»Π°ΡΡΠΎΡΠΌΠ΅Π½Π½ΠΎ-Π½Π΅Π·Π°Π²ΠΈΡΠΈΠΌΡΠΉΒ». ΠΡΠΎ ΠΎΠ·Π½Π°ΡΠ°Π΅Ρ, ΡΡΠΎ ΠΊΠΎΠ΄, ΠΊΠΎΡΠΎΡΡΠΉ Π²Ρ ΠΏΠΈΡΠ΅ΡΠ΅ Π½Π° ΠΎΠ΄Π½ΠΎΠΉ ΠΏΠ»Π°ΡΡΠΎΡΠΌΠ΅, ΠΌΠΎΠΆΠ½ΠΎ Π»Π΅Π³ΠΊΠΎ Π·Π°ΠΏΡΡΡΠΈΡΡ Π½Π° Π΄ΡΡΠ³ΠΎΠΉ. ΠΡΠΎ Π½Π°Π·ΡΠ²Π°Π΅ΡΡΡ ΠΏΡΠΈΠ½ΡΠΈΠΏΠΎΠΌ Β«ΠΏΠΈΡΠ΅ΠΌ ΠΎΠ΄ΠΈΠ½ ΡΠ°Π·, Π·Π°ΠΏΡΡΠΊΠ°Π΅ΠΌ Π³Π΄Π΅ ΡΠ³ΠΎΠ΄Π½ΠΎΒ» (Ρ ΠΎΡΡ Π½Π° ΠΏΡΠ°ΠΊΡΠΈΠΊΠ΅ ΡΡΠΎ Π½Π΅ Π²ΡΠ΅Π³Π΄Π° ΡΠ°ΠΊ ΠΏΡΠΎΡΡΠΎ, ΠΊΠ°ΠΊ ΠΊΠ°ΠΆΠ΅ΡΡΡ).
Π§ΡΠΎΠ±Ρ Π·Π°ΠΏΡΡΡΠΈΡΡ ΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Java, Π²Π°ΠΌ Π½ΡΠΆΠ½ΠΎ ΡΡΠΈ Π²Π΅ΡΠΈ:
ΠΠΈΡΡΡΠ°Π»ΡΠ½Π°Ρ ΠΌΠ°ΡΠΈΠ½Π° Java (JVM) Π³Π°ΡΠ°Π½ΡΠΈΡΡΠ΅Ρ, ΡΡΠΎ Ρ Π²Π°ΡΠΈΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ Java Π΅ΡΡΡ Π΄ΠΎΡΡΡΠΏ ΠΊ ΠΌΠΈΠ½ΠΈΠΌΠ°Π»ΡΠ½ΡΠΌ ΡΠ΅ΡΡΡΡΠ°ΠΌ, Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΡΠΌ Π΄Π»Ρ ΠΈΡ Π·Π°ΠΏΡΡΠΊΠ°. ΠΠΌΠ΅Π½Π½ΠΎ Π±Π»Π°Π³ΠΎΠ΄Π°ΡΡ JVM ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Java ΡΠ°ΠΊ Π»Π΅Π³ΠΊΠΎ Π·Π°ΠΏΡΡΠΊΠ°ΡΡΡΡ Π½Π° ΡΠ°Π·Π½ΡΡ ΠΏΠ»Π°ΡΡΠΎΡΠΌΠ°Ρ .
Π‘ΡΠ΅Π΄Π° ΠΈΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ Java (JRE) ΠΏΡΠ΅Π΄ΠΎΡΡΠ°Π²Π»ΡΠ΅Ρ ΡΠΎΠ±ΠΎΠΉ Β«ΠΊΠΎΠ½ΡΠ΅ΠΉΠ½Π΅ΡΒ» Π΄Π»Ρ Π²ΡΠ΅Ρ ΡΡΠΈΡ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² ΠΈ ΠΊΠΎΠ΄Π° Π΄Π»Ρ Π·Π°ΠΏΡΡΠΊΠ° ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ. JDK β ΡΡΠΎ Β«ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡΒ», ΠΊΠΎΡΠΎΡΡΠΉ ΠΈΠ½ΡΠ΅ΡΠΏΡΠ΅ΡΠΈΡΡΠ΅Ρ ΡΠ°ΠΌ ΠΊΠΎΠ΄ ΠΈ Π²ΡΠΏΠΎΠ»Π½ΡΠ΅Ρ Π΅Π³ΠΎ. Π JDK ΡΠ°ΠΊΠΆΠ΅ Π΅ΡΡΡ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΡ ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠ°, Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΡΠ΅ Π΄Π»Ρ Π½Π°ΠΏΠΈΡΠ°Π½ΠΈΡ ΠΊΠΎΠ΄Π° Java (ΠΊΠ°ΠΊ ΠΈ ΡΠ»Π΅Π΄ΡΠ΅Ρ ΠΈΠ· Π½Π°Π·Π²Π°Π½ΠΈΡ).
Π₯ΠΎΡΠΎΡΠ°Ρ Π½ΠΎΠ²ΠΎΡΡΡ Π·Π°ΠΊΠ»ΡΡΠ°Π΅ΡΡΡ Π² ΡΠΎΠΌ, ΡΡΠΎ ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠ°ΠΌ Π½ΡΠΆΠ½ΠΎ ΡΠΎΠ»ΡΠΊΠΎ ΠΏΠΎΠ·Π°Π±ΠΎΡΠΈΡΡΡΡ ΠΎ Π·Π°Π³ΡΡΠ·ΠΊΠ΅ JDK, ΠΏΠΎΡΠΊΠΎΠ»ΡΠΊΡ ΠΎΠ½ ΠΏΠΎΡΡΠ°Π²Π»ΡΠ΅ΡΡΡ Π²ΠΌΠ΅ΡΡΠ΅ Ρ Π΄Π²ΡΠΌΡ Π΄ΡΡΠ³ΠΈΠΌΠΈ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΠ°ΠΌΠΈ.
ΠΠ°ΠΊ Π½Π°ΡΠ°ΡΡ ΠΏΠΈΡΠ°ΡΡ Π½Π° Java
ΠΡΠ»ΠΈ Π²Ρ ΠΏΠ»Π°Π½ΠΈΡΡΠ΅ΡΠ΅ ΡΠ°Π·ΡΠ°Π±Π°ΡΡΠ²Π°ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Π½Π° Java Π½Π° ΡΠ²ΠΎΠ΅ΠΌ Π½Π°ΡΡΠΎΠ»ΡΠ½ΠΎΠΌ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠ΅, ΡΠΎ Π²Π°ΠΌ Π½ΡΠΆΠ½ΠΎ Π±ΡΠ΄Π΅Ρ Π·Π°Π³ΡΡΠ·ΠΈΡΡ ΠΈ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ JDK.
ΠΡ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΠΏΠΎΠ»ΡΡΠΈΡΡ ΠΏΠΎΡΠ»Π΅Π΄Π½ΡΡ Π²Π΅ΡΡΠΈΡ JDK Π½Π΅ΠΏΠΎΡΡΠ΅Π΄ΡΡΠ²Π΅Π½Π½ΠΎ Ρ ΡΠ°ΠΉΡΠ° Oracle. ΠΠ°ΠΊ ΡΠΎΠ»ΡΠΊΠΎ Π²Ρ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΠ΅ Π΅Π³ΠΎ, Π²Π°Ρ ΠΊΠΎΠΌΠΏΡΡΡΠ΅Ρ Π±ΡΠ΄Π΅Ρ ΠΈΠΌΠ΅ΡΡ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡ ΠΏΠΎΠ½ΠΈΠΌΠ°ΡΡ ΠΈ Π·Π°ΠΏΡΡΠΊΠ°ΡΡ ΠΊΠΎΠ΄ Π½Π° Java. Π’Π΅ΠΌ Π½Π΅ ΠΌΠ΅Π½Π΅Π΅, Π²Π°ΠΌ Π²ΡΠ΅ ΡΠ°Π²Π½ΠΎ ΠΏΠΎΠ½Π°Π΄ΠΎΠ±ΠΈΡΡΡ Π½Π΅ΠΊΠΎΡΠΎΡΠΎΠ΅ Π²ΡΠΏΠΎΠΌΠΎΠ³Π°ΡΠ΅Π»ΡΠ½ΠΎΠ΅ ΠΠ, ΡΡΠΎΠ±Ρ Π±ΡΠ»ΠΎ Π΄Π΅ΠΉΡΡΠ²ΠΈΡΠ΅Π»ΡΠ½ΠΎ ΡΠ΄ΠΎΠ±Π½ΠΎ ΠΏΠΈΡΠ°ΡΡ ΠΊΠΎΠ΄. ΠΡΠΎ ΡΠ°ΠΊ Π½Π°Π·ΡΠ²Π°Π΅ΠΌΠ°Ρ Β«ΠΈΠ½ΡΠ΅Π³ΡΠΈΡΠΎΠ²Π°Π½Π½Π°Ρ ΡΡΠ΅Π΄Π° ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈΒ» ΠΈΠ»ΠΈ IDE: ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡ, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌΡΠΉ ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠ°ΠΌΠΈ Π΄Π»Ρ Π²Π²ΠΎΠ΄Π° ΡΠ΅ΠΊΡΡΠ° ΠΊΠΎΠ΄Π° ΠΈ Π²ΡΠ·ΠΎΠ²Π° JDK.
ΠΡΠΈ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠ΅ Π΄Π»Ρ Android Π²Ρ Π±ΡΠ΄Π΅ΡΠ΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ IDE Android Studio. ΠΠ½Π° Π½Π΅ ΡΠΎΠ»ΡΠΊΠΎ ΠΏΠΎΡΠ»ΡΠΆΠΈΡ ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡΠΎΠΌ Π΄Π»Ρ ΠΊΠΎΠ΄Π° Π½Π° Java (ΠΈΠ»ΠΈ Kotlin), Π½ΠΎ ΠΈ ΡΡΠ°Π½Π΅Ρ ΠΌΠΎΡΡΠΎΠΌ Π΄Π»Ρ Π΄ΠΎΡΡΡΠΏΠ° ΠΊ ΡΠΏΠ΅ΡΠΈΡΠΈΡΠ½ΡΠΌ Π΄Π»Ρ Android Π²ΡΠ·ΠΎΠ²Π°ΠΌ ΠΈΠ· SDK.
ΠΠ»Ρ ΡΠ΅Π»Π΅ΠΉ Π½Π°ΡΠ΅Π³ΠΎ ΠΊΡΠ°ΡΠΊΠΎΠ³ΠΎ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²Π° ΠΏΠΎ Java ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΈ ΠΏΡΠΎΡΠ΅ Π½Π°ΠΏΠΈΡΠ°ΡΡ ΡΠ²ΠΎΠΉ ΠΊΠΎΠ΄ Π½Π΅ΠΏΠΎΡΡΠ΅Π΄ΡΡΠ²Π΅Π½Π½ΠΎ Π² ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΈ-ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡΠ΅ Java. ΠΠ½ΠΈ ΠΌΠΎΠ³ΡΡ Π±ΡΡΡ ΡΠΊΠ°ΡΠ°Π½Ρ Π΄Π»Ρ Android ΠΈ iOS, ΠΌΠΎΠΆΠ½ΠΎ Π΄Π°ΠΆΠ΅ Π½Π°ΠΉΡΠΈ Π²Π΅Π±-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ, ΠΊΠΎΡΠΎΡΡΠ΅ ΡΠ°Π±ΠΎΡΠ°ΡΡ Π² Π²Π°ΡΠ΅ΠΌ Π±ΡΠ°ΡΠ·Π΅ΡΠ΅. ΠΡΠΈ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΡ ΠΏΡΠ΅Π΄ΠΎΡΡΠ°Π²Π»ΡΡΡ Π²ΡΠ΅ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎΠ΅ Π² ΠΎΠ΄Π½ΠΎΠΌ ΠΌΠ΅ΡΡΠ΅ ΠΈ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΡΡ ΡΡΠ°Π·Ρ Π½Π°ΡΠ°ΡΡ ΡΠ΅ΡΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΊΠΎΠ΄Π°. ΠΠ°ΠΏΡΠΈΠΌΠ΅Ρ, compilejava.net.
ΠΠ°ΡΠΊΠΎΠ»ΡΠΊΠΎ Π»Π΅Π³ΠΊΠΎ Π½Π°ΡΡΠΈΡΡΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π½Π° Java?
ΠΡΠ»ΠΈ Π²Ρ Π½ΠΎΠ²ΠΈΡΠΎΠΊ Π² ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠ΅ Π½Π° Java, ΡΠΎ Π²Π°ΡΠΈ ΠΎΠΏΠ°ΡΠ΅Π½ΠΈΡ Π²ΠΏΠΎΠ»Π½Π΅ ΠΏΠΎΠ½ΡΡΠ½Ρ. Π’Π°ΠΊ Π½Π°ΡΠΊΠΎΠ»ΡΠΊΠΎ ΠΆΠ΅ Π»Π΅Π³ΠΊΠΎ ΠΈΠ·ΡΡΠΈΡΡ Java?
ΠΡΠΎΡ Π²ΠΎΠΏΡΠΎΡ ΠΈΠΌΠ΅Π΅Ρ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΡΡΠ±ΡΠ΅ΠΊΡΠΈΠ²Π½ΡΡ ΠΏΡΠΈΡΠΎΠ΄Ρ, Π½ΠΎ Π»ΠΈΡΠ½ΠΎ Ρ Π±Ρ ΠΎΡΠ½Π΅Ρ Java ΠΊ ΡΠ·ΡΠΊΠ°ΠΌ, Π½Π΅ ΡΠ°ΠΌΡΠΌ ΠΏΡΠΎΡΡΡΠΌ Π΄Π»Ρ ΠΈΠ·ΡΡΠ΅Π½ΠΈΡ. Π₯ΠΎΡΡ ΠΎΠ½ ΠΏΡΠΎΡΠ΅, ΡΠ΅ΠΌ C++, ΠΈ ΡΠ°ΡΡΠΎ ΠΎΠΏΠΈΡΡΠ²Π°Π΅ΡΡΡ ΠΊΠ°ΠΊ Π±ΠΎΠ»Π΅Π΅ ΡΠ΄ΠΎΠ±Π½ΡΠΉ Π΄Π»Ρ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ, Π½ΠΎ ΠΎΠ½, Π±Π΅Π·ΡΡΠ»ΠΎΠ²Π½ΠΎ, Π½Π΅ ΡΡΠΎΠ»Ρ ΠΏΡΠΎΡΡ, ΠΊΠ°ΠΊ ΡΠ°ΠΊΠΈΠ΅ Π΅Π³ΠΎ ΠΊΠΎΠ½ΠΊΡΡΠ΅Π½ΡΡ, ΠΊΠ°ΠΊ Python ΠΈΠ»ΠΈ BASIC, ΠΊΠΎΡΠΎΡΡΠ΅ Π±ΠΎΠ»ΡΡΠ΅ ΠΏΠΎΠ΄Ρ ΠΎΠ΄ΡΡ Π΄Π»Ρ ΠΈΠ·ΡΡΠ΅Π½ΠΈΡ Π½Π°ΡΠΈΠ½Π°ΡΡΠΈΠΌ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡΠ°ΠΌ.
C# ΡΠ°ΠΊΠΆΠ΅ Π½Π΅ΠΌΠ½ΠΎΠ³ΠΎ ΠΏΡΠΎΡΠ΅ ΠΏΠΎ ΡΡΠ°Π²Π½Π΅Π½ΠΈΡ Ρ Java, Ρ ΠΎΡΡ ΠΎΠ½ΠΈ ΠΎΡΠ΅Π½Ρ ΠΏΠΎΡ ΠΎΠΆΠΈ.
ΠΠΎΠ½Π΅ΡΠ½ΠΎ, Π·Π°Π΄Π°Π²ΡΠΈΡΡ ΠΊΠΎΠ½ΠΊΡΠ΅ΡΠ½ΠΎΠΉ ΡΠ΅Π»ΡΡ β ΡΡΠ°ΡΡ ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠΎΠΌ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ Π΄Π»Ρ Android, β ΠΏΡΠΎΡΠ΅ Π²ΡΠ΅Π³ΠΎ ΡΡΠ°Π·Ρ Π½Π°ΡΠ°ΡΡ Ρ ΡΠ·ΡΠΊΠ°, ΠΊΠΎΡΠΎΡΡΠΉ ΡΠΆΠ΅ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅ΡΡΡ ΡΡΠΎΠΉ ΠΏΠ»Π°ΡΡΠΎΡΠΌΠΎΠΉ.
Π£ ΡΠ·ΡΠΊΠ° Java Π΅ΡΡΡ ΡΠ²ΠΎΠΈ ΠΎΡΠΎΠ±Π΅Π½Π½ΠΎΡΡΠΈ, Π½ΠΎ Π΅Π³ΠΎ, Π±Π΅Π·ΡΡΠ»ΠΎΠ²Π½ΠΎ, ΠΌΠΎΠΆΠ½ΠΎ ΠΈΠ·ΡΡΠΈΡΡ, ΠΈ ΠΊΠ°ΠΊ ΡΠΎΠ»ΡΠΊΠΎ Π²Ρ Π΅Π³ΠΎ ΠΎΡΠ²ΠΎΠΈΡΠ΅, Π²Π°ΠΌ ΠΎΡΠΊΡΠΎΠ΅ΡΡΡ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²ΠΎ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΠ΅ΠΉ. Π ΠΏΠΎΡΠΊΠΎΠ»ΡΠΊΡ Java ΠΈΠΌΠ΅Π΅Ρ ΠΌΠ½ΠΎΠ³ΠΎ ΠΎΠ±ΡΠ΅Π³ΠΎ Ρ C ΠΈ C#, Π²Ρ ΡΠΌΠΎΠΆΠ΅ΡΠ΅ ΠΏΠ΅ΡΠ΅ΠΉΡΠΈ Π½Π° ΡΡΠΈ ΡΠ·ΡΠΊΠΈ Π±Π΅Π· ΠΎΡΠΎΠ±ΡΡ ΡΡΠΈΠ»ΠΈΠΉ.
ΠΠ°ΠΊΠΎΠ² ΡΠΈΠ½ΡΠ°ΠΊΡΠΈΡ Java?
ΠΡΠ΅ΠΆΠ΄Π΅ ΡΠ΅ΠΌ ΠΌΡ ΠΏΠΎΠ³ΡΡΠ·ΠΈΠΌΡΡ Π² ΡΠ°ΠΌΡΡ ΡΡΡΡ ΡΡΠΎΠ³ΠΎ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²Π° ΠΏΠΎ Java Π΄Π»Ρ Π½Π°ΡΠΈΠ½Π°ΡΡΠΈΡ , ΡΡΠΎΠΈΡ ΡΠ΄Π΅Π»ΠΈΡΡ Π½Π΅ΠΊΠΎΡΠΎΡΠΎΠ΅ Π²ΡΠ΅ΠΌΡ ΠΈΠ·ΡΡΠ΅Π½ΠΈΡ ΡΠΈΠ½ΡΠ°ΠΊΡΠΈΡΠ° Java.
Π‘ΠΈΠ½ΡΠ°ΠΊΡΠΈΡ Java ΠΎΡΠ½ΠΎΡΠΈΡΡΡ ΠΊ ΡΠΏΠΎΡΠΎΠ±Ρ Π½Π°ΠΏΠΈΡΠ°Π½ΠΈΡ ΠΊΠΎΠ½ΠΊΡΠ΅ΡΠ½ΡΡ Π°Π»Π³ΠΎΡΠΈΡΠΌΠΎΠ². Java ΠΎΡΠ΅Π½Ρ ΠΏΡΠΈΠ½ΡΠΈΠΏΠΈΠ°Π»Π΅Π½ Π² ΡΡΠΎΠΌ Π²ΠΎΠΏΡΠΎΡΠ΅, ΠΈ, Π΅ΡΠ»ΠΈ Π²Ρ Π½Π΅ ΠΏΠΈΡΠ΅ΡΠ΅ ΠΊΠΎΠ΄ ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Π½ΡΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ, ΡΠΎ Π²Π°ΡΠ° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° Π½Π΅ Π±ΡΠ΄Π΅Ρ ΡΠ°Π±ΠΎΡΠ°ΡΡ!
ΠΠ° ΡΠ°ΠΌΠΎΠΌ Π΄Π΅Π»Π΅ Ρ Π½Π°ΠΏΠΈΡΠ°Π» ΡΠ΅Π»ΡΡ ΡΡΠ°ΡΡΡ ΠΎ ΡΠΈΠ½ΡΠ°ΠΊΡΠΈΡΠ΅ Java Π΄Π»Ρ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ Android, ΠΊΡΠ°ΡΠΊΠΎ ΠΏΠ΅ΡΠ΅ΡΠΈΡΠ»Ρ ΠΎΡΠΎΠ±Π΅Π½Π½ΠΎΡΡΠΈ ΡΠΈΠ½ΡΠ°ΠΊΡΠΈΡΠ°:
ΠΡΠ»ΠΈ Π²Ρ Π½Π°ΠΆΠΈΠΌΠ°Π΅ΡΠ΅ ΠΊΠ½ΠΎΠΏΠΊΡ Β«Π·Π°ΠΏΡΡΡΠΈΡΡΒ» ΠΈΠ»ΠΈ Β«ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡΒ» ΠΈ ΠΏΠΎΠ»ΡΡΠ°Π΅ΡΠ΅ ΠΎΡΠΈΠ±ΠΊΡ, ΡΠΎ Π΅ΡΡΡ Π±ΠΎΠ»ΡΡΠ°Ρ Π²Π΅ΡΠΎΡΡΠ½ΠΎΡΡΡ, ΡΡΠΎ Π²Ρ Π³Π΄Π΅-ΡΠΎ ΠΏΡΠΎΠΏΡΡΡΠΈΠ»ΠΈ ΡΠΎΡΠΊΡ Ρ Π·Π°ΠΏΡΡΠΎΠΉ!
ΠΡ Π½ΠΈΠΊΠΎΠ³Π΄Π° Π½Π΅ ΠΏΠ΅ΡΠ΅ΡΡΠ°Π½Π΅ΡΠ΅ Π΄Π΅Π»Π°ΡΡ ΡΡΠΎ, ΠΈ ΡΡΠΎ Π½ΠΈΠΊΠΎΠ³Π΄Π° Π½Π΅ ΠΏΠ΅ΡΠ΅ΡΡΠ°Π½Π΅Ρ Π²Π°Ρ ΡΠ°Π·Π΄ΡΠ°ΠΆΠ°ΡΡ. Π Π°ΡΡΠ»Π°Π±ΡΡΠ΅ΡΡ!
Π‘ ΡΡΠΈΠΌΠΈ Π·Π½Π°Π½ΠΈΡΠΌΠΈ ΠΌΡ ΡΠΌΠΎΠΆΠ΅ΠΌ Π³Π»ΡΠ±ΠΆΠ΅ ΠΏΠΎΠ³ΡΡΠ·ΠΈΡΡΡΡ Π² ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²ΠΎ ΠΏΠΎ Java!
ΠΡΠ½ΠΎΠ²Ρ Java: Π²Π°ΡΠ° ΠΏΠ΅ΡΠ²Π°Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ°
ΠΠ°ΠΉΠ΄ΠΈΡΠ΅ Π½Π° compilejava.net, ΠΈ Π²Π°Ρ Π²ΡΡΡΠ΅ΡΠΈΡ ΡΠ΅Π΄Π°ΠΊΡΠΎΡ Ρ ΠΊΡΡΠ΅ΠΉ Π³ΠΎΡΠΎΠ²ΡΡ ΠΏΡΠΈΠΌΠ΅ΡΠΎΠ².
(ΠΡΠ»ΠΈ ΠΆΠ΅ Π²Ρ ΠΏΡΠ΅Π΄ΠΏΠΎΡΠΈΡΠ°Π΅ΡΠ΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π΄ΡΡΠ³ΡΡ IDE ΠΈΠ»ΠΈ ΡΡΠΎΡΠΎΠ½Π½Π΅Π΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅, ΡΡΠΎ ΡΠΎΠΆΠ΅ ΠΏΡΠ΅ΠΊΡΠ°ΡΠ½ΠΎ! Π‘ΠΊΠΎΡΠ΅Π΅ Π²ΡΠ΅Π³ΠΎ, Π²Π°Ρ Π½ΠΎΠ²ΡΠΉ ΠΏΡΠΎΠ΅ΠΊΡ Π±ΡΠ΄Π΅Ρ ΡΠΎΡΡΠΎΡΡΡ ΠΈΠ· Π°Π½Π°Π»ΠΎΠ³ΠΈΡΠ½ΠΎΠ³ΠΎ ΠΊΠΎΠ΄Π°).
Π£Π΄Π°Π»ΠΈΡΠ΅ Π²ΡΠ΅, ΠΊΡΠΎΠΌΠ΅ ΡΠ»Π΅Π΄ΡΡΡΠ΅Π³ΠΎ:
ΠΡΠΎ ΡΠΎ, ΡΡΠΎ ΠΌΡ, ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡΡ, ΠΌΡ Π½Π°Π·ΡΠ²Π°Π΅ΠΌ Β«ΡΠ°Π±Π»ΠΎΠ½ΠΎΠΌΒ» (ΡΡΠΎΡ ΠΊΠΎΠ΄ ΡΠΊΠΎΠΏΠΈΡΠΎΠ²Π°Π½ ΠΈΠ· ΡΡΠ΅Π±Π½ΠΈΠΊΠ° Java ΠΎΡ Π€ΠΈΠ»Π° ΠΠ°Π½ΡΠΈ). Π¨Π°Π±Π»ΠΎΠ½Π½ΡΠΉ ΠΊΠΎΠ΄ β ΡΠ°ΠΊ ΠΌΠΎΠΆΠ½ΠΎ Π½Π°Π·Π²Π°ΡΡ Π»ΡΠ±ΠΎΠΉ ΠΊΠΎΠ΄, ΠΊΠΎΡΠΎΡΡΠΉ Π²ΡΡΡΠ΅ΡΠ°Π΅ΡΡΡ Π²Π½ΡΡΡΠΈ ΠΏΡΠ°ΠΊΡΠΈΡΠ΅ΡΠΊΠΈ Π»ΡΠ±ΠΎΠΉ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ.
ΠΠ΅ΡΠ²Π°Ρ ΡΡΡΠΎΠΊΠ° Π·Π΄Π΅ΡΡ ΠΎΠΏΡΠ΅Π΄Π΅Π»ΡΠ΅Ρ Β«ΠΊΠ»Π°ΡΡΒ», ΠΊΠΎΡΠΎΡΡΠΉ ΠΏΠΎ ΡΡΡΠΈ ΡΠ²Π»ΡΠ΅ΡΡΡ ΠΌΠΎΠ΄ΡΠ»Π΅ΠΌ ΠΊΠΎΠ΄Π°. ΠΠ°ΡΠ΅ΠΌ Π½Π°ΠΌ Π½ΡΠΆΠ΅Π½ ΠΌΠ΅ΡΠΎΠ΄ Π²Π½ΡΡΡΠΈ ΡΡΠΎΠ³ΠΎ ΠΊΠ»Π°ΡΡΠ°, ΠΊΠΎΡΠΎΡΡΠΉ ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»ΡΠ΅Ρ ΡΠΎΠ±ΠΎΠΉ Π½Π΅Π±ΠΎΠ»ΡΡΠΎΠΉ Π±Π»ΠΎΠΊ ΠΊΠΎΠ΄Π°, Π²ΡΠΏΠΎΠ»Π½ΡΡΡΠΈΠΉ Π·Π°Π΄Π°ΡΡ. Π ΠΊΠ°ΠΆΠ΄ΠΎΠΉ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ΅ Java Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±ΡΡΡ ΠΌΠ΅ΡΠΎΠ΄ main, ΡΠ°ΠΊ ΠΊΠ°ΠΊ ΠΎΠ½ ΡΠΎΠΎΠ±ΡΠ°Π΅Ρ Java, Π³Π΄Π΅ Π½Π°ΡΠΈΠ½Π°Π΅ΡΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ°.
ΠΠ± ΠΎΡΡΠ°Π»ΡΠ½ΠΎΠΌ ΠΏΠΎΠ³ΠΎΠ²ΠΎΡΠΈΠΌ ΡΡΡΡ Π½ΠΈΠΆΠ΅, Π½Π΅ Π±Π΅ΡΠΏΠΎΠΊΠΎΠΉΡΠ΅ΡΡ. ΠΡΠ΅, ΡΡΠΎ Π½Π°ΠΌ Π½ΡΠΆΠ½ΠΎ Π·Π½Π°ΡΡ Π΄Π»Ρ ΡΡΠΎΠ³ΠΎ ΡΡΠΎΠΊΠ° Java ΠΏΡΡΠΌΠΎ ΡΠ΅ΠΉΡΠ°Ρ, β ΡΡΠΎ ΡΠΎ, ΡΡΠΎ ΠΊΠΎΠ΄, ΠΊΠΎΡΠΎΡΡΠΉ ΠΌΡ Π΄Π΅ΠΉΡΡΠ²ΠΈΡΠ΅Π»ΡΠ½ΠΎ Ρ ΠΎΡΠΈΠΌ Π·Π°ΠΏΡΡΡΠΈΡΡ, Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±ΡΡΡ ΠΏΠΎΠΌΠ΅ΡΠ΅Π½ Π² ΡΠΈΠ³ΡΡΠ½ΡΠ΅ ΡΠΊΠΎΠ±ΠΊΠΈ ΠΏΠΎΠ΄ ΡΠ»ΠΎΠ²ΠΎΠΌ Β«mainΒ».
ΠΠΎΠΌΠ΅ΡΡΠΈΡΠ΅ ΡΡΠ΄Π° ΡΠ»Π΅Π΄ΡΡΡΠΈΠΉ ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡ:
ΠΡΠΎΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡ Π½Π°ΠΏΠΈΡΠ΅Ρ ΡΠ»ΠΎΠ²Π°: Β«Hello world!Β» Π½Π° Π²Π°ΡΠ΅ΠΌ ΡΠΊΡΠ°Π½Π΅. ΠΠ°ΠΆΠΌΠΈΡΠ΅ Β«Compile & ExecuteΒ» ΠΈ Π²Ρ ΡΠ²ΠΈΠ΄ΠΈΡΠ΅ Π΅Π³ΠΎ Π² Π΄Π΅ΠΉΡΡΠ²ΠΈΠΈ.
ΠΠΎΠ·Π΄ΡΠ°Π²Π»ΡΡ! ΠΡ ΡΠΎΠ»ΡΠΊΠΎ ΡΡΠΎ Π½Π°ΠΏΠΈΡΠ°Π»ΠΈ ΡΠ²ΠΎΠ΅ ΠΏΠ΅ΡΠ²ΠΎΠ΅ Java-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅!
ΠΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅ Π² Java
Π’Π΅ΠΏΠ΅ΡΡ ΠΏΡΠΈΡΠ»ΠΎ Π²ΡΠ΅ΠΌΡ ΡΠ°ΡΡΠΊΠ°Π·Π°ΡΡ ΠΎ Π½Π΅ΠΊΠΎΡΠΎΡΡΡ Π±ΠΎΠ»Π΅Π΅ Π²Π°ΠΆΠ½ΡΡ Π²Π΅ΡΠ°Ρ , Π»Π΅ΠΆΠ°ΡΠΈΡ Π² ΠΎΡΠ½ΠΎΠ²Π΅ Java. ΠΠ°Π»ΠΎ ΡΡΠΎ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ Π±ΠΎΠ»Π΅Π΅ ΡΡΠ½Π΄Π°ΠΌΠ΅Π½ΡΠ°Π»ΡΠ½ΡΠΌ Π² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΠΈ, ΡΠ΅ΠΌ ΠΎΠ±ΡΡΠ΅Π½ΠΈΠ΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ !
ΠΠ΅ΡΠ΅ΠΌΠ΅Π½Π½Π°Ρ ΠΏΠΎ ΡΡΡΠΈ ΡΠ²Π»ΡΠ΅ΡΡΡ Β«ΠΊΠΎΠ½ΡΠ΅ΠΉΠ½Π΅ΡΠΎΠΌΒ» Π΄Π»Ρ Π½Π΅ΠΊΠΎΡΠΎΡΡΡ Π΄Π°Π½Π½ΡΡ . ΠΡΠΎ ΠΎΠ·Π½Π°ΡΠ°Π΅Ρ, ΡΡΠΎ Π²Ρ Π²ΡΠ±Π΅ΡΠ΅ΡΠ΅ ΡΠ»ΠΎΠ²ΠΎ, ΠΊΠΎΡΠΎΡΠΎΠ΅ Π±ΡΠ΄Π΅Ρ ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»ΡΡΡ ΠΊΠ°ΠΊΠΎΠ΅-ΡΠΎ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅. ΠΠ°ΠΌ ΡΠ°ΠΊΠΆΠ΅ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎ ΠΎΠΏΡΠ΅Π΄Π΅Π»ΠΈΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅, ΠΎΡΠ½ΠΎΠ²Π°Π½Π½ΡΠ΅ Π½Π° ΡΠΈΠΏΠ΅ Π΄Π°Π½Π½ΡΡ , Π½Π° ΠΊΠΎΡΠΎΡΡΠ΅ ΠΎΠ½ΠΈ Π±ΡΠ΄ΡΡ ΡΡΡΠ»Π°ΡΡΡΡ.
ΠΠΎΡ ΡΡΠΈ ΠΎΡΠ½ΠΎΠ²Π½ΡΡ ΡΠΈΠΏΠ° ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ , ΠΊΠΎΡΠΎΡΡΠ΅ ΠΌΡ ΡΠΎΠ±ΠΈΡΠ°Π΅ΠΌΡΡ Π²Π²Π΅ΡΡΠΈ Π² ΡΡΠΎΠΌ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²Π΅ ΠΏΠΎ Java:
ΠΠ°ΠΊ ΡΠΎΠ»ΡΠΊΠΎ ΠΌΡ ΠΎΠΏΡΠ΅Π΄Π΅Π»ΡΠ΅ΠΌ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ, ΠΌΡ ΠΌΠΎΠΆΠ΅ΠΌ Π²ΡΡΠ°Π²ΠΈΡΡ Π΅Π΅ Π² Π½Π°Ρ ΠΊΠΎΠ΄, ΡΡΠΎΠ±Ρ ΠΈΠ·ΠΌΠ΅Π½ΠΈΡΡ Π²ΡΡ ΠΎΠ΄Π½ΡΠ΅ Π΄Π°Π½Π½ΡΠ΅. ΠΠ°ΠΏΡΠΈΠΌΠ΅Ρ:
Π’Π΅ΠΏΠ΅ΡΡ ΠΌΡ ΠΏΠ΅ΡΠ°ΡΠ°Π΅ΠΌ Π½Π° ΡΠΊΡΠ°Π½Π΅, ΠΊΠ°ΠΊ ΠΈ ΡΠ°Π½ΡΡΠ΅, Π½ΠΎ Π½Π° ΡΡΠΎΡ ΡΠ°Π· Π·Π°ΠΌΠ΅Π½ΡΠ΅ΠΌ Β«Hello world!Β» Π½Π° Β«Hello + ΠΈΠΌΡΒ». ΠΡΠΎΡ ΠΊΠΎΠ΄ ΠΏΠΎΠΊΠ°Π·ΡΠ²Π°Π΅Ρ ΡΡΡΠΎΠΊΡ Β«HelloΒ», Π·Π° ΠΊΠΎΡΠΎΡΠΎΠΉ ΡΠ»Π΅Π΄ΡΠ΅Ρ Π»ΡΠ±ΠΎΠ΅ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅, ΡΠΎΠ΄Π΅ΡΠΆΠ°ΡΠ΅Π΅ΡΡ Π² ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΉ ΡΡΡΠΎΠΊΠΎΠ²ΠΎΠΉ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΠΎΠΉ!
Π£ΡΠ»ΠΎΠ²Π½ΡΠ΅ ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡΡ Π² Java
ΠΡΠ΅ ΠΎΠ΄Π½Π° ΠΈΠ· ΡΠ°ΠΌΡΡ Π²Π°ΠΆΠ½ΡΡ ΠΎΡΠ½ΠΎΠ² Java β ΡΡΠΎ ΡΠ°Π±ΠΎΡΠ° Ρ ΡΡΠ»ΠΎΠ²Π½ΡΠΌΠΈ ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡΠ°ΠΌΠΈ.
Π£ΡΠ»ΠΎΠ²Π½ΡΠ΅ ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡΡ Π±Π»ΠΎΠΊΠΈ ΠΊΠΎΠ΄Π°, ΠΊΠΎΡΠΎΡΡΠ΅ Π²ΡΠΏΠΎΠ»Π½ΡΡΡΡΡ ΡΠΎΠ»ΡΠΊΠΎ ΠΏΡΠΈ ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Π½ΡΡ ΡΡΠ»ΠΎΠ²ΠΈΡΡ . ΠΠ°ΠΏΡΠΈΠΌΠ΅Ρ, ΠΌΡ ΠΌΠΎΠΆΠ΅ΠΌ Π·Π°Ρ ΠΎΡΠ΅ΡΡ ΠΏΡΠ΅Π΄ΠΎΡΡΠ°Π²ΠΈΡΡ ΡΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½ΡΠ΅ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»ΡΡΠΊΠΈΠ΅ ΠΏΡΠ°Π²Π° ΠΎΡΠ½ΠΎΠ²Π½ΠΎΠΌΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ Π½Π°ΡΠ΅Π³ΠΎ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ.
ΠΠΎΡΠΌΠΎΡΡΠΈΡΠ΅ Π½Π° ΡΠ»Π΅Π΄ΡΡΡΠΈΠΉ ΠΊΠΎΠ΄:
ΠΠ°ΠΏΡΡΡΠΈΡΠ΅ ΡΡΠΎΡ ΠΊΠΎΠ΄, ΠΈ Π²Ρ ΡΠ²ΠΈΠ΄ΠΈΡΠ΅, ΡΡΠΎ ΡΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½ΡΠ΅ ΡΠ°Π·ΡΠ΅ΡΠ΅Π½ΠΈΡ ΠΏΡΠ΅Π΄ΠΎΡΡΠ°Π²Π»Π΅Π½Ρ. ΠΠΎ, Π΅ΡΠ»ΠΈ Π²Ρ ΠΈΠ·ΠΌΠ΅Π½ΠΈΡΠ΅ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ name Π½Π° ΡΡΠΎ-ΡΠΎ Π΄ΡΡΠ³ΠΎΠ΅, ΡΠΎ ΠΊΠΎΠ΄ Π½Π΅ Π±ΡΠ΄Π΅Ρ ΡΠ°Π±ΠΎΡΠ°ΡΡ.
ΠΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅, ΡΡΠΎ ΠΏΡΠΈ Π½Π°Π»ΠΎΠΆΠ΅Π½ΠΈΠΈ ΡΡΠ»ΠΎΠ²ΠΈΡ Π½Π° Π΄Π°Π½Π½ΡΠ΅ ΠΌΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌ Π΄Π²Π° Π·Π½Π°ΠΊΠ° Β«=Β». ΠΡ ΠΆΠ΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΠ΅ ΡΠΎΠ»ΡΠΊΠΎ ΠΎΠ΄ΠΈΠ½, ΠΊΠΎΠ³Π΄Π° ΠΏΡΠΈΡΠ²Π°ΠΈΠ²Π°Π΅ΡΠ΅ ΠΊΠ°ΠΊΠΈΠ΅-ΡΠΎ Π΄Π°Π½Π½ΡΠ΅ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠΌ.
ΠΠ΅ΡΠΎΠ΄Ρ Π½Π° Java
ΠΡΠ΅ ΠΎΠ΄Π½Π° ΠΏΡΠΎΡΡΠ°Ρ ΠΊΠΎΠ½ΡΠ΅ΠΏΡΠΈΡ, ΠΊΠΎΡΠΎΡΡΡ ΠΌΡ ΠΌΠΎΠΆΠ΅ΠΌ Π²Π²Π΅ΡΡΠΈ Π² ΡΡΠΎΠΌ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²Π΅ Java β ΡΡΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ ΠΌΠ΅ΡΠΎΠ΄ΠΎΠ². ΠΡΠΎ Π΄Π°ΡΡ Π²Π°ΠΌ Π½Π΅ΠΌΠ½ΠΎΠ³ΠΎ Π±ΠΎΠ»ΡΡΠ΅ ΠΏΠΎΠ½ΠΈΠΌΠ°Π½ΠΈΡ ΡΠΎΠ³ΠΎ, ΠΊΠ°ΠΊ ΡΡΡΡΠΊΡΡΡΠΈΡΠΎΠ²Π°Π½ Java-ΠΊΠΎΠ΄ ΠΈ ΡΡΠΎ Ρ Π½ΠΈΠΌ ΠΌΠΎΠΆΠ½ΠΎ ΡΠ΄Π΅Π»Π°ΡΡ.
ΠΡΠ΅, ΡΡΠΎ ΠΌΡ ΡΠΎΠ±ΠΈΡΠ°Π΅ΠΌΡΡ ΡΠ΄Π΅Π»Π°ΡΡ, β ΡΡΠΎ Π²Π·ΡΡΡ ΡΠ°ΡΡΡ ΠΊΠΎΠ΄Π°, ΠΊΠΎΡΠΎΡΡΠΉ ΠΌΡ ΡΠΆΠ΅ Π½Π°ΠΏΠΈΡΠ°Π»ΠΈ, Π° Π·Π°ΡΠ΅ΠΌ ΠΏΠΎΠΌΠ΅ΡΡΠΈΡΡ Π΅Π³ΠΎ Π² Π΄ΡΡΠ³ΠΎΠΉ ΠΌΠ΅ΡΠΎΠ΄ Π²Π½Π΅ ΠΌΠ΅ΡΠΎΠ΄Π° main :
ΠΡΠ»ΠΈ Π±Ρ ΠΌΡ Π½Π°ΠΏΠΈΡΠ°Π»ΠΈ Π²ΡΠ·ΠΎΠ² grantPermission() Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΡΠ°Π·, ΡΠΎ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ Β«Special user priveleges grantedΒ» ΡΠ°ΠΊΠΆΠ΅ ΠΎΡΠΎΠ±ΡΠ°Π·ΠΈΠ»ΠΎΡΡ Π±Ρ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΡΠ°Π·. ΠΠΌΠ΅Π½Π½ΠΎ ΡΡΠΎ Π΄Π΅Π»Π°Π΅Ρ ΠΌΠ΅ΡΠΎΠ΄Ρ ΡΠ°ΠΊΠΈΠΌΠΈ ΡΡΠ½Π΄Π°ΠΌΠ΅Π½ΡΠ°Π»ΡΠ½ΡΠΌΠΈ ΠΎΡΠ½ΠΎΠ²Π°ΠΌΠΈ Java: ΠΎΠ½ΠΈ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΡΡ Π²ΡΠΏΠΎΠ»Π½ΡΡΡ ΠΏΠΎΠ²ΡΠΎΡΡΡΡΠΈΠ΅ΡΡ Π·Π°Π΄Π°ΡΠΈ, Π½Π΅ Π·Π°ΠΏΠΈΡΡΠ²Π°Ρ ΠΊΠΎΠ΄ ΡΠ½ΠΎΠ²Π° ΠΈ ΡΠ½ΠΎΠ²Π°.
ΠΠ΅ΡΠ΅Π΄Π°ΡΠ° Π°ΡΠ³ΡΠΌΠ΅Π½ΡΠΎΠ² Π² Java
ΠΠΎ ΡΠ°ΠΌΠΎΠ΅ Π·Π°ΠΌΠ΅ΡΠ°ΡΠ΅Π»ΡΠ½ΠΎΠ΅ Π² ΠΌΠ΅ΡΠΎΠ΄Π°Ρ ΡΠΎ, ΡΡΠΎ ΠΎΠ½ΠΈ ΠΌΠΎΠ³ΡΡ ΠΏΡΠΈΠ½ΠΈΠΌΠ°ΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅ ΠΈ ΠΌΠ°Π½ΠΈΠΏΡΠ»ΠΈΡΠΎΠ²Π°ΡΡ ΠΈΠΌΠΈ. ΠΡ ΡΠ΄Π΅Π»Π°Π΅ΠΌ ΡΡΠΎ, ΠΏΠ΅ΡΠ΅Π΄Π°Π² ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅ Π² Π½Π°ΡΠΈ ΠΌΠ΅ΡΠΎΠ΄Ρ ΠΊΠ°ΠΊ Β«ΡΡΡΠΎΠΊΠΈΒ». ΠΠΎΡ Π΄Π»Ρ ΡΠ΅Π³ΠΎ ΠΈ Π½ΡΠΆΠ½Ρ ΡΠΊΠΎΠ±ΠΊΠΈ, ΡΠ»Π΅Π΄ΡΡΡΠΈΠ΅ Π·Π° Π½Π°Π·Π²Π°Π½ΠΈΠ΅ΠΌ ΠΌΠ΅ΡΠΎΠ΄Π°.
ΠΠ°Π΄Π΅ΡΡΡ, ΡΡΠΎ Π΄Π°ΡΡ Π²Π°ΠΌ ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ ΠΎ ΡΠΎΠΌ, Π½Π°ΡΠΊΠΎΠ»ΡΠΊΠΎ ΠΌΠΎΡΠ½ΡΠΌΠΈ ΠΌΠΎΠ³ΡΡ Π±ΡΡΡ ΠΌΠ΅ΡΠΎΠ΄Ρ!
Π Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΠ΅
ΠΠ°Π΄Π΅ΡΡΡ, ΡΠ΅ΠΏΠ΅ΡΡ Ρ Π²Π°Ρ Π΅ΡΡΡ Ρ ΠΎΡΠΎΡΠ΅Π΅ ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ ΠΎ ΡΠΎΠΌ, ΠΊΠ°ΠΊ ΠΈΠ·ΡΡΠ°ΡΡ Java. ΠΡ Π΄Π°ΠΆΠ΅ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΡΠ°ΠΌΠΈ Π½Π°ΠΏΠΈΡΠ°ΡΡ ΠΊΠ°ΠΊΠΎΠΉ-Π½ΠΈΠ±ΡΠ΄Ρ ΠΏΡΠΎΡΡΠΎΠΉ ΠΊΠΎΠ΄: ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅ ΠΈ ΡΡΠ»ΠΎΠ²Π½ΡΠ΅ ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡΡ, Π²Ρ Π΄Π΅ΠΉΡΡΠ²ΠΈΡΠ΅Π»ΡΠ½ΠΎ ΠΌΠΎΠΆΠ΅ΡΠ΅ Π·Π°ΡΡΠ°Π²ΠΈΡΡ Java Π΄Π΅Π»Π°ΡΡ Π½Π΅ΠΊΠΎΡΠΎΡΡΠ΅ ΠΈΠ½ΡΠ΅ΡΠ΅ΡΠ½ΡΠ΅ Π²Π΅ΡΠΈ ΡΠΆΠ΅ ΡΠ΅ΠΉΡΠ°Ρ.
Π‘Π»Π΅Π΄ΡΡΡΠΈΠΉ ΡΡΠ°ΠΏ ΡΠΎΡΡΠΎΠΈΡ Π² ΠΏΠΎΠ½ΠΈΠΌΠ°Π½ΠΈΠΈ ΠΎΠ±ΡΠ΅ΠΊΡΠ½ΠΎ-ΠΎΡΠΈΠ΅Π½ΡΠΈΡΠΎΠ²Π°Π½Π½ΠΎΠ³ΠΎ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ ΠΈ ΠΊΠ»Π°ΡΡΠΎΠ². ΠΡΠΎ ΠΏΠΎΠ½ΠΈΠΌΠ°Π½ΠΈΠ΅ Π΅ΡΡΡ ΡΠΎ, ΡΡΠΎ Π΄Π΅ΠΉΡΡΠ²ΠΈΡΠ΅Π»ΡΠ½ΠΎ Π΄Π°Π΅Ρ Java ΠΈ ΠΏΠΎΠ΄ΠΎΠ±Π½ΡΠΌ ΡΠ·ΡΠΊΠ°ΠΌ ΠΈΡ ΡΠΈΠ»Ρ, Π½ΠΎ ΠΏΠΎΠ½Π°ΡΠ°Π»Ρ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ Π½Π΅ΠΌΠ½ΠΎΠ³ΠΎ ΡΠ»ΠΎΠΆΠ½ΡΠΌ Π΄Π»Ρ ΠΎΡΠΌΡΡΠ»Π΅Π½ΠΈΡ.
macagua/example.java.helloworld
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.rst
This is «Hello World» Example for Java.
The structure HelloWorld package is like this:
For compile the main class for package, execute the follow command:
This generate the Main.class file into HelloWorld directory.
For run the main class for package, execute the follow command:
This show the Hello world message.
For pack the main class for package as a JAR file, execute the follow command:
For run the JAR file packed, execute the follow command:
#1. ΠΠ²ΠΎΠ΄Π½ΡΠΉ ΠΊΡΡΡ ΠΏΠΎ ΡΠ·ΡΠΊΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ JAVA. Hello World
Hello, World!
ΠΠΎΠ±ΡΠΎ ΠΏΠΎΠΆΠ°Π»ΠΎΠ²Π°ΡΡ Π½Π° ΠΊΡΡΡ ΠΎΡΠ½ΠΎΠ² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π½Π° ΡΠ·ΡΠΊΠ΅ Java.
ΠΡΠ΄ΠΈ ΡΠ΅ΡΠ°ΡΡ ΡΠ°Π·Π»ΠΈΡΠ½ΡΠ΅ Π·Π°Π΄Π°ΡΠΈ ΠΏΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ Π²ΡΡΠΈΡΠ»ΠΈΡΠ΅Π»ΡΠ½ΠΎΠΉ ΡΠ΅Ρ Π½ΠΈΠΊΠΈ β ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠΎΠ², ΡΠΌΠ°ΡΡΡΠΎΠ½ΠΎΠ² ΠΈ Ρ.ΠΏ. ΠΡΠΎΡ ΠΏΡΠΎΡΠ΅ΡΡ Π²ΠΎΠ·ΠΌΠΎΠΆΠ΅Π½ Π±Π»Π°Π³ΠΎΠ΄Π°ΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ°ΠΌ β ΠΈΠ½ΡΡΡΡΠΊΡΠΈΡΠΌ Π΄Π»Ρ Π²ΡΡΠΈΡΠ»ΠΈΡΠ΅Π»ΡΠ½ΡΡ ΠΌΠ°ΡΠΈΠ½, Π½Π°ΠΏΠΈΡΠ°Π½Π½ΡΠΌ Π½Π° ΡΠ°Π·Π»ΠΈΡΠ½ΡΡ ΡΠ·ΡΠΊΠ°Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ.
ΠΠ΅ΡΠ²ΡΠ΅ ΡΠ·ΡΠΊΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π±ΡΠ»ΠΈ ΠΏΠΎΠ½ΡΡΠ½Ρ ΠΌΠ°ΡΠΈΠ½Π°ΠΌ, ΠΊΠΎΡΠΎΡΡΠ΅ ΠΏΠΎΠ½ΠΈΠΌΠ°ΡΡ ΡΠΎΠ»ΡΠΊΠΎ ΡΠ·ΡΠΊ Π΅Π΄ΠΈΠ½ΠΈΡ ΠΈ Π½ΡΠ»Π΅ΠΉ. ΠΠΎ ΡΠ°ΠΊΠΈΠ΅ ΡΠ·ΡΠΊΠΈ ΡΡΡΠ΄Π½Ρ Π΄Π»Ρ ΠΏΠΎΠ½ΠΈΠΌΠ°Π½ΠΈΡ Π»ΡΠ΄ΡΠΌΠΈ.
ΠΠΎΠ·ΠΆΠ΅ Π±ΡΠ»ΠΈ ΡΠΎΠ·Π΄Π°Π½Ρ ΡΠ·ΡΠΊΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ, Π±ΠΎΠ»Π΅Π΅ ΠΏΠΎΠ½ΡΡΠ½ΡΠ΅ Π΄Π»Ρ Π»ΡΠ΄Π΅ΠΉ. ΠΡΠΎ ΠΏΡΠΈΠ²Π΅Π»ΠΎ ΠΊ ΡΠ°Π·Π΄Π΅Π»Π΅Π½ΠΈΡ ΡΡΡΠ΄Π° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΈΡΡΠΎΠ². ΠΡΠΈΠΊΠ»Π°Π΄Π½ΡΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡΡ ΡΠΎΠ·Π΄Π°ΡΡ ΠΈ ΠΎΠΏΠΈΡΡΠ²Π°ΡΡ Π°Π±ΡΡΡΠ°ΠΊΡΠΈΠΈ Π² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ°Ρ . Π ΠΏΠ΅ΡΠ΅Π²ΠΎΠ΄ΠΎΠΌ ΡΡΠΈΡ Π°Π±ΡΡΡΠ°ΠΊΡΠΈΠΉ Π² ΠΌΠ°ΡΠΈΠ½Π½ΡΠ΅ ΠΈΠ½ΡΡΡΡΠΊΡΠΈΠΈ, ΠΏΠΎΠ½ΡΡΠ½ΡΠ΅ ΠΠΠ, Π·Π°Π½ΠΈΠΌΠ°ΡΡΡΡ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡΡ ΠΈ ΡΠ½ΡΠ΅ΡΠΏΡΠ΅ΡΠ°ΡΠΎΡΡ β ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ, Π½Π°ΠΏΠΈΡΠ°Π½Π½ΡΠ΅ Π½Π°ΠΏΠΈΡΠ°Π½Π½ΡΠ΅ ΡΠΈΡΡΠ΅ΠΌΠ½ΡΠΌΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡΠ°ΠΌΠΈ. Π Π΄Π°Π½Π½ΠΎΠΌ ΠΊΡΡΡΠ΅ ΠΌΡ ΡΠ°ΡΡΠΌΠ°ΡΠΈΠ²Π°Π΅ΠΌ ΠΈΠΌΠ΅Π½Π½ΠΎ ΠΏΡΠΈΠΊΠ»Π°Π΄Π½ΠΎΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅.
Java β ΠΎΠ±ΡΠ΅ΠΊΡΠ½ΠΎ-ΠΎΡΠΈΠ΅Π½ΡΠΈΡΠΎΠ²Π°Π½Π½ΡΠΉ ΡΠ·ΡΠΊ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ. Π Π½Π΅ΠΌ ΡΡΡΠ΅ΡΡΠ²ΡΡΡ ΠΊΠ»Π°ΡΡΡ (class) ΠΈ ΠΎΠ±ΡΠ΅ΠΊΡΡ (object). ΠΠ±ΡΠ΅ΠΊΡΡ Π² Java ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»ΡΡΡ ΡΠΎΠ±ΠΎΠΉ ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡΡ ΠΊΠ»Π°ΡΡΠ°.
ΠΠ°ΠΏΡΠΈΠΌΠ΅Ρ, ΠΌΠΎΠ΄Π΅Π»Ρ android ΡΠΌΠ°ΡΡΡΠΎΠ½Π° Samsung Galaxy s6 Π²ΠΎΠΎΠ±ΡΠ΅ β ΡΡΠΎ ΠΊΠ»Π°ΡΡ, Π° ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡ Galaxy s6, ΠΊΠΎΡΡΡΠΉ Π²Ρ Π·Π°ΠΊΠ°ΠΆΠ΅ΡΠ΅ Π½Π° Ebay ΠΈ ΠΎΠ½ ΠΏΡΠΈΠ΄Π΅Ρ ΠΊ Π²Π°ΠΌ ΠΏΠΎ ΠΏΠΎΡΡΠ΅ β ΡΡΠΎ ΠΊΠΎΠ½ΠΊΡΠ΅ΡΠ½ΡΠΉ ΠΎΠ±ΡΠ΅ΠΊΡ, ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡ ΠΊΠ»Π°ΡΡΠ°, ΠΈ Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ Π΄Π΅Π»Π°ΡΡ Ρ Π½ΠΈΠΌ Π²ΡΠ΅, ΡΡΠΎ Ρ ΠΎΡΠΈΡΠ΅.
ΠΠΠ β ΠΎΠ±ΡΠ΅ΠΊΡΠ½ΠΎ-ΠΎΡΠΈΠ΅Π½ΡΠΈΡΠΎΠ²Π°Π½Π½ΠΎΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ β ΠΎΠ΄Π½ΠΎ ΠΈΠ· ΠΎΡΠ½ΠΎΠ²Π½ΡΡ Π½Π°ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠΉ Π² ΡΠΎΠ·Π΄Π°Π½ΠΈΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌ. ΠΡ Π΅ΡΠ΅ Π²Π΅ΡΠ½Π΅ΠΌΡΡ ΠΊ ΡΡΠΎΠΉ ΡΠ΅ΠΌΠ΅ Π² ΠΏΠΎΡΠ»Π΅Π΄ΡΡΡΠΈΡ ΡΡΠΎΠΊΠ°Ρ .
Π‘ΡΠ΅Π΄Π° ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ Π½Π° Java
ΠΠ»Ρ Π½Π°ΠΏΠΈΡΠ°Π½ΠΈΡ ΠΊΠΎΠ΄Π° ΠΈ ΡΠ°Π±ΠΎΡΡ Ρ ΠΏΡΠΈΠΌΠ΅ΡΠ°ΠΌΠΈ ΡΡΠ΅Π±ΡΠ΅ΡΡΡ ΡΡΠ΅Π΄Π° ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ. ΠΡΠΎ Π½Π°Π±ΠΎΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌ, ΡΡΠΈΠ»ΠΈΡ ΠΈ Π΄ΡΡΠ³ΠΈΡ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠΎΠ², Π±Π΅Π· ΠΊΠΎΡΠΎΡΡΡ ΡΠ΅ΠΉΡΠ°Ρ Π½Π΅ ΠΎΠ±Ρ ΠΎΠ΄ΠΈΡΡΡ Π½ΠΈ ΠΎΠ΄ΠΈΠ½ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡ. Π‘ΡΠ΅Π΄Π° ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ Π΄Π΅Π»Π°Π΅Ρ ΠΏΡΠΎΡΠ΅ΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π±ΠΎΠ»Π΅Π΅ Π±ΡΡΡΡΡΠΌ ΠΈ ΠΏΠΎΠ½ΡΡΠ½ΡΠΌ Π±Π»Π°Π³ΠΎΠ΄Π°ΡΡ Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΎΠΉ ΠΏΡΠΎΠ²Π΅ΡΠΊΠ΅ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎΡΡΠΈ ΠΊΠΎΠ΄Π° ΠΈ ΠΏΠΎΠ΄ΡΠΊΠ°Π·ΠΊΠ°ΠΌ. Π Π΅ΠΊΠΎΠΌΠ΅Π½Π΄ΡΠ΅ΠΌ Π΄Π»Ρ ΡΡΠΎΠ³ΠΎ ΠΊΡΡΡΠ° ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΡΡΠ΅Π΄Ρ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ IntelliJ IDEA β ΡΠΊΠ°ΡΠ°ΠΉΡΠ΅ Π±Π΅ΡΠΏΠ»Π°ΡΠ½ΡΡ Π²Π΅ΡΡΠΈΡ Community Edition ΠΈ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΠ΅ Π΅Π΅.
ΠΠ΅ΡΠ²Π°Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° Π½Π° Java
ΠΠ°ΠΏΡΡΡΠΈΡΠ΅ ΡΡΠ΅Π΄Ρ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ ΠΈ Π½Π°ΠΆΠΌΠΈΡΠ΅ Π‘ΠΎΠ·Π΄Π°ΡΡ ΠΏΡΠΎΠ΅ΠΊΡ (Create new project). ΠΠ°Π»Π΅Π΅ Π² ΠΎΠΊΠ½Π΅ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΠΏΡΠΎΠ΅ΠΊΡΠ° ΡΠ»Π΅Π²Π° Π²Π²Π΅ΡΡ Ρ Π²ΡΠ±Π΅ΡΠΈΡΠ΅ ΡΠ·ΡΠΊ ΠΏΡΠΎΠ΅ΠΊΡΠ° Java ΠΈ Π½Π°ΠΆΠΌΠΈΡΠ΅ Π²Π½ΠΈΠ·Ρ ΠΊΠ½ΠΎΠΏΠΊΡ Next. ΠΠ°Π»ΡΠ½Π΅ΠΉΡΠΈΠ΅ Π½Π°ΡΡΡΠΎΠΉΠΊΠΈ ΠΌΠΎΠΆΠ½ΠΎ ΠΎΡΡΠ°Π²ΠΈΡΡ ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ. ΠΠ° ΠΏΠΎΡΠ»Π΅Π΄Π½Π΅ΠΌ ΡΠΊΡΠ°Π½Π΅ ΠΌΠΎΠΆΠ½ΠΎ ΠΈΠ·ΠΌΠ΅Π½ΠΈΡΡ ΠΈΠΌΡ ΠΈ ΠΌΠ΅ΡΡΠΎΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΠΏΡΠΎΠ΅ΠΊΡΠ°, ΠΈ ΡΠΎΠ·Π΄Π°ΡΡ ΠΏΡΠΎΠ΅ΠΊΡ Π½Π°ΠΆΠ°ΡΠΈΠ΅ΠΌ ΠΊΠ½ΠΎΠΏΠΊΠΈ Finish.
ΠΠ°Π»Π΅Π΅ ΠΎΡΠΊΡΠΎΠ΅ΡΡΡ ΠΏΡΡΡΠΎΠ΅ ΠΎΠΊΠ½ΠΎ ΠΏΡΠΎΠ΅ΠΊΡΠ° Π² ΡΡΠ΅Π΄Π΅ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ. Π‘Π»Π΅Π²Π° ΠΎΡΠΊΡΠΎΠΉΡΠ΅ Π²ΠΊΠ»Π°Π΄ΠΊΡ Project Π΄Π΅ΡΠ΅Π²Π° ΠΏΡΠΎΠ΅ΠΊΡΠ°. Π Π°ΡΠΊΡΠΎΠΉΡΠ΅ ΠΏΡΠΎΠ΅ΠΊΡ ΠΈ Π½Π°ΠΉΠ΄ΠΈΡΠ΅ Π²Π½ΡΡΡΠΈ ΠΏΠ°ΠΏΠΊΡ src. Π ΡΡΠΎΠΉ ΠΏΠ°ΠΏΠΊΠ΅ Π²ΡΠ΅Π³Π΄Π° ΡΠ°Π·ΠΌΠ΅ΡΠ°Π΅ΡΡΡ ΠΊΠΎΠ΄, Π½Π°ΠΏΠΈΡΠ°Π½Π½ΡΠΉ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡΠ°ΠΌΠΈ. ΠΠΎΠΊΠ° ΠΎΠ½Π° ΠΏΡΡΡΠ°, Π²Π΅Π΄ΠΈ ΠΌΡ Π΅ΡΠ΅ Π½ΠΈΡΠ΅Π³ΠΎ Π½Π΅ ΠΏΠΈΡΠ°Π»ΠΈ. ΠΠ°Π²Π°ΠΉΡΠ΅ ΡΡΠΎ ΠΈΡΠΏΡΠ°Π²ΠΈΠΌ.
ΠΡΠ°Π²ΠΎΠΉ ΠΊΠ»Π°Π²ΠΈΡΠ΅ΠΉ ΠΌΡΡΠΈ Π²ΡΠ·ΠΎΠ²ΠΈΡΠ΅ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ½ΠΎΠ΅ ΠΌΠ΅Π½Ρ ΠΏΠ°ΠΏΠΊΠΈ src ΠΈ Π²ΡΠ±Π΅ΡΠΈΡΠ΅ New> Java Class. ΠΠ°Π»Π΅Π΅ ΡΠΊΠ°ΠΆΠΈΡΠ΅ ΠΈΠΌΡ ΠΊΠ»Π°ΡΡΠ° β Main. ΠΡΠΎ Π±ΡΠ΄Π΅Ρ Π³Π»Π°Π²Π½ΡΠΉ ΠΊΠ»Π°ΡΡ Π½Π°ΡΠ΅Π³ΠΎ ΠΏΡΠΎΠ΅ΠΊΡΠ°, Π² Π½Π΅ΠΌ ΠΌΡ Π±ΡΠ΄Π΅ΠΌ ΠΏΠΈΡΠ°ΡΡ Π½Π°Ρ ΠΊΠΎΠ΄.
ΠΠ°Π²Π°ΠΉΡΠ΅ Π½Π°ΠΏΠΈΡΠ΅ΠΌ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Hello World, ΠΊΠΎΡΠΎΡΠ°Ρ ΠΏΡΠΎΡΡΠΎ Π²ΡΠ²ΠΎΠ΄ΠΈΡ Π½Π° ΡΠΊΡΠ°Π½ Π½Π°Π΄ΠΏΠΈΡΡ Β«Hello, World!Β».
ΠΠ΅ΡΠ²Π°Ρ ΡΡΡΠΎΠΊΠ° ΠΎΠ±ΡΡΠ²Π»ΡΠ΅Ρ ΠΊΠ»Π°ΡΡ ΠΏΠΎΠ΄ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ΠΌ Main.
Π Java ΠΊΠ°ΠΆΠ΄Π°Ρ ΡΡΡΠΎΠΊΠ° ΠΊΠΎΠ΄Π°, ΠΊΠΎΡΠΎΡΠ°Ρ ΠΌΠΎΠΆΠ΅Ρ Π²ΡΠΏΠΎΠ»Π½ΡΡΡΡΡ Π΄ΠΎΠ»ΠΆΠ½Π° Π½Π°Ρ ΠΎΠ΄ΠΈΡΡΡΡ Π²Π½ΡΡΡΠΈ ΠΊΠ»Π°ΡΡΠ°. ΠΡΠ° ΡΡΡΠΎΠΊΠ° ΠΎΠ±ΡΡΠ²Π»ΡΠ΅Ρ ΠΊΠ»Π°ΡΡ Main, ΠΌΠΎΠ΄ΠΈΡΠΈΠΊΠ°ΡΠΎΡ Π΄ΠΎΡΡΡΠΏΠ° public ΠΎΠ·Π½Π°ΡΠ°Π΅Ρ ΡΡΠΎ ΠΊΠ»Π°ΡΡ ΠΎΠ±ΡΠ΅Π΄ΠΎΡΡΡΠΏΠ΅Π½ ΠΈ Π»ΡΠ±ΠΎΠΉ Π΄ΡΡΠ³ΠΎΠΉ ΠΊΠ»Π°ΡΡ ΠΌΠΎΠΆΠ΅Ρ ΠΏΠΎΠ»ΡΡΠΈΡΡ Π΄ΠΎΡΡΡΠΏ ΠΊ Π½Π΅ΠΌΡ. ΠΠ° Π΄Π°Π½Π½ΡΠΉ ΠΌΠΎΠΌΠ΅Π½Ρ ΡΡΠΎ Π½Π΅ Π²Π°ΠΆΠ½ΠΎ, ΡΠ°ΠΊ ΡΡΠΎ Π½Π΅ Π²ΠΎΠ»Π½ΡΠΉΡΠ΅ΡΡ. ΠΠ»Ρ Π½Π°ΡΠ°Π»Π° ΠΏΡΠΎΡΡΠΎ Π½Π°ΠΏΠΈΡΠ΅ΠΌ Π½Π°Ρ ΠΊΠΎΠ΄ Π² ΠΊΠ»Π°ΡΡΠ΅ Main, Π° ΠΏΡΠΎ ΠΎΠ±ΡΠ΅ΠΊΡΡ ΠΏΠΎΠ³ΠΎΠ²ΠΎΡΠΈΠΌ ΠΏΠΎΠ·ΠΆΠ΅.
ΠΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅, ΡΡΠΎ, ΠΊΠΎΠ³Π΄Π° ΠΌΡ ΠΎΠ±ΡΡΠ²Π»ΡΠ΅ΠΌ ΠΎΠ±ΡΠ΅Π΄ΠΎΡΡΡΠΏΠ½ΡΠΉ ΠΊΠ»Π°ΡΡ (public), ΠΌΡ Π΄ΠΎΠ»ΠΆΠ½Ρ ΠΎΠ±ΡΡΠ²ΠΈΡΡ Π΅Π³ΠΎ Π² ΡΠ°ΠΉΠ»Π΅ Ρ ΡΠ΅ΠΌ ΠΆΠ΅ ΠΈΠΌΠ΅Π½Π΅ΠΌ (Main.java), ΠΈΠ½Π°ΡΠ΅ ΠΌΡ ΠΏΠΎΠ»ΡΡΠΈΠΌ ΠΎΡΠΈΠ±ΠΊΡ ΠΏΡΠΈ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ.
ΠΡΠΎ ΡΠΎΡΠΊΠ° Π²Ρ ΠΎΠ΄Π° Π½Π°ΡΠ΅ΠΉ Java ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ. ΠΠ΅ΡΠΎΠ΄ main Π΄ΠΎΠ»ΠΆΠ΅Π½ ΠΈΠΌΠ΅ΡΡ ΡΠΎΡΠ½ΠΎ ΡΠ°ΠΊΡΡ ΠΆΠ΅ ΡΠΈΠ³Π½Π°ΡΡΡΡ, ΠΊΠ°ΠΊ ΠΏΠΎΠΊΠ°Π·Π°Π½ΠΎ, ΠΈΠ½Π°ΡΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° Π½Π΅ Π±ΡΠ΄Π΅Ρ ΡΠ°Π±ΠΎΡΠ°ΡΡ.
ΠΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ ΡΡΠΎΠΉ ΡΡΡΠΎΠΊΠΈ ΠΌΡ Π²ΡΠ²ΠΎΠ΄ΠΈΠΌ Π½Π° ΡΠΊΡΠ°Π½ Β«Hello, World!Β».
ΠΡΠΎ ΠΌΠ°ΡΡΠΈΠ² ΡΡΡΠΎΠΊ. ΠΡ Π±ΡΠ΄Π΅ΠΌ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π΅Π³ΠΎ Π² ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΌ ΡΡΠΎΠΊΠ΅, ΡΠ°ΠΊ ΡΡΠΎ Π½Π΅ Π²ΠΎΠ»Π½ΡΠΉΡΠ΅ΡΡ, Π΅ΡΠ»ΠΈ ΡΠ΅ΠΉΡΠ°Ρ Π²Ρ Π½Π΅ Π²ΡΠ΅ ΠΏΠΎΠ½ΠΈΠΌΠ°Π΅ΡΠ΅.
ΠΠΎΠΊΠ° ΠΏΠΎΡΡΠ΅Π½ΠΈΡΡΠΉΡΠ΅ΡΡ Π²ΡΠ²ΠΎΠ΄ΠΈΡΡ ΡΠ°Π·Π»ΠΈΡΠ½ΡΠΉ ΡΠ΅ΠΊΡΡ, ΠΈΠ±ΠΎ ΡΠΎΠ»ΡΠΊΠΎ ΠΏΡΠ°ΠΊΡΠΈΠΊΠ° ΡΠ΄Π΅Π»Π°Π΅Ρ ΠΈΠ· Π²Π°Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡΠ°!
ΠΡΠ΅ΠΆΠ΄Π΅ ΡΠ΅ΠΌ ΠΏΠ΅ΡΠ΅Ρ ΠΎΠ΄ΠΈΡΡ ΠΊ ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΌΡ ΡΡΠΎΠΊΡ, ΡΠ°ΠΊΠΆΠ΅ ΡΠ΅ΠΊΠΎΠΌΠ΅Π½Π΄ΡΠ΅ΠΌ ΠΏΠΎΡΠΈΡΠ°ΡΡ Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠ΅ ΠΌΠ°ΡΠ΅ΡΠ°Π»Ρ Π½ΠΈΠΆΠ΅.
ΠΠ²ΠΎΠ΄Π½ΡΠΉ ΠΊΡΡΡ ΠΏΠΎ ΡΠ·ΡΠΊΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ JAVA. Hello World
Hello, World!
ΠΠΎΠ±ΡΠΎ ΠΏΠΎΠΆΠ°Π»ΠΎΠ²Π°ΡΡ Π½Π° ΠΊΡΡΡ ΠΎΡΠ½ΠΎΠ² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π½Π° ΡΠ·ΡΠΊΠ΅ Java.
ΠΡΠ΄ΠΈ ΡΠ΅ΡΠ°ΡΡ ΡΠ°Π·Π»ΠΈΡΠ½ΡΠ΅ Π·Π°Π΄Π°ΡΠΈ ΠΏΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ Π²ΡΡΠΈΡΠ»ΠΈΡΠ΅Π»ΡΠ½ΠΎΠΉ ΡΠ΅Ρ Π½ΠΈΠΊΠΈ β ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠΎΠ², ΡΠΌΠ°ΡΡΡΠΎΠ½ΠΎΠ² ΠΈ Ρ.ΠΏ. ΠΡΠΎΡ ΠΏΡΠΎΡΠ΅ΡΡ Π²ΠΎΠ·ΠΌΠΎΠΆΠ΅Π½ Π±Π»Π°Π³ΠΎΠ΄Π°ΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ°ΠΌ β ΠΈΠ½ΡΡΡΡΠΊΡΠΈΡΠΌ Π΄Π»Ρ Π²ΡΡΠΈΡΠ»ΠΈΡΠ΅Π»ΡΠ½ΡΡ ΠΌΠ°ΡΠΈΠ½, Π½Π°ΠΏΠΈΡΠ°Π½Π½ΡΠΌ Π½Π° ΡΠ°Π·Π»ΠΈΡΠ½ΡΡ ΡΠ·ΡΠΊΠ°Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ.
ΠΠ΅ΡΠ²ΡΠ΅ ΡΠ·ΡΠΊΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π±ΡΠ»ΠΈ ΠΏΠΎΠ½ΡΡΠ½Ρ ΠΌΠ°ΡΠΈΠ½Π°ΠΌ, ΠΊΠΎΡΠΎΡΡΠ΅ ΠΏΠΎΠ½ΠΈΠΌΠ°ΡΡ ΡΠΎΠ»ΡΠΊΠΎ ΡΠ·ΡΠΊ Π΅Π΄ΠΈΠ½ΠΈΡ ΠΈ Π½ΡΠ»Π΅ΠΉ. ΠΠΎ ΡΠ°ΠΊΠΈΠ΅ ΡΠ·ΡΠΊΠΈ ΡΡΡΠ΄Π½Ρ Π΄Π»Ρ ΠΏΠΎΠ½ΠΈΠΌΠ°Π½ΠΈΡ Π»ΡΠ΄ΡΠΌΠΈ.
ΠΠΎΠ·ΠΆΠ΅ Π±ΡΠ»ΠΈ ΡΠΎΠ·Π΄Π°Π½Ρ ΡΠ·ΡΠΊΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ, Π±ΠΎΠ»Π΅Π΅ ΠΏΠΎΠ½ΡΡΠ½ΡΠ΅ Π΄Π»Ρ Π»ΡΠ΄Π΅ΠΉ. ΠΡΠΎ ΠΏΡΠΈΠ²Π΅Π»ΠΎ ΠΊ ΡΠ°Π·Π΄Π΅Π»Π΅Π½ΠΈΡ ΡΡΡΠ΄Π° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΈΡΡΠΎΠ². ΠΡΠΈΠΊΠ»Π°Π΄Π½ΡΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡΡ ΡΠΎΠ·Π΄Π°ΡΡ ΠΈ ΠΎΠΏΠΈΡΡΠ²Π°ΡΡ Π°Π±ΡΡΡΠ°ΠΊΡΠΈΠΈ Π² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ°Ρ . Π ΠΏΠ΅ΡΠ΅Π²ΠΎΠ΄ΠΎΠΌ ΡΡΠΈΡ Π°Π±ΡΡΡΠ°ΠΊΡΠΈΠΉ Π² ΠΌΠ°ΡΠΈΠ½Π½ΡΠ΅ ΠΈΠ½ΡΡΡΡΠΊΡΠΈΠΈ, ΠΏΠΎΠ½ΡΡΠ½ΡΠ΅ ΠΠΠ, Π·Π°Π½ΠΈΠΌΠ°ΡΡΡΡ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡΡ ΠΈ ΡΠ½ΡΠ΅ΡΠΏΡΠ΅ΡΠ°ΡΠΎΡΡ β ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ, Π½Π°ΠΏΠΈΡΠ°Π½Π½ΡΠ΅ Π½Π°ΠΏΠΈΡΠ°Π½Π½ΡΠ΅ ΡΠΈΡΡΠ΅ΠΌΠ½ΡΠΌΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡΠ°ΠΌΠΈ. Π Π΄Π°Π½Π½ΠΎΠΌ ΠΊΡΡΡΠ΅ ΠΌΡ ΡΠ°ΡΡΠΌΠ°ΡΠΈΠ²Π°Π΅ΠΌ ΠΈΠΌΠ΅Π½Π½ΠΎ ΠΏΡΠΈΠΊΠ»Π°Π΄Π½ΠΎΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅.
Java β ΠΎΠ±ΡΠ΅ΠΊΡΠ½ΠΎ-ΠΎΡΠΈΠ΅Π½ΡΠΈΡΠΎΠ²Π°Π½Π½ΡΠΉ ΡΠ·ΡΠΊ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ. Π Π½Π΅ΠΌ ΡΡΡΠ΅ΡΡΠ²ΡΡΡ ΠΊΠ»Π°ΡΡΡ (class) ΠΈ ΠΎΠ±ΡΠ΅ΠΊΡΡ (object). ΠΠ±ΡΠ΅ΠΊΡΡ Π² Java ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»ΡΡΡ ΡΠΎΠ±ΠΎΠΉ ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡΡ ΠΊΠ»Π°ΡΡΠ°.
ΠΠ°ΠΏΡΠΈΠΌΠ΅Ρ, ΠΌΠΎΠ΄Π΅Π»Ρ android ΡΠΌΠ°ΡΡΡΠΎΠ½Π° Samsung Galaxy s6 Π²ΠΎΠΎΠ±ΡΠ΅ β ΡΡΠΎ ΠΊΠ»Π°ΡΡ, Π° ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡ Galaxy s6, ΠΊΠΎΡΡΡΠΉ Π²Ρ Π·Π°ΠΊΠ°ΠΆΠ΅ΡΠ΅ Π½Π° Ebay ΠΈ ΠΎΠ½ ΠΏΡΠΈΠ΄Π΅Ρ ΠΊ Π²Π°ΠΌ ΠΏΠΎ ΠΏΠΎΡΡΠ΅ β ΡΡΠΎ ΠΊΠΎΠ½ΠΊΡΠ΅ΡΠ½ΡΠΉ ΠΎΠ±ΡΠ΅ΠΊΡ, ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡ ΠΊΠ»Π°ΡΡΠ°, ΠΈ Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ Π΄Π΅Π»Π°ΡΡ Ρ Π½ΠΈΠΌ Π²ΡΠ΅, ΡΡΠΎ Ρ ΠΎΡΠΈΡΠ΅.
ΠΠΠ β ΠΎΠ±ΡΠ΅ΠΊΡΠ½ΠΎ-ΠΎΡΠΈΠ΅Π½ΡΠΈΡΠΎΠ²Π°Π½Π½ΠΎΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ β ΠΎΠ΄Π½ΠΎ ΠΈΠ· ΠΎΡΠ½ΠΎΠ²Π½ΡΡ Π½Π°ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠΉ Π² ΡΠΎΠ·Π΄Π°Π½ΠΈΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌ. ΠΡ Π΅ΡΠ΅ Π²Π΅ΡΠ½Π΅ΠΌΡΡ ΠΊ ΡΡΠΎΠΉ ΡΠ΅ΠΌΠ΅ Π² ΠΏΠΎΡΠ»Π΅Π΄ΡΡΡΠΈΡ ΡΡΠΎΠΊΠ°Ρ .
Π‘ΡΠ΅Π΄Π° ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ Π½Π° Java
ΠΠ»Ρ Π½Π°ΠΏΠΈΡΠ°Π½ΠΈΡ ΠΊΠΎΠ΄Π° ΠΈ ΡΠ°Π±ΠΎΡΡ Ρ ΠΏΡΠΈΠΌΠ΅ΡΠ°ΠΌΠΈ ΡΡΠ΅Π±ΡΠ΅ΡΡΡ ΡΡΠ΅Π΄Π° ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ. ΠΡΠΎ Π½Π°Π±ΠΎΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌ, ΡΡΠΈΠ»ΠΈΡ ΠΈ Π΄ΡΡΠ³ΠΈΡ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠΎΠ², Π±Π΅Π· ΠΊΠΎΡΠΎΡΡΡ ΡΠ΅ΠΉΡΠ°Ρ Π½Π΅ ΠΎΠ±Ρ ΠΎΠ΄ΠΈΡΡΡ Π½ΠΈ ΠΎΠ΄ΠΈΠ½ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡ. Π‘ΡΠ΅Π΄Π° ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ Π΄Π΅Π»Π°Π΅Ρ ΠΏΡΠΎΡΠ΅ΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π±ΠΎΠ»Π΅Π΅ Π±ΡΡΡΡΡΠΌ ΠΈ ΠΏΠΎΠ½ΡΡΠ½ΡΠΌ Π±Π»Π°Π³ΠΎΠ΄Π°ΡΡ Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΎΠΉ ΠΏΡΠΎΠ²Π΅ΡΠΊΠ΅ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎΡΡΠΈ ΠΊΠΎΠ΄Π° ΠΈ ΠΏΠΎΠ΄ΡΠΊΠ°Π·ΠΊΠ°ΠΌ. Π Π΅ΠΊΠΎΠΌΠ΅Π½Π΄ΡΠ΅ΠΌ Π΄Π»Ρ ΡΡΠΎΠ³ΠΎ ΠΊΡΡΡΠ° ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΡΡΠ΅Π΄Ρ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ IntelliJ IDEA β ΡΠΊΠ°ΡΠ°ΠΉΡΠ΅ Π±Π΅ΡΠΏΠ»Π°ΡΠ½ΡΡ Π²Π΅ΡΡΠΈΡ Community Edition ΠΈ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΠ΅ Π΅Π΅.
ΠΠ΅ΡΠ²Π°Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° Π½Π° Java
ΠΠ°ΠΏΡΡΡΠΈΡΠ΅ ΡΡΠ΅Π΄Ρ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ ΠΈ Π½Π°ΠΆΠΌΠΈΡΠ΅ Π‘ΠΎΠ·Π΄Π°ΡΡ ΠΏΡΠΎΠ΅ΠΊΡ (Create new project). ΠΠ°Π»Π΅Π΅ Π² ΠΎΠΊΠ½Π΅ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΠΏΡΠΎΠ΅ΠΊΡΠ° ΡΠ»Π΅Π²Π° Π²Π²Π΅ΡΡ Ρ Π²ΡΠ±Π΅ΡΠΈΡΠ΅ ΡΠ·ΡΠΊ ΠΏΡΠΎΠ΅ΠΊΡΠ° Java ΠΈ Π½Π°ΠΆΠΌΠΈΡΠ΅ Π²Π½ΠΈΠ·Ρ ΠΊΠ½ΠΎΠΏΠΊΡ Next. ΠΠ°Π»ΡΠ½Π΅ΠΉΡΠΈΠ΅ Π½Π°ΡΡΡΠΎΠΉΠΊΠΈ ΠΌΠΎΠΆΠ½ΠΎ ΠΎΡΡΠ°Π²ΠΈΡΡ ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ. ΠΠ° ΠΏΠΎΡΠ»Π΅Π΄Π½Π΅ΠΌ ΡΠΊΡΠ°Π½Π΅ ΠΌΠΎΠΆΠ½ΠΎ ΠΈΠ·ΠΌΠ΅Π½ΠΈΡΡ ΠΈΠΌΡ ΠΈ ΠΌΠ΅ΡΡΠΎΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΠΏΡΠΎΠ΅ΠΊΡΠ°, ΠΈ ΡΠΎΠ·Π΄Π°ΡΡ ΠΏΡΠΎΠ΅ΠΊΡ Π½Π°ΠΆΠ°ΡΠΈΠ΅ΠΌ ΠΊΠ½ΠΎΠΏΠΊΠΈ Finish.
ΠΠ°Π»Π΅Π΅ ΠΎΡΠΊΡΠΎΠ΅ΡΡΡ ΠΏΡΡΡΠΎΠ΅ ΠΎΠΊΠ½ΠΎ ΠΏΡΠΎΠ΅ΠΊΡΠ° Π² ΡΡΠ΅Π΄Π΅ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ. Π‘Π»Π΅Π²Π° ΠΎΡΠΊΡΠΎΠΉΡΠ΅ Π²ΠΊΠ»Π°Π΄ΠΊΡ Project Π΄Π΅ΡΠ΅Π²Π° ΠΏΡΠΎΠ΅ΠΊΡΠ°. Π Π°ΡΠΊΡΠΎΠΉΡΠ΅ ΠΏΡΠΎΠ΅ΠΊΡ ΠΈ Π½Π°ΠΉΠ΄ΠΈΡΠ΅ Π²Π½ΡΡΡΠΈ ΠΏΠ°ΠΏΠΊΡ src. Π ΡΡΠΎΠΉ ΠΏΠ°ΠΏΠΊΠ΅ Π²ΡΠ΅Π³Π΄Π° ΡΠ°Π·ΠΌΠ΅ΡΠ°Π΅ΡΡΡ ΠΊΠΎΠ΄, Π½Π°ΠΏΠΈΡΠ°Π½Π½ΡΠΉ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡΠ°ΠΌΠΈ. ΠΠΎΠΊΠ° ΠΎΠ½Π° ΠΏΡΡΡΠ°, Π²Π΅Π΄ΠΈ ΠΌΡ Π΅ΡΠ΅ Π½ΠΈΡΠ΅Π³ΠΎ Π½Π΅ ΠΏΠΈΡΠ°Π»ΠΈ. ΠΠ°Π²Π°ΠΉΡΠ΅ ΡΡΠΎ ΠΈΡΠΏΡΠ°Π²ΠΈΠΌ.
ΠΡΠ°Π²ΠΎΠΉ ΠΊΠ»Π°Π²ΠΈΡΠ΅ΠΉ ΠΌΡΡΠΈ Π²ΡΠ·ΠΎΠ²ΠΈΡΠ΅ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ½ΠΎΠ΅ ΠΌΠ΅Π½Ρ ΠΏΠ°ΠΏΠΊΠΈ src ΠΈ Π²ΡΠ±Π΅ΡΠΈΡΠ΅ New> Java Class. ΠΠ°Π»Π΅Π΅ ΡΠΊΠ°ΠΆΠΈΡΠ΅ ΠΈΠΌΡ ΠΊΠ»Π°ΡΡΠ° β Main. ΠΡΠΎ Π±ΡΠ΄Π΅Ρ Π³Π»Π°Π²Π½ΡΠΉ ΠΊΠ»Π°ΡΡ Π½Π°ΡΠ΅Π³ΠΎ ΠΏΡΠΎΠ΅ΠΊΡΠ°, Π² Π½Π΅ΠΌ ΠΌΡ Π±ΡΠ΄Π΅ΠΌ ΠΏΠΈΡΠ°ΡΡ Π½Π°Ρ ΠΊΠΎΠ΄.
ΠΠ°Π²Π°ΠΉΡΠ΅ Π½Π°ΠΏΠΈΡΠ΅ΠΌ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Hello World, ΠΊΠΎΡΠΎΡΠ°Ρ ΠΏΡΠΎΡΡΠΎ Π²ΡΠ²ΠΎΠ΄ΠΈΡ Π½Π° ΡΠΊΡΠ°Π½ Π½Π°Π΄ΠΏΠΈΡΡ Β«Hello, World!Β».
ΠΠ΅ΡΠ²Π°Ρ ΡΡΡΠΎΠΊΠ° ΠΎΠ±ΡΡΠ²Π»ΡΠ΅Ρ ΠΊΠ»Π°ΡΡ ΠΏΠΎΠ΄ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ΠΌ Main.
Π Java ΠΊΠ°ΠΆΠ΄Π°Ρ ΡΡΡΠΎΠΊΠ° ΠΊΠΎΠ΄Π°, ΠΊΠΎΡΠΎΡΠ°Ρ ΠΌΠΎΠΆΠ΅Ρ Π²ΡΠΏΠΎΠ»Π½ΡΡΡΡΡ Π΄ΠΎΠ»ΠΆΠ½Π° Π½Π°Ρ ΠΎΠ΄ΠΈΡΡΡΡ Π²Π½ΡΡΡΠΈ ΠΊΠ»Π°ΡΡΠ°. ΠΡΠ° ΡΡΡΠΎΠΊΠ° ΠΎΠ±ΡΡΠ²Π»ΡΠ΅Ρ ΠΊΠ»Π°ΡΡ Main, ΠΌΠΎΠ΄ΠΈΡΠΈΠΊΠ°ΡΠΎΡ Π΄ΠΎΡΡΡΠΏΠ° public ΠΎΠ·Π½Π°ΡΠ°Π΅Ρ ΡΡΠΎ ΠΊΠ»Π°ΡΡ ΠΎΠ±ΡΠ΅Π΄ΠΎΡΡΡΠΏΠ΅Π½ ΠΈ Π»ΡΠ±ΠΎΠΉ Π΄ΡΡΠ³ΠΎΠΉ ΠΊΠ»Π°ΡΡ ΠΌΠΎΠΆΠ΅Ρ ΠΏΠΎΠ»ΡΡΠΈΡΡ Π΄ΠΎΡΡΡΠΏ ΠΊ Π½Π΅ΠΌΡ. ΠΠ° Π΄Π°Π½Π½ΡΠΉ ΠΌΠΎΠΌΠ΅Π½Ρ ΡΡΠΎ Π½Π΅ Π²Π°ΠΆΠ½ΠΎ, ΡΠ°ΠΊ ΡΡΠΎ Π½Π΅ Π²ΠΎΠ»Π½ΡΠΉΡΠ΅ΡΡ. ΠΠ»Ρ Π½Π°ΡΠ°Π»Π° ΠΏΡΠΎΡΡΠΎ Π½Π°ΠΏΠΈΡΠ΅ΠΌ Π½Π°Ρ ΠΊΠΎΠ΄ Π² ΠΊΠ»Π°ΡΡΠ΅ Main, Π° ΠΏΡΠΎ ΠΎΠ±ΡΠ΅ΠΊΡΡ ΠΏΠΎΠ³ΠΎΠ²ΠΎΡΠΈΠΌ ΠΏΠΎΠ·ΠΆΠ΅.
ΠΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅, ΡΡΠΎ, ΠΊΠΎΠ³Π΄Π° ΠΌΡ ΠΎΠ±ΡΡΠ²Π»ΡΠ΅ΠΌ ΠΎΠ±ΡΠ΅Π΄ΠΎΡΡΡΠΏΠ½ΡΠΉ ΠΊΠ»Π°ΡΡ (public), ΠΌΡ Π΄ΠΎΠ»ΠΆΠ½Ρ ΠΎΠ±ΡΡΠ²ΠΈΡΡ Π΅Π³ΠΎ Π² ΡΠ°ΠΉΠ»Π΅ Ρ ΡΠ΅ΠΌ ΠΆΠ΅ ΠΈΠΌΠ΅Π½Π΅ΠΌ (Main.java), ΠΈΠ½Π°ΡΠ΅ ΠΌΡ ΠΏΠΎΠ»ΡΡΠΈΠΌ ΠΎΡΠΈΠ±ΠΊΡ ΠΏΡΠΈ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ.
ΠΡΠΎ ΡΠΎΡΠΊΠ° Π²Ρ ΠΎΠ΄Π° Π½Π°ΡΠ΅ΠΉ Java ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ. ΠΠ΅ΡΠΎΠ΄ main Π΄ΠΎΠ»ΠΆΠ΅Π½ ΠΈΠΌΠ΅ΡΡ ΡΠΎΡΠ½ΠΎ ΡΠ°ΠΊΡΡ ΠΆΠ΅ ΡΠΈΠ³Π½Π°ΡΡΡΡ, ΠΊΠ°ΠΊ ΠΏΠΎΠΊΠ°Π·Π°Π½ΠΎ, ΠΈΠ½Π°ΡΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° Π½Π΅ Π±ΡΠ΄Π΅Ρ ΡΠ°Π±ΠΎΡΠ°ΡΡ.
ΠΡΠΈ ΠΏΠΎΠΌΠΎΡΠΈ ΡΡΠΎΠΉ ΡΡΡΠΎΠΊΠΈ ΠΌΡ Π²ΡΠ²ΠΎΠ΄ΠΈΠΌ Π½Π° ΡΠΊΡΠ°Π½ Β«Hello, World!Β».
ΠΡΠΎ ΠΌΠ°ΡΡΠΈΠ² ΡΡΡΠΎΠΊ. ΠΡ Π±ΡΠ΄Π΅ΠΌ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π΅Π³ΠΎ Π² ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΌ ΡΡΠΎΠΊΠ΅, ΡΠ°ΠΊ ΡΡΠΎ Π½Π΅ Π²ΠΎΠ»Π½ΡΠΉΡΠ΅ΡΡ, Π΅ΡΠ»ΠΈ ΡΠ΅ΠΉΡΠ°Ρ Π²Ρ Π½Π΅ Π²ΡΠ΅ ΠΏΠΎΠ½ΠΈΠΌΠ°Π΅ΡΠ΅.
ΠΠΎΠΊΠ° ΠΏΠΎΡΡΠ΅Π½ΠΈΡΡΠΉΡΠ΅ΡΡ Π²ΡΠ²ΠΎΠ΄ΠΈΡΡ ΡΠ°Π·Π»ΠΈΡΠ½ΡΠΉ ΡΠ΅ΠΊΡΡ, ΠΈΠ±ΠΎ ΡΠΎΠ»ΡΠΊΠΎ ΠΏΡΠ°ΠΊΡΠΈΠΊΠ° ΡΠ΄Π΅Π»Π°Π΅Ρ ΠΈΠ· Π²Π°Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡΠ°!
Hello World in Java on Windows
This DrJava-based Java programming environment is no longer being supported (because DrJava in no longer being actively developed and DrJava is incompatible with Java 11). It has been replaced by the following IntelliJ-based programming environment for Windows.
This document instructs you on how to set up our Java programming environment for your Windows computer. It also provides a step-by-step guide for creating, compiling, and executing a Java program using either DrJava or the Command Prompt. All of the software used is freely available.
These instructions apply to 32-bit and 64-bit Windows 8, Windows 7, Vista SP1, and XP SP3.
You can defer steps 4β6 until Section 1.5 of the textbook.
We strongly recommend using the Windows installer described below; however, we do have manual instructions.
0. Install the Programming Environment |
Our installer downloads, installs, and configures the Java programming environment you will be using, including Java SE 7, DrJava, and the standard libraries from our textbook.
Note that the installation can take several minutes or longer if you have a slow internet connection.
1. Create the Program in DrJava |
Now you are ready to write your first Java program. You will develop your Java programs in an application called DrJava. DrJava features many specialized programming tools including syntax highlighting, bracket matching, auto indenting, and line numbering.
2. Compile the Program from DrJava |
It is now time to convert your Java program into a form more amenable for execution on a computer. To do this, click the Compile button. If all goes well, you should see the following message in the Compiler Output pane at the bottom:
If DrJava complains in some way, you mistyped something. Check your program carefully, using the error messages in the Compiler Output pane as a guide.
3. Execute the Program from DrJava |
Now it is time to run your program. This is the fun part.
4. Command-Line Interface with the Command Prompt |
5. Compile the Program from the Command Prompt |
You will use the javac command to convert your Java program into a form more amenable for execution on a computer.
6. Execute the Program from the Command Prompt |
Listed below are some common questions about this document. If you encounter errors that you can’t figure out, ask for help.
When running the installer, I get an access denied error message. What should I do? Make sure you are using an administrator account. Rerun the installer.
The installer doesn’t execute. Why? The installer requires PowerShell. Run Windows Update to update your computer. If you are running Windows XP, you must have Service Pack 3. You can manually download PowerShell 2.0 for Windows XP or Vista by clicking the corresponding link under Windows Management Framework Core (WinRM 2.0 and Windows PowerShell 2.0).
The installer got stuck after selecting some text, but there are no error messages? The Command Prompt may have gone into Select Mode, which pauses the installation until you press Enter twice to exit that mode.
The installer didn’t work on my machine. What should I do? First, please contact a staff member to identify what went wrong.
What does the installer do? In short, it downloads, installs, and configures Java, Java3D, DrJava, Checkstyle, Findbugs, and the standard libraries. Here is a more detailed list:
How do I completely uninstall introcs.exe?
What happens if I rerun the installer? It will re-download, install, and configure Java, Java 3D, Checkstyle, Findbugs, DrJava, and the standard libraries.
I couldn’t get a Java runtime to install. Any advice? Try downloading Java using the Windows 7, XP offline installer.
What should I do if I have previously installed DrJava in another location? We suggest deleting it and using the version in C:\Users\ \introcs by using the newly created DrJava shortcut.
Can I use a different version of Java? Yes, but you will have to configure the Windows environment variables and DrJava compiler properties yourself.
Can I use an IDE other than DrJava? Yes you can use another IDE (such as Eclipse) but you will have to configure the IDE properties yourself (such as the classpath). If you have a 64-bit version of Java, install the 64-bit version of Eclipse.
When I launch the Eclipse IDE, I get a «Failed to load the JNI shared library» error. How can I fix this? You probably have a 64-bit version of Java and a 32-bit version of Eclipse. The installer installs a 64-bit version of Java if you have a 64-bit machine, which takes precedent over a previously installed 32-bit version of Java. To correct, either update to a 64-bit version of Eclipse or remove the C:\Users\ \introcs\java directory so that Windows uses your previously installed 32-bit version of Java. You can also specify which version of Java to use in the Eclipse.ini file.
When using standard input, how do I signify that there is no more data? If you are entering input from the keyboard, type Ctrl-z for EOF (end of file).
If so, it is likely an issue with the Windows PATH environment variable. From the Command Prompt, type the following command to display it:
I successfully compiled HelloWorld.java with javac, but, when I execute, I get the error message «Exception in thread «main» java.lang.NoClassDefFoundError: HelloWorld». What am I doing wrong? First, verify that the file HelloWorld.class is in the current directory. Be sure to type java HelloWorld without a trailing .class or .java.
When I compile or execute a program from the Command Prompt that uses the standard libraries, I get an error. How can I fix this? Be sure to use the wrapper scripts javac-introcs and java-introcs.
How do I navigate to another drive from the Windows Command Prompt? From the Command Prompt, type H: to switch to the H: drive. Then, use the cd command to navigate to the desired directory.
Where can I learn more about Command Prompt? Microsoft maintains a command-line reference.
Can I use the Windows PowerShell instead of the Command Prompt? The Windows PowerShell is a more advanced command-line shell. However, it does not currently support the redirection of standard input.
Last modified on August 14, 2019.
Copyright Β© 2000β2019 Robert Sedgewick and Kevin Wayne. All rights reserved.
Java Hello World
ΠΡΠΎΡ Π½Π΅Π±ΠΎΠ»ΡΡΠΎΠΉ ΡΡΠΎΠΊ Π½Π°ΠΏΠΈΡΠ°Π½ Π΄Π»Ρ ΡΠ΅Ρ , ΠΊΡΠΎ ΡΠΎΠ»ΡΠΊΠΎ ΠΏΡΡΠ°Π΅ΡΡΡ ΡΠ΄Π΅Π»Π°ΡΡ ΠΏΠ΅ΡΠ²ΡΠΉ ΡΠ°Π³ ΠΊ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π½Π° Java. Π ΡΡΠΎΠΌ ΡΡΠΎΠΊΠ΅ Ρ ΠΏΠΎΠΊΠ°ΠΆΡ, ΠΊΠ°ΠΊ Π½Π°ΡΠ°ΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°ΡΡ Π½Π° Java, ΡΡΠΎ Π΄Π»Ρ ΡΡΠΎΠ³ΠΎ Π½Π°Π΄ΠΎ ΠΈ ΠΌΡ Π½Π°ΠΏΠΈΡΠ΅ΠΌ ΠΏΠ΅ΡΠ²ΠΎΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π½Π° Java.
ΠΠ° Π±Π»ΠΎΠ³Π΅ ΡΠΆΠ΅ Π½Π΅ ΠΌΠ°Π»ΠΎΠ΅ ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΠΈ ΠΏΠΎ ΡΠ°Π·Π½ΡΠΌ ΡΠ΅Ρ Π½ΠΈΠΊΠ°ΠΌ java, Π½ΠΎ Π½Π΅Ρ ΡΠ°ΠΌΠΎΠ³ΠΎ ΠΏΡΠΎΡΡΠΎΠ³ΠΎ, Π²ΠΎΡ ΡΡΡ Ρ ΠΈ ΠΏΠΎΠΊΠ°ΠΆΡ ΡΡΠΎ.
Π§ΡΠΎ ΡΠ°ΠΊΠΎΠ΅ Java?
Π’Π΅Ρ ΠΊΡΠΎ ΠΎΡΠ²Π΅ΡΠΈΡ Π½Π° Π²ΠΎΠΏΡΠΎΡ βΠ§ΡΠΎ ΡΠ°ΠΊΠΎΠ΅ Java?β β Π§ΠΠ, ΠΏΡΠΎΡΡ Π·Π°ΠΊΡΡΡΡ Π² Π²Π°ΡΠ΅ΠΌ Π±ΡΠ°ΡΠ·Π΅ΡΠ΅ Π²ΠΊΠ»Π°Π΄ΠΊΡ Ρ ΡΡΠΈΠΌ ΡΠ°ΠΉΡΠΎΠΌ, Π½Ρ Π° ΡΠ΅Ρ ΠΊΡΠΎ Π·Π½Π°Π΅Ρ, ΡΡΠΎ ΠΆΠ΅ ΡΠ°ΠΊΠΎΠ΅ Java Ρ ΠΏΠΎΠΏΡΠΎΡΡ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΠΌΠΈΠ½ΡΡ Π²Π½ΠΈΠΌΠ°Π½ΠΈΡ.
Java β ΡΡΠΎ ΠΊΡΠΎΡΡΠΏΠ»Π°ΡΡΠΎΡΠΌΠ΅Π½Π½ΡΠΉ ΡΠ·ΡΠΊ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ.
Π¨Π°Π³ 1.
Π‘ΡΠ°Π²ΠΈΠΌ ΡΠΎΠ³Π»Π°ΡΠ΅Π½ΠΈΠ΅ Ρ Π»ΠΈΡΠ΅Π½Π·ΠΈΠ΅ΠΉ ΠΈ ΠΊΠ°ΡΠ°Π΅ΠΌ ΠΏΠΎΡΠ»Π΅ ΡΡΠΎΠ³ΠΎ jdk, ΡΠ°ΠΊ ΠΊΠ°ΠΊ Ρ ΠΌΠ΅Π½Ρ Windows x64, ΡΠΎ Ρ ΡΠΎΠΎΡΠ²Π΅ΡΡΡΠ²Π΅Π½Π½ΠΎ Π΄Π»Ρ Π½Π΅Π΅ ΠΈ ΠΊΠ°ΡΠ°Ρ jdk.
Π¨Π°Π³ 2.
ΠΠΎΡΠ»Π΅ ΡΠΎΠ³ΠΎ ΠΊΠ°ΠΊ ΠΌΡ ΡΠΊΠ°ΡΠ°Π»ΠΈ JDK7 ΠΏΠΎΡΠ° Π±Ρ Π΅Ρ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ.
ΠΠΎΡΠ»Π΅ ΡΠΎΠ³ΠΎ ΠΊΠ°ΠΊ Π²Ρ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΠ»ΠΈ jdk7 Π½ΡΠΆΠ½ΠΎ ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎ Π»ΠΈ Π²ΡΠ΅ ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½ΠΎ, Π΄Π»Ρ Π·Π°Ρ
ΠΎΠ΄ΠΈΠΌ Π² ΠΊΠΎΠ½ΡΠΎΠ»Ρ cmd ΠΈ ΠΏΠΈΡΠ΅ΠΌ ΡΠ»Π΅Π΄ΡΡΡΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ:
ΠΡ Π΄ΠΎΠ»ΠΆΠ½Ρ ΡΠ²ΠΈΠ΄Π΅ΡΡ ΡΠ»Π΅Π΄ΡΡΡΠ΅Π΅:
Π¨Π°Π³ 3.
ΠΠ»Ρ ΡΠΎΠ³ΠΎ ΡΡΠΎΠ±Ρ Π½Π°ΠΏΠΈΡΠ°ΡΡ ΡΠ²ΠΎΠ΅ ΠΏΠ΅ΡΠ²ΠΎΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π½Π° java Π»ΡΡΡΠ΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ IDE β ΡΡΠΎ ΡΡΠ΅Π΄Π° ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ.
ΠΡ Π±ΡΠ΄Π΅ΠΌ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ IntelliJ IDEA 12.0.4 ΡΠΊΠ°ΡΠ°ΡΡ Π΅Ρ ΠΌΠΎΠΆΠ½ΠΎ ΡΡΡ: http://www.jetbrains.com/idea/download/index.html
ΠΠΎΡΠ»Π΅ ΡΠΎΠ³ΠΎ ΠΊΠ°ΠΊ ΡΠΊΠ°ΡΠ°Π΅ΡΠ΅ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΠ΅ ΠΈ Π·Π°ΠΏΡΡΡΠΈΡΠ΅.
Π¨Π°Π³ 4.
Π’Π΅ΠΏΠ΅ΡΡ ΡΠΎΠ·Π΄Π°Π΅ΠΌ ΠΏΡΠΎΠ΅ΠΊΡ Π² ΡΠΆΠ΅ Π·Π°ΠΏΡΡΠ΅Π½Π½ΠΎΠΉ Intellij IDEA 12.
ΠΠ΅ Π·Π°Π±ΡΠ΄ΡΡΠ΅ ΠΏΡΠΎΠΉΡΠΈ Π½ΡΠ»Π΅Π²ΠΎΠΉ ΡΠ°Π³.
Π¨Π°Π³ 5.
ΠΠΈΡΠ΅ΠΌ Hello Wolrd ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅.
Π Π² ΡΠΎΠ·Π΄Π°Π½Π½ΠΎΠΌ ΠΊΠ»Π°ΡΡΠ΅ Π΄ΠΎΠ±Π°Π²ΡΡΠ΅ ΡΠ»Π΅Π΄ΡΡΡΠ΅Π΅ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅:
Π£ Π²Π°Ρ Π΄ΠΎΠ»ΠΆΠ½ΠΎ ΠΏΠΎΠ»ΡΡΠΈΡΡΡ ΡΠ°ΠΊ:
Π¨Π°Π³ 6.
Π’Π΅ΠΏΠ΅ΡΡ Π·Π°ΠΏΡΡΡΠΈΠΌ Π½Π°ΡΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅.
ΠΠ° ΡΡΠΎΠΌ Π²ΡΠ΅. Π£ΡΠΏΠ΅Ρ ΠΎΠ² Π²Π°ΠΌ Π² ΠΈΠ·ΡΡΠ΅Π½ΠΈΠΈ Java. ΠΡΠ»ΠΈ Π²Ρ Ρ ΠΎΡΠΈΡΠ΅ ΠΏΠΎΠ»ΡΡΠ°ΡΡ Π±Π΅ΡΠΏΠ»Π°ΡΠ½ΡΠ΅ ΡΡΠΎΠΊΠΈ ΠΏΠΎ java ΡΠΎ ΠΏΠΎΠ΄ΠΏΠΈΡΠΈΡΠ΅ΡΡ Π² ΡΠΎΡΠΌΠ΅ Π½ΠΈΠΆΠ΅ ΠΈ Ρ Π±ΡΠ΄Ρ Π²Π°ΠΌ ΠΏΡΠΈΡΡΠ»Π°ΡΡ ΠΈΠ½ΡΠ΅ΡΠ΅ΡΠ½ΡΠ΅ ΡΡΠΎΠΊΠΈ ΠΏΠΎ Java.
Hello World in Java on Windows
This DrJava-based Java programming environment is no longer being supported (because DrJava in no longer being actively developed and DrJava is incompatible with Java 11). It has been replaced by the following IntelliJ-based programming environment for Windows.
This document instructs you on how to set up our Java programming environment for your Windows computer. It also provides a step-by-step guide for creating, compiling, and executing your first Java program using either DrJava or the Command Prompt. All of the software used is freely available.
These instructions apply to 32-bit and 64-bit Windows 8, Windows 7, Vista SP1, and XP SP3.
0. Install the Programming Environment |
Our installer downloads, installs, and configures the Java programming environment you will be using, including Java SE 7, DrJava, the textbook libraries, and the Command Prompt.
Note that the installation can take several minutes or longer if you have a slow internet connection.
1. Create the Program in DrJava |
Now you are ready to write your first Java program. You will develop your Java programs in an application called DrJava. DrJava features many specialized programming tools including syntax highlighting, bracket matching, auto indenting, and line numbering.
2. Compile the Program from DrJava |
It is now time to convert your Java program into a form more amenable for execution on a computer. To do this, click the Compile button. If all goes well, you should see the following message in the Compiler Output pane at the bottom:
If DrJava complains in some way, you mistyped something. Check your program carefully, using the error messages in the Compiler Output pane as a guide.
3. Execute the Program from DrJava |
Now it is time to run your program. This is the fun part.
4. Command-Line Interface |
5. Compile the Program from the Command Prompt |
You will use the javac command to convert your Java program into a form more amenable for execution on a computer.
6. Execute the Program from the Command Prompt |
7. Static Code Analysis Tools |
You can use Findbugs and Checkstyle to check the style of your programs and identify common bug patterns.
The installer doesn’t execute. Why? The installer requires PowerShell. Run Windows Update to update your computer. If you are running Windows XP, you must have Service Pack 3. You can manually download PowerShell 2.0 for Windows XP or Vista by clicking the corresponding link under Windows Management Framework Core (WinRM 2.0 and Windows PowerShell 2.0).
The installer doesn’t work on my machine and I’m using Kaspersky Anti-Virus. What should I do? You must temporarily disable Kaspersky Anti-Virus.
The installer still doesn’t work on my machine. What should I do? Please consult a staff member to identify what went wrong.
What does the installer do? In short, it downloads, installs, and configures Java, DrJava, Findbugs, Checkstyle, and the textbook libraries. Here is a more detailed list:
How do I completely uninstall algs4.exe?
What happens if I rerun the installer? It will re-download, install, and configure Java, Checkstyle, Findbugs, DrJava, and the textbook libraries.
What should I do if I have previously installed DrJava in another location? We suggest deleting it and using the version in C:\Users\username\algs4 by using the newly created DrJava shortcut on the desktop.
Can I use a different version of Java? Yes, but you will need to configure the Windows environment variables and DrJava compiler properties yourself.
Can I use an IDE other than DrJava? Yes you can use another IDE (such as Eclipse) but you will have to configure the IDE properties yourself (such as the classpath).
If so, it is likely an issue with the Windows PATH environment variable. From the Command Prompt, type the following command to display it:
How do I navigate to another drive from the Windows Command Prompt? From the Command Prompt, type H: to switch to the H: drive. Then, use the cd command to navigate to the desired directory.
Where can I learn more about Command Prompt? Microsoft maintains a command-line reference.
Can I use the Windows PowerShell instead of the Command Prompt? The Windows PowerShell is a more advanced command-line shell. However, it does not currently support the redirection of standard input.
What’s the sha256sum of algs4.exe? 58207c99fd91b3f7247c234ef6f61e6fe1deef9b56f0307ce6f6c7bd55a124a5 Window Size to 80 x 25.
Last modified on August 14, 2019.
Copyright Β© 2000β2019 Robert Sedgewick and Kevin Wayne. All rights reserved.
Written by David Reilly
Revised May 12, 1999
Previous | Next
— David Reilly, May 1999
Before I begin to cover the basics of Java programming, I should point out that Java is an object-orientated language, and may not be suitable for first time programmers. Learning a new language takes some time, but learning your first object-orientated language can be exceedingly difficult. Nonetheless, if you’ve done some C programming before, the shift into Java shouldn’t be unreachable, providing you obtain a good reference book. There are also those that believe programmers should start with an object-orientated language first, and many universities have adopted this practice. Still, you’ve been fairly warned π
This tutorial will presume that you have some basic programming knowledge, particularly in C, as it will not be covering such principles as sequence, selection and repetition. If you are unsure on ‘ for ‘ loops, or complex ‘ if ‘ statements, I’d suggest coming back here at a later point.
Application or Applet?
Applets are commonly used to enhance the interactivity of a web page, and deliver client-side content. Applets run in their own frame, and can display graphics, accept input from GUI components, and even open network connections. Due the potential security risks associated with running applets from external and potentially malicious sources, most web browsers limit file access, and impose additional restrictions on applets (such as only being able to connect to the hostname from which the applet was downloaded).
Fortunately, stand-alone applications have no such restrictions, and a full range of functionality is provided for in the way of pre-written Java classes. Stand-alone applications can run as a console application (writing text to the screen or terminal window), or they can have a graphical user-interface, by opening a new window or dialog box. You’ve used applications before, such as word processors, text editors, and games. The Java language is capable of all this things.
Since stand-alone applications offer more freedom to the programmer, and applets running under a browser often demonstrate a certain degree of instability depending on the platform under which it is run, this tutorial series will concentrate primarily upon the stand-alone application.
The first thing required for writing stand-alone Java applications is a java compiler/interpreter. While there are commercial offerings available, such as Visual J++ and Borland JBuilder, a freely available SDK is available from Sun, the original creators of the Java language. It contains a compiler, interpreter, debugger, and more. I highly recommend using the latest version of Sun’s Java Development Kit (JDK). You should download the JDK from http://java.sun.com.
To compile your first java application, enter the following (assuming that the java directory is in your path) :
If everything goes according to plan, the message «Hello World!», followed by a newline should appear on your terminal/screen. You’ve just compiled and executed your first application.
How it works
For those new to object-orientated programming, the concept of a class will be new to you. We defined a new class, called myfirstjavaprog. Simplistically, a class is the definition for a segment of code that can contain both data (called attributes) and functions (called methods).
When the interpreter executes a class, it looks for a particular method by the name of main, which will sound familiar to C programmers. The main method is passed as a parameter an array of strings (similar to the argv[] of C), and is declared as a static method (more on this in a later tutorial).
To output text from the program, we execute the ‘ println ‘ method of System.out, which is Java’s output stream. Unix users will appreciate the theory behind such a stream, as it is actually standard output. For those who are instead used to the Wintel platform, it will write the string passed to it to the user’s screen.
That wraps it up for this first part of the introduction to Java tutorial series. In the next tutorial, we’ll cover some more object-orientated principles, and extend your knowledge of the Java language and syntax.
LuisJoseSanchez/hello-world-java
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Hello world with Java ☕
This is a simple «Hello world» done with Java programming language.
This is the source code of the program:
Notice that System.out.println(«Hello world!»); shows the string «Hello world!» on the screen.
To compile the «Hello World» program, type the following:
ismaelpacheco13/hello-world-java
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Hello World with Java ☕
This is a simple «Hello World» coded with Java (just joking this is actually really complex)
This is the source code of the program:
Notice that System.out.print(«Hello World»); shows the string «Hello World» on the screen.
To compile the «Hello World» program type the following:
Getting Started with Java IDL:
Developing the Hello World Server
The example server consists of two classes, the servant and the server. The servant, HelloImpl, is the implementation of the Hello IDL interface; each Hello instance is implemented by a HelloImpl instance. The servant is a subclass of HelloPOA, which is generated by the idlj compiler from the example IDL.
The servant contains one method for each IDL operation, in this example, the sayHello() and shutdown() methods. Servant methods are just like ordinary Java methods; the extra code to deal with the ORB, with marshaling arguments and results, and so on, is provided by the skeleton.
The server class has the server’s main() method, which:
This lesson introduces the basics of writing a CORBA server. For an example of the «Hello World» program with a persistent object server, see Example 2: Hello World with Persistent State. For more discussion of CORBA servers, see Developing Servers.
The steps in this lesson cover:
Creating HelloServer.java
To create HelloServer.java,
Understanding HelloServer.java
This section explains each line of HelloServer.java, describing what the code does, as well as why it is needed for this application.
Performing Basic Setup
The structure of a CORBA server program is the same as most Java applications: You import required library packages, declare the server class, define a main() method, and handle exceptions.
Importing Required Packages
First, we import the packages required for the server class:
Defining the Servant Class
In this example, we are defining the class for the servant object within HelloServer.java, but outside the HelloServer class.
The servant is a subclass of HelloPOA so that it inherits the general CORBA functionality generated for it by the compiler.
First, we create a private variable, orb that is used in the setORB(ORB) method. The setORB method is a private method defined by the application developer so that they can set the ORB value with the servant. This ORB value is used to invoke shutdown() on that specific ORB in response to the shutdown() method invocation from the client.
Next, we declare and implement the required sayHello() method:
And last of all, we implement the shutdown() method in a similar way. The shutdown() method calls the org.omg.CORBA.ORB.shutdown(boolean) method for the ORB. The shutdown(false) operation indicate that the ORB should shut down immediately, without waiting for processing to complete.
Declaring the Server Class
The next step is to declare the server class:
Defining the main() Method
Every Java application needs a main method. It is declared within the scope of the HelloServer class:
Handling CORBA System Exceptions
Because all CORBA programs can throw CORBA system exceptions at runtime, all of the main() functionality is placed within a try-catch block. CORBA programs throw runtime exceptions whenever trouble occurs during any of the processes (marshaling, unmarshaling, upcall) involved in invocation. The exception handler simply prints the exception and its stack trace to standard output so you can see what kind of thing has gone wrong.
The try-catch block is set up inside main(), as shown:
Creating and Initializing an ORB Object
A CORBA server needs a local ORB object, as does the CORBA client. Every server instantiates an ORB and registers its servant objects so that the ORB can find the server when it receives an invocation for it.
The ORB variable is declared and initialized inside the try-catch block.
The call to the ORB’s init() method passes in the server’s command line arguments, allowing you to set certain properties at runtime.
Get a Reference to the Root POA and Activate the POAManager
The reference to the root POA is retrieved and the POAManager is activated from within the try-catch block.
The activate() operation changes the state of the POA manager to active, causing associated POAs to start processing requests. The POA manager encapsulates the processing state of the POAs with which it is associated. Each POA object has an associated POAManager object. A POA manager may be associated with one or more POA objects.
Managing the Servant Object
Instantiating the Servant Object
We instantiate the servant object inside the try-catch block, just after activating the POA manager, as shown:
The section of code describing the servant class was explained previously.
In the next line of code, setORB(orb) is defined on the servant so that ORB.shutdown() can be called as part of the shutdown operation. This step is required because of the shutdown() method defined in Hello.idl.
There are other options for implementing the shutdown operation. In this example, the shutdown() method called on the Object takes care of shutting down an ORB. In another implementation, the shutdown method implementation could have simply set a flag, which the server could have checked and called shutdown().
The next set of code is used to get the object reference associated with the servant. The narrow() method is required to cast CORBA object references to their proper types.
Working with COS Naming
The HelloServer works with the Common Object Services (COS) Naming Service to make the servant object’s operations available to clients. The server needs an object reference to the naming service so that it can publish the references to the objects implementing various interfaces. These object references are used by the clients for invoking methods. Another way a servant can make the objects available to clients for invocations is by stringifying the object references to a file.
The two options for Naming Services are:
This example uses orbd.
Obtaining the Initial Naming Context
In the try-catch block, below getting the object reference for the servant, we call orb.resolve_initial_references() to get an object reference to the name server:
The string «NameService» is defined for all CORBA ORBs. When you pass in that string, the ORB returns a naming context object that is an object reference for the name service. The string «NameService» indicates:
The proprietary string «TNameService» indicates that the naming service will be transient when using ORBD’s naming service.
Narrowing the Object Reference
As with all CORBA object references, objRef is a generic CORBA object. To use it as a NamingContextExt object, you must narrow it to its proper type. The call to narrow() is just below the previous statement:
Here you see the use of an idlj-generated helper class, similar in function to HelloHelper. The ncRef object is now an org.omg.CosNaming.NamingContextExt and you can use it to access the naming service and register the server, as shown in the next topic.
The NamingContextExt object is part of the Interoperable Naming Service specification.
Registering the Servant with the Name Server
Just below the call to narrow(), we create a new NameComponent array. Because the path to Hello has a single element, we create the single-element array that NamingContext.resolve requires for its work:
Finally, we pass path and the servant object to the naming service, binding the servant object to the «Hello» id:
Now, when the client calls resolve("Hello") on the initial naming context, the naming service returns an object reference to the Hello servant.
Waiting for Invocation
The previous sections describe the code that makes the server ready; the next section explains the code that enables it to simply wait around for a client to request its service. The following code, which is at the end of (but within) the try-catch block, shows how to accomplish this.
When called by the main thread, ORB.run() enables the ORB to perform work using the main thread, waiting until an invocation comes from the ORB. Because of its placement in main(), after an invocation completes and sayHello() returns, the server will wait again. This is the reason that the HelloClient explicitly shuts down the ORB after completing its task.
Compiling the Hello World Server
Now we will compile the HelloServer.java so that we can correct any errors before continuing with this tutorial.
Windows users note that you should substitute backslashes (\) for the slashes (/) in all paths in this document.
To compile HelloServer.java,
Running the Hello World Server
Running the Hello World Application discusses running HelloServer and the rest of the application.
Understanding The Server-Side Implementation Models
CORBA supports at least two different server-side mappings for implementing an IDL interface:
Using the Inheritance Model, you implement the IDL interface using an implementation class that also extends the compiler-generated skeleton.
Inheritance models include:
The default server-side mapping generated when either the -fall or -fserver arguments are used conform to Chapter 11, Portable Object Adapter (POA) of the CORBA 2.3.1 Specification (formal/99-10-07). For more information on the POA, see Portable Object Adapter.
The advantages of using the Portable Object Adaptor (POA) are:
NOTE: ImplBase is obsoleted in favor of the POA model, but is provided to allow compatibility with servers written in J2SE 1.3 and prior. We do not recommend creating new servers using this nonstandard model.
Using the Delegation Model, you implement the IDL interface using two classes:
The Delegation model is also known as the Tie model, or the Tie Delegation model. It inherits from either the POA or ImplBase compiler-generated skeleton, so the models will be described as POA/Tie or ImplBase/Tie models in this document.
This tutorial presents the POA Inheritance model for server-side implementation. For tutorials using the other server-side implementations, see the following documents:
The ImplBase server-side model is an Inheritance Model, as is the POA model. Use the idlj compiler with the -oldImplBase flag to generate server-side bindings that are compatible with older version of Java IDL (prior to J2SE 1.4).
Note that using the -oldImplBase flag is non-standard: these APIs are obsoleted. You would use this flag ONLY for compatibility with existing servers written in J2SE 1.3 or earlier. In that case, you would need to modify an existing MAKEFILE to add the -oldImplBase flag to the idlj compiler, otherwise POA-based server-side mappings will be generated.
Apache NetBeans 14
ΠΠΎΠ±ΡΠΎ ΠΏΠΎΠΆΠ°Π»ΠΎΠ²Π°ΡΡ Π² IDE NetBeans!
Π ΡΡΠΎΠΌ ΡΡΠ΅Π±Π½ΠΎΠΉ ΠΊΡΡΡΠ΅ ΠΏΡΠΈΠ²ΠΎΠ΄ΠΈΡΡΡ ΠΎΡΠ΅Π½Ρ ΠΏΡΠΎΡΡΠΎΠ΅ ΠΈ Π±ΡΡΡΡΠΎΠ΅ Π²Π²Π΅Π΄Π΅Π½ΠΈΠ΅ Π² ΠΏΠΎΡΠΎΠΊ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΉ IDE NetBeans ΠΏΡΡΠ΅ΠΌ ΠΏΠΎΡΠ°Π³ΠΎΠ²ΠΎΠ³ΠΎ ΠΎΠΏΠΈΡΠ°Π½ΠΈΠ΅ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΠΏΡΠΎΡΡΠΎΠ³ΠΎ ΠΊΠΎΠ½ΡΠΎΠ»ΡΠ½ΠΎΠ³ΠΎ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ «Hello World» Java. ΠΠ·Π½Π°ΠΊΠΎΠΌΠ»Π΅Π½ΠΈΠ΅ Ρ ΡΡΠΈΠΌ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²ΠΎΠΌ Π΄Π°ΡΡ ΠΎΠ±ΡΠ΅Π΅ ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ ΠΎ ΡΠΎΠ·Π΄Π°Π½ΠΈΠΈ, ΡΠ±ΠΎΡΠΊΠ΅ ΠΈ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠΈ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ Π² ΡΡΠ΅Π΄Π΅ IDE.
ΠΠ·ΡΡΠ΅Π½ΠΈΠ΅ ΠΌΠ°ΡΠ΅ΡΠΈΠ°Π»Π°, ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»Π΅Π½Π½ΠΎΠ³ΠΎ Π² ΡΡΠΎΠΌ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²Π΅, Π·Π°Π½ΠΈΠΌΠ°Π΅Ρ ΠΏΡΠΈΠ±Π»ΠΈΠ·ΠΈΡΠ΅Π»ΡΠ½ΠΎ 10 ΠΌΠΈΠ½ΡΡ.
ΠΠΎΡΠ»Π΅ Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΡ ΡΡΠΎΠ³ΠΎ ΡΡΠ΅Π±Π½ΠΎΠ³ΠΎ ΠΊΡΡΡΠ° ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠ΅ΡΠ΅ΠΉΡΠΈ ΠΊ ΡΡΠ΅Π±Π½ΡΠΌ ΠΊΠ°ΡΡΠ°ΠΌ, Π½Π° ΠΊΠΎΡΠΎΡΡΠ΅ ΠΈΠΌΠ΅ΡΡΡΡ ΡΡΡΠ»ΠΊΠΈ Π½Π° ΡΡΡΠ°Π½ΠΈΡΠ΅ ΠΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΡΠΈΡ, ΠΎΠ±ΡΡΠ΅Π½ΠΈΠ΅ & ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΊΠ°. Π£ΡΠ΅Π±Π½ΡΠ΅ ΠΊΠ°ΡΡΡ ΠΎΠ±Π΅ΡΠΏΠ΅ΡΠΈΠ²Π°ΡΡ ΠΏΠΎΠ»Π½ΡΠ΅ ΡΡΠ΅Π±Π½ΡΠ΅ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²Π°, Π² ΠΊΠΎΡΠΎΡΡΡ ΠΎΠΏΠΈΡΡΠ²Π°ΡΡΡΡ ΡΠΈΡΠΎΠΊΠΈΠΉ Π΄ΠΈΠ°ΠΏΠ°Π·ΠΎΠ½ ΡΡΠ½ΠΊΡΠΈΠΉ IDE ΠΈ ΠΏΡΠΈΠ΅ΠΌΠΎΠ² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π΄Π»Ρ ΡΠ°Π·Π»ΠΈΡΠ½ΡΡ ΡΠΈΠΏΠΎΠ² ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ. ΠΡΠ»ΠΈ Π½Π΅ Π½ΡΠΆΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ «ΠΠ΄ΡΠ°Π²ΡΡΠ²ΡΠΉ, ΠΌΠΈΡ», ΠΌΠΎΠΆΠ½ΠΎ ΠΏΡΠΎΠΏΡΡΡΠΈΡΡ ΡΡΠΎ ΡΡΠ΅Π±Π½ΠΎΠ΅ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²ΠΎ ΠΈ ΠΏΠ΅ΡΠ΅ΠΉΡΠΈ Π½Π°ΠΏΡΡΠΌΡΡ ΠΊ ΡΡΠ΅Π±Π½ΡΠΌ ΠΊΠ°ΡΡΠ°ΠΌ.
ΠΠ»Ρ ΡΠ°Π±ΠΎΡΡ Ρ ΡΡΠΈΠΌ ΡΡΠ΅Π±Π½ΡΠΌ ΠΊΡΡΡΠΎΠΌ ΡΡΠ΅Π±ΡΡΡΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ½ΠΎΠ΅ ΠΎΠ±Π΅ΡΠΏΠ΅ΡΠ΅Π½ΠΈΠ΅ ΠΈ ΡΠ΅ΡΡΡΡΡ, ΠΏΠ΅ΡΠ΅ΡΠΈΡΠ»Π΅Π½Π½ΡΠ΅ Π½ΠΈΠΆΠ΅.
Π²Π΅ΡΡΠΈΡ 7.2, 7.3, 7.4 ΠΈΠ»ΠΈ 8.0
ΠΠ°ΡΡΡΠΎΠΉΠΊΠ° ΠΏΡΠΎΠ΅ΠΊΡΠ°
ΠΠ»Ρ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΠΏΡΠΎΠ΅ΠΊΡΠ° IDE Π²ΡΠΏΠΎΠ»Π½ΠΈΡΠ΅ ΡΠ»Π΅Π΄ΡΡΡΠΈΠ΅ Π΄Π΅ΠΉΡΡΠ²ΠΈΡ:
Start IDE NetBeans.
Π ΠΌΠ΅Π½Ρ IDE Π²ΡΠ±Π΅ΡΠΈΡΠ΅ ‘Π€Π°ΠΉΠ» > Π‘ΠΎΠ·Π΄Π°ΡΡ ΠΏΡΠΎΠ΅ΠΊΡ’, ΠΊΠ°ΠΊ ΠΏΠΎΠΊΠ°Π·Π°Π½ΠΎ Π½Π° ΡΠΈΡΡΠ½ΠΊΠ΅.
Π ΠΌΠ°ΡΡΠ΅ΡΠ΅ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΠΏΡΠΎΠ΅ΠΊΡΠ° ΡΠ°Π·Π²Π΅ΡΠ½ΠΈΡΠ΅ ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΡ «Java» ΠΈ Π²ΡΠ±Π΅ΡΠΈΡΠ΅ «ΠΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Java». ΠΠ°ΡΠ΅ΠΌ Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ½ΠΎΠΏΠΊΡ «ΠΠ°Π»ΡΡΠ΅».
ΠΠ° ΡΡΡΠ°Π½ΠΈΡΠ΅ ΠΌΠ°ΡΡΠ΅ΡΠ° «ΠΠΌΡ ΠΈ ΠΌΠ΅ΡΡΠΎΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅» Π²ΡΠΏΠΎΠ»Π½ΠΈΡΠ΅ ΡΠ»Π΅Π΄ΡΡΡΠΈΠ΅ Π΄Π΅ΠΉΡΡΠ²ΠΈΡ (ΡΠΌ. ΡΠΈΡΡΠ½ΠΎΠΊ Π½ΠΈΠΆΠ΅):
Π²Π²Π΅Π΄ΠΈΡΠ΅ HelloWorldApp Π² ΠΏΠΎΠ»Π΅ «ΠΠΌΡ ΠΏΡΠΎΠ΅ΠΊΡΠ°»;
ΠΠ΅ ΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°ΠΉΡΠ΅ ΡΠ»Π°ΠΆΠΎΠΊ «ΠΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΎΡΠ΄Π΅Π»ΡΠ½ΡΡ ΠΏΠ°ΠΏΠΊΡ Π΄Π»Ρ Ρ ΡΠ°Π½Π΅Π½ΠΈΡ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊ».
Π² ΠΏΠΎΠ»Π΅ «Π‘ΠΎΠ·Π΄Π°ΡΡ Π³Π»Π°Π²Π½ΡΠΉ ΠΊΠ»Π°ΡΡ» Π²Π²Π΅Π΄ΠΈΡΠ΅ helloworldapp.HelloWorldApp ;
ΠΠ°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ½ΠΎΠΏΠΊΡ «ΠΠ°Π²Π΅ΡΡΠΈΡΡ».
ΠΡΠΎΠ΅ΠΊΡ Π±ΡΠ΄Π΅Ρ ΡΠΎΠ·Π΄Π°Π½ ΠΈ ΠΎΡΠΊΡΡΡ Π² ΡΡΠ΅Π΄Π΅ IDE. ΠΠ° ΡΠΊΡΠ°Π½Π΅ Π΄ΠΎΠ»ΠΆΠ½Ρ Π±ΡΡΡ ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»Π΅Π½Ρ ΡΠ»Π΅Π΄ΡΡΡΠΈΠ΅ ΡΠ»Π΅ΠΌΠ΅Π½ΡΡ:
ΠΎΠΊΠ½ΠΎ «ΠΡΠΎΠ΅ΠΊΡΡ», ΠΊΠΎΡΠΎΡΠΎΠ΅ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ Π΄Π΅ΡΠ΅Π²ΠΎ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² ΠΏΡΠΎΠ΅ΠΊΡΠ°, Π² ΡΠΎΠΌ ΡΠΈΡΠ»Π΅ ΠΈΡΡ ΠΎΠ΄Π½ΡΠ΅ ΡΠ°ΠΉΠ»Ρ, Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ, ΠΎΡ ΠΊΠΎΡΠΎΡΡΡ Π·Π°Π²ΠΈΡΠΈΡ ΠΊΠΎΠ΄, ΠΈ Ρ.Π΄.;
ΠΎΠΊΠ½ΠΎ ΡΠ΅Π΄Π°ΠΊΡΠΎΡΠ° ΠΈΡΡ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΊΠΎΠ΄Π° Ρ ΠΎΡΠΊΡΡΡΡΠΌ ΡΠ°ΠΉΠ»ΠΎΠΌ HelloWorldApp ;
ΠΎΠΊΠ½ΠΎ «ΠΠ΅ΡΠ΅Ρ ΠΎΠ΄Ρ», ΠΊΠΎΡΠΎΡΠΎΠ΅ ΠΌΠΎΠΆΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π΄Π»Ρ Π±ΡΡΡΡΠΎΠ³ΠΎ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΡ ΠΌΠ΅ΠΆΠ΄Ρ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ°ΠΌΠΈ Π²Π½ΡΡΡΠΈ Π²ΡΠ±ΡΠ°Π½Π½ΠΎΠ³ΠΎ ΠΊΠ»Π°ΡΡΠ°.
ΠΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ ΠΊΠΎΠ΄Π° ΠΊ Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈ ΡΠΎΠ·Π΄Π°Π½Π½ΠΎΠΌΡ ΠΈΡΡ ΠΎΠ΄Π½ΠΎΠΌΡ ΡΠ°ΠΉΠ»Ρ
ΠΠΎΡΠΊΠΎΠ»ΡΠΊΡ Π² ΠΌΠ°ΡΡΠ΅ΡΠ΅ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΠΏΡΠΎΠ΅ΠΊΡΠ° Π½Π΅ Π±ΡΠ» ΡΠ½ΡΡ ΡΠ»Π°ΠΆΠΎΠΊ «Π‘ΠΎΠ·Π΄Π°ΡΡ Π³Π»Π°Π²Π½ΡΠΉ ΠΊΠ»Π°ΡΡ», ΡΡΠ΅Π΄ΠΎΠΉ IDE Π±ΡΠ» ΡΠΎΠ·Π΄Π°Π½ Π½ΠΎΠ²ΡΠΉ Π³Π»Π°Π²Π½ΡΠΉ ΠΊΠ»Π°ΡΡ. Π ΠΊΠΎΠ΄Ρ ΡΡΠΎΠ³ΠΎ ΠΊΠ»Π°ΡΡΠ° ΠΌΠΎΠΆΠ½ΠΎ Π΄ΠΎΠ±Π°Π²ΠΈΡΡ, Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ, ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ «Hello World!» ΠΏΡΡΠ΅ΠΌ Π·Π°ΠΌΠ΅Π½Ρ ΡΡΡΠΎΠΊΠΈ
Π‘ΠΎΡ ΡΠ°Π½ΠΈΡΠ΅ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΡ ΠΏΡΡΠ΅ΠΌ Π²ΡΠ±ΠΎΡΠ° ΠΊΠΎΠΌΠ°Π½Π΄Ρ «Π€Π°ΠΉΠ»» > «Π‘ΠΎΡ ΡΠ°Π½ΠΈΡΡ».
Π€Π°ΠΉΠ» Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±ΡΡΡ ΠΏΠΎΡ ΠΎΠΆ Π½Π° ΡΠ»Π΅Π΄ΡΡΡΠΈΠΉ ΠΏΡΠΈΠΌΠ΅Ρ:
ΠΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΡ ΠΈ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΏΡΠΎΠ΅ΠΊΡΠ°
ΠΠ»Π°Π³ΠΎΠ΄Π°ΡΡ ΡΡΠ½ΠΊΡΠΈΠΈ ΡΡΠ΅Π΄Ρ IDE «ΠΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΡ ΠΏΡΠΈ ΡΠΎΡ ΡΠ°Π½Π΅Π½ΠΈΠΈ» ΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡ ΠΏΡΠΎΠ΅ΠΊΡ Π²ΡΡΡΠ½ΡΡ Π΄Π»Ρ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ Π² ΡΡΠ΅Π΄Π΅ IDE Π½Π΅ ΡΡΠ΅Π±ΡΠ΅ΡΡΡ. ΠΡΠΈ ΡΠΎΡ ΡΠ°Π½Π΅Π½ΠΈΠΈ ΠΈΡΡ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΡΠ°ΠΉΠ»Π° Java Π² ΡΡΠ΅Π΄Π΅ IDE Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΡΡΡ Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠ°Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΡ.
Π€ΡΠ½ΠΊΡΠΈΡ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ ΠΏΡΠΈ ΡΠΎΡ ΡΠ°Π½Π΅Π½ΠΈΠΈ ΠΎΡΠΊΠ»ΡΡΠ°Π΅ΡΡΡ Π² ΠΎΠΊΠ½Π΅ «Π‘Π²ΠΎΠΉΡΡΠ²Π° ΠΏΡΠΎΠ΅ΠΊΡΠ°». Π©Π΅Π»ΠΊΠ½ΠΈΡΠ΅ ΠΏΡΠΎΠ΅ΠΊΡ ΠΏΡΠ°Π²ΠΎΠΉ ΠΊΠ½ΠΎΠΏΠΊΠΎΠΉ ΠΌΡΡΠΈ, Π²ΡΠ±Π΅ΡΠΈΡΠ΅ «Π‘Π²ΠΎΠΉΡΡΠ²Π°». Π ΠΎΠΊΠ½Π΅ «Π‘Π²ΠΎΠΉΡΡΠ²Π°» ΠΏΠ΅ΡΠ΅ΠΉΠ΄ΠΈΡΠ΅ Π½Π° Π²ΠΊΠ»Π°Π΄ΠΊΡ «ΠΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΡ». Π€Π»Π°ΠΆΠΎΠΊ «ΠΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΡ ΠΏΡΠΈ ΡΠΎΡ ΡΠ°Π½Π΅Π½ΠΈΠΈ» ΡΠ°ΡΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ Π²Π²Π΅ΡΡ Ρ ΡΠΏΡΠ°Π²Π°. ΠΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅, ΡΡΠΎ Π² ΠΎΠΊΠ½Π΅ «Π‘Π²ΠΎΠΉΡΡΠ²Π° ΠΏΡΠΎΠ΅ΠΊΡΠ°» ΠΌΠΎΠΆΠ½ΠΎ Π²ΡΠΏΠΎΠ»Π½ΡΡΡ Π½Π°ΡΡΡΠΎΠΉΠΊΡ ΠΌΠ½ΠΎΠ³ΠΎΡΠΈΡΠ»Π΅Π½Π½ΡΡ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠΎΠ² ΠΏΡΠΎΠ΅ΠΊΡΠ°: Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ ΠΏΡΠΎΠ΅ΠΊΡΠ°, ΠΏΠ°ΠΊΠ΅ΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅, ΡΠ±ΠΎΡΠΊΠ°, Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΈ Ρ. Π΄.
ΠΠ»Ρ Π·Π°ΠΏΡΡΠΊΠ° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΠ΅ ΡΠ»Π΅Π΄ΡΡΡΠΈΠ΅ Π΄Π΅ΠΉΡΡΠ²ΠΈΡ.
ΠΡΠ±Π΅ΡΠΈΡΠ΅ ‘ΠΡΠΏΠΎΠ»Π½ΠΈΡΡ > ΠΠ°ΠΏΡΡΠΊ ΠΏΡΠΎΠ΅ΠΊΡΠ°’.
ΠΠ° ΡΠΊΡΠ°Π½Π΅ Π΄ΠΎΠ»ΠΆΠ½Ρ ΠΏΠΎΡΠ²ΠΈΡΡΡΡ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΡ, ΠΏΠΎΠ΄ΠΎΠ±Π½ΡΠ΅ ΠΏΡΠΈΠ²Π΅Π΄Π΅Π½Π½ΡΠΌ Π½ΠΈΠΆΠ΅.
ΠΠΎΠ·Π΄ΡΠ°Π²Π»ΡΠ΅ΠΌ! ΠΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° ΡΠ°Π±ΠΎΡΠ°Π΅Ρ!
ΠΡΠ»ΠΈ ΠΏΡΠΈ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ Π²ΠΎΠ·Π½ΠΈΠΊΠ»ΠΈ ΠΎΡΠΈΠ±ΠΊΠΈ, ΠΎΠ½ΠΈ ΠΎΡΠΌΠ΅ΡΠ°ΡΡΡΡ ΡΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½ΡΠΌΠΈ ΠΊΡΠ°ΡΠ½ΡΠΌΠΈ ΡΠΈΠΌΠ²ΠΎΠ»Π°ΠΌΠΈ Π² Π»Π΅Π²ΠΎΠΌ ΠΈ ΠΏΡΠ°Π²ΠΎΠΌ ΠΏΠΎΠ»ΡΡ ΡΠ΅Π΄Π°ΠΊΡΠΎΡΠ° ΠΈΡΡ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΊΠΎΠ΄Π°. Π‘ΠΈΠΌΠ²ΠΎΠ»Ρ Π² Π»Π΅Π²ΠΎΠΌ ΠΏΠΎΠ»Π΅ ΡΠΊΠ°Π·ΡΠ²Π°ΡΡ Π½Π° ΠΎΡΠΈΠ±ΠΊΠΈ Π² ΡΠΎΠΎΡΠ²Π΅ΡΡΡΠ²ΡΡΡΠΈΡ ΡΡΡΠΎΠΊΠ°Ρ . Π‘ΠΈΠΌΠ²ΠΎΠ»Ρ Π² ΠΏΡΠ°Π²ΠΎΠΌ ΠΏΠΎΠ»Π΅ ΡΠΊΠ°Π·ΡΠ²Π°ΡΡ Π½Π° Π²ΡΠ΅ ΠΎΠ±Π»Π°ΡΡΠΈ ΡΠ°ΠΉΠ»Π°, Π² ΠΊΠΎΡΠΎΡΡΡ Π΅ΡΡΡ ΠΎΡΠΈΠ±ΠΊΠΈ, Π² ΡΠΎΠΌ ΡΠΈΡΠ»Π΅ Π½Π΅ ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ°Π΅ΠΌΡΠ΅ Π²ΠΈΠ·ΡΠ°Π»ΡΠ½ΠΎ ΠΎΡΠΈΠ±ΠΊΠΈ Π² ΡΡΡΠΎΠΊΠ°Ρ . ΠΠ»Ρ ΠΏΠΎΠ»ΡΡΠ΅Π½ΠΈΡ ΠΎΠΏΠΈΡΠ°Π½ΠΈΡ ΠΎΡΠΈΠ±ΠΊΠΈ ΠΌΠΎΠΆΠ½ΠΎ Π½Π°Π²Π΅ΡΡΠΈ ΠΊΡΡΡΠΎΡ Π½Π° ΠΌΠ΅ΡΠΊΡ ΠΎΡΠΈΠ±ΠΊΠΈ. ΠΠ»Ρ ΠΏΠ΅ΡΠ΅Ρ ΠΎΠ΄Π° ΠΊ ΡΡΡΠΎΠΊΠ΅ Ρ ΠΎΡΠΈΠ±ΠΊΠΎΠΉ ΡΠ΅Π»ΠΊΠ½ΠΈΡΠ΅ ΡΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½ΡΠΉ ΡΠΈΠΌΠ²ΠΎΠ» Π² ΠΏΡΠ°Π²ΠΎΠΌ ΠΏΠΎΠ»Π΅.
Π‘Π±ΠΎΡΠΊΠ° ΠΈ ΡΠ°Π·Π²Π΅ΡΡΡΠ²Π°Π½ΠΈΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ
ΠΠΎΡΠ»Π΅ ΡΠ±ΠΎΡΠΊΠΈ ΠΈ ΡΠ΅ΡΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Π΄Π»Ρ ΠΏΠΎΠ΄Π³ΠΎΡΠΎΠ²ΠΊΠΈ Π΅Π³ΠΎ ΠΊ ΡΠ°Π·Π²Π΅ΡΡΡΠ²Π°Π½ΠΈΡ ΠΌΠΎΠΆΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ «ΠΡΠΈΡΡΠΈΡΡ ΠΈ ΡΠΎΠ±ΡΠ°ΡΡ». ΠΡΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠΈ ΠΊΠΎΠΌΠ°Π½Π΄Ρ «ΠΡΠΈΡΡΠΈΡΡ ΠΈ ΡΠΎΠ±ΡΠ°ΡΡ» Π² ΡΡΠ΅Π΄Π΅ IDE Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈ Π·Π°ΠΏΡΡΠΊΠ°Π΅ΡΡΡ ΡΡΠ΅Π½Π°ΡΠΈΠΉ ΡΠ±ΠΎΡΠΊΠΈ, Π²ΡΠΏΠΎΠ»Π½ΡΡΡΠΈΠΉ ΡΠ»Π΅Π΄ΡΡΡΠΈΠ΅ Π·Π°Π΄Π°ΡΠΈ:
ΡΠ΄Π°Π»Π΅Π½ΠΈΠ΅ ΠΏΡΠ΅Π΄Π²Π°ΡΠΈΡΠ΅Π»ΡΠ½ΠΎ ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°Π½Π½ΡΡ ΡΠ°ΠΉΠ»ΠΎΠ² ΠΈ Π΄ΡΡΠ³ΠΈΡ ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠΎΠ² ΡΠ±ΠΎΡΠΊΠΈ;
ΠΏΠΎΠ²ΡΠΎΡΠ½Π°Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΈ ΡΠΎΡΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΡΠ°ΠΉΠ»Π° JAR, ΡΠΎΠ΄Π΅ΡΠΆΠ°ΡΠ΅Π³ΠΎ ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°Π½Π½ΡΠ΅ ΡΠ°ΠΉΠ»Ρ.
ΠΠ»Ρ ΡΠ±ΠΎΡΠΊΠΈ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΠ΅ ΡΠ»Π΅Π΄ΡΡΡΠΈΠ΅ Π΄Π΅ΠΉΡΡΠ²ΠΈΡ
ΠΡΠ±Π΅ΡΠΈΡΠ΅ ‘ΠΡΠΏΠΎΠ»Π½ΠΈΡΡ > ΠΡΠΈΡΡΠΈΡΡ ΠΈ ΡΠΎΠ±ΡΠ°ΡΡ ΠΏΡΠΎΠ΅ΠΊΡ’.
ΠΡΠ°ΠΊ, ΡΠ΅ΠΏΠ΅ΡΡ Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ Π²ΡΠΏΠΎΠ»Π½ΡΡΡ Π±Π°Π·ΠΎΠ²ΡΠ΅ Π·Π°Π΄Π°ΡΠΈ ΠΏΠΎ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π² ΡΡΠ΅Π΄Π΅ IDE.
ΠΠΎΠ΄ΡΠΎΠ±Π½Π΅Π΅ ΠΎ ΡΠΎΠΌ, ΠΊΠ°ΠΊ Π·Π°ΠΏΡΡΡΠΈΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΠΈΠ· ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠΈ, ΡΠΌ. Π³Π»Π°Π²Ρ ΠΠ°ΠΏΡΡΠΊ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ Java ΡΡΠ΅Π±Π½ΠΎΠ³ΠΎ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²Π° ΠΏΠΎ ΡΠΏΠ°ΠΊΠΎΠ²ΠΊΠ΅ ΠΈ ΡΠ°ΡΠΏΡΠ΅Π΄Π΅Π»Π΅Π½ΠΈΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ Java.
ΠΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠ΅ ΡΠ²Π΅Π΄Π΅Π½ΠΈΡ
ΠΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ ΠΎ ΡΠΎΠ·Π΄Π°Π½ΠΈΠΈ ΡΡΠ°Π½Π΄Π°ΡΡΠ½ΡΡ ΠΈ ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ»ΡΠ½ΡΡ ΠΏΡΠΎΠ΅ΠΊΡΠΎΠ² Java ΠΈ ΡΠ°Π±ΠΎΡΠ΅ Ρ Π½ΠΈΠΌΠΈ ΡΠΌ. Π² ΡΠ°Π·Π΄Π΅Π»Π΅ Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΏΡΠΎΠ΅ΠΊΡΠΎΠ² Java Π² Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠ΅ Π Π°Π·ΡΠ°Π±ΠΎΡΠΊΠ° ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ Π² IDE NetBeans.
ΠΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠ΅ ΡΠ²Π΅Π΄Π΅Π½ΠΈΡ ΠΎ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ Java Π² ΡΡΠ΅Π΄Π΅ IDE, Π²ΠΊΠ»ΡΡΠ°Ρ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ ΠΏΡΡΠ΅ΠΌ ΠΊ ΠΊΠ»Π°ΡΡΠ°ΠΌ, Π΄ΠΎΡΡΡΠΏΠ½Ρ Π² Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠ΅ Π Π°Π·ΡΠ°Π±ΠΎΡΠΊΠ° Π±Π°Π·ΠΎΠ²ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ Java.
ΠΠ»Ρ ΠΏΠΎΠ»ΡΡΠ΅Π½ΠΈΡ ΠΏΠΎΠ΄ΡΠΎΠ±Π½ΡΡ ΠΈΠ½ΡΡΡΡΠΊΡΠΈΠΉ ΠΎ ΡΠΎΠΌ, ΠΊΠ°ΠΊ ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡ ΠΈ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ ΠΏΡΠΎΡΡΠΎΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ «Hello World!» Π² ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌΠΎΠΉ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½ΠΎΠΉ ΡΠΈΡΡΠ΅ΠΌΠ΅, ΡΠΌ. Π·Π°Π½ΡΡΠΈΠ΅ ΠΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ «Hello World» Π² ΡΡΠ΅Π±Π½ΡΡ ΠΊΡΡΡΠ°Ρ ΠΏΠΎ Java.
Π§ΡΠΎΠ±Ρ Π½Π°ΠΉΡΠΈ ΡΠ²Π΅Π΄Π΅Π½ΠΈΡ, ΡΠ²ΡΠ·Π°Π½Π½ΡΠ΅ Ρ ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Π½ΡΠΌ ΡΠΈΠΏΠΎΠΌ ΡΠ°Π·ΡΠ°Π±Π°ΡΡΠ²Π°Π΅ΠΌΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠΉΡΠ΅ ΠΊΠ°ΡΡΡ ΠΎΠ±ΡΡΠ΅Π½ΠΈΡ Π΄Π»Ρ ΡΡΠΎΠ³ΠΎ ΡΠΈΠΏΠ° ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ. ΠΠ°ΠΆΠ΄Π°Ρ ΡΡΠ΅Π±Π½Π°Ρ ΠΊΠ°ΡΡΠ° ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ ΡΡΠ΄ ΡΡΠ΅Π±Π½ΡΡ ΠΊΡΡΡΠΎΠ² ΠΈ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ² ΡΠ°Π·Π»ΠΈΡΠ½ΡΡ ΡΡΠΎΠ²Π½Π΅ΠΉ ΡΠ»ΠΎΠΆΠ½ΠΎΡΡΠΈ. ΠΠΎΡΡΡΠΏΠ½Ρ ΡΠ»Π΅Π΄ΡΡΡΠΈΠ΅ ΡΡΠ΅Π±Π½ΡΠ΅ ΠΊΠ°ΡΡΡ:
ΠΠΈΡΠ΅ΠΌ, ΡΠΎΠ±ΠΈΡΠ°Π΅ΠΌ ΠΈ Π·Π°ΠΏΡΡΠΊΠ°Π΅ΠΌ HelloWorld Π΄Π»Ρ Android Π² Π±Π»ΠΎΠΊΠ½ΠΎΡΠ΅. Java 8 ΠΈ Android N
ΠΠ²Π° Ρ ΠΏΠΎΠ»ΠΎΠ²ΠΈΠ½ΠΎΠΉ Π³ΠΎΠ΄Π° Π½Π°Π·Π°Π΄ Ρ ΠΎΠΏΡΠ±Π»ΠΈΠΊΠΎΠ²Π°Π» ΡΡΠ°ΡΡΡ ΠΠΈΡΠ΅ΠΌ, ΡΠΎΠ±ΠΈΡΠ°Π΅ΠΌ ΠΈ Π·Π°ΠΏΡΡΠΊΠ°Π΅ΠΌ HelloWorld Π΄Π»Ρ Android Π² Π±Π»ΠΎΠΊΠ½ΠΎΡΠ΅. ΠΠ½Π° ΡΡΠ°Π»Π° ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ ΠΎΠ³ΡΠΎΠΌΠ½ΠΎΠΉ ΠΏΠΎΠΏΡΠ»ΡΡΠ½ΠΎΡΡΡΡ ΠΈ Π½Π°Π±ΡΠ°Π»Π° ΠΎΠΊΠΎΠ»ΠΎ 80 000 ΠΏΡΠΎΡΠΌΠΎΡΡΠΎΠ². Π‘ ΠΏΠΎΡΠ²Π»Π΅Π½ΠΈΠ΅ΠΌ Π½ΠΎΠ²ΡΡ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠΎΠ², ΡΠ°ΠΊΠΈΡ ΠΊΠ°ΠΊ Jack ToolChain, Π²ΠΎΠ·Π½ΠΈΠΊΠ»Π° Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎΡΡΡ ΠΏΠ΅ΡΠ΅ΠΈΠ·Π΄Π°Π½ΠΈΡ ΠΈ ΠΎΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΡ ΡΡΠ°ΡΡΠΈ.
ΠΠΎΠ³Π΄Π° Ρ Π½Π°ΡΠ°Π» ΠΈΠ·ΡΡΠ°ΡΡ Android, Π·Π°Ρ ΠΎΡΠ΅Π»ΠΎΡΡ ΠΏΠΎΠ»Π½ΠΎΡΡΡΡ Π½Π°ΠΏΠΈΡΠ°ΡΡ ΠΈ ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡ Android-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π²ΡΡΡΠ½ΡΡ β Π±Π΅Π· ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ IDE. ΠΠ΄Π½Π°ΠΊΠΎ ΡΡΠ° Π·Π°Π΄Π°ΡΠ° ΠΎΠΊΠ°Π·Π°Π»Π°ΡΡ Π½Π΅ΠΏΡΠΎΡΡΠΎΠΉ ΠΈ Π·Π°Π½ΡΠ»Π° Ρ ΠΌΠ΅Π½Ρ Π΄ΠΎΠ²ΠΎΠ»ΡΠ½ΠΎ ΠΌΠ½ΠΎΠ³ΠΎ Π²ΡΠ΅ΠΌΠ΅Π½ΠΈ. ΠΠΎ ΠΊΠ°ΠΊ ΠΎΠΊΠ°Π·Π°Π»ΠΎΡΡ β ΡΠ°ΠΊΠΎΠΉ ΠΏΠΎΠ΄Ρ ΠΎΠ΄ ΠΏΡΠΈΠ½ΡΡ Π±ΠΎΠ»ΡΡΡΡ ΠΏΠΎΠ»ΡΠ·Ρ ΠΈ ΠΏΡΠΎΡΡΠ½ΠΈΠ» ΠΌΠ½ΠΎΠ³ΠΈΠ΅ ΡΠΎΠ½ΠΊΠΎΡΡΠΈ, ΠΊΠΎΡΠΎΡΡΠ΅ ΡΠΊΡΡΠ²Π°ΡΡ IDE.
ΠΡΠΏΠΎΠ»ΡΠ·ΡΡ ΡΠΎΠ»ΡΠΊΠΎ Π±Π»ΠΎΠΊΠ½ΠΎΡ, ΠΌΡ Π½Π°ΠΏΠΈΡΠ΅ΠΌ ΡΠΎΠ²ΡΠ΅ΠΌ ΠΌΠ°Π»Π΅Π½ΡΠΊΠΎΠ΅ ΡΡΠ΅Π±Π½ΠΎΠ΅ Android-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅. Π Π·Π°ΡΠ΅ΠΌ ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΡΠ΅ΠΌ Π΅Π³ΠΎ, ΡΠΎΠ±Π΅ΡΡΠΌ ΠΈ Π·Π°ΠΏΡΡΡΠΈΠΌ Π½Π° ΡΡΡΡΠΎΠΉΡΡΠ²Π΅ β ΠΈ Π²ΡΡ ΡΠ΅ΡΠ΅Π· ΠΊΠΎΠΌΠ°Π½Π΄Π½ΡΡ ΡΡΡΠΎΠΊΡ. ΠΠ°ΠΈΠ½ΡΠ΅ΡΠ΅ΡΠΎΠ²Π°Π»ΠΎ? Π’ΠΎΠ³Π΄Π° ΠΏΡΠΎΡΡ.
ΠΡΡΡΠΏΠ»Π΅Π½ΠΈΠ΅
Π― Π±ΡΠ» ΠΏΠΎΡΠ°ΠΆΡΠ½, Π½Π°ΡΠΊΠΎΠ»ΡΠΊΠΎ ΡΠ»ΠΎΠΆΠ½ΡΠΌ ΠΈ Π·Π°ΠΏΡΡΠ°Π½Π½ΡΠΌ ΡΠ²Π»ΡΠ΅ΡΡΡ ΡΠ°Π±Π»ΠΎΠ½Π½ΠΎΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π² Android Studio. ΠΠ½ΠΎ ΠΏΡΠΎΡΡΠΎ Π½Π°Π³ΡΠΎΠΌΠΎΠΆΠ΄Π΅Π½ΠΎ ΡΠ΅ΡΡΡΡΠ°ΠΌΠΈ. Π Π² ΠΌΠ΅Π½ΡΡΠ΅ΠΉ ΡΡΠ΅ΠΏΠ΅Π½ΠΈ β ΠΊΠΎΠ΄ΠΎΠΌ ΠΈ ΡΠΊΡΠΈΠΏΡΠ°ΠΌΠΈ. Π₯ΠΎΡΡ Π²ΡΡ ΡΡΠΎ ΠΎΠ½ΠΎ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π΄Π΅Π»Π°ΡΡ β ΡΡΠΎ Π²ΡΠ²ΠΎΠ΄ΠΈΡΡ Π½Π° ΡΠΊΡΠ°Π½ HelloWorld! ΠΡΠΎΠΌΠ΅ ΡΠΎΠ³ΠΎ, Π² ΠΊΠ½ΠΈΠ³Π°Ρ ΠΈ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²Π°Ρ , ΠΊΠΎΡΠΎΡΡΠ΅ Ρ ΠΏΡΠΎΡΠΌΠΎΡΡΠ΅Π», ΠΎΠ±ΡΡΡΠ½ΡΠ΅ΡΡΡ, ΠΊΠ°ΠΊ Ρ ΠΏΠΎΠΌΠΎΡΡΡ Π΄ΠΈΠ°Π»ΠΎΠ³ΠΎΠ²ΡΡ ΠΎΠΊΠΎΠ½ ΡΠΎΠ·Π΄Π°ΡΡ IDEA-ΡΠ½ΡΠΉ ΠΈΠ»ΠΈ ΡΠΊΠ»ΠΈΠΏΡΠΎΠ²ΡΠΉ HelloWorld β ΠΈ ΠΎΡ Π½Π΅Π³ΠΎ ΡΠΆΠ΅ ΠΈΠ΄ΡΡ Π΄Π°Π»ΡΠ½Π΅ΠΉΡΠ΅Π΅ ΠΏΠΎΠ²Π΅ΡΡΠ²ΠΎΠ²Π°Π½ΠΈΠ΅. Π ΡΡΠΎ ΠΏΡΠΎΠΈΡΡ ΠΎΠ΄ΠΈΡ Β«ΠΏΠΎΠ΄ ΠΊΠ°ΠΏΠΎΡΠΎΠΌΒ» β ΠΎΡΡΠ°ΡΡΡΡ ΡΠΎΠ»ΡΠΊΠΎ Π³Π°Π΄Π°ΡΡ.
ΠΡ ΡΠΎΠ·Π΄Π°Π΄ΠΈΠΌ ΡΠ²ΠΎΠΉ ΡΠ°Π±Π»ΠΎΠ½Π½ΡΠΉ ΠΏΡΠΎΠ΅ΠΊΡ, ΠΊΠΎΡΠΎΡΡΠΉ ΠΈΠ΄Π΅Π°Π»ΡΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π΄Π»Ρ ΡΡΠ΅Π±Π½ΡΡ ΡΠ΅Π»Π΅ΠΉ. Π’Π°ΠΌ Π½Π΅ Π±ΡΠ΄Π΅Ρ Π½ΠΈΡΠ΅Π³ΠΎ Π»ΠΈΡΠ½Π΅Π³ΠΎ, ΡΠΎΠ»ΡΠΊΠΎ Π²ΡΡ ΡΠ°ΠΌΠΎΠ΅ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎΠ΅. Π ΠΏΠΎΡΠΎΠΌ Π΄Π΅ΡΠ°Π»ΡΠ½ΠΎ ΡΠ°Π·Π±Π΅ΡΡΠΌ, ΠΊΠ°ΠΊ Π΅Π³ΠΎ ΡΠΎΠ±ΡΠ°ΡΡ ΠΈ Π·Π°ΠΏΡΡΡΠΈΡΡ Π½Π° Π²Π°ΡΠ΅ΠΌ Android-ΡΡΡΡΠΎΠΉΡΡΠ²Π΅. Π ΠΊΠΎΠ½ΡΠ΅ ΡΡΠ°ΡΡΠΈ Π±ΡΠ΄Π΅Ρ ΡΡΡΠ»ΠΊΠ° Π½Π° ΡΠΊΠ°ΡΠΈΠ²Π°Π½ΠΈΠ΅ Π°ΡΡ ΠΈΠ²Π° Ρ ΠΈΡΠΎΠ³ΠΎΠ²ΡΠΌ ΠΏΡΠΎΠ΅ΠΊΡΠΎΠΌ β Π΅ΡΠ»ΠΈ Π²ΠΎΠ·Π½ΠΈΠΊΠ½ΡΡ ΠΊΠ°ΠΊΠΈΠ΅-ΡΠΎ Π²ΠΎΠΏΡΠΎΡΡ β ΠΌΠΎΠΆΠ΅ΡΠ΅ ΡΠ²Π΅ΡΠΈΡΡΡΡ Ρ Π½ΠΈΠΌ.
Π’Π°ΠΊΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ, Π²Ρ Π±ΡΠ΄Π΅ΡΠ΅ Π½Π° 100% Π·Π½Π°ΡΡ ΠΈ ΠΏΠΎΠ½ΠΈΠΌΠ°ΡΡ ΡΠΎΡΡΠ°Π² Π²Π°ΡΠ΅Π³ΠΎ ΠΏΡΠΎΠ΅ΠΊΡΠ° ΠΈ ΠΏΡΠΎΡΠ΅ΡΡ Π΅Π³ΠΎ ΡΠ±ΠΎΡΠΊΠΈ. Π₯ΠΎΡΡ ΡΡΠΎΡ ΡΠ΅ΡΡΠΎΠ²ΡΠΉ ΠΏΡΠΎΠ΅ΠΊΡ ΠΏΡΠ΅Π΄Π½Π°Π·Π½Π°ΡΠ΅Π½ Π΄Π»Ρ ΠΎΠ±ΡΡΠ΅Π½ΠΈΡ, ΠΏΡΠΈ Π½Π΅Π±ΠΎΠ»ΡΡΠΎΠΉ Π΄ΠΎΡΠ°Π±ΠΎΡΠΊΠ΅ Π΅Π³ΠΎ ΠΌΠΎΠΆΠ½ΠΎ Π±ΡΠ΄Π΅Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΊΠ°ΠΊ ΠΏΡΠΎΡΠ½ΡΠΉ ΡΡΠ½Π΄Π°ΠΌΠ΅Π½Ρ Π΄Π»Ρ Π²Π°ΡΠΈΡ ΡΠ΅Π°Π»ΡΠ½ΡΡ ΠΏΡΠΎΠ΅ΠΊΡΠΎΠ².
ΠΠΎΠ΄Π³ΠΎΡΠΎΠ²ΠΊΠ°
ΠΠ»Ρ Π½Π°ΡΠ°Π»Π° Π½Π°ΠΌ Π½ΡΠΆΠ½ΠΎ ΡΠΊΠ°ΡΠ°ΡΡ ΠΈ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠΈ (command line tools). Π‘ΡΡΠ»ΠΊΠ° Π½Π° ΠΈΡ ΡΠΊΠ°ΡΠΈΠ²Π°Π½ΠΈΠ΅ Π½Π°Ρ ΠΎΠ΄ΠΈΡΡΡ Π²Π½ΠΈΠ·Ρ ΡΡΡΠ°Π½ΠΈΡΡ, ΠΏΠΎΡΠ²ΡΡΡΠ½Π½ΠΎΠΉ Android Studio (https://developer.android.com/studio/index.html).
Android SDK 24 ΡΡΠΎ ΠΊΠ°ΠΊ ΡΠ°Π· Android N (Nougat / 7). ΠΡΠΈΠ½ΠΈΠΌΠ°Π΅ΠΌ ΡΡΠ»ΠΎΠ²ΠΈΡ, ΡΠΊΠ°ΡΠΈΠ²Π°Π΅ΠΌ ΡΡΡΠ°Π½ΠΎΠ²ΡΠΈΠΊ, Π·Π°ΠΏΡΡΠΊΠ°Π΅ΠΌ Π΅Π³ΠΎ. ΠΡΡΠ°Π²ΠΈΠΌ Π²ΡΡ ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ. ΠΠ½ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡΡ Π² Π΄ΠΈΡΠ΅ΠΊΡΠΎΡΠΈΡ Π²ΠΈΠ΄Π° C:\Users\kciray\AppData\Local\Android\android-sdk. ΠΠ°ΠΏΠΎΠΌΠ½ΠΈΡΠ΅ ΡΡΠΎΡ ΠΏΡΡΡ, ΡΠ°ΠΌ Π±ΡΠ΄ΡΡ Π½Π°Ρ ΠΎΠ΄ΠΈΡΡΡ Π½Π°ΡΠΈ ΠΎΡΠ½ΠΎΠ²Π½ΡΠ΅ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΡ.
ΠΠ°Π»Π΅Π΅, Π·Π°ΠΏΡΡΠΊΠ°Π΅ΡΠ΅ SDK Manager (ΠΈΠ· ΠΏΠ°ΠΏΠΊΠΈ android-sdk) ΠΈ ΡΠΎΠΆΠ΅ ΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅ΡΠ΅ Π½Π°Π±ΠΎΡ ΠΏΠΎ-ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ. Π’Π°ΠΌ Π΅ΡΡΡ Π²ΡΡ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎΠ΅, Π²ΠΊΠ»ΡΡΠ°Ρ Π½ΠΎΠ²ΡΠΉ Jack-ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡ. Π’Π°ΠΊΠΆΠ΅ Π²Π°ΠΌ ΠΏΠΎΠ½Π°Π΄ΠΎΠ±ΠΈΡΡΡ JDK 8.
ΠΠ»Π°Π²Π½ΠΎΠ΅ ΡΡΠ΅Π±ΠΎΠ²Π°Π½ΠΈΠ΅ ΠΏΠ΅ΡΠ΅Π΄ ΠΏΡΠΎΡΡΠ΅Π½ΠΈΠ΅ΠΌ ΡΡΠΎΠΉ ΡΡΠ°ΡΡΠΈ β ΠΊΡΠΎΠΌΠ΅ ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½Π½ΠΎΠ³ΠΎ ΡΠΎΡΡΠ° Π²Ρ Π΄ΠΎΠ»ΠΆΠ½Ρ ΡΠΆΠ΅ ΡΠΌΠ΅ΡΡ Π·Π°ΠΏΡΡΠΊΠ°ΡΡ Π½Π° Π²Π°ΡΠ΅ΠΌ Π΄Π΅Π²Π°ΠΉΡΠ΅ ΡΠΎΡ Helloworld, ΠΊΠΎΡΠΎΡΡΠΉ ΠΏΠΎΡΡΠ°Π²Π»ΡΠ΅ΡΡΡ Π²ΠΌΠ΅ΡΡΠ΅ Ρ Eclipse ΠΈΠ»ΠΈ Android Studio. Π’.Π΅. Ρ Π²Π°Ρ Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±ΡΡΡ Π½Π°ΡΡΡΠΎΠ΅Π½ Π΄ΡΠ°ΠΉΠ²Π΅Ρ usb, Π²ΠΊΠ»ΡΡΠ΅Π½Π° ΠΎΡΠ»Π°Π΄ΠΊΠ° ΠΏΠΎ usb Π½Π° Π²Π°ΡΠ΅ΠΌ Π΄Π΅Π²Π°ΠΉΡΠ΅ ΠΈ Ρ.Π΄β¦ ΠΠ»ΠΈ ΠΆΠ΅ ΡΠΎΠ·Π΄Π°Π½ ΠΈ Π½Π°ΡΡΡΠΎΠ΅Π½ ΡΠΌΡΠ»ΡΡΠΎΡ. ΠΡΠΎ ΡΠΎΠ²ΡΠ΅ΠΌ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ°ΡΠ½ΡΠ΅ Π²Π΅ΡΠΈ, ΠΈ ΠΈΡ ΡΠ°ΡΡΠΌΠΎΡΡΠ΅Π½ΠΈΠ΅ Π²ΡΡ ΠΎΠ΄ΠΈΡ Π·Π° ΡΠ°ΠΌΠΊΠΈ Π΄Π°Π½Π½ΠΎΠΉ ΡΡΠ°ΡΡΠΈ β Π² ΡΠ΅ΡΠΈ Π΄ΠΎΡΡΠ°ΡΠΎΡΠ½ΠΎ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΠΈ. ΠΡΡΠ°ΡΠΈ ΠΏΡΠΎΡΠΈΡΠ°ΡΡ ΠΏΠ°ΡΡ Π³Π»Π°Π² ΠΈΠ· ΠΊΠ½ΠΈΠ³ ΡΠΎΠΆΠ΅ Π±ΡΠ΄Π΅Ρ Π½Π΅ Π»ΠΈΡΠ½ΠΈΠΌ β Ρ ΠΎΡΡ Π±Ρ ΠΏΠΎΠ½ΠΈΠΌΠ°ΡΡ, ΠΊΠ°ΠΊ ΡΡΡΡΠΎΠ΅Π½ ΠΌΠ°Π½ΠΈΡΠ΅ΡΡ, ΡΠ΅ΡΡΡΡΡ, Π΄Π° ΠΈ Π²ΠΎΠΎΠ±ΡΠ΅ ΠΎΡΠ½ΠΎΠ²Ρ ΡΠ·ΡΠΊΠ° Java. Π Π² ΡΡΠΎΠΉ ΡΡΠ°ΡΡΠ΅ Ρ ΠΎΠΏΠΈΡΡ ΡΠΎ, ΠΎ ΡΡΠΌ ΠΊΠ½ΠΈΠ³ΠΈ ΠΌΠΎΠ»ΡΠ°Ρ.
ΠΠ°ΠΏΠΈΡΠ°Π½ΠΈΠ΅ ΠΏΡΠΎΠ΅ΠΊΡΠ°
ΠΠ»Ρ Π½Π°ΡΠ°Π»Π°, ΡΠΎΠ·Π΄Π°ΠΉΡΠ΅ Π½Π΅ΠΊΠΎΡΠΎΡΡΡ ΠΏΠ°ΠΏΠΊΡ, Π³Π΄Π΅ Π±ΡΠ΄Π΅Ρ Π²Π°Ρ ΠΏΡΠΎΠ΅ΠΊΡ. ΠΠ°Π·ΠΎΠ²ΡΠΌ Π΅Ρ testapp. Π Π½Π΅ΠΉ ΡΠΎΠ·Π΄Π°ΠΉΡΠ΅ Π΅ΡΡ 3 ΠΏΠ°ΠΏΠΊΠΈ β bin, res ΠΈ src.
Π‘ΠΎΠ·Π΄Π°ΠΉΡΠ΅ Π² testapp ΠΏΡΡΡΠΎΠΉ ΡΠ΅ΠΊΡΡΠΎΠ²ΡΠΉ ΡΠ°ΠΉΠ» ΠΈ ΠΈΠ·ΠΌΠ΅Π½ΠΈΡΠ΅ Π΅Π³ΠΎ ΠΈΠΌΡ Π½Π° AndroidManifest.xml.
ΠΠΎΠ±Π°Π²ΡΡΠ΅ Π² Π½Π΅Π³ΠΎ ΡΠ»Π΅Π΄ΡΡΡΠ΅Π΅:
Π’ΡΡ Π²ΡΡ ΠΏΡΠΎΡΡΠΎ. ΠΡ Π½Π°ΠΌΠ΅ΡΠ΅Π½Ρ ΡΠ΄Π΅Π»Π°ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Ρ ΠΈΠΌΠ΅Π½Π΅ΠΌ TestApp, ΠΊΠΎΡΠΎΡΠΎΠ΅ ΠΏΡΠΈ ΡΡΠ°ΡΡΠ΅ Π·Π°ΠΏΡΡΠΊΠ°Π΅Ρ ΠΊΠ»Π°ΡΡ MainActivity. ΠΡΡΠ°Π»ΠΎΡΡ ΡΠΎΠ»ΡΠΊΠΎ Π½Π°ΠΏΠΈΡΠ°ΡΡ ΡΡΠΎΡ Π½Π΅Π±ΠΎΠ»ΡΡΠΎΠΉ ΠΊΠ»Π°ΡΡ β ΠΈ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π³ΠΎΡΠΎΠ²ΠΎ. ΠΡΠ»ΠΈ Π½ΡΠΆΠ½ΠΎ β ΠΎΡΡΠ΅Π΄Π°ΠΊΡΠΈΡΡΠΉΡΠ΅ Π² ΡΠ΅Π³Π΅ uses-sdk ΡΠ²ΠΎΠΉΡΡΠ²ΠΎ android:targetSdkVersion β ΠΏΠΎΡΡΠ°Π²ΡΡΠ΅ ΡΡ Π²Π΅ΡΡΠΈΡ, ΠΊΠΎΡΠΎΡΠ°Ρ Ρ Π²Π°Ρ.
ΠΠ°Π»Π΅Π΅ β ΡΠΎΠ·Π΄Π°Π΄ΠΈΠΌ ΠΏΡΠΎΡΡΠ΅ΠΉΡΠΈΠΉ ΡΠ΅ΡΡΡΡ β ΡΡΡΠΎΠΊΡ Hello test app. ΠΠΎΠΎΠ±ΡΠ΅-ΡΠΎ ΠΌΡ ΠΌΠΎΠ³Π»ΠΈ ΠΎΠ±ΠΎΠΉΡΠΈΡΡ ΠΈ Π±Π΅Π· ΡΠ΅ΡΡΡΡΠ°, Π²ΡΡΠ°Π²ΠΈΠ² ΡΡΡ ΡΡΡΠΎΠΊΡ ΠΏΡΡΠΌΠΎ Π² Java ΠΊΠΎΠ΄. ΠΠΎ Π½Π΅ΠΊΠΎΡΠΎΡΡΠ΅ ΡΠ°Π³ΠΈ ΡΠ±ΠΎΡΠΊΠΈ ΡΠ°Π±ΠΎΡΠ°ΡΡ Ρ ΡΠ΅ΡΡΡΡΠ°ΠΌΠΈ, ΠΈ ΡΡΠΎΠ±Ρ ΡΠ²ΠΈΠ΄Π΅ΡΡ ΠΈΠ½ΡΠ΅ΡΠ΅ΡΠ½ΡΠ΅ ΠΌΠΎΠΌΠ΅Π½ΡΡ β ΠΌΡ Π²ΡΡ-ΡΠ°ΠΊΠΈ ΠΏΠΎΡΠ°Π±ΠΎΡΠ°Π΅ΠΌ Ρ Π½ΠΈΠΌΠΈ.
ΠΠ°Π²Π°ΠΉΡΠ΅ ΡΠΎΠ·Π΄Π°Π΄ΠΈΠΌ Π² ΠΏΠ°ΠΏΠΊΠ΅ res ΠΏΠ°ΠΏΠΊΡ values. ΠΡΠ΅ ΡΠ΅ΡΡΡΡΡ ΡΠ»Π΅Π΄ΡΠ΅Ρ ΡΠ°Π·Π±ΠΈΠ²Π°ΡΡ ΠΏΠΎ ΠΏΠ°ΠΏΠΊΠ°ΠΌ. ΠΠ°Π»Π΅Π΅ β Π² Π½Π΅ΠΉ ΡΠΎΠ·Π΄Π°Π΄ΠΈΠΌ ΠΏΡΡΡΠΎΠΉ ΡΠ°ΠΉΠ» strings.xml, Π° Π² Π½ΡΠΌ Π½Π°ΠΏΠΈΡΠ΅ΠΌ:
ΠΠΎΡ ΠΈ Π²ΡΠ΅ ΡΠ΅ΡΡΡΡΡ, Π½Π°ΠΌ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΡΠ΅. ΠΡΠΎΡΡΠΎ, Π½Π΅ ΡΠ°ΠΊ Π»ΠΈ? ΠΠ°Π»Π΅Π΅ ΡΠΎΠ·Π΄Π°Π΄ΠΈΠΌ Π²Π½ΡΡΡΠΈ src ΠΏΠ°ΠΏΠΊΡ com, Π² Π½Π΅ΠΉ ΠΏΠ°ΠΏΠΊΡ example, ΠΏΠΎΡΠΎΠΌ Π΅ΡΡ Π½ΠΈΠΆΠ΅ ΠΏΠΎ ΠΈΠ΅ΡΠ°ΡΡ ΠΈΠΈ ΠΏΠ°ΠΏΠΊΡ testapp β Π° ΡΠ°ΠΌ ΡΠΆΠ΅ Π½Π°Ρ ΠΊΠ»Π°ΡΡ MainActivity.java. ΠΠΎΠ±Π°Π²ΠΈΠΌ ΡΡΠ΄Π° ΠΊΠΎΠ΄:
Π‘ΡΡΡΠΊΡΡΡΠ° ΠΊΠ°ΡΠ°Π»ΠΎΠ³ΠΎΠ² Π΄ΠΎΠ»ΠΆΠ½Π° ΠΏΠΎΠ»ΡΡΠΈΡΡΡ ΡΠ°ΠΊΠ°Ρ
Π ΡΡΠΎ ΡΠΎΠ±ΡΡΠ²Π΅Π½Π½ΠΎ Π²ΡΡ, ΡΡΠΎ Π½Π°ΠΌ Π±ΡΠ»ΠΎ Π½ΡΠΆΠ½ΠΎ Π΄Π»Ρ ΠΏΡΠΎΡΡΠ΅ΠΉΡΠ΅Π³ΠΎ ΠΏΡΠΎΠ΅ΠΊΡΠ°. ΠΠ»Ρ ΡΡΠ°Π²Π½Π΅Π½ΠΈΡ β
Π‘ΠΎΠ±ΡΡΠ²Π΅Π½Π½ΠΎ, Π°Π²ΡΠΎΠΌΠ°ΡΠΈΠ·Π°ΡΠΈΡ ΡΠ΅ΡΠ΅Π· gradle, ΡΠ°Π±ΠΎΡΠ° Ρ git ΠΈ IDE β Π²Π΅ΡΠΈ ΠΎΡΠ΅Π½Ρ Π²Π°ΠΆΠ½ΡΠ΅, ΠΎΠ΄Π½Π°ΠΊΠΎ Π½Π° ΡΡΠ°ΠΏΠ΅ ΠΈΠ·ΡΡΠ΅Π½ΠΈΡ Android ΠΌΠ½Π΅ Π±Ρ ΠΎΡΠ΅Π½Ρ Ρ ΠΎΡΠ΅Π»ΠΎΡΡ ΠΎΡ Π½ΠΈΡ Π°Π±ΡΡΡΠ°Π³ΠΈΡΠΎΠ²Π°ΡΡΡΡ.
Π‘Π±ΠΎΡΠΊΠ°
Π’Π΅ΠΏΠ΅ΡΡ ΠΆΠ΅ ΠΏΠΎΠ΄Ρ ΠΎΠ΄ΠΈΠΌ ΠΊ ΡΠ°ΠΌΠΎΠΌΡ Π²Π°ΠΆΠ½ΠΎΠΌΡ ΠΈ ΡΠ»ΠΎΠΆΠ½ΠΎΠΌΡ ΡΡΠ°ΠΏΡ. ΠΡ Π±ΡΠ΄Π΅ΠΌ ΠΌΠ½ΠΎΠ³ΠΎ ΡΠ°Π±ΠΎΡΠ°ΡΡ Ρ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠΎΠΉ, ΠΏΠΎΡΡΠΎΠΌΡ ΡΠ΅ΠΊΠΎΠΌΠ΅Π½Π΄ΡΡ Π²Π°ΠΌ Π²ΡΠ΅ ΠΊΠΎΠΌΠ°Π½Π΄Ρ, Π΄Π°Π½Π½ΡΠ΅ Π·Π΄Π΅ΡΡ, Π·Π°ΠΏΠΈΡΡΠ²Π°ΡΡ Π² ΠΎΠ΄ΠΈΠ½ ΡΠ°ΠΉΠ» ΠΈ Π½Π°Π·Π²Π°ΡΡ Π΅Π³ΠΎ Compile.bat. Π ΠΊΠΎΠ½ΡΠ΅ ΡΠ°ΠΉΠ»Π° ΠΏΠΎΡΠ»Π΅ ΠΊΠΎΠΌΠ°Π½Π΄ ΠΌΠΎΠΆΠ΅ΡΠ΅ Π΄ΠΎΠ±Π°Π²ΠΈΡΡ pause, ΡΡΠΎΠ±Ρ Π±ΡΠ» Π²ΠΈΠ΄Π΅Π½ ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ ΠΈ ΠΎΡΠΈΠ±ΠΊΠΈ β Π΅ΡΠ»ΠΈ ΡΠ°ΠΊΠΎΠ²ΡΠ΅ Π²ΠΎΠ·Π½ΠΈΠΊΠ½ΡΡ.
ΠΠΎΠ΄Π³ΠΎΡΠΎΠ²ΠΊΠ° ΠΏΡΡΠ΅ΠΉ
ΠΠ΅ΡΠ²ΠΎΠ΅, ΡΡΠΎ ΠΌΡ ΡΠ΄Π΅Π»Π°Π΅ΠΌ Π΄Π»Ρ ΡΠ΄ΠΎΠ±ΡΡΠ²Π° ΠΈ ΠΊΡΠ°ΡΠΊΠΎΡΡΠΈ β ΡΠΎΠ·Π΄Π°Π΄ΠΈΠΌ ΡΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½ΡΠ΅ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅, Π² ΠΊΠΎΡΠΎΡΡΡ Π±ΡΠ΄Π΅ΠΌ Ρ ΡΠ°Π½ΠΈΡΡ ΠΏΡΡΠΈ. ΠΠ»Ρ Π½Π°ΡΠ°Π»Π° β ΠΎΠΏΡΠ΅Π΄Π΅Π»ΠΈΠΌ Π½Π°ΡΠΈ ΠΎΡΠ½ΠΎΠ²Π½ΡΠ΅ Π΄ΠΈΡΠ΅ΠΊΡΠΎΡΠΈΠΈ. ΠΠ°ΠΌ Π½ΡΠΆΠ½ΠΎ Π·Π°ΠΌΠ΅Π½ΠΈΡΡ ΠΏΡΡΠΈ ΠΊ JDK ΠΈ Android SDK Π½Π° ΡΠ΅, ΠΊΠΎΡΠΎΡΡΠ΅ Ρ Π²Π°Ρ.
ΠΠ°Π»Π΅Π΅ β ΠΏΡΡΠΈ Π½Π΅ΠΏΠΎΡΡΠ΅Π΄ΡΡΠ²Π΅Π½Π½ΠΎ ΠΊ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ°ΠΌ. Π― ΡΠ΅ΠΊΠΎΠΌΠ΅Π½Π΄ΡΡ Π²Π°ΠΌ ΠΏΡΠΎΡΠΌΠΎΡΡΠ΅ΡΡ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ΠΈ Π²Π°ΡΠΈΡ SDK ΠΈ ΡΠ±Π΅Π΄ΠΈΡΡΡ Π² ΡΠΎΠΌ, ΡΡΠΎ Π²ΡΡ Π½Π° ΠΌΠ΅ΡΡΠ΅. Π’Π°ΠΊΠΆΠ΅ ΠΏΠΎΠ΄ΠΊΠΎΡΡΠ΅ΠΊΡΠΈΡΠΎΠ²Π°ΡΡ Π²Π΅ΡΡΠΈΠΈ, ΠΊΠΎΡΠΎΡΡΠ΅ ΠΏΡΠΈΡΡΡΡΡΠ²ΡΡΡ Π² ΠΏΡΡΡΡ .
ΠΠ΅ΠΆΠ΄Ρ ΠΏΡΠΎΡΠΈΠΌ, Π² Π±ΠΎΠ»Π΅Π΅ ΡΡΠ°ΡΡΡ Π²Π΅ΡΡΠΈΡΡ ΡΡΠΈΠ»ΠΈΡΠ° aapt Π½Π°Ρ ΠΎΠ΄ΠΈΠ»Π°ΡΡ Π² platform-tools β ΠΈ Ρ Π½Π΅ ΠΈΡΠΊΠ»ΡΡΠ°Ρ ΡΡΠΎ ΠΎΠ½Π° ΠΈ\ΠΈΠ»ΠΈ Π΄ΡΡΠ³ΠΈΠ΅ ΠΌΠΎΠ³ΡΡ ΡΠ»ΠΈΠ½ΡΡΡ ΠΊΡΠ΄Π°-Π½ΠΈΠ±ΡΠ΄Ρ Π΅ΡΡ. Π’Π°ΠΊ ΡΡΠΎ Π±ΡΠ΄ΡΡΠ΅ Π²Π½ΠΈΠΌΠ°ΡΠ΅Π»ΡΠ½Ρ. ΠΡΠ»ΠΈ Π²Ρ Π²ΡΡ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎ ΡΠ²Π΅ΡΠΈΡΠ΅ ΡΠ΅ΠΉΡΠ°Ρ β ΡΠΎ ΠΎΡΡΠ°Π»ΡΠ½Π°Ρ ΡΠ°ΡΡΡ ΡΡΠ°ΡΡΠΈ Π΄ΠΎΠ»ΠΆΠ½Π° ΠΏΡΠΎΠΉΡΠΈ Π³Π»Π°Π΄ΠΊΠΎ.
Π Π΅ΡΡ β Π² ΠΏΠ°ΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ Π·Π°Π±ΡΡΠΌ Π½Π°ΡΠΈ ΠΏΠ°ΠΊΠ΅ΡΡ ΠΈ ΠΊΠ»Π°ΡΡΡ. ΠΡΠ»ΠΈ Π·Π°Ρ ΠΎΠ΄ΠΈΡΠ΅ ΠΈΡ ΡΠΌΠ΅Π½ΠΈΡΡ β Π²Π°ΠΌ Π½Π΅ ΠΏΡΠΈΠ΄ΡΡΡΡ Π±Π΅Π³Π°ΡΡ ΠΏΠΎ ΠΊΠΎΠ΄Ρ β Π²ΡΠ΅ Π½Π°ΡΡΡΠΎΠΉΠΊΠΈ Π²Π½Π°ΡΠ°Π»Π΅.
ΠΠΎΠ΄Π³ΠΎΡΠΎΠ²ΠΊΠ° ΠΊ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ
ΠΠ»Ρ Π½Π°ΡΠ°Π»Π° ΡΠΏΡΠΎΡΡ β Π° Π²Ρ Π½ΠΈΠΊΠΎΠ³Π΄Π° Π½Π΅ Π·Π°Π΄ΡΠΌΡΠ²Π°Π»ΠΈΡΡ, ΠΊΠ°ΠΊ ΡΠ°Π±ΠΎΡΠ°Π΅Ρ Π·Π°Π³Π°Π΄ΠΎΡΠ½ΡΠΉ ΠΊΠ»Π°ΡΡ R? Π‘ΠΎΠ±ΡΡΠ²Π΅Π½Π½ΠΎ ΠΌΠ΅Π½Ρ ΠΎΠ½ ΡΠΏΠ΅ΡΠ²Π° ΡΠΌΡΡΠΈΠ» ΠΈΠ·-Π·Π° Π΅Π³ΠΎ ΡΠ²Π΅ΡΡ ΡΠ΅ΡΡΠ΅ΡΡΠ²Π΅Π½Π½ΡΡ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΠ΅ΠΉ. ΠΠ°ΠΊ Π½Π° ΡΡΠ°ΠΏΠ΅ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ ΠΌΠΎΠΆΠ½ΠΎ ΡΠ΅ΡΠ΅Π· ΠΏΠΎΠ»Ρ ΠΊΠ»Π°ΡΡΠ° ΠΎΠ±ΡΠ°ΡΠ°ΡΡΡΡ ΠΊ XML-ΡΠ°ΠΉΠ»Π°ΠΌ Π² Π΄ΡΡΠ³ΠΈΡ ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π°Ρ ? Π― ΠΏΡΠ΅Π΄ΠΏΠΎΠ»ΠΎΠΆΠΈΠ», ΡΡΠΎ ΡΡΡ ΠΎΡΡΠ΄ΡΠ΅Ρ ΠΏΡΠ΅ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡ β ΡΠ°ΠΊ ΠΎΠ½ΠΎ ΠΈ ΠΎΠΊΠ°Π·Π°Π»ΠΎΡΡ.
Π‘ΠΎΠ±ΡΡΠ²Π΅Π½Π½ΠΎ, Π΅ΡΡΡ ΡΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½Π°Ρ ΡΡΠΈΠ»ΠΈΡΠ° AAPT β ΠΎΠ½Π° ΠΏΡΠΎΡ ΠΎΠ΄ΠΈΡΡΡ ΠΏΠΎ ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π°ΠΌ Π²Π°ΡΠΈΡ ΡΠ΅ΡΡΡΡΠΎΠ² ΠΈ ΡΠΎΠ·Π΄Π°ΡΡ ΡΠΎΡ ΡΠ°ΠΌΡΠΉ R.java. ΠΠΊΠ°Π·ΡΠ²Π°Π΅ΡΡΡ, Π²ΡΡ ΠΎΡΠ΅Π½Ρ Π΄Π°ΠΆΠ΅ ΠΏΡΠΎΡΡΠΎ β ΡΡΠΎ ΠΏΡΠΎΡΡΠΎ ΠΊΠ»Π°ΡΡ, Π² ΡΠΎΡΡΠ°Π²Π΅ ΠΊΠΎΡΠΎΡΠΎΠ³ΠΎ Π΄ΡΡΠ³ΠΈΠ΅ ΡΡΠ°ΡΠΈΡΠ΅ΡΠΊΠΈΠ΅ Π²Π»ΠΎΠΆΠ΅Π½Π½ΡΠ΅ ΠΊΠ»Π°ΡΡΡ Ρ ΡΠ΅Π»ΠΎΡΠΈΡΠ»Π΅Π½Π½ΡΠΌΠΈ ΠΊΠΎΠ½ΡΡΠ°Π½ΡΠ°ΠΌΠΈ. Π Π²ΡΡ! ΠΠ½ Π²ΡΠ³Π»ΡΠ΄ΠΈΡ ΠΏΡΠΈΠΌΠ΅ΡΠ½ΠΎ ΡΠ°ΠΊ:
Π’Π΅ΠΏΠ΅ΡΡ Π΄Π°Π²Π°ΠΉΡΠ΅ ΡΠΎΠ·Π΄Π°Π΄ΠΈΠΌ Π΅Π³ΠΎ Ρ Π²Π°Ρ. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌ ΡΠ»Π΅Π΄ΡΡΡΠΈΠ΅ ΠΊΠΎΠΌΠ°Π½Π΄Ρ:
ΠΠ°Π²Π°ΠΉΡΠ΅ ΡΠ°Π·Π±Π΅ΡΡΠΌΡΡ, ΡΡΠΎ ΠΊ ΡΠ΅ΠΌΡ. AAPT β Android Asset Packaging Tool β Π±ΡΠΊΠ²Π°Π»ΡΠ½ΠΎ Β«ΡΠΏΠ°ΠΊΠΎΠ²ΡΠΈΠΊ Π°Π½Π΄ΡΠΎΠΈΠ΄-ΠΈΠΌΡΡΠ΅ΡΡΠ²Π°Β». ΠΠ³ΠΎ ΠΎΠΏΡΠΈΠΈ:
Π’Π΅ΠΏΠ΅ΡΡ Π² Π½Π°ΡΠ΅ΠΌ ΠΏΡΠΎΠ΅ΠΊΡΠ΅ Π½Π΅Ρ Π½ΠΈΠΊΠ°ΠΊΠΎΠΉ ΠΌΠ°Π³ΠΈΠΈ ΠΈ ΠΎΠ½ ΠΏΠΎΠ»Π½ΠΎΡΡΡΡ ΡΠΈΠ½ΡΠ°ΠΊΡΠΈΡΠ΅ΡΠΊΠΈ ΠΊΠΎΡΡΠ΅ΠΊΡΠ΅Π½ Π² ΡΠ°ΠΌΠΊΠ°Ρ Java. Π ΡΠ΅ΠΏΠ΅ΡΡ ΡΠ°ΠΌΠΎΠ΅ ΠΈΠ½ΡΠ΅ΡΠ΅ΡΠ½ΠΎΠ΅. ΠΠΎΠΌΠ½ΠΈΡΠ΅, ΠΊΠ°ΠΊ ΠΊΠ»Π°ΡΡΠΈΡΠ΅ΡΠΊΠΈΠ΅ Java-ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ ΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΡΡΡΡΡ ΡΠ΅ΡΠ΅Π· javac? Π Π°Π½ΡΡΠ΅ ΠΎΠ½ ΡΠ°ΠΊΠΆΠ΅ Π²Ρ ΠΎΠ΄ΠΈΠ» Π² ΠΏΠΎΡΠ»Π΅Π΄ΠΎΠ²Π°ΡΠ΅Π»ΡΠ½ΠΎΡΡΡ ΡΠ±ΠΎΡΠΊΠΈ Android-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ. ΠΡ Π±ΡΠ°Π»ΠΈ Π½Π°ΡΠΈ ΠΈΡΡ ΠΎΠ΄Π½ΠΈΠΊΠΈ (*.java), ΠΏΠΎΠ»ΡΡΠ°Π»ΠΈ ΠΈΠ· Π½ΠΈΡ Π±Π°ΠΉΡ-ΠΊΠΎΠ΄ JVM (*.class) ΠΈ ΡΠΆΠ΅ ΠΏΠΎΡΠΎΠΌ ΠΈΠ· Π½Π΅Π³ΠΎ ΠΏΠΎΠ»ΡΡΠ°Π»ΠΈ Π±Π°ΠΉΡ-ΠΊΠΎΠ΄ Π΄Π»Ρ Dalvic (*.dex). Π‘ ΠΏΠΎΡΠ²Π»Π΅Π½ΠΈΠ΅ΠΌ Jack ToolChain ΠΌΡ ΡΠΎΠΊΡΠ°ΡΠΈΠ»ΠΈ Π½Π°ΡΡ ΠΏΠΎΡΠ»Π΅Π΄ΠΎΠ²Π°ΡΠ΅Π»ΡΠ½ΠΎΡΡΡ ΡΠ±ΠΎΡΠΊΠΈ Π½Π° ΠΎΠ΄ΠΈΠ½ ΡΠ°Π³. ΠΠ· ΠΈΡΡ ΠΎΠ΄Π½ΠΈΠΊΠΎΠ² (*.java) ΠΌΡ ΡΡΠ°Π·Ρ ΠΆΠ΅ ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ Π±Π°ΠΉΡ-ΠΊΠΎΠ΄ Π΄Π»Ρ Dalvic (*.dex).
ΠΠ΄Π΅ ΠΆΠ΅ Π²Π·ΡΡΡ ΠΠΆΠ΅ΠΊΠ°? ΠΠ½ Π½Π°Ρ ΠΎΠ΄ΠΈΡΡΡ Π² ΠΏΠ°ΠΏΠΊΠ΅ build-tools Π² Π²ΠΈΠ΄Π΅ jack.jar ΠΈ Π·Π°ΠΏΡΡΠΊΠ°Π΅ΡΡΡ ΠΊΠ°ΠΊ ΠΎΠ±ΡΡΠ½ΡΠΉ Java-Π°ΡΡ ΠΈΠ².
Π£Π±Π΅Π΄ΠΈΡΠ΅ΡΡ Π² ΡΠΎΠΌ, ΡΡΠΎ Π² ΠΏΠ°ΠΏΠΊΠ΅ bin Π½Π°Ρ ΠΎΠ΄ΠΈΡΡΡ Π½Π°Ρ classes.dex. Π’Π΅ΠΏΠ΅ΡΡ ΠΎΡΡΠ°Π»ΠΎΡΡ ΡΠΎΠ»ΡΠΊΠΎ ΡΠΏΠ°ΠΊΠΎΠ²Π°ΡΡ Π΅Π³ΠΎ Π²ΠΌΠ΅ΡΡΠ΅ Ρ ΡΠ΅ΡΡΡΡΠ°ΠΌΠΈ Π² APK-ΡΠ°ΠΉΠ». Π‘Π΄Π΅Π»Π°Π΅ΠΌ ΡΡΠΎ:
ΠΠ΄Π΅ΡΡ ΠΎΠΏΡΠΈΠΈ Π°Π½Π°Π»ΠΎΠ³ΠΈΡΠ½Ρ ΡΠ΅ΠΌ, ΠΊΠΎΡΠΎΡΡΠ΅ ΠΌΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π»ΠΈ ΠΏΡΠΈ ΡΠΎΠ·Π΄Π°Π½ΠΈΠΈ R.java:
Π‘ΠΎΠ±ΡΡΠ²Π΅Π½Π½ΠΎ, ΡΡΠΈ ΡΡΡΠΎΡΠΊΠΈ Π·Π°ΠΏΡΡΠΊΠ°ΡΡ 2 Java-ΡΡΠΈΠ»ΠΈΡΡ, ΠΊΠΎΡΠΎΡΡΠ΅ Π½Π΅ ΠΈΠΌΠ΅ΡΡ Π½ΠΈΠΊΠ°ΠΊΠΎΠ³ΠΎ ΠΎΡΠ½ΠΎΡΠ΅Π½ΠΈΡ ΠΊ Android SDK β Π½ΠΎ ΠΎΠ½ΠΈ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΡ. ΠΠ΅ΡΠ²Π°Ρ ΡΠΎΠ·Π΄Π°ΡΡ ΡΠ°ΠΉΠ» AndroidTest.keystore (ΠΏΡΠΎΠ²Π΅ΡΡΡΠ΅ Π΅Π³ΠΎ Π½Π°Π»ΠΈΡΠΈΠ΅), Π° Π²ΡΠΎΡΠ°Ρ β ΡΡΠΎΡ ΡΠ°ΠΉΠ» ΡΠΎΠ΅Π΄ΠΈΠ½ΡΠ΅Ρ Ρ AndroidTest.unsigned.apk. ΠΠΎΠ»ΡΡΠ°Π΅ΡΡΡ ΡΠ°ΠΉΠ» AndroidTest.signed.apk. ΠΠΎΡ ΡΠ°ΠΊΠΎΠΉ Π΄ΠΈΠΊΠΈΠΉ ΠΊΡΠ°ΡΡ ΡΠ°ΠΉΠ»ΠΎΠ². ΠΠΎ ΠΎΠ΄Π½Π°ΠΆΠ΄Ρ ΡΠΎΠ·Π΄Π°Π² bat-ΡΠΊΡΠΈΠΏΡ Π·Π°ΠΏΡΡΠΊΠ°ΠΉΡΠ΅ Π΅Π³ΠΎ β ΠΈ ΠΎΠ½ Π±ΡΠ΄Π΅Ρ Π΄Π΅Π»Π°ΡΡ Π²ΡΡ ΡΡΠΎ Π² Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΎΠΌ ΡΠ΅ΠΆΠΈΠΌΠ΅.
Π― Π΄ΡΠΌΠ°Ρ, Π½Π΅ ΡΡΠΎΠΈΡ ΡΡΠ°ΡΠΈΡΡ Π²ΡΠ΅ΠΌΡ Π½Π° Π΄Π΅ΡΠ°Π»ΡΠ½ΡΠΉ ΡΠ°Π·Π±ΠΎΡ ΠΎΠΏΡΠΈΠΉ ΡΡΠΈΡ ΡΡΠΈΠ»ΠΈΡ Π² ΠΏΡΠ΅Π΄Π΅Π»Π°Ρ Π΄Π°Π½Π½ΠΎΠΉ ΡΡΠ°ΡΡΠΈ. ΠΡΠΎΡΡΠΎ Π½ΡΠΆΠ½ΠΎ ΡΠ»ΠΎΠ²ΠΈΡΡ ΡΡΡΡ β ΠΎΠ½ΠΈ Π±Π΅ΡΡΡ AndroidTest.unsigned.apk, ΠΏΠΎΠ΄ΠΏΠΈΡΡΠ²Π°ΡΡ Π΅Π³ΠΎ ΡΠ°ΠΉΠ»ΠΎΠΌ AndroidTest.keystore ΠΈ ΡΠΎΡ ΡΠ°Π½ΡΡΡ Π² AndroidTest.signed.apk. ΠΡΠ»ΠΈ Π΅ΡΡΡ ΠΆΠ΅Π»Π°Π½ΠΈΠ΅, ΠΌΠΎΠΆΠ΅ΡΠ΅ ΠΏΠΎΡΠΈΡΠ°ΡΡ Π² Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΡΠΈΠΈ.
ΠΠ°ΠΏΡΡΠΊ
Π’Π΅ΠΏΠ΅ΡΡ, ΠΊΠΎΠ³Π΄Π° ΠΌΡ Π½Π°ΠΊΠΎΠ½Π΅Ρ ΡΠΎΠ±ΡΠ°Π»ΠΈ Π½Π°Ρ apk-ΡΠ°ΠΉΠ» β ΠΌΠΎΠΆΠ΅ΠΌ Π΅Π³ΠΎ Π·Π°ΠΏΡΡΡΠΈΡΡ. ΠΠΎΠ΄ΠΊΠ»ΡΡΠΈΡΠ΅ ΠΏΠΎ usb Π²Π°ΡΠ΅ ΡΡΡΡΠΎΠΉΡΡΠ²ΠΎ, ΠΈΠ»ΠΈ ΠΆΠ΅ Π·Π°ΠΏΡΡΡΠΈΡΠ΅ ΡΠΌΡΠ»ΡΡΠΎΡ. Π Π·Π°ΡΠ΅ΠΌ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΠ΅
ΠΡΠ»ΠΈ Π²ΡΡ ΠΏΡΠΎΡΠ»ΠΎ ΡΠ΄Π°ΡΠ½ΠΎ, Π²Ρ ΡΠ²ΠΈΠ΄ΠΈΡΠ΅ ΡΡΠΎ-ΡΠΎ Π²ΡΠΎΠ΄Π΅ ΡΡΠΎΠ³ΠΎ:
ΠΠ°ΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅
ΠΠΎΡΠ»Π΅ ΡΠ±ΠΎΡΠΊΠΈ Π²ΡΠ΅Ρ ΡΠ°ΠΉΠ»ΠΎΠ² Π΄Π΅ΡΠ΅Π²ΠΎ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ΠΎΠ² Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π±ΡΡΡ ΠΏΡΠΈΠΌΠ΅ΡΠ½ΠΎ ΡΠ°ΠΊΠΈΠΌ.
Π’Π΅ΠΏΠ΅ΡΡ Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ Π½Π°Π³Π»ΡΠ΄Π½ΠΎ ΡΠ²ΠΈΠ΄Π΅ΡΡ ΠΈ ΠΏΠΎΠ½ΡΡΡ, ΠΊΠ°ΠΊ ΠΏΡΠΎΠΈΡΡ ΠΎΠ΄ΠΈΡ ΡΠ±ΠΎΡΠΊΠ° Π°Π½Π΄ΡΠΎΠΈΠ΄-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Π½Π° Π±ΠΎΠ»Π΅Π΅ Π½ΠΈΠ·ΠΊΠΎΠΌ ΡΡΠΎΠ²Π½Π΅. ΠΠΎΠ³Π΄Π° Π±ΡΠ΄Π΅ΡΠ΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ IDE β Π΅ΡΠ»ΠΈ ΡΠ±ΠΎΡΠΊΠ° Π²Π΄ΡΡΠ³ ΠΏΠΎΠΉΠ΄ΡΡ Π½Π΅ ΡΠ°ΠΊ (Π° ΡΠ°ΠΊΠΎΠ΅ ΡΠ°ΡΡΠΎ Π±ΡΠ²Π°Π΅Ρ) β ΡΠΌΠΎΠΆΠ΅ΡΠ΅ Π²ΡΡΡΠ»ΠΈΡΡ ΡΠΈΡΡΠ°ΡΠΈΡ ΠΊΠ°ΠΊ Π½Π°Π΄ΠΎ. Π’Π°ΠΊΠΆΠ΅ ΠΎΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅ Π½Π° ΡΠΎ, ΡΡΠΎ ΠΈΡΠΎΠ³ΠΎΠ²ΡΠΉ apk-ΡΠ°ΠΉΠ» Π·Π°Π½ΠΈΠΌΠ°Π΅Ρ Π²ΡΠ΅Π³ΠΎ ΠΎΠΊΠΎΠ»ΠΎ 4 ΠΊΠΈΠ»ΠΎΠ±Π°ΠΉΡ.
ΠΡΠΊΠ»Π°Π΄ΡΠ²Π°Ρ Π°ΡΡ ΠΈΠ² ΠΏΡΠΎΠ΅ΠΊΡΠ°. ΠΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅, ΡΡΠΎ Ρ Π΄ΠΎΠ±Π°Π²ΠΈΠ» ΡΡΠ΄Π° Π΅ΡΡ ΠΎΠ΄ΠΈΠ½ ΠΌΠ°Π»Π΅Π½ΡΠΊΠΈΠΉ ΡΠΊΡΠΈΠΏΡ β Clear.bat. ΠΠ½ ΡΠ΄Π°Π»ΡΠ΅Ρ Π²ΡΠ΅ ΡΠΎΠ·Π΄Π°Π½Π½ΡΠ΅ ΠΏΡΠΈ ΡΠ±ΠΎΡΠΊΠ΅ ΡΠ°ΠΉΠ»Ρ. Π ΠΏΠΎΡΡΠ°Π²ΠΈΠ» Π΅Π³ΠΎ Π·Π°ΠΏΡΡΠΊ Π½Π° Π½Π°ΡΠ°Π»ΠΎ Compile.bat. Π’Π°ΠΊΠΆΠ΅ Π΄ΠΎΠ±Π°Π²ΠΈΠ» ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠΈ Ρ ΠΏΠΎΠΌΠΎΡΡΡ Rem β ΠΏΠΎ ΡΠ°Π³Π°ΠΌ.
Π’Π°ΠΊΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ, ΡΠΊΡΠΈΠΏΡ ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ ΠΏΠΎΠ»Π½ΡΡ ΠΎΡΠΈΡΡΠΊΡ ΠΈ ΠΏΠ΅ΡΠ΅ΡΠ±ΠΎΡΠΊΡ ΠΏΡΠΎΠ΅ΠΊΡΠ°, Π²ΠΊΠ»ΡΡΠ°Ρ ΠΏΠΎΠ΄ΠΏΠΈΡΡ, Π° ΡΠ°ΠΊΠΆΠ΅ ΡΠ΄Π°Π»Π΅Π½ΠΈΠ΅ Π΅Π³ΠΎ Π½Π° ΡΡΡΡΠΎΠΉΡΡΠ²Π΅, ΡΡΡΠ°Π½ΠΎΠ²ΠΊΡ ΠΈ Π·Π°ΠΏΡΡΠΊ.
ΠΠΎΠΈ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΡ
ΠC: Windows 10 Pro x64
JDK: 1.8.0_73
Android SDK: 24
ΠΠΎΠ΄Π΅Π»Ρ: Meizu MX4
Android: 5.1
ΠΠ‘: Flyme 5.6.8.9 beta
Release: JavaFX 2.2.40
Last Updated: September 2013
[+] Show/Hide Table of Contents
About This Tutorial
1 Hello World, JavaFX Style
2 Creating a Form in JavaFX
3 Fancy Forms with JavaFX CSS
4 Using FXML to Create a User Interface
5 Animation and Visual Effects in JavaFX
6 Deploying Your First JavaFX Application
Application Files
View Source Code
Download Source Code
Profiles
Gail Chappell
Technical Writer, Oracle
Gail is part of the JavaFX documentation team and enjoys working on cutting-edge, innovative documentation.
Nancy Hildebrandt
Technical Writer, Oracle
Nancy is a technical writer in the JavaFX group. She has a background in content management systems, enterprise server-client software, and XML. She lives on 480 acres in the middle of nowhere with horses, a donkey, dogs, cats, and chickens, and stays connected by satellite.
We Welcome Your Comments
If you have questions about JavaFX, please go to the forum.
Getting Started with JavaFX
1 Hello World, JavaFX Style
The best way to teach you what it is like to create and build a JavaFX application is with a βHello Worldβ application. An added benefit of this tutorial is that it enables you to test that your JavaFX technology is properly installed.
The tool used in this tutorial is NetBeans IDE 7.3. Before you begin, ensure that the version of NetBeans IDE that you are using supports JavaFX 2. See the System Requirements for details.
Construct the Application
NetBeans opens the HelloWorld.java file and populates it with the code for a basic Hello World application, as shown in Example 1-1.
Example 1-1 Hello World
Here are the important things to know about the basic structure of a JavaFX application:
The main class for a JavaFX application extends the javafx.application.Application class. The start() method is the main entry point for all JavaFX applications.
A JavaFX application defines the user interface container by means of a stage and a scene. The JavaFX Stage class is the top-level JavaFX container. The JavaFX Scene class is the container for all content. Example 1-1 creates the stage and scene and makes the scene visible in a given pixel size.
In JavaFX, the content of the scene is represented as a hierarchical scene graph of nodes. In this example, the root node is a StackPane object, which is a resizable layout node. This means that the root node’s size tracks the scene’s size and changes when the stage is resized by a user.
The root node contains one child node, a button control with text, plus an event handler to print a message when the button is pressed.
The main() method is not required for JavaFX applications when the JAR file for the application is created with the JavaFX Packager tool, which embeds the JavaFX Launcher in the JAR file. However, it is useful to include the main() method so you can run JAR files that were created without the JavaFX Launcher, such as when using an IDE in which the JavaFX tools are not fully integrated. Also, Swing applications that embed JavaFX code require the main() method.
Figure 1-1 shows the scene graph for the Hello World application. For more information on scene graphs see Working with the JavaFX Scene Graph.
Figure 1-1 Hello World Scene Graph
Description of «Figure 1-1 Hello World Scene Graph»
Run the Application
Click the Say Hello World button.
Verify that the text βHello World!β is printed to the NetBeans output window.
Figure 1-2 shows the Hello World application, JavaFX style.
Figure 1-2 Hello World, JavaFX style
Description of «Figure 1-2 Hello World, JavaFX style»
Where to Go Next
This concludes the basic Hello World tutorial, but continue reading for more lessons on developing JavaFX applications:
Creating a Form in JavaFX teaches the basics of screen layout, how to add controls to a layout, and how to create input events.
Fancy Forms with JavaFX CSS provides simple style tricks for enhancing your application, including adding a background image and styling buttons and text.
Using FXML to Create a User Interface shows an alternate method for creating the login user interface. FXML is an XML-based language that provides the structure for building a user interface separate from the application logic of your code.
Animation and Visual Effects in JavaFX shows how to bring an application to life by adding timeline animation and blend effects.
Deploying Your First JavaFX Application describes how to run your application outside NetBeans IDE.
Java hello world
Π ΡΡΠΎΠΌ ΡΡΠΎΠΊΠ΅ ΠΌΡ ΡΠΎΠ·Π΄Π°Π΄ΠΈΠΌ Π½Π°ΡΡ ΠΏΠ΅ΡΠ²ΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π½Π° ΡΠ·ΡΠΊΠ΅ Java.
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Π½Π° ΡΠ·ΡΠΊΠ΅ Java ΡΠΎΡΡΠΎΠΈΡ ΠΈΠ· ΡΡΠ΅Ρ
ΡΠ»Π΅Π΄ΡΡΡΠΈΡ
ΡΠ°Π³ΠΎΠ²:
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΈΡΡ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΡΠ°ΠΉΠ»Π°
ΠΡΠ°ΠΊ, ΠΎΡΠΊΡΡΠ²Π°Π΅ΠΌ ΡΠ΅ΠΊΡΡΠΎΠ²ΡΠΉ ΡΠ΅Π΄Π°ΠΊΡΠΎΡ ΠΈ ΠΏΠΈΡΠ΅ΠΌ Π² Π½Π΅ΠΌ ΠΊΠΎΠ΄ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Hello World, ΡΠ΅Π»Ρ ΠΊΠΎΡΠΎΡΠΎΠΉ β Π²ΡΠ²ΠΎΠ΄ Π½Π° ΡΠΊΡΠ°Π½ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΡ Hello World!
ΠΡΠ»ΠΈ Π²Ρ ΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΠ΅ΡΡ Notepad++ ΡΠΎ Π½ΡΠΆΠ½ΠΎ Π²ΡΠ±ΡΠ°ΡΡ Π’ΠΈΠΏ ΡΠ°ΠΉΠ»Π°:Java source file (*.java)
ΠΡΠ΄ΡΡΠ΅ Π²Π½ΠΈΠΌΠ°ΡΠ΅Π»ΡΠ½Ρ! ΡΠ°ΠΉΠ» Π΄ΠΎΠ»ΠΆΠ΅Π½ Π½Π°Π·ΡΠ²Π°ΡΡΡΡ Π² ΡΠΎΡΠ½ΠΎΡΡΠΈ ΡΠ°ΠΊ, ΠΊΠ°ΠΊ Π½Π°Π·ΡΠ²Π°Π΅ΡΡΡ Π½Π°Ρ ΠΊΠ»Π°ΡΡ β HelloWorld. Π’Π°ΠΊ ΠΆΠ΅ Π²Π°ΠΆΠ½ΠΎ ΡΡΠΈΡΡΠ²Π°ΡΡ ΡΠ΅Π³ΠΈΡΡΡ Π±ΡΠΊΠ². HelloWorld ΠΈ helloworld Π² Π΄Π°Π½Π½ΠΎΠΌ ΡΠ»ΡΡΠ°Π΅ ΡΡΠΎ ΡΠ°Π·Π½ΡΠ΅ ΡΠ»ΠΎΠ²Π°!
ΠΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΡ ΠΈΡΡ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΡΠ°ΠΉΠ»Π°
ΠΡΡ ΠΎΠ΄Π½ΡΠΉ ΡΠ°ΠΉΠ» Ρ ΠΊΠΎΠ΄ΠΎΠΌ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ ΡΠΎΠ·Π΄Π°Π½, ΡΠ΅ΠΏΠ΅ΡΡ ΠΏΠ΅ΡΠ΅ΠΉΠ΄Π΅ΠΌ ΠΊ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ. ΠΠ»Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ Java ΠΏΡΠ΅Π΄Π½Π°Π·Π½Π°ΡΠ΅Π½ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡ javac, ΠΊΠΎΡΠΎΡΡΠΉ Π²Ρ ΠΎΠ΄ΠΈΡ Π² ΡΠΎΡΡΠ°Π² ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½Π½ΠΎΠ³ΠΎ Π½Π°ΠΌΠΈ Π² ΠΏΠ΅ΡΠ²ΠΎΠΌ ΡΡΠΎΠΊΠ΅ ΠΏΠ°ΠΊΠ΅ΡΠ° JDK.
ΠΠ»Ρ ΡΠΎΠ³ΠΎ, ΡΡΠΎΠ±Ρ ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡ ΠΈΡΡ ΠΎΠ΄Π½ΡΠΉ ΡΠ°ΠΉΠ», ΠΎΡΠΊΡΡΠ²Π°Π΅ΠΌ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΡΡ ΡΡΡΠΎΠΊΡ. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ Π² ΠΌΠ΅Π½Ρ Windows ΠΡΡΠΊ Π² ΡΡΡΠΎΠΊΠ΅ ΠΏΠΎΠΈΡΠΊΠ° Π²Π²ΠΎΠ΄ΠΈΠΌ ΠΊΠΎΠΌΠ°Π½Π΄Ρ cmd ΠΈ ΠΆΠΌΠ΅ΠΌ Enter. ΠΠΎΡΠ»Π΅ ΡΡΠΎΠ³ΠΎ ΠΎΡΠΊΡΠΎΠ΅ΡΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠ΅ ΠΎΠΊΠ½ΠΎ.
Π’Π΅ΠΏΠ΅ΡΡ Π² Π½Π΅ΠΌ Π½ΡΠΆΠ½ΠΎ ΠΈΠ·ΠΌΠ΅Π½ΠΈΡΡ ΡΠ΅ΠΊΡΡΠΈΠΉ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ Π½Π° ΡΠΎΡ, Π² ΠΊΠΎΡΠΎΡΠΎΠΌ Π½Π°Ρ ΠΎΠ΄ΠΈΡΡΡ Π½Π°Ρ ΠΈΡΡ ΠΎΠ΄Π½ΡΠΉ ΡΠ°ΠΉΠ» (Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ C:\studyjava\). ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ Π²Π²ΠΎΠ΄ΠΈΠΌ ΡΠ»Π΅Π΄ΡΡΡΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ:
ΠΠΎΡΠ»Π΅ ΡΠΎΠ³ΠΎ, ΠΊΠ°ΠΊ Π΄ΠΈΡΠ΅ΠΊΡΠΎΡΠΈΡ ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»Π°ΡΡ, Π²Π²ΠΎΠ΄ΠΈΠΌ ΠΊΠΎΠΌΠ°Π½Π΄Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ
ΠΠΎΡΠ»Π΅ ΡΡΠΎΠ³ΠΎ, ΠΎΠΊΠ½ΠΎ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠΈ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π²ΡΠ³Π»ΡΠ΄Π΅ΡΡ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ (ΡΠΈΡ 2.2):
Π’ΠΎ Π΅ΡΡΡ, ΠΌΡ Π½Π΅ ΠΏΠΎΠ»ΡΡΠΈΠΌ Π½ΠΈΠΊΠ°ΠΊΠΎΠ³ΠΎ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠΆΠ΄Π΅Π½ΠΈΡ, ΠΎ ΡΠΎΠΌ, ΡΡΠΎ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°Π»Π°ΡΡ ΡΡΠΏΠ΅ΡΠ½ΠΎ. ΠΠ΄Π½Π°ΠΊΠΎ, Π² ΠΏΠ°ΠΏΠΊΠ΅ Ρ Π½Π°ΡΠΈΠΌ ΠΈΡΡ ΠΎΠ΄Π½ΡΠΌ ΡΠ°ΠΉΠ»ΠΎΠΌ, Π΄ΠΎΠ»ΠΆΠ΅Π½ ΠΏΠΎΡΠ²ΠΈΡΡΡΡ ΡΠ°ΠΉΠ» HelloWorld.class. ΠΡΠΎ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ
ΠΡΠ° ΠΊΠΎΠΌΠ°Π½Π΄Π° Π²ΡΠ²ΠΎΠ΄ΠΈΡ Π½Π° ΡΠΊΡΠ°Π½ ΡΠΏΠΈΡΠΎΠΊ Π²ΡΠ΅Ρ ΡΠ°ΠΉΠ»ΠΎΠ², Π½Π°Ρ ΠΎΠ΄ΡΡΠΈΡ ΡΡ Π² Π²ΡΠ±ΡΠ°Π½Π½ΠΎΠΉ Π΄ΠΈΡΠ΅ΠΊΡΠΎΡΠΈΠΈ (ΡΠΈΡ 2.3).
ΠΡΠ»ΠΈ ΡΠ°ΠΉΠ» HelloWorld.class ΠΏΡΠΈΡΡΡΡΡΠ²ΡΠ΅Ρ Π² ΡΡΠΎΠΌ ΡΠΏΠΈΡΠΊΠ΅, ΡΠΎ ΡΡΠΎ Π·Π½Π°ΡΠΈΡ, ΡΡΠΎ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°Π»Π°ΡΡ ΡΡΠΏΠ΅ΡΠ½ΠΎ.
ΠΡΠ»ΠΈ Π² ΠΊΠΎΠ΄Π΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π΅ΡΡΡ ΠΎΡΠΈΠ±ΠΊΠ°, ΡΠΎ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡ Java ΠΏΡΠΈ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ Π½Π°ΠΌ ΠΎΠ± ΡΡΠΎΠΌ ΡΠΎΠΎΠ±ΡΠΈΡ.
ΠΡΠΎΠ²Π΅Π΄Π΅ΠΌ ΡΠΊΡΠΏΠ΅ΡΠΈΠΌΠ΅Π½Ρ: ΠΡΠΊΡΠΎΠ΅ΠΌ Π² ΡΠ΅ΠΊΡΡΠΎΠ²ΠΎΠΌ ΡΠ΅Π΄Π°ΠΊΡΠΎΡΠ΅ Π½Π°Ρ ΡΠ°ΠΉΠ» HelloWorld.java ΠΈ ΡΠ΄Π°Π»ΠΈΠΌ ΠΏΠΎΡΠ»Π΅Π΄Π½ΡΡ Π·Π°ΠΊΡΡΠ²Π°ΡΡΡΡΡΡ ΡΠΈΠ³ΡΡΠ½ΡΡ ΡΠΊΠΎΠ±ΠΊΡ Β«>Β». Π‘ΠΎΡ ΡΠ°Π½ΠΈΠΌ ΡΠ°ΠΉΠ» ΠΈ ΠΏΠΎΠΏΡΠΎΠ±ΡΠ΅ΠΌ Π΅Π³ΠΎ Π΅ΡΠ΅ ΡΠ°Π· ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡ. Π ΠΈΡΠΎΠ³Π΅ ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ ΠΎΠ± ΠΎΡΠΈΠ±ΠΊΠ΅ (ΡΠΈΡ 2.4).
Π§ΡΠΎΠ±Ρ ΠΈΡΠΏΡΠ°Π²ΠΈΡΡ ΠΎΡΠΈΠ±ΠΊΡ, Π½ΡΠΆΠ½ΠΎ Π²Π½ΠΎΠ²Ρ ΠΎΡΠΊΡΡΡΡ ΡΠ°ΠΉΠ» Π΄Π»Ρ ΡΠ΅Π΄Π°ΠΊΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ, ΡΡΡΡΠ°Π½ΠΈΡΡ ΠΎΡΠΈΠ±ΠΊΡ, ΡΠΎΡ ΡΠ°Π½ΠΈΡΡ ΡΠ°ΠΉΠ» ΠΈ Π΅ΡΠ΅ ΡΠ°Π· Π΅Π³ΠΎ ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡ.
ΠΠ°ΠΏΡΡΠΊ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ
ΠΠ΅ΡΠ΅Ρ ΠΎΠ΄ΠΈΠΌ ΠΊ ΠΏΠΎΡΠ»Π΅Π΄Π½Π΅ΠΉ ΡΡΠ°Π΄ΠΈΠΈ β Π·Π°ΠΏΡΡΠΊΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ.
ΠΠ²ΠΎΠ΄ΠΈΠΌ Π² ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΌ ΠΎΠΊΠ½Π΅:
ΠΈ Π΅ΡΠ»ΠΈ Π²ΡΠ΅ ΠΏΠ΅ΡΠ΅Π΄ ΡΡΠΈΠΌ Π±ΡΠ»ΠΎ ΡΠ΄Π΅Π»Π°Π½ΠΎ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎ, ΡΠΎ ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ β Π²ΡΠ²ΠΎΠ΄ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΡ Β«Hello World!Β» (ΡΠΈΡ 2.5).
ΠΡΠ΅ ΡΠ°Π· ΠΎΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅ Π½Π° ΡΡΠ²ΡΡΠ²ΠΈΡΠ΅Π»ΡΠ½ΠΎΡΡΡ ΠΊ ΡΠ΅Π³ΠΈΡΡΡΡ Π² Java. ΠΡΠ»ΠΈ Π²Ρ Π½Π°ΠΏΠΈΡΠ΅ΡΠ΅ helloworld Π²ΠΌΠ΅ΡΡΠΎ HelloWorld, ΡΠΎ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° Π·Π°ΠΏΡΡΠ΅Π½Π° Π½Π΅ Π±ΡΠ΄Π΅Ρ, ΠΏΠΎΡΠΎΠΌΡ ΡΡΠΎ Java ΠΏΠΎΠΏΡΠΎΡΡΡ Π½Π΅ Π½Π°ΠΉΠ΄Π΅Ρ ΡΠ°ΠΉΠ» Ρ ΡΠ°ΠΊΠΈΠΌ ΠΈΠΌΠ΅Π½Π΅ΠΌ.
Π ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ Π΄ΠΎΠΌΠ°ΡΠ½Π΅Π³ΠΎ Π·Π°Π΄Π°Π½ΠΈΡ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΠΏΠΎΡΠΊΡΠΏΠ΅ΡΠΈΠΌΠ΅Π½ΡΠΈΡΠΎΠ²Π°ΡΡ ΠΈ Π²ΡΠ²ΠΎΠ΄ΠΈΡΡ Π½Π° ΡΠΊΡΠ°Π½ ΠΊΠ°ΠΊΠΎΠ΅-Π»ΠΈΠ±ΠΎ ΡΠ²ΠΎΠ΅ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ Π²ΠΌΠ΅ΡΡΠΎ Hello World!.
Getting Started with Java IDL
This is possible because Java IDL is based on the Common Object Request Brokerage Architecture (CORBA), an industry-standard distributed object model. A key feature of CORBA is IDL, a language-neutral Interface Definition Language. Each language that supports CORBA has its own IDL mapping—and as its name implies, Java IDL supports the mapping for Java. To learn more about the IDL-to-Java language mapping, see IDL-to-Java Language Mapping.
To support interaction between objects in separate programs, Java IDL provides an Object Request Broker, or ORB. The ORB is a class library that enables low-level communication between Java IDL applications and other CORBA-compliant applications.
This tutorial teaches the basic tasks needed to build a CORBA distributed application using Java IDL. You will build the classic «Hello World» program as a distributed application. The Hello World program has a single operation that returns a string to be printed.
Any relationship between distributed objects has two sides: the client and the server. The server provides a remote interface, and the client calls a remote interface. These relationships are common to most distributed object standards, including Java Remote Method Invocation (RMI, RMI-IIOP) and CORBA. Note that in this context, the terms client and server define object-level rather than application-level interaction—any application could be a server for some objects and a client of others. In fact, a single object could be the client of an interface provided by a remote object and at the same time implement an interface to be called remotely by other objects.
This figure shows how a one-method distributed object is shared between a CORBA client and server to implement the classic «Hello World» application.
A one-method distributed object shared between a CORBA client and server.
On the client side, the application includes a reference for the remote object. The object reference has a stub method, which is a stand-in for the method being called remotely. The stub is actually wired into the ORB, so that calling it invokes the ORB’s connection capabilities, which forwards the invocation to the server.
On the server side, the ORB uses skeleton code to translate the remote invocation into a method call on the local object. The skeleton translates the call and any parameters to their implementation-specific format and calls the method being invoked. When the method returns, the skeleton code transforms results or errors, and sends them back to the client via the ORBs.
Between the ORBs, communication proceeds by means of a shared protocol, IIOP—the Internet Inter-ORB Protocol. IIOP, which is based on the standard TCP/IP internet protocol, defines how CORBA-compliant ORBs pass information back and forth. Like CORBA and IDL, the IIOP standard is defined by OMG, the Object Management Group.
The Java IDL Development Process and the Hello World Tutorial
Despite its simple design, the Hello World program lets you learn and experiment with all the tasks required to develop almost any CORBA program that uses static invocation. The following steps provide a general guide to designing and developing a distributed object application with Java IDL. Links to the relevant steps of the tutorial will guide you through creating this sample application.
You define the interface for the remote object using the OMG’s Interface Definition Langauge (IDL). You use IDL instead of the Java language because the idlj compiler automatically maps from IDL, generating all Java language stub and skeleton source files, along with the infrastructure code for connecting to the ORB. Also, by using IDL, you make it possible for developers to implement clients and servers in any other CORBA-compliant language.
Note that if you’re implementing a client for an existing CORBA service, or a server for an existing client, you would get the IDL interfaces from the implementer—such as a service provider or vendor. You would then run the idlj compiler over those interfaces and follow these steps.
Writing the IDL file in this tutorial walks you through defining the remote interface for the simple «Hello World» example.
When you run the idlj compiler over your interface definition file, it generates the Java version of the interface, as well as the class code files for the stubs and skeletons that enable your applications to hook into the ORB.
Mapping Hello.idl to Java in this tutorial walks you through these steps for the simple «Hello World» example.
Once you run the idlj compiler, you can use the skeletons it generates to put together your server application. In addition to implementing the methods of the remote interface, your server code includes a mechanism to start the ORB and wait for invocation from a remote client.
Developing the Hello World Server walks you through writing a simple server for the «Hello World» application.
Similarly, you use the stubs generated by the idlj compiler as the basis of your client application. The client code builds on the stubs to start its ORB, look up the server using the name service provided with Java IDL, obtain a reference for the remote object, and call its method.
Developing a Client Application walks you through writing a simple client application.
Once you implement a server and a client, you can start the name service, then start the server, then run the client.
Running the Hello World Application walks you through running the server and client program that together make up the «Hello World» application, and the name service that enables them to find one another.
Using Stringified Object References walks you through making an object reference when there is no naming service.
For More Information
Although concepts are explained as they are introduced in the tutorial, you will find more information in the Concepts section. New terms are linked to their definitions throughout the tutorial.
The Object Management Group no longer maintains this site, but the CORBA for Beginnners page contains links to web pages that provide introductory CORBA information.
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΈ Π·Π°ΠΏΡΡΠΊ ΠΏΠ΅ΡΠ²ΠΎΠ³ΠΎ Java-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ (ΡΠ°ΡΡΡ 1)
ΠΠ΅ΡΠ΅Π΄ Π½Π°ΡΠ°Π»ΠΎΠΌ ΡΠ°Π±ΠΎΡΡ
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΏΡΠΎΠ΅ΠΊΡΠ°
ΠΡΠ»ΠΈ Π½ΠΈ ΠΎΠ΄ΠΈΠ½ ΠΏΡΠΎΠ΅ΠΊΡ Π² Π΄Π°Π½Π½ΡΠΉ ΠΌΠΎΠΌΠ΅Π½Ρ Π½Π΅ ΠΎΡΠΊΡΡΡ, Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ½ΠΎΠΏΠΊΡ Create New Project Π½Π° ΡΠΊΡΠ°Π½Π΅ ΠΏΡΠΈΠ²Π΅ΡΡΡΠ²ΠΈΡ. Π ΠΏΡΠΎΡΠΈΠ²Π½ΠΎΠΌ ΡΠ»ΡΡΠ°Π΅, Π²ΡΠ±Π΅ΡΠΈΡΠ΅ ΠΏΡΠ½ΠΊΡ New Project Π² ΠΌΠ΅Π½Ρ File. Π ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠ΅ ΠΎΡΠΊΡΠΎΠ΅ΡΡΡ ΠΌΠ°ΡΡΠ΅Ρ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΠΏΡΠΎΠ΅ΠΊΡΠ°.
Π Π»Π΅Π²ΠΎΠΉ ΠΏΠ°Π½Π΅Π»ΠΈ Π²ΡΠ±Π΅ΡΠΈΡΠ΅ Java Module.
Π ΠΏΡΠ°Π²ΠΎΠΉ ΡΠ°ΡΡΠΈ ΡΡΡΠ°Π½ΠΈΡΡ, Π² ΠΏΠΎΠ»Π΅ Project name, Π²Π²Π΅Π΄ΠΈΡΠ΅ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΏΡΠΎΠ΅ΠΊΡΠ°: HelloWorld.
ΠΡΠ»ΠΈ Π΄ΠΎ ΡΡΠΎΠ³ΠΎ Π²Ρ Π½ΠΈΠΊΠΎΠ³Π΄Π° Π½Π΅ Π½Π°ΡΡΡΠ°ΠΈΠ²Π°Π»ΠΈ JDK Π² IntelliJ IDEA Π² (Π² ΡΠ°ΠΊΠΎΠΌ ΡΠ»ΡΡΠ°Π΅ Π² ΠΏΠΎΠ»Π΅ Project SDK ΡΡΠΎΠΈΡ ), Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎ ΡΠ΄Π΅Π»Π°ΡΡ ΡΡΠΎ ΡΠ΅ΠΉΡΠ°Ρ.
ΠΠΌΠ΅ΡΡΠΎ Π½Π°ΠΆΠΌΠΈΡΠ΅ New ΠΈ Π² ΠΏΠΎΠ΄ΠΌΠ΅Π½Ρ Π²ΡΠ±Π΅ΡΠΈΡΠ΅ JDK.
Π ΠΎΠΊΠ½Π΅ Select Home Directory for JDK Π²ΡΠ±Π΅ΡΠΈΡΠ΅ Π΄ΠΈΡΠ΅ΠΊΡΠΎΡΠΈΡ, Π² ΠΊΠΎΡΠΎΡΡΡ ΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π»ΠΎΡΡ JDK ΠΈ Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΠ.
ΠΠ΅ΡΡΠΈΡ JDK, ΠΊΠΎΡΠΎΡΡΡ Π²Ρ Π²ΡΠ±ΡΠ°Π»ΠΈ, ΠΏΠΎΡΠ²ΠΈΡΡΡ Π² ΠΏΠΎΠ»Π΅ Project SDK.
ΠΠ»ΠΈΠΊΠ½ΠΈΡΠ΅ Next.
Π£ΡΡΠΈΡΠ΅, ΡΡΠΎ ΡΠΊΠ°Π·Π°Π½Π½Π°Ρ Π²Π΅ΡΡΠΈΡ JDK Π±ΡΠ΄Π΅Ρ ΡΠ²ΡΠ·Π°Π½Π° ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ ΡΠΎ Π²ΡΠ΅ΠΌΠΈ ΠΏΡΠΎΠ΅ΠΊΡΠ°ΠΌΠΈ ΠΈ Java ΠΌΠΎΠ΄ΡΠ»ΡΠΌΠΈ, ΠΊΠΎΡΠΎΡΡΠ΅ Π² Π΄Π°Π»ΡΠ½Π΅ΠΉΡΠ΅ΠΌ Π±ΡΠ΄ΡΡ ΡΠΎΠ·Π΄Π°Π²Π°ΡΡΡΡ.
ΠΠ° ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΉ ΡΡΡΠ°Π½ΠΈΡΠ΅ ΠΎΡΡΡΠ΅ΡΡΠ²Π»ΡΠ΅ΡΡΡ Π²ΡΠ±ΠΎΡ ΠΌΠ°ΡΡΠ΅ΡΠ° Π΄Π»Ρ ΡΠΊΠ°Π·Π°Π½ΠΈΡ Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΡ ΡΠ΅Ρ Π½ΠΎΠ»ΠΎΠ³ΠΈΠΉ, ΠΊΠΎΡΠΎΡΡΠ΅ Π±ΡΠ΄ΡΡ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°ΡΡΡΡ Π² Π½Π°ΡΠ΅ΠΌ ΠΌΠΎΠ΄ΡΠ»Π΅.
ΠΠΎΡΠΊΠΎΠ»ΡΠΊΡ Π½Π°ΡΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π±ΡΠ΄Π΅Ρ «ΡΡΠ°ΡΡΠΌ Π΄ΠΎΠ±ΡΡΠΌ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ΠΌ Java», ΠΌΡ Π½Π΅ Π½ΡΠΆΠ΄Π°Π΅ΠΌΡΡ Π² Π»ΡΠ±ΠΎΠΉ ΠΈΠ· ΡΡΠΈΡ ΡΠ΅Ρ Π½ΠΎΠ»ΠΎΠ³ΠΈΠΉ. Π’Π°ΠΊ ΡΡΠΎ ΠΏΡΠΎΡΡΠΎ Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ½ΠΎΠΏΠΊΡ Finish.
ΠΠΎΠ΄ΠΎΠΆΠ΄ΠΈΡΠ΅, ΠΏΠΎΠΊΠ° IntelliJ IDEA ΡΠΎΠ·Π΄Π°Π΅Ρ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΡΠ΅ ΡΡΡΡΠΊΡΡΡΡ ΠΏΡΠΎΠ΅ΠΊΡΠ°. ΠΠΎΠ³Π΄Π° ΡΡΠΎΡ ΠΏΡΠΎΡΠ΅ΡΡ Π·Π°Π²Π΅ΡΡΠΈΡΡΡ, Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΡΠ²ΠΈΠ΄Π΅ΡΡ ΡΡΡΡΠΊΡΡΡΡ ΠΠ°ΡΠ΅Π³ΠΎ Π½ΠΎΠ²ΠΎΠ³ΠΎ ΠΏΡΠΎΠ΅ΠΊΡΠ° Π² ΠΎΠΊΠ½Π΅ Project.
ΠΠ·ΡΡΠ΅Π½ΠΈΠ΅ ΡΡΡΡΠΊΡΡΡΡ ΠΏΡΠΎΠ΅ΠΊΡΠ°
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΏΠ°ΠΊΠ΅ΡΠ°
Π ΠΌΠ΅Π½Ρ New Π²ΡΠ±Π΅ΡΠΈΡΠ΅ Package. (ΠΌΠΎΠΆΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΡΡΡΠ΅Π»ΠΊΠΈ Π²Π²Π΅ΡΡ ΠΈ Π²Π½ΠΈΠ· Π΄Π»Ρ Π½Π°Π²ΠΈΠ³Π°ΡΠΈΠΈ ΠΏΠΎ ΠΌΠ΅Π½Ρ, ENTER Π΄Π»Ρ Π²ΡΠ±ΠΎΡΠ° Π²ΡΠ΄Π΅Π»Π΅Π½Π½ΠΎΠ³ΠΎ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ°)
Π ΠΎΡΠΊΡΡΠ²ΡΠ΅ΠΌΡΡ ΠΎΠΊΠ½Π΅ New Package Π²Π²Π΅Π΄ΠΈΡΠ΅ ΠΈΠΌΡ ΠΏΠ°ΠΊΠ΅ΡΠ° (com.example.helloworld). ΠΠ°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ½ΠΎΠΏΠΊΡ ΠΠ (ΠΈΠ»ΠΈ ΠΊΠ»Π°Π²ΠΈΡΡ ENTER).
ΠΠΎΠ²ΡΠΉ ΠΏΠ°ΠΊΠ΅Ρ ΠΏΠΎΡΠ²ΠΈΡΡΡ ΠΎΠΊΠ½Π΅ Project.
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΊΠ»Π°ΡΡΠ°
ΠΠ°ΠΆΠΌΠΈΡΠ΅ ALT + INSERT. Π ΠΎΠΊΠ½Π΅ New ΠΈΠ· ΡΠΏΠΈΡΠΊΠ° Π΄ΠΎΡΡΡΠΏΠ½ΡΡ Π΄Π΅ΠΉΡΡΠ²ΠΈΠΉ Ρ Π²ΡΠ΄Π΅Π»Π΅Π½Π½ΡΠΌ ΠΏΠ°ΠΊΠ΅ΡΠΎΠΌ com.example.helloworld Π²ΡΠ±ΠΈΡΠ°Π΅ΠΌ Java Class ΠΈ Π½Π°ΠΆΠΈΠΌΠ°Π΅ΠΌ Enter.
Π ΠΏΠΎΡΠ²ΠΈΠ²ΡΠ΅ΠΌΡΡ ΠΎΠΊΠ½Π΅ Create New Class Π² ΠΏΠΎΠ»Π΅ Name Π²Π²ΠΎΠ΄ΠΈΠΌ ΠΈΠΌΡ HelloWorld. Π ΠΏΠΎΠ»Π΅ Kind ΠΎΡΡΠ°Π²Π»ΡΠ΅ΠΌ ΡΠΈΠΏ Class ΠΈ Π½Π°ΠΆΠΈΠΌΠ°Π΅ΠΌ Enter, ΡΡΠΎΠ±Ρ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠ΄ΠΈΡΡ ΡΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΊΠ»Π°ΡΡΠ°.
Π‘ΠΎΠ·Π΄Π°Π½Π½ΡΠΉ ΠΊΠ»Π°ΡΡ HelloWorld ΠΏΠΎΡΠ²Π»ΡΠ΅ΡΡΡ Π² ΡΡΡΡΠΊΡΡΡΠ΅ ΠΏΡΠΎΠ΅ΠΊΡΠ°:
ΠΠ° ΡΡΠΎΠΌ Π²ΡΠ΅ ΠΏΡΠΈΠ³ΠΎΡΠΎΠ²Π»Π΅Π½ΠΈΡ Π·Π°ΠΊΠΎΠ½ΡΠ΅Π½Ρ. Π‘Π°ΠΌ ΠΏΡΠΎΡΠ΅ΡΡ Π½Π°ΠΏΠΈΡΠ°Π½ΠΈΡ Π½Π°ΡΠ΅Π³ΠΎ ΠΏΠ΅ΡΠ²ΠΎΠ³ΠΎ ΠΊΠΎΠ΄Π° Π±ΡΠ΄Π΅Ρ ΡΠ°Π·ΠΎΠ±ΡΠ°Π½ Π²ΠΎ Π²ΡΠΎΡΠΎΠΉ ΡΠ°ΡΡΠΈ ΡΡΠ°ΡΡΠΈ.
ΠΠΈΡΠ΅ΠΌ Hello World Π½Π° Java
Java β ΡΠ°ΠΌΠ°Ρ ΠΏΠΎΠΏΡΠ»ΡΡΠ½Π°Ρ ΠΏΠ»Π°ΡΡΠΎΡΠΌΠ° Π΄Π»Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π² ΠΌΠΈΡΠ΅. ΠΠ° ΡΡΠΎΠΌ ΡΠ·ΡΠΊΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ ΡΠ°Π±ΠΎΡΠ°Π΅Ρ Π±ΠΎΠ»Π΅Π΅ 3 Π±ΠΈΠ»ΠΈΠΎΠ½ΠΎΠ² ΡΡΡΡΠΎΠΉΡΡΠ²! ΠΠΎΠ½Π΅ΡΠ½ΠΎ ΠΆΠ΅, ΡΠ°ΠΌΠ°Ρ ΠΏΠΎΠΏΡΠ»ΡΡΠ½Π°Ρ ΠΏΠ»Π°ΡΡΠΎΡΠΌΠ° β Androi, Π΄ΡΡΠ³ΠΈΠ΅ ΡΠ·ΡΠΊΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π·Π΄Π΅ΡΡ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°ΡΡΡΡ Ρ ΡΡΡΠ΄ΠΎΠΌ. ΠΡΠΎΠΌΠ΅ Android-ΡΡΡΡΠΎΠΉΡΡΠ², Π½Π° Java ΡΠ°Π±ΠΎΡΠ°ΡΡ Π½Π°ΡΡΠΎΠ»ΡΠ½ΡΠ΅ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΡ, ΠΊΠ½ΠΎΠΏΠΎΡΠ½ΡΠ΅ ΡΠ΅Π»Π΅ΡΠΎΠ½Ρ (ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½Π°Ρ ΡΠΈΡΡΠ΅ΠΌΠ° Symbian), Π° ΡΠ°ΠΊΠΆΠ΅ Π΄ΡΡΠ³ΠΈΠ΅ ΡΡΡΡΠΎΠΉΡΡΠ²Π°: Blu-Ray ΠΏΠ»Π΅Π΅ΡΡ, ΡΠ΅Π»Π΅Π²ΠΈΠ·ΠΎΡΡ, ΠΏΡΠΈΡΡΠ°Π²ΠΊΠΈβ¦ Π’Π°ΠΊ ΡΡΠΎ Java β ΡΠ·ΡΠΊ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ, ΠΊΠΎΡΠΎΡΡΠΉ ΠΏΠΎΠ΄ΠΎΠΉΠ΄Π΅Ρ Π΄Π»Ρ ΠΏΠΎΡΡΠΈ Π²ΡΠ΅Ρ ΡΡΡΡΠΎΠΉΡΡΠ².
Π‘Π΅ΠΉΡΠ°Ρ ΠΈΠ΄Π΅Ρ Π°ΠΊΡΠΈΠ²Π½Π°Ρ Π±ΠΎΡΡΠ±Π° ΠΌΠ΅ΠΆΠ΄Ρ Java ΠΈ C++, ΠΎΠ΄Π½Π°ΠΊΠΎ ΠΊΠ°ΠΊΠΎΠΉ ΡΠ·ΡΠΊ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ β Π²ΡΠ±ΠΈΡΠ°ΡΡ Π²Π°ΠΌ. ΠΠ°ΡΠ½Π΅ΠΌ!
ΠΠ΅ΡΠ²ΡΠΉ ΠΊΠΎΠ΄ Π½Π° Java
Π§ΡΠΎΠ±Ρ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ Π΅Π³ΠΎ, Π½Π°Π΄ΠΎ ΠΏΠ΅ΡΠ΅ΠΉΡΠΈ ΠΏΠΎ Π°Π΄ΡΠ΅ΡΡ ideone.com ΠΈ Π²ΡΡΠ°Π²ΠΈΡΡ ΠΊΠΎΠ΄ Π² ΡΠ΅ΠΊΡΡΠΎΠ²ΠΎΠ΅ ΠΏΠΎΠ»Π΅. ΠΡΠΈ ΠΊΠ»ΠΈΠΊΠ΅ ΠΏΠΎ ΠΊΠ½ΠΎΠΏΠΊΠ΅ βRunβ Π² ΠΏΠΎΠ΄Π΅ βstdoutβ Π²ΡΠ²Π΅Π΄Π΅ΡΡΡ ΡΠ΅ΠΊΡΡ, ΠΊΠΎΡΠΎΡΡΠΉ ΠΌΡ Ρ ΠΎΡΠ΅Π»ΠΈ Π²ΡΠ²Π΅ΡΡΠΈ. Π£ΡΠ°! Π’Π΅ΠΏΠ΅ΡΡ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΠΌΠ΅Π½ΡΡΡ ΡΠ΅ΠΊΡΡ Π² ΠΊΠ°Π²ΡΡΠΊΠ°Ρ Π½Π° ΡΠ²ΠΎΠΉ.
ΠΠ°ΠΆΠ½ΠΎ! ΠΠΎΠΊΠ° ΡΡΠΎ ΠΌΠΎΠΆΠ½ΠΎ Π²ΡΠ²Π΅ΡΡΠΈ ΡΠΎΠ»ΡΠΊΠΎ Π»Π°ΡΠΈΠ½ΠΈΡΡ, Π΄Π»Ρ ΠΊΠΈΡΠΈΠ»Π»ΠΈΡΡ ΠΏΠΎΠ½Π°Π΄ΠΎΠ±ΡΡΡΡ Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠ΅ ΡΡΠ½ΠΊΡΠΈΠΈ!
Π’Π°ΠΊΠΆΠ΅ ΠΊΠΎΠ΄ Π΄ΠΎΡΡΡΠΏΠ΅Π½ ΠΏΠΎ ΡΡΠΎΠΉ ΡΡΡΠ»ΠΊΠ΅.
Π Π°Π·Π±ΠΎΡ ΠΊΠΎΠ΄Π°
Π ΠΊΠΎΠ΄Π΅ ΠΊΠ°ΠΆΠ΄Π°Ρ ΡΡΡΠΎΠΊΠ° ΡΡΠΎ-Π½ΠΈΠ±ΡΠ΄Ρ Π΄Π° ΠΎΠ·Π½Π°ΡΠ°Π΅Ρ. ΠΠ°Π²Π°ΠΉΡΠ΅ ΡΠ°Π·Π±Π΅ΡΠ΅ΠΌΡΡ, ΡΡΠΎ ΠΈΠΌΠ΅Π½Π½ΠΎ!
ΠΡΠΎ β ΠΊΠ»Π°ΡΡ. ΠΠ»Π°ΡΡ β ΡΡΠΎ ΡΠ°ΡΡΡ ΠΊΠΎΠ΄Π°, ΠΎΡΠ²Π΅ΡΠ°ΡΡΠ°Ρ Π·Π° ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Π½ΡΡ Π·Π°Π΄Π°ΡΡ, ΠΊΠΎΡΠΎΡΠ°Ρ, Π² ΡΠ²ΠΎΡ ΠΎΡΠ΅ΡΠ΅Π΄Ρ, ΡΠΎΡΡΠΎΠΈΡ ΠΈΠ· ΠΏΠΎΠ΄Π·Π°Π΄Π°Ρ β ΡΡΠ½ΠΊΡΠΈΠΉ. Π ΠΊΠ»Π°ΡΡΠΎΠ², ΠΈ ΡΡΠ½ΠΊΡΠΈΠΉ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΌΠ½ΠΎΠ³ΠΎ, Π° ΠΌΠΎΠΆΠ΅Ρ ΠΈ ΠΌΠ°Π»ΠΎ β Π²ΡΠ΅ Π·Π°Π²ΠΈΡΠΈΡ ΠΎΡ ΠΌΠ°ΡΡΡΠ°Π±ΠΎΠ² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ. Π‘Π΅ΠΉΡΠ°Ρ ΠΊΠ»Π°ΡΡ ΠΎΠ΄ΠΈΠ½, Π½ΠΎ Π΅ΡΠ»ΠΈ ΠΈΡ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ, ΡΠΎ Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±ΡΡΡ Π³Π»Π°Π²Π½ΡΠΉ ΠΊΠ»Π°ΡΡ β ΠΏΠ΅ΡΠ΅Π΄ Π½ΠΈΠΌ ΡΡΠ°Π²ΠΈΡΡΡ ΠΊΠ»ΡΡΠ΅Π²ΠΎΠ΅ ΡΠ»ΠΎΠ²ΠΎ public.
public static void main (String[] args) throws java.lang.Exception
ΠΡΠΎ β Π³Π»Π°Π²Π½Π°Ρ ΡΡΠ½ΠΊΡΠΈΡ ΠΊΠ»Π°ΡΡΠ°. ΠΠ½Π° Π·Π°ΠΏΡΡΠΊΠ°Π΅ΡΡΡ ΠΏΠ΅ΡΠ²ΠΎΠΉ. Π€ΡΠ½ΠΊΡΠΈΠΉ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΌΠ½ΠΎΠ³ΠΎ, Π½ΠΎ main () Π΄ΠΎΠ»ΠΆΠ½Π° ΠΏΡΠΈΡΡΡΡΡΠ²ΠΎΠ²Π°ΡΡ Π²ΡΠ΅Π³Π΄Π°. Π ΡΠΊΠΎΠ±ΠΊΠ°Ρ ΡΠΊΠ°Π·Π°Π½Ρ Π°ΡΠ³ΡΠΌΠ΅Π½ΡΡ β ΠΈΠ½ΡΡΡΡΠΊΡΠΈΠΈ ΡΡΠ½ΠΊΡΠΈΠΈ, Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΊΠΎΡΠΎΡΡΡ ΠΎΠ½Π° ΠΏΠΎΠ½ΠΈΠΌΠ°Π΅Ρ, ΠΊΠ°ΠΊΠΈΠ΅ Π΄Π°Π½Π½ΡΠ΅ Π΅ΠΉ Π½ΡΠΆΠ½ΠΎ ΠΏΡΠΈΠ½ΠΈΠΌΠ°ΡΡ, ΠΈ ΠΏΡΠΈΠ½ΠΈΠΌΠ°Π΅Ρ ΠΈΡ . ΠΠ΄Π΅ΡΡ ΡΡΠΎ Π°ΡΠ³ΡΠΌΠ΅Π½ΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠΈ, Ρ. Π΅. ΡΠΊΠ°Π·Π°Π½ΠΈΠ΅ Π½Π° ΡΡΠΈΡΡΠ²Π°Π½ΠΈΠ΅ Π΄Π°Π½Π½ΡΡ Ρ ΠΊΠ»Π°Π²ΠΈΠ°ΡΡΡΡ. ΠΠΎΡΠ»Π΅ Π°ΡΠ³ΡΠΌΠ΅Π½ΡΠΎΠ² ΡΠΊΠ°Π·Π°Π½ΠΎ ΠΊΠ»ΡΡΠ΅Π²ΠΎΠ΅ ΡΠ»ΠΎΠ²ΠΎ throws Ρ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ΠΌ β ΠΎΠ½ΠΎ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ΅ Π·Π°Π²Π΅ΡΡΠΈΡΡΡΡ Π±Π΅Π· ΡΠ°ΡΠ°Π»ΡΠ½ΡΡ Π΄Π»Ρ ΡΠΈΡΡΠ΅ΠΌΡ ΠΎΡΠΈΠ±ΠΎΠΊ ΠΏΡΠΈ Π²ΠΎΠ·Π½ΠΈΠΊΠ½ΠΎΠ²Π΅Π½ΠΈΠΈ Π½Π΅ΠΏΠΎΠ»Π°Π΄ΠΎΠΊ Π² ΠΊΠΎΠ΄Π΅, Π·Π΄Π΅ΡΡ β ΡΠ·ΡΠΊΠΎΠ²ΡΡ .
System.out.println («Hello, World!»);
ΠΡΠΎ β ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡ Π²ΡΠ²ΠΎΠ΄Π°, ΡΠΎ Π΅ΡΡΡ ΠΈΠ½ΡΡΡΡΠΊΡΠΈΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ΅. ΠΠΏΠ΅ΡΠ°ΡΠΎΡ println Π²ΡΠ²ΠΎΠ΄ΠΈΡ Π·Π°Π΄Π°Π½Π½ΡΡ Π² ΡΠΊΠΎΠ±ΠΊΠ°Ρ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ β ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ ΠΈΠ»ΠΈ ΡΡΡΠΎΠΊΡ. ΠΠ΄Π΅ΡΡ ΡΡΠΎ ΡΡΡΠΎΠΊΠ°, ΠΏΠΎΡΡΠΎΠΌΡ ΠΎΠ½Π° ΡΠΊΠ°Π·Π°Π½Π° Π² ΠΊΠ°Π²ΡΡΠΊΠ°Ρ .
ΠΡΠΎ Π²Π΅ΡΡ ΠΊΠΎΠ΄. ΠΡ ΠΊΠ°ΠΊ, ΡΠ»ΠΎΠΆΠ½ΠΎ?
ΠΠ°ΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅
Java β ΡΠΎΠ²ΡΠ΅ΠΌΠ΅Π½Π½ΡΠΉ, Π±ΡΡΡΡΠΎ ΡΠ°Π·Π²ΠΈΠ²Π°ΡΡΠΈΠΉΡΡ ΡΠ·ΡΠΊ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ. ΠΡΠ±ΠΎΡ Π²ΡΠ΅ ΡΠ°Π²Π½ΠΎ ΡΡΠΎΠΈΡ Π·Π° Π²Π°ΠΌΠΈ, Π½ΠΎ Π·Π΄Π΅ΡΡ Π²ΡΠ΅ Π·Π°Π²ΠΈΡΠΈΡ ΠΎΡ ΠΏΡΠ΅Π΄ΠΏΠΎΡΡΠ΅Π½ΠΈΠΉ: Π΅ΡΠ»ΠΈ ΠΈΠ½ΡΠ΅ΡΠ΅ΡΡΡΡ ΠΌΠΎΠ±ΠΈΠ»ΡΠ½ΡΠ΅ ΠΏΠ»Π°ΡΡΠΎΡΠΌΡ ΠΈΠ»ΠΈ ΡΠ΅Ρ Π½ΠΈΠΊΠ°, ΡΠΎ ΡΠΎΠ³Π΄Π° Java, Π° Π΅ΡΠ»ΠΈ ΠΆΠ΅ Π½ΡΠΆΠ½ΠΎ ΠΏΠΈΡΠ°ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΏΠΎΠ΄ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΡ, ΠΈ Π²Π°ΠΆΠ½Π° ΡΠΊΠΎΡΠΎΡΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ β ΡΠΎΠ³Π΄Π°, Π½Π΅ΡΠΎΠΌΠ½Π΅Π½Π½ΠΎ, C++ ΠΈΠ»ΠΈ Python. Π£Π΄Π°ΡΠΈ Π²Π°ΠΌ!
Π‘ ΡΠ΅ΠΌ ΠΏΠΎΠ·Π½Π°ΠΊΠΎΠΌΠΈΠΌΡΡ:
ΠΠ°ΡΡΠ°Π»ΠΎ Π²ΡΠ΅ΠΌΡ Π½Π°ΠΏΠΈΡΠ°ΡΡ Π½Π°ΡΡ ΠΏΠ΅ΡΠ²ΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π½Π° Java. ΠΠΎ ΡΡΠ°Π΄ΠΈΡΠΈΠΈ ΡΡΠΎ Π±ΡΠ΄Π΅Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ°, ΠΊΠΎΡΠΎΡΠ°Ρ Π²ΡΠ²ΠΎΠ΄ΠΈΡ ΡΡΠ°Π·Ρ ΡΠΈΠΏΠ° «Hello World!» Π½Π° ΡΠΊΡΠ°Π½ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠ°. ΠΠ»Ρ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΡΠ°ΠΊΠΎΠΉ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ ΠΌΠΎΠΆΠ½ΠΎ Π²ΠΎΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ ΠΎΠ±ΡΡΠ½ΡΠΌ ΡΠ΅ΠΊΡΡΠΎΠ²ΡΠΌ ΡΠ΅Π΄Π°ΠΊΡΠΎΡΠΎΠΌ. Π ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½ΠΎΠΉ ΡΠΈΡΡΠ΅ΠΌΠ΅ Linux ΡΡΠΎ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ, Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ, ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° gedit (ΠΏΠΎΡΠΈΡΠ°ΡΡ ΠΎΠ± ΡΡΠΎΠΉ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ΅ ΠΌΠΎΠΆΠ½ΠΎ Π·Π΄Π΅ΡΡ). ΠΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»ΠΈ ΠΠ‘ Windows ΠΌΠΎΠ³ΡΡ Π²ΠΎΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ ΡΡΠ°Π½Π΄Π°ΡΡΠ½ΠΎΠΉ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΎΠΉ «Π±Π»ΠΎΠΊΠ½ΠΎΡ» (notepad.exe). ΠΡΠ°ΠΊ, Π·Π°ΠΏΡΡΡΠΈΡΠ΅ ΡΠ΅ΠΊΡΡΠΎΠ²ΡΠΉ ΡΠ΅Π΄Π°ΠΊΡΠΎΡ ΠΈ Π½Π°Π±Π΅ΡΠΈΡΠ΅ ΠΈΠ»ΠΈ ΡΠΊΠΎΠΏΠΈΡΡΠΉΡΠ΅ Π² ΠΎΠΊΠ½ΠΎ ΡΠ΅Π΄Π°ΠΊΡΠΎΡΠ° ΡΠ»Π΅Π΄ΡΡΡΠΈΠΉ ΡΠ΅ΠΊΡΡ:
ΠΠΈΡΡΠΈΠ½Π³ 1. Π’Π΅ΠΊΡΡ ΠΏΠ΅ΡΠ²ΠΎΠΉ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π½Π° Java
public static void main ( String args [ ] ) <
ΠΠ°ΡΡΠ°Π»ΠΎ Π²ΡΠ΅ΠΌΡ ΠΏΡΠ΅Π²ΡΠ°ΡΠΈΡΡ Π½Π°Ρ ΠΈΡΡ ΠΎΠ΄Π½ΡΠΉ ΠΊΠΎΠ΄ Π² ΡΠ°ΠΌΡΡ Π½Π°ΡΡΠΎΡΡΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ! ΠΡΠ° Π·Π°Π΄Π°ΡΠ° «ΠΏΠΎ ΡΠΈΠ»Π°ΠΌ» ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ΅-ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΎΡΡ javac. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ Π²ΠΎΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠΎΠΉ. ΠΠ°ΠΏΡΡΡΠΈΡΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ «ΡΠ΅ΡΠΌΠΈΠ½Π°Π»» Π² Linux ΠΈΠ»ΠΈ cmd Π² Windows. ΠΠ΅ΡΠ΅ΠΉΠ΄ΠΈΡΠ΅ Π² ΠΊΠ°ΡΠ°Π»ΠΎΠ³, Π³Π΄Π΅ Π»Π΅ΠΆΠΈΡ Π½Π°Ρ ΡΠ°ΠΉΠ», ΠΈ ΡΠΊΠΎΠΌΠ°Π½Π΄ΡΠΉΡΠ΅:
ΠΡΠ»ΠΈ Π²ΡΠ΅ ΠΏΡΠΎΡΠ»ΠΎ Π±Π΅Π· ΠΎΡΠΈΠ±ΠΎΠΊ, ΡΠΎ Π² ΡΠ΅ΠΊΡΡΠ΅ΠΌ ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π΅ ΠΏΠΎΡΠ²ΠΈΡΡΡ Π΅ΡΠ΅ ΠΎΠ΄ΠΈΠ½ ΡΠ°ΠΉΠ» HelloWorld.class. ΠΡΠΎ ΠΈ Π΅ΡΡΡ java-ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° Π² Π±Π°ΠΉΡ-ΠΊΠΎΠ΄Π΅, Π΄Π»Ρ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ ΠΊΠΎΡΠΎΡΠΎΠΉ Π½ΡΠΆΠ½Π° Π²ΡΡΠ΅ΡΠΏΠΎΠΌΡΠ½ΡΡΠ°Ρ Π²ΠΈΡΡΡΠ°Π»ΡΠ½Π°Ρ ΠΌΠ°ΡΠΈΠ½Π°.
ΠΠ»Ρ ΡΠΎΠ³ΠΎ, ΡΡΠΎΠ±Ρ ΡΠ²ΠΈΠ΄Π΅ΡΡ Π² ΡΠ΅ΡΠΌΠΈΠ½Π°Π»Π΅ Π·Π°Π²Π΅ΡΠ½ΡΡ ΡΡΠ°Π·Ρ «ΠΠ΄ΡΠ°Π²ΡΡΠ²ΡΠΉΡΠ΅, Π³ΠΎΠ²ΠΎΡΠΈΡ ΠΊΠΎΠΌΠΏΡΡΡΠ΅Ρ ΡΠ΅ΡΠ΅Π· Π²ΠΈΡΡΡΠ°Π»ΡΠ½ΡΡ ΠΌΠ°ΡΠΈΠ½Ρ Java!» Π½Π΅ ΠΌΠ΅Π½ΡΡ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ ΡΠΊΠΎΠΌΠ°Π½Π΄ΡΠΉΡΠ΅:
Π¨ΠΏΠ°ΡΠ³Π°Π»ΠΊΠ°
ΠΡΠ±ΠΎΠΉ Π½ΠΎΡΠΌΠ°Π»ΡΠ½ΡΠΉ ΡΠ΅Π»ΠΎΠ²Π΅ΠΊ ΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ ΡΠΏΠ°ΡΠ³Π°Π»ΠΊΠ°ΠΌΠΈ (Π½Ρ, Π΅ΡΠ»ΠΈ, ΠΊΠΎΠ½Π΅ΡΠ½ΠΎ ΠΎΠ½ Π½Π΅ Π½Π° ΡΠΊΠ·Π°ΠΌΠ΅Π½Π΅), ΡΠ΅ΠΌ Π±ΠΎΠ»Π΅Π΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡ ΠΈΠ»ΠΈ ΠΈΠ½ΠΆΠ΅Π½Π΅Ρ, ΠΊΠΎΡΠΎΡΠΎΠΌΡ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎ Π΄Π΅ΡΠΆΠ°ΡΡ Π² Π³ΠΎΠ»ΠΎΠ²Π΅ ΠΌΠ°ΡΡΡ ΡΠ°Π·Π»ΠΈΡΠ½ΠΎΠΉ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΠΈ ΠΈ Π΄Π΅ΡΠ°Π»Π΅ΠΉ. Π§ΡΠΎΠ±Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΌΠ°ΡΠ΅ΡΠΈΠ°Π» Π΄Π°Π½Π½ΠΎΠ³ΠΎ Π·Π°Π½ΡΡΠΈΡ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎ ΠΈΠΌΠ΅ΡΡ ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ ΠΎ ΠΊΠΎΠΌΠ°Π½Π΄Π°Ρ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½ΠΎΠΉ ΡΠΈΡΡΠ΅ΠΌΡ (ΠΠ‘) Π΄Π»Ρ ΡΠ°Π±ΠΎΡΡ Π² ΡΠ΅ΡΠΌΠΈΠ½Π°Π»Π΅. ΠΠ°ΠΏΠΎΠΌΠ½ΠΈΠΌ, ΡΡΠΎ ΠΏΠΎΡΠ»Π΅ Π»ΡΠ±ΠΎΠΉ ΠΊΠΎΠΌΠ°Π½Π΄Ρ Π½ΡΠΆΠ½ΠΎ Π½Π°ΠΆΠ°ΡΡ ΠΊΠ»Π°Π²ΠΈΡΡ Enter. ΠΡΠΈΠ²ΠΎΠ΄ΠΈΠΌ, Π΄Π»Ρ ΡΠΏΡΠ°Π²ΠΊΠΈ, Π½Π΅ΠΊΠΎΡΠΎΡΡΠ΅ ΠΈΠ· ΠΊΠΎΠΌΠ°Π½Π΄ Π½Π°ΠΈΠ±ΠΎΠ»Π΅Π΅ ΡΠ°ΡΠΏΡΠΎΡΡΡΠ°Π½Π΅Π½Π½ΡΡ ΠΠ‘:
ΠΠ°ΠΊ Π½Π°ΠΉΡΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ cmd Π² Windows? ΠΠ°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ½ΠΎΠΏΠΊΡ «ΠΡΡΠΊ»->ΠΡΠΏΠΎΠ»Π½ΠΈΡΡ ΠΈ Π²Π²Π΅Π΄ΠΈΡΠ΅ «cmd» ΠΈ Π½Π°ΠΆΠΌΠΈΡΠ΅ Enter.
JavaFX β Π±Π΅Π·ΡΠ΄Π΅ΠΉΠ½ΡΠΉ HelloWorld
ΠΠΏΠΈΡΠ°Π½ΠΈΠ΅ Π·Π°ΠΏΡΡΠΊΠ° HelloWorld ΠΈΠ· ΠΏΡΠΈΠΌΠ΅ΡΠ°, ΠΏΡΠ΅Π΄Π»ΠΎΠΆΠ΅Π½Π½ΠΎΠ³ΠΎ Oracle Π² Β«Getting Started with JavaFXΒ», Π½ΠΎ Π±Π΅Π·ΡΠ΄Π΅ΠΉΠ½ΠΎ, ΡΠΎ Π΅ΡΡΡ, Π±Π΅Π· IntelliJ IDEA ΠΈ Π²ΠΎΠΎΠ±ΡΠ΅ ΠΊΠ°ΠΊΠΎΠΉ-Π»ΠΈΠ±ΠΎ IDE. Π Π΅Π°Π»ΠΈΠ·ΠΎΠ²Π°Π½ΠΎ Π½Π° ΠΠ Ρ Windows. ΠΠΏΡΡ ΠΎΡΠ½ΠΎΡΠΈΡΡΡ ΠΊ ΠΊΠ»Π°ΡΡΡ Β«Π§Π°ΠΉΠ½ΠΈΠΊ β ΡΠ°ΠΉΠ½ΠΈΠΊΡΒ». ΠΠ½Π΅Π·Π°ΠΏΠ½ΠΎ ΠΎΠΊΠ°Π·Π°Π»ΠΎΡΡ, ΡΡΠΎ Π΄Π»Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ ΠΈ Π·Π°ΠΏΡΡΠΊΠ° ΠΏΡΠΎΡΡΠ΅ΠΉΡΠ΅Π³ΠΎ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΈΠ· ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠΈ Π½Π΅Π΄ΠΎΡΡΠ°ΡΠΎΡΠ½ΠΎ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΠΈ ΡΡΡΠΎΡΠΈΠ°Π»Π°, Π² ΠΊΠΎΡΠΎΡΠΎΠΌ ΠΏΡΠΈΠ²Π΅Π΄Π΅Π½ ΠΊΠΎΠ΄ ΡΡΠΎΠ³ΠΎ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ.
Π§Π΅Π»ΠΎΠ²Π΅ΠΊΡ ΠΎΠΏΡΡΠ½ΠΎΠΌΡ ΡΠ°ΠΊΠΈΠ΅ Π·Π°ΠΏΠΈΡΠΊΠΈ ΠΌΠΎΠ³ΡΡ ΠΏΠΎΠΊΠ°Π·Π°ΡΡΡΡ Π·Π°Π±Π°Π²Π½ΡΠΌΠΈ. ΠΠ΄Π½Π°ΠΊΠΎ, ΡΠ΅ΠΌ, ΠΊΡΠΎ ΡΠΎΠ»ΡΠΊΠΎ ΠΏΠΎΠ΄ΠΎΡΠ΅Π» ΠΊ ΠΏΠΎΠ»Ρ, ΡΡΠ΅ΡΠ½Π½ΠΎΠΌΡ Π³ΡΠ°Π±Π»ΡΠΌΠΈ, ΠΏΠΎΠ΄ΠΎΠ±Π½ΡΠΉ ΠΏΡΡΠ΅Π²ΠΎΠ΄ΠΈΡΠ΅Π»Ρ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΏΠΎΠ»Π΅Π·Π½ΡΠΌ.
Π‘ΠΏΡΠΎΡΠΈΡΠ΅ β Π·Π°ΡΠ΅ΠΌ, ΡΠΎΠ±ΡΡΠ²Π΅Π½Π½ΠΎ? ΠΠ»Ρ ΠΎΠ±ΡΡΠ΅Π½ΠΈΡ, ΠΊΠ°ΠΊ ΠΈ Π²ΡΠ΅ HelloWorld`Ρ. ΠΠ΅ Ρ
ΠΎΡΡ ΡΠΌΠ°Π»ΡΡΡ Π·Π½Π°ΡΠ΅Π½ΠΈΡ IDE ΠΈ Π·Π°ΡΠ²Π»ΡΡΡ: Β«Π’ΠΎΠ»ΡΠΊΠΎ Π±Π»ΠΎΠΊΠ½ΠΎΡ! Π’ΠΎΠ»ΡΠΊΠΎ Ρ
Π°ΡΠ΄ΠΊΠΎΡ!Β» ΠΠΎ ΠΊΠΎΠΌΠ°Π½Π΄Π½Π°Ρ ΡΡΡΠΎΠΊΠ° ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ Π΅ΡΠ»ΠΈ ΠΈ Π½Π΅ ΠΏΠΎΠ½ΡΡΡ Π²ΡΡ ΠΌΠ΅Ρ
Π°Π½ΠΈΠΊΡ, ΡΠΎ Ρ
ΠΎΡΡ Π±Ρ Π·Π°Π³Π»ΡΠ½ΡΡΡ ΠΏΠΎΠ΄ ΠΊΠ°ΠΏΠΎΡ. ΠΡΠΎΠ±Π΅Π½Π½ΠΎ ΠΊΠΎΠ³Π΄Π° Π½Π΅ΠΊΠΎΡΠΎΡΡΠΉ ΠΎΠΏΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π·Π° Π΅Π΄Ρ ΡΠΆΠ΅ Π΅ΡΡΡ. ΠΠ½Π΅Π·Π°ΠΏΠ½ΠΎ Π²ΠΎΠ·Π½ΠΈΠΊΠ»ΠΎ ΠΆΠ΅Π»Π°Π½ΠΈΠ΅ ΡΠ°ΡΡΠΈΡΠΈΡΡ Π³ΠΎΡΠΈΠ·ΠΎΠ½ΡΡ ΠΈ ΠΎΡΠ²ΠΎΠΈΡΡ, Π½Ρ, Π΄ΠΎΠΏΡΡΡΠΈΠΌ, Java. ΠΠΎ ΠΊΡΠ°ΠΉΠ½Π΅ΠΉ ΠΌΠ΅ΡΠ΅, ΠΏΠΎΠΏΡΠΎΠ±ΠΎΠ²Π°ΡΡ.
ΠΡΡΡ ΡΠΎΠ²Π΅ΡΡΠ΅Π½Π½ΠΎ Π·Π°ΠΌΠ΅ΡΠ°ΡΠ΅Π»ΡΠ½ΡΠΉ ΠΏΠΎΡΡ Π Π°Π±ΠΎΡΠ° Ρ Java Π² ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠ΅ ΠΎΡ Qwertovsky. ΠΡΠ΅ ΠΆΠ΅, Π΄Π»Ρ Π΄Π°Π»ΡΠ½Π΅ΠΉΡΠ΅Π³ΠΎ ΠΏΠΎΠ³ΡΡΠΆΠ΅Π½ΠΈΡ ΠΌΠ°Π»ΠΎΠ²Π°ΡΠΎ Π³ΠΎΠ»ΠΎΠΉ ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ, Ρ ΠΎΡΠ΅ΡΡΡ ΠΎΠΊΠΎΡΠ΅ΠΊ. ΠΠ΅Π»Π°ΡΠ΅Π»ΡΠ½ΠΎ, Π² Π²ΠΈΠ΄Π΅ Π΄Π΅ΡΠΊΡΠΎΠΏΠ½ΠΎΠ³ΠΎ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ. ΠΠΎΡΠΈΡΠ°Π», ΠΊΠ°ΠΊΠΈΠ΅ Π΅ΡΡΡ Π²Π°ΡΠΈΠ°Π½ΡΡ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ GUI Π΄Π»Ρ Java-ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌ, ΠΈ ΡΡΠΎ ΠΎ Π½ΠΈΡ Π΄ΡΠΌΠ°Π΅Ρ Π½Π°ΡΠΎΠ΄, ΠΎΡΡΠ°Π½ΠΎΠ²ΠΈΠ»ΡΡ ΠΏΠΎΠΊΠ° Π½Π° JavaFX. ΠΠΊΠ°Π·Π°Π»ΠΎΡΡ, ΡΡΠΎ Π½Π° ΡΡΡΡΠΊΠΎΠΌ Π² ΡΠ°Π·Π½ΠΎΠ³ΠΎ ΡΠΎΠ΄Π° ΠΈΠ½ΡΠ΅ΡΠ½Π΅ΡΠ°Ρ ΠΏΡΠΎ JFX Π½Π°ΠΏΠΈΡΠ°Π½ΠΎ Π΄ΠΎΠ²ΠΎΠ»ΡΠ½ΠΎ ΠΌΠ°Π»ΠΎ, ΠΈ ΡΡΡΠ΅ΡΡΠ²Π΅Π½Π½ΠΎΠΉ ΡΠ°ΡΡΡΡ ΠΏΡΠΎ ΠΏΠ΅ΡΠ²ΡΡ Π²Π΅ΡΡΠΈΡ. ΠΠ½Π°ΡΠΈΡ, ΠΏΡΠΈΠ΄Π΅ΡΡΡ ΡΡΡΡ Π½Π° ΡΠ°ΠΉΡΠ΅ Oracle.
jfxpub-overview ΡΠΎΠΎΠ±ΡΠ°Π΅Ρ Π½Π°ΠΌ, ΡΡΠΎ, ΠΏΠΎΡΠΊΠΎΠ»ΡΠΊΡ JavaFX-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΏΠΈΡΡΡΡΡ Π½Π° ΡΠ·ΡΠΊΠ΅ Java, Ρ ΠΌΠΎΠ³Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π΄Π»Ρ ΠΈΡ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΡΠ²ΠΎΠΉ Π»ΡΠ±ΠΈΠΌΡΠΉ ΡΠ΅Π΄Π°ΠΊΡΠΎΡ ΠΈΠ»ΠΈ ΠΊΠ°ΠΊΡΡ-Π½ΠΈΠ±ΡΠ΄Ρ IDE (NetBeans, Eclipse ΠΈΠ»ΠΈ IntelliJ IDEA). ΠΡΠ΅Π΄Π»Π°Π³Π°Π΅ΡΡΡ Π·Π°Π³Π»ΡΠ½ΡΡΡ Π½Π° ΡΠ°ΠΉΡ www.oracle.com ΠΈ ΡΠΊΠ°ΡΠ°ΡΡ Oracle JDK 7 Ρ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΊΠΎΠΉ JavaFX 2.2.n, Π° ΠΏΠΎΡΠΎΠΌ Π²ΠΎΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ ΠΏΠΎΡΠΎΠ±ΠΈΠ΅ΠΌ jfxpub-get_started, ΡΡΠΎΠ±Ρ ΡΠΎΠ·Π΄Π°ΡΡ ΠΏΡΠΎΡΡΠΎΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅, Π΄Π΅ΠΌΠΎΠ½ΡΡΡΠΈΡΡΡΡΠ΅Π΅ ΡΠ°Π±ΠΎΡΡ ΡΠΎ ΡΠ»ΠΎΡΠΌΠΈ, ΡΠ°Π±Π»ΠΈΡΠ°ΠΌΠΈ ΡΡΠΈΠ»Π΅ΠΉ ΠΈ Π²ΠΈΠ·ΡΠ°Π»ΡΠ½ΡΠΌΠΈ ΡΡΡΠ΅ΠΊΡΠ°ΠΌΠΈ. ΠΡΠ΅ ΡΠ°ΠΌ ΠΏΡΠ΅Π΄Π»Π°Π³Π°Π΅ΡΡΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ JavaFX Scene Builder Π΄Π»Ρ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»ΡΡΠΊΠΎΠ³ΠΎ ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡΠ° Π±Π΅Π· ΠΊΠΎΠ΄ΠΈΠ½Π³Π°, Π½ΠΎ ΡΡΠΎ ΠΊΠ°ΠΊ-Π½ΠΈΠ±ΡΠ΄Ρ ΠΏΠΎΡΠΎΠΌ.
Π£ΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½ JDK ΠΈ (Π½Π° Π²ΡΡΠΊΠΈΠΉ ΡΠ»ΡΡΠ°ΠΉ) JRE. Π£ ΠΌΠ΅Π½Ρ Π² ΡΠΈΡΡΠ΅ΠΌΠ½ΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ PATH ΡΠ°ΠΌΠΎ Π½ΠΈΡΠ΅Π³ΠΎ Π½Π΅ ΠΏΡΠΎΠΏΠΈΡΠ°Π»ΠΎΡΡ, ΠΈ Ρ Π²ΡΡΡΠ½ΡΡ ΠΏΡΠΎΠΏΠΈΡΡΠ²Π°ΡΡ Π½Π΅ ΡΡΠ°Π».
ΠΠ΅ΡΠ΅ΠΌ ΡΠΏΠΎΠΌΡΠ½ΡΡΡΠΉ ΠΏΡΠΈΠΌΠ΅Ρ ΠΊΠ°ΠΊ Π΅ΡΡΡ.
ΠΠ²ΡΠΎΡΡ ΠΏΠΎΡΠΎΠ±ΠΈΡ ΠΏΡΠ΅Π΄Π»Π°Π³Π°ΡΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ NetBeans IDE 7.3. ΠΠ±ΠΎΠΉΠ΄Π΅ΠΌΡΡ. ΠΠ΅Π»Π°Π΅ΠΌ ΠΏΠ°ΠΏΠΊΡ Π΄Π»Ρ ΠΏΡΠΎΠ΅ΠΊΡΠ°, Π΄ΠΎΠΏΡΡΡΠΈΠΌ, D:\GetStart\, Π² Π½Π΅ΠΉ ΡΠΎΠ·Π΄Π°Π΅ΠΌ ΠΏΠ°ΠΏΠΊΡ Π΄Π»Ρ ΠΈΡΡ ΠΎΠ΄Π½ΠΈΠΊΠΎΠ² src ΠΈ ΠΏΠ°ΠΏΠΊΡ Π΄Π»Ρ ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠΎΠ² ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ out. Π Π°Π· ΡΠΆ ΠΏΡΠΎΠ±Π½ΡΠΉ ΠΊΠ»Π°ΡΡ ΠΎΡΠ½ΠΎΡΠΈΡΡΡ ΠΊ ΠΏΠ°ΠΊΠ΅ΡΡ helloworld, Π½Π°Π΄ΠΎ ΡΠ΄Π΅Π»Π°ΡΡ ΠΎΠ΄Π½ΠΎΠΈΠΌΠ΅Π½Π½ΡΡ ΠΏΠ°ΠΏΠΊΡ Π² src ΠΈ ΠΏΠΎΠ»ΠΎΠΆΠΈΡΡ ΡΡΠ΄Π° ΡΠ°ΠΉΠ» HelloWorld.java.
Π§ΡΠΎΠ±Ρ ΡΡΠΎ ΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°Π»ΠΎΡΡ, ΡΠ΄Π΅Π»Π°Π΅ΠΌ Π² ΠΊΠΎΡΠ½Π΅ ΠΏΡΠΎΠ΅ΠΊΡΠ° ΡΠ°ΠΉΠ» compile.cmd. Π’Π°ΠΊ ΡΠ΄ΠΎΠ±Π½Π΅Π΅ Π²Π½ΠΎΡΠΈΡΡ ΠΏΡΠ°Π²ΠΊΠΈ Π² ΠΊΠΎΠΌΠ°Π½Π΄Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ β Π½Π΅ Π½Π°Π΄ΠΎ ΠΏΠΎΠ»Π°Π³Π°ΡΡΡΡ Π½Π° ΠΏΠ°ΠΌΡΡΡ ΠΈΠ½ΡΠ΅ΡΠΏΡΠ΅ΡΠ°ΡΠΎΡΠ° ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠΈ, ΠΈ Π²ΠΎΠΎΠ±ΡΠ΅, ΠΌΠΎΠΆΠ½ΠΎ ΠΎΠ±ΠΎΠΉΡΠΈΡΡ Π±Π΅Π· cmd.exe, ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ Π»ΡΠ±ΠΈΠΌΡΠΌ ΡΠ°ΠΉΠ»ΠΎΠ²ΡΠΌ ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅ΡΠΎΠΌ, Π° Ρ ΠΎΡΡ Π±Ρ ΠΈ ΠΏΡΠΎΠ²ΠΎΠ΄Π½ΠΈΠΊΠΎΠΌ.
jfxpub-overview ΡΠ°ΡΡΠΊΠ°Π·Π°Π», ΡΡΠΎ JavaFX ΠΏΠΎΠ»Π½ΠΎΡΡΡΡ Π²ΡΡΡΠΎΠ΅Π½ Π² Java SE 7 JRE ΠΈ JDK. ΠΠ° ΡΡΡΠ°Π½ΠΈΡΠ΅ downloads ΠΆΠ΅Π»Π°ΡΡΠΈΠΌ ΡΠΊΠ°ΡΠ°ΡΡ JavaFX Π΄Π»Ρ Java SE 7 ΠΏΡΠ΅Π΄Π»Π°Π³Π°ΡΡ ΠΏΡΠΎΡΡΠΎ ΡΠΊΠ°ΡΠ°ΡΡ Java SE 7. Π‘ΡΠ΅Π΄ΠΈ ΡΠ°ΠΉΠ»ΠΎΠ² JDK Π½Π΅Ρ javafxc ΠΈ javafx. ΠΠΎ Π²ΡΠ΅ΠΉ Π²ΠΈΠ΄ΠΈΠΌΠΎΡΡΠΈ, ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡ JFX-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΠΌΠΎΠΆΠ½ΠΎ ΡΠ°ΠΊ ΠΆΠ΅, ΠΊΠ°ΠΊ ΠΈ Π»ΡΠ±ΠΎΠΉ Π΄ΡΡΠ³ΠΎΠΉ java-ΡΠ°ΠΉΠ». ΠΠΎΡΡΠΎΠΌΡ Π² ΠΊΠΎΠΌΠ°Π½Π΄Π½ΡΠΉ ΡΠ°ΠΉΠ» Π·Π°ΠΏΠΈΡΠ΅ΠΌ Π΄Π²Π΅ ΡΡΡΠΎΡΠΊΠΈ:
ΠΡΠΎΡΠ°Ρ ΡΡΡΠΎΡΠΊΠ° Π΄Π°Π΅Ρ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡ ΡΠ°ΡΡΠΌΠΎΡΡΠ΅ΡΡ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΡ ΠΎΠ± ΠΎΡΠΈΠ±ΠΊΠ°Ρ . ΠΡΠ»ΠΈ ΠΆΠ΅ Π² ΠΏΠΎΡΠ²ΠΈΠ²ΡΠ΅ΠΌΡΡ ΠΎΠΊΠ½Π΅ cmd.exe Π±ΡΠ΄Π΅Ρ Π΅Π΄ΠΈΠ½ΡΡΠ²Π΅Π½Π½ΠΎΠ΅ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ Β«ΠΠ»Ρ ΠΏΡΠΎΠ΄ΠΎΠ»ΠΆΠ΅Π½ΠΈΡ Π½Π°ΠΆΠΌΠΈΡΠ΅ Π»ΡΠ±ΡΡ ΠΊΠ»Π°Π²ΠΈΡΡ. Β», Π·Π½Π°ΡΠΈΡ, ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠ°Ρ ΠΊΠΎΠΌΠ°Π½Π΄Π° Π²ΡΠΏΠΎΠ»Π½Π΅Π½Π° Π±Π΅Π· ΠΎΡΠΈΠ±ΠΎΠΊ.
ΠΠ΄Π½Π°ΠΊΠΎ, Π·Π°ΠΏΡΡΠΊ Π²ΡΠ΄Π°ΡΡ Π΄Π»ΠΈΠ½Π½ΡΡ ΠΏΡΠΎΡΡΡΠ½Ρ, ΠΊΠΎΡΠΎΡΠ°Ρ, Π²Π΅ΡΠΎΡΡΠ½ΠΎ, Π²ΡΡ Π΄Π°ΠΆΠ΅ Π½Π΅ Π²Π»Π΅Π·Π΅Ρ Π² ΠΎΠΊΠ½ΠΎ Π²ΡΠ²ΠΎΠ΄Π°. 18 ΠΎΡΠΈΠ±ΠΎΠΊ, ΡΡΠΎ-ΡΠΎ Π½Π΅ Π½Π°ΠΉΠ΄Π΅Π½ΠΎ, ΡΡΠΎ-ΡΠΎ Π½Π΅ ΡΡΡΠ΅ΡΡΠ²ΡΠ΅Ρ. Π§ΡΠΎΠ±Ρ ΠΏΠΎΡΠΌΠΎΡΡΠ΅ΡΡ Π²ΡΠ΅ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΡ ΠΏΠΎΠ»Π½ΠΎΡΡΡΡ, ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠ΅ΡΠ²ΡΡ ΡΡΡΠΎΡΠΊΡ CMD-ΡΠ°ΠΉΠ»Π° Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡΡ ΠΏΠ΅ΡΠ΅Π½Π°ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ΠΌ ΠΏΠΎΡΠΎΠΊΠ° Π²ΡΠ²ΠΎΠ΄Π° ΠΎΡΠΈΠ±ΠΎΠΊ Π² ΡΠ°ΠΉΠ» Β«2> result.txtΒ».
Π₯ΠΎΡΠ΅Π»ΠΎΡΡ Π±Ρ Π·Π°ΠΏΡΡΡΠΈΡΡ. Π ΡΠΏΠΎΠΌΡΠ½ΡΡΠΎΠΉ ΡΠ΅ΠΌΠ΅ Π½Π° ΡΠΎΡΡΠΌΠ΅ Oracle ΠΏΡΠ΅Π΄Π»Π°Π³Π°Π΅ΡΡΡ Π²Π°ΡΠΈΠ°Π½Ρ Ρ ΡΠΏΠ°ΠΊΠΎΠ²ΠΊΠΎΠΉ Π² jar, Π½ΠΎ ΠΏΠΎΠΏΡΠΎΠ±ΡΠ΅ΠΌ ΡΠ½Π°ΡΠ°Π»Π° Π·Π°ΠΏΡΡΡΠΈΡΡ ΡΠ°ΠΊ. Π‘Π΄Π΅Π»Π°Π΅ΠΌ Π΅ΡΠ΅ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΡΠΉ ΡΠ°ΠΉΠ» run.cmd Ρ Π·Π°ΡΠ°Π½Π΅Π΅ ΡΠΊΠ°Π·Π°Π½Π½ΠΎΠΉ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΎΠΉ JFX:
ΠΡΠΈ Π·Π°ΠΏΡΡΠΊΠ΅ ΠΏΠΎΠ»ΡΡΠΈΠΌ ΠΎΡΠΈΠ±ΠΊΡ:
ΠΡ ΡΡΠΎ ΠΆ, Π·Π½Π°ΡΠΈΡ, classpath Π΅ΡΠ΅ ΠΌΠ°Π»ΠΎΠ²Π°Ρ, Π½Π°Π΄ΠΎ ΡΠΊΠ°Π·Π°ΡΡ ΠΈ ΠΌΠ΅ΡΡΠΎ ΠΆΠΈΡΠ΅Π»ΡΡΡΠ²Π° Π½Π°ΡΠ΅Π³ΠΎ ΠΎΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°Π½Π½ΠΎΠ³ΠΎ ΠΊΠ»Π°ΡΡΠ°:
ΠΠ°ΠΏΡΡΠΊ ΡΡΠΎΠΉ ΠΊΠΎΠΌΠ°Π½Π΄Ρ Π½Π°ΠΊΠΎΠ½Π΅Ρ-ΡΠΎ ΠΏΡΠΈΠ²Π΅Π΄Π΅Ρ ΠΊ ΠΏΠΎΡΠ²Π»Π΅Π½ΠΈΡ ΠΎΠΊΠΎΡΠΊΠ° Ρ ΠΊΠ½ΠΎΠΏΠΊΠΎΠΉ Ρ ΠΈΠ»Π»ΡΡΡΡΠ°ΡΠΈΠΈ get_started. ΠΡΠΈ ΡΡΠΎΠΌ Π±ΡΠ΄Π΅Ρ Π²ΠΈΠ΄Π½Π° ΠΈ ΠΊΠΎΠ½ΡΠΎΠ»Ρ cmd.exe. ΠΠ°ΠΆΠ°ΡΠΈΠ΅ Π½Π° ΠΊΠ½ΠΎΠΏΠΊΡ Π² ΠΎΠΊΠΎΡΠΊΠ΅ ΠΏΡΠΈΠ²Π΅Π΄Π΅Ρ ΠΊ ΠΏΠΎΡΠ²Π»Π΅Π½ΠΈΡ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΡ Β«Hello World!Β» Π² ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ.
Π£ΠΏΠ°ΠΊΠΎΠ²Π°ΡΡ Π² jar Π²ΡΠ΅-ΡΠ°ΠΊΠΈ Ρ ΠΎΡΠ΅Π»ΠΎΡΡ Π±Ρ. ΠΠΎΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌΡΡ ΡΡΠΈΠ»ΠΈΡΠΎΠΉ javafxpackager. ΠΠ°ΠΏΡΡΠ΅Π½Π½Π°Ρ Π² ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ Π±Π΅Π· ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠΎΠ², ΠΎΠ½Π° Π²ΡΠ΄Π°Π΅Ρ Π΄ΠΎΠ²ΠΎΠ»ΡΠ½ΠΎ ΠΏΠΎΠ΄ΡΠΎΠ±Π½ΡΡ ΠΈ ΠΏΠΎΠ½ΡΡΠ½ΡΡ ΡΠΏΡΠ°Π²ΠΊΡ ΠΏΠΎ ΡΠ²ΠΎΠΈΠΌ ΠΎΠΏΡΠΈΡΠΌ. ΠΠΎΠΆΠ½ΠΎ ΡΠ΄Π΅Π»Π°ΡΡ ΡΠ°ΠΉΠ» jar.cmd:
ΠΠ· ΠΏΡΠΎΠ²ΠΎΠ΄Π½ΠΈΠΊΠ° ΠΏΠΎΠ»ΡΡΠΈΠ²ΡΠΈΠΉΡΡ jar Ρ ΠΌΠ΅Π½Ρ Π·Π°ΠΏΡΡΠΊΠ°Π΅ΡΡΡ Π΄Π²ΠΎΠΉΠ½ΡΠΌ ΡΠ΅Π»ΡΠΊΠΎΠΌ ΠΌΡΡΠΊΠΈ. ΠΠ΄Π½Π°ΠΊΠΎ, ΡΠ°ΠΉΠ»ΠΎΠ²ΡΠΉ ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ Π·Π°Ρ ΠΎΠ΄ΠΈΡ Π² ΡΡΠΎΡ ΡΠ°ΠΉΠ», ΠΊΠ°ΠΊ Π² Π°ΡΡ ΠΈΠ² (ΠΊΠΎΠΈΠΌ ΡΠ°ΠΉΠ», ΡΠΎΠ±ΡΡΠ²Π΅Π½Π½ΠΎ, ΠΈ ΡΠ²Π»ΡΠ΅ΡΡΡ). ΠΡΠΎΠΌΠ΅ ΡΠΎΠ³ΠΎ, Π² ΠΏΡΠΎΠ²ΠΎΠ΄Π½ΠΈΠΊΠ΅ ΡΠ°ΠΉΠ» Π·Π°ΠΏΡΡΠΊΠ°Π΅ΡΡΡ Π±Π΅Π· ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ. ΠΠΎΡΡΠΎΠΌΡ Π΄Π»Ρ ΡΠ΄ΠΎΠ±ΡΡΠ²Π° Ρ Π΄ΠΎΠ±Π°Π²ΠΈΠ» Π΅ΡΠ΅ ΠΈ run_jar.cmd:
ΠΠ°Π»Π΅Π΅ Π² ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²Π΅ ΠΏΡΠ΅Π΄Π»Π°Π³Π°Π΅ΡΡΡ ΡΠ΄Π΅Π»Π°ΡΡ ΠΎΠΊΠ½ΠΎ Π²Π²ΠΎΠ΄Π° Π»ΠΎΠ³ΠΈΠ½Π° ΠΈ ΠΏΠ°ΡΠΎΠ»Ρ Ρ ΡΠ΅Π»ΡΡ ΠΎΠ±ΡΡΠ΅Π½ΠΈΡ ΠΎΡΠ½ΠΎΠ²Π°ΠΌ ΡΠ°Π·ΠΌΠ΅ΡΠ΅Π½ΠΈΡ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ², ΠΏΠΎΡΠΎΠΌ ΠΈΠ· ΡΡΠΎΠ³ΠΎ ΠΎΠΊΠ½Π° Π΄Π΅Π»Π°Π΅ΡΡΡ ΡΡΠΈΠ»ΡΠ½Π°Ρ ΠΊΡΠ°ΡΠΎΡΡΠ»Π΅ΡΠΊΠ° Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ ΠΊΠ°ΡΠΊΠ°Π΄Π½ΡΡ ΡΠ°Π±Π»ΠΈΡ ΡΡΠΈΠ»Π΅ΠΉ (CSS), Π·Π°ΡΠ΅ΠΌ ΡΠΈΡΡΠ΅ΡΡΡ ΡΡΠ° ΠΆΠ΅ ΡΠΎΡΠΌΠ°, Π½ΠΎ Ρ ΠΏΠΎΠΌΠΎΡΡΡ FXML. ΠΠΎ Π²ΡΠ΅Ρ ΡΡΠΈΡ Π΄Π΅ΠΉΡΡΠ²ΠΈΡΡ ΡΠ°Π·Π±ΡΠΎΡΠ°Π½ΠΎ Π½Π΅ΠΌΠ½ΠΎΠΆΠ΅ΡΠΊΠΎ Π³ΡΠ°Π±Π΅Π»Ρ. ΠΠΈΡΠ΅Π³ΠΎ ΠΎΡΠΎΠ±Π΅Π½Π½ΠΎ ΡΠ»ΠΎΠΆΠ½ΠΎΠ³ΠΎ β ΠΏΡΠΎΡΡΠΎ Π½Π΅ΠΎΡΠ΅Π²ΠΈΠ΄Π½ΠΎΡΡΠΈ, ΠΎ ΠΊΠΎΡΠΎΡΡΡ Π² ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²Π΅ Π½Π΅ ΡΠΊΠ°Π·Π°Π½ΠΎ, Π° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π² ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠ΅ Π½Π΅ ΠΎΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡ ΠΈΠ»ΠΈ Π½Π΅ Π·Π°ΠΏΡΡΡΠΈΡΡ.