[ecko_annotated header=”” annotation=””]In this article I’ll try to provide step by step tutorial for beginners. For those who know nothing about Java and required environment or even about software development in general.[/ecko_annotated]
So, let’s begin.
For now, Java is the most popular in the world. It means you made a good choice :). It could be a bit difficult to start studying Java alone without any help that’s why I decided to prepare this roadmap.
I’ll split my article in a few logical parts like basic knowledge, required tools, databases, etc
First steps
-
What is JDK and why we need it?
JDK stands for Java Development Kit. In few words jdk translates Java language commands (your program) to computer instructions.
You can download the latest jdk here. Just download and install. Follow official instructions. Now you are ready to write and run simple Java app. Just don’t forget to check if your jdk works properly. Open command line and execute commandjava -version
if everything fine you will see Java version in console. By good old tradition first app should be called HelloWorld. Don’t spend your time on it and download app here. Run command line in the same folder with HelloWorld app and execute following command
javac HelloWorld.java
.JDK will compile the app and create new file HelloWorld.class – computer language version of Java app. Now you are ready to run our example. Execute command
java HelloWorld
in console and you will see this response
Hello, World
Let’s postpone explanation how this app works just remember the following – you should compile each project and only then run it.
-
Simplest Java app
HelloWorld is the simplest Java app and it consists of one class. Class is a logical unit in Java. In real life project could contain thousands of classes.
package com.devua.article; import java.util.Date; public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); } }
First line is declaration of package. Package is not mandatory but it’s good practice. One important thing is if you add package declaration you should put file in corresponding folder structure. In our case it should be something like MyTestProject/com/devua/article/HelloWorld.java. For test purpose you could skip package declaration. Otherwise when you compile you should go to MyTestProject folder, open command line and execute
javac com/devua/article/HelloWorld.java
and then execute
java com.devua.article.HelloWorld
Then we declare – import – the whole path to each other class which we need for our app. If we don’t need other classes we don’t import anything (We don’t use Date class here, so this import actually is not needed). Then we declare class itself. Hence, Java app is set of classes from one to infinity. ‘Cause apps have ability to grow all the time we group classes in packages from the start. I will not explain you how to write the code inside the classes, it takes a long time to do this and there are many good books on that subject. In Ukraine we usually recommend this one: Bruce Eckel – Thinking in Java but you can take any other book for beginners. Also I would recommend these two books: Jeanne Boyarsky and Scott Selikoff – OCA / OCP Java SE 8 Programmer Certification Kit. It’s shorter and cleaner so you will learn faster, especially if you have some elementary level in programming. Also, if you start with “Thinking In Java” you can skip GUI chapter without any harm. Even I would recommend you to stop reading before chapter about I/O then take few weeks to practice and only after that read the rest of the book.
Above I explained really basic things. I recommend you now to spend few weeks on reading some book for beginners and coding each practice tasks from that book.
Now when you got some information about language itself and how to run simple app I’ll describe more specific stuff.
Tools
-
IDE
It’s quite usual for Java app to consist of many classes so it would be difficult to manage the whole project in a file manager. Also, if you write code in plain text editor it’s quite easy to make mistakes: any kind of typo, misusing Java language command, lost parenthesis, etc. So, for real work everybody uses IDE (integrated development environment) – application which assists you during development process. The most popular IDEs in Java world are Eclipse, Intellij IDEA and NetBeans. I prefer Eclipse, but you can try all of them. Just download, install, create new project, create new class with name HelloWorld, copy content from file above and finally run. It will allow you to decide which one suits you the best. IDE will not do your job but at least save you from stupid mistakes.
-
Build tools
As I mentioned above Java project could contain many classes also it could contain dozens third party libraries and hundreds configuration files. It is possible to manage everything manually but it’s much easier to use specific tools called – build tools. The oldest one is Ant, the most popular – Maven and the newest is Gradle. All these tools allow you to control and manage middle size and big projects. You don’t need them for oneclass practice tasks but if you would like to develop some pet project or just successfully pass job interview it’s better to spend some time on reading docs about them and creating test project with Maven and Gradle.
-
Version control systems (VCS)
When you start to develop more complex projects you would like to check history of changes from time to time, perhaps rollback some changes and revert files to previous state. If you are not alone on the project it is quite nice to save project on shared folder and trace changes of each other. For such purpose we use version control systems. Nowadays the most popular VCS are GIT and SVN. There is no need to setup these stuff on local server, you can find a lot of free services online like github, bitbucket, assembla, etc. Again, it’s not mandatory to use VCS for test or pet projects but it’s good practice and such experience would be a big plus on a job interview.
Career path
Now You read really short list of required knowledge and standard tools but you should understand it’s quite far from real tasks in Java development.
There are different types of Java apps and developers in those areas have slightly different set of skills.You can start working as:
-
Android developer
Honestly, I would say it’s not even Java developer but you will need knowledge of Java there. Just to feel a spirit of android development you could setup Android Studio, run emulators, download and run some “hello world” for android. I would say it’s quite different “world” comparing to plain Java app..
-
Embedded developer
Low-level development for different kind of devices. Strong knowledge of core Java is must have. You will work a lot with device specifications. It would be useful to know how hardware and communication protocols works.
-
Desktop Java
You should know core Java especially concurrency and you will have to learn Swing or SWT for user interface development. Actually it’s not so popular but still there are some market behind.
-
Enterprise software developer
Pay attention – enterprise software not always means enterprise Java. It’s most widespread direction in Java. Enterprise software is a computer software used to satisfy the needs of an organization.
Enterprise software
Most probably you will start working on enterprise project. There are two different approaches to build enterprise software with Java:
- based on Java standard technologies i.e. JSF, EJB, etc.
- based on Spring (or any other lightweight framework) and separated UI.
Nowadays the second way is more popular. Typical structure of such project is
frontend -> backend -> DB
As usual frontend is written in some modern JS framework and quite often Java developers who are working mostly on backend do nothing there. Communication between frontend and backend could be implemented in different ways for example REST services. REST service is exposed URL, when frontend calls this URL backend executes some action or returns some data. Such approach allows to separate frontend and backend. Let assume you as Java developer will work only on backend. I explained above how to compile and run plain Java app. In case enterprise software it works in a bit different way. After compilation you should build deployment package (file with extension .war) and run it on web server like Tomcat, Jetty, etc.
More details how to create webproject and deploy on Tomcat you can find here or here
Databases
Most applications store results to DB so that you should have at least general knowledge about communication with DB. Core of DB operation in Java is JDBC API. The JDBC API is a Java API that can access any kind of tabular data, especially data stored in a Relational Database. JDBC overview.
There are few different approaches were implemented over JDBC: jpa, jdo or something like jooq, where you can work with DB without using JDBC API directly but in fact it’s really recommended to try working with JDBC API at the beginning.
One more interesting thing you should know about DB is nosql solutions which are quite popular today so don’t forget to read about it and learn difference between sql and nosql solutions.
Not The End
It’s quite difficult to cover all stuff which are required in daily job of Java developer so I tried just to show you right direction. Some time in article I simplified things so don’t hesitate to double-check and read more. Studying things one by one in logical order allows you to develop skills properly. Don’t jump immediately on omnipresent frameworks like Spring. I would rather recommend you to read something about software design principles like DRY, KISS, YAGNI, SOLID. Pay attention to naming and code convention in general. Don’t be greedy – use full and clear names for variables and methods, put parenthesis everywhere, avoid ternary and unary operators if you can, do not write long classes and methods. Any newcomer should understand your code without comments and docs. Be clear and consistent in your code.
I’m pretty sure if you read a bit about everything I wrote and run few test projects it will give you good chance to obtain Java trainee/junior position.
If you found mistake or just have some idea for improvement – let me know by mail andriy@andrunevchyn.com
Roadmap for Java beginners
[ecko_annotated header=”” annotation=””]In this article I’ll try to provide step by step tutorial for beginners. For those who know nothing about Java and required environment or even about software development in general.[/ecko_annotated] So, let’s begin. For now, Java is the most popular in the [...]
Andriy Andrunevchyn