A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service
Java is a common programming language, can actually do a lot of things, how to learn Java to see how to Use.
But there are some general steps:
1. Familiar with a text editor, such as vim, Emacs, notepad++, textmate, etc. Know which are open source, which are closed source, and which are Charged. Develop the habit of not using pirated software.
2. Install the JDK (it is recommended to install OPENJDK with your Linux Distribution's package manager, which may need to read the release specific Documentation)
3. Write a Java Hello World program, compile it with the command-line tool javac, and then run the program with the Java command. The process is familiar with source code (helloworld.java), bytecode (helloworld.class), virtual machine These things, and the Java Packages (package) impact on the path where The. class file is located (packNet . Java. The path of the Util is net/java/util/xx.java).
"javac for compiling Java files, java [options] [sourcefiles] [@files]"
"java command for executing program Java [options] classfile"
The Javac Helloworld.java compiles the build helloworld.class, and then executes the Java HelloWorld to run the Program. 】
"Java Package Packages, for better organization classes, distinguish between class name namespaces." tree-shaped directory, Easy to find, avoid conflicts, control access rights, different Java programs to Classify. 】
The effect of the Java package on the path where The. class file is located: packages org.test; The Java file should be placed in The./org/test subdirectory, and Java xx should run Java org/test/xx under the current directory (not subdirectories).
3.5. if both command-line tools are proficient, you can start choosing a favorite integrated development environment, such as Eclipse. of course, develop the habit of not using pirated software. Be familiar with how to establish "engineering" and the use of shortcut keys.
4. Learn about Java's process-oriented programming, including basic data structures, expressions, statements, control flows, function Calls.(for The basic data structure you can review the blog I wrote Earlier)
5. Learn Java's object-oriented programming, including class, reference type and value type differences, members, methods, access control, inheritance, polymorphism, interface, interface Implementation. By the way, learn the basic idea of object-oriented, that is, object, message, encapsulation, inheritance, polymorphism, etc., These common content is not java-specific.
5.5 should have been involved.garbage collection in Java。 Be aware of memory leaks that occur even with garbage collection (such as designing array containers yourself, elements are references, elements are logically removed, but not Qingcheng null). Note Garbage collection can only reclaim objects in Memory.In addition to memory, other resources cannot be shut down by Garbage Collection. For example, files, pipelines, sockets, database connections, etc., garbage collection is not going to help you shut down.
6. Learn about JavaException Handling, but it is more important to learn when to use special return values instead of exceptions, when to throw exceptions without handling exceptions, to know what Pokemon catch and its harms, and to understand why Java's checked exception is a bad Feature. If you want, learn about Java1.7 's Try-with-resource statement and autocloseable interface at the same time.
7. Familiar with Java common data structure, such as basic array type, and generic container (java.util.*), especially java.util.list<t> interface and java.util.arraylist<t> implementation , and Java.util.map<t,u> interface and java.util.hashmap<t,u> Implementations. (you don't have to touch the previous java1.5 without a generic parameter) also notice the difference between the basic type int, double, and the boxed type integer and double, and how they are automatically converted.
8. Familiar with the various tools in the Java standard library, including date time, string formatting, io, etc. If you know that you want to close () the file yourself in the finally clause, or use Java1.7 's try-with-resource, don't be paranoid that the garbage collector will turn off the file for You.
9. Learn about the naming habits of java, and the general javabeans, and know why Getter/setter is better than directly manipulating member Variables. In this way, the Java variables, methods Named. Also see if your IDE can automatically generate getter and setter for YOU.
10. Use a Third-party library (such as the Apache Commons Lang Common tool Library) to have your program rely on its binary jar package (instead of copying the source code directly), compile and run with the command line (note classpath, etc.) And be familiar with how to add third-party dependencies with your integrated development Environment. Feel the hassle of manually managing Dependencies.
11. Learn about Maven's use, try to get maven to help you with your dependencies, and try to get Maven to help you create an eclipse Project. Try Maven Package release Again.
12. Learn about Software testing, How JUnit is used, and how junit is used in the Ide. Have time to look at coverage tools.
13. Read the "design pattern" written by Gang of four (this book is in C + + and Smalltalk languages, but it is still suitable for java). Specifically this book, the http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612 library should be able to borrow the original english, Because I've borrowed it.
The next step is to look at the specific aspects of the application, to see the NEEDS. For example (no order Below)
"...." if you're not comfortable learning java, learn Python.
* If the concept of object-oriented programming is a bit unaccustomed, learn Smalltalk. (ruby is ok, but not as Smalltalk Classic.) Ruby's documentation is a big mishap. ）
* If Java is too verbose, learn Python
* If Java is too verbose, and you want to use the jvm, you have the energy to learn Scala
* If the relationship between objects is a bit dizzy, learn uml, and some of its diagrams, can be intuitive modeling of programs and Operations. Your IDE may have plugins that can generate UML Diagrams. But don't be too obsessed with these methodologies.
debugging and accessibility Learn about the debugging tools that your integrated development environment provides, and add breakpoints to try
* Try Jconsole or VISUALVM to monitor the status of another jvm.
* Use the Profiling tool to find the slow place in the Program. Eclipse has profiling Tools. VISUALVM also has such a function. (if you don't mind using closed source software, try Jprofiler and Yourkit)
* Some JVMs allow code to be updated at run Time. Eclipse can be integrated with some jvms. This allows you to modify the code frequently without restarting the JVM frequently. Useful for some "heavy" projects. (if You do not mind the use of Closed-source software, also try Jrebel)
"multithreading" Read FirstThis chapter in Oracle's Java tutorial, keep your eye on "Happens-before"this word, After learning should be able to write the correct concurrent program."
* Take the time to find out how multi-core processors, caches, memory relationships, and the reordering of memory Read-write instructions inside the CPU are the details of why multithreaded programming is so Difficult.
* Learn Java's multithreaded programming interface, mainlylock, ConditionUsage of
* Every object in Java can be usedsynchronizedStatement synchronization, There is a wait, notify method, but this set of mechanisms are Flawed.
* Look at the lock and condition interfaces in Java.util.concurrent.lock to see how they solve these flaws.
* After learning, learn to usefuture and PromiseTo synchronize, instead of manually using lock and Condition.
* There are alsosemaphore, cyclic barrier, count-down latch, Phaserand other advanced synchronization tools, you may be able to reinvent some wheels less.
* There are alsoBlockingqueue
* Learn how to make threads stop, and why you should frequently confirm isinterrupted () rather than thread.stop () (see the Thread.stop () document in the Java api).
* If You're comfortable, learn to use runnable to encapsulate "tasks" instead of "threads", with Java's ownthreadpoolexecuter, Forkjoinpooland other tools to help you manage your THREADS.
* You should have noticed that many of the containers inside java.util are not thread-safe, but java.util.Collections can help you create some secure versions. Also pay attention to java.util.concurrent inside there are concurrentmap and other containers for Use.
* If you are free, look at the memory model (Memory Consistency Model) andNo lock synchronization(see Java memory model and java.util.concurrent.atomic).
* If you are free, see if there are other models besides "shared memory multithreaded programming" (multi-process multi-processing, Messaging Message passing, etc.). Maybe you've fallen in love with Blockingqueue.
"reflection, meta-programming" Learning JavaReflectionmechanisms, and the use of Annotation.
* If you are comfortable, try the use of java.lang.reflect.Proxy.
* If still comfortable, play a game of Cglib (a Third-party library).
"network programming" Learn ip, TCP protocol (computer Professional should learn, review), learn socket programming (note that the garbage collector will not help you switch off the socket).
1. If you are not very concerned about http, seeJava.nio, learn single-threaded polling io multiplexing (Selector).
* If you don't understand the intent of nio, get to know the c10k Problem. Http://www.kegel.com/c10k.html
* If the body does not have a strange words, about the operating system (including the C Language) provided by the select, poll, epoll, Kqueue and other Interfaces.
* If the body is still not strange, try to write a file server with Java.nio.
* If there is still energy, the Internet grilled a steak there is no other communication library, such asNettysuch as
2. If you care about the Web and http, learn about the HTTP protocol and client programming with Java for HTTP.
* If you're comfortable, learn HTML and write static HTML pages (no Java required)
* If You're comfortable, write a Web parser (crawl Page) based on dom, xpath, or CSS selector in Java.
* If you're comfortable, learn Java's servlet interface (don't learn JSP first) for Web server-side programming. Learn how to use the standard servlet container, including the use of Web. XML and the concepts of listener, filter, etc. and the specific use of a servlet container, such as jetty or tomcat.
* If still comfortable, try learning a template language (such as haml, velocity, freemarker, "are there other better frameworks?"). I don't know, "string.format, if you really want to learn jsp, JSP is ok, but not recommended."
* If you still feel comfortable, learn the spring framework in the Web framework, or struts, to see your tastes.
* If You're comfortable, take a look at Spring Bean container and all sorts of messy tools Inside.
* If You're comfortable, or have a need, find out what a restful Web Service is, review http, and find the right Java Tool.
* You might think that Jackson is a useful thing to parse JSON With.
"database" Learn about relational databases (computer majors should learn, review), including sql. Choose a database management system to familiarize yourself with (such as mariadb, or (if you don't hate oracle) with MySQL acquired by Oracle. Learn from Java alone). Then look at their official documentation to teach you how to connect to this database in Java. This will involve the JDBC Interface. Also be sure to know the SQL injection security vulnerability, and how to use PreparedStatement to prevent injection!! Suggested See http://bobby-tables.com/
* May involve a "transaction" issue, so that you unknowingly start to understandJava Transaction API (JTA)。
* If You're comfortable, learn about object-relational transformations (such as hibernate).
* You can also learn about non-relational databases and how to access them in Java.
"logging" learn a bitslf4j and LogbackThe Usage.
* If you have the energy, know how many Java log frameworks are in the world, and how slf4j bridges these frameworks.
Build system learn about Ant Usage.
* If You're comfortable, learn to use Ivy to download packages from Maven's repositories to resolve Dependencies.
Versioning learns the basic usage of a distributed versioning controller (such as git, Mercurial, Bzr, darcs, etc.), and how to use it to manage Java engineering. Hopefully You've started using Maven and know why it's not good to put ide-generated project files (such as Eclipse. Project,.classpath and. Metadata) into the version controller. Then learn how to use version control in the IDE (eclipse comes with a git plugin).
* If you feel comfortable, build a linux+ssh+git server for your lab and install a Gitlab (a web interface).
* Learn the difference between "centralized version controller" and "distributed version controller" and persuade colleagues to stop using old "centralized version controllers" such as svn, cvs, or Sourcesafe.
* Open a GitHub account. If you don't like git, use BitBucket and so On.
"continuous integration" yourself (or for your lab) build a continuous integration (continuous Integration) server, such as jenkins, to compile your program regularly. It is recommended to use a distributed version controller such as Git.
* If you do open source software, try GitHub and Travis.
"fragmented tools" Amoy java.nio.files inside what to use the east, and then Amoy a Amoy apache Commons lang and Commons io have what useful tools. Commons logging do not use again, with slf4j and Logback.
XML learns xml, DOM, and XPath. XML is something that can be used Everywhere. You can also use it to write your own configuration File.
* If you feel uncomfortable, learn json and YAML.
* If still not comfortable, learn to study text file Parsing.
"grammar Analysis and compiler" learn ANTLR or other parser generator usage
* If you feel comfortable, write a calculator yourself.
* If you still feel comfortable, write yourself a domain-specific Language (DSL).
"efficient containers" Learn Fastutil or trove, if you need to do a lot of numerical calculations.
【Distributed Computing"learn the idea of MapReduce and its realization."
* If You're comfortable, learn the Scala language and Apache Spark, which is much faster than mapreduce.
【inter-process Communication"look at activemq, Mina and rmi.
Other languages (non-jvm) learn another common scripting language (such as python, Ruby, actually Perl is ok, but not recommended) and know when Java is not the best choice.
The Java language and Java virtual machines are read through (yimushihang, not read) Java Language specification, as well as with Java Virtual machine Specification.
* Learn the concepts of the following interpreter (interpreter), compiler (compiler), Instant compiler (just-in-time compiler), and optimizer (optimiser).
* If you are not afraid of the compiler topic, learn the concepts and differences between the method JIT and the tracing jit.
"memory management" StudyGarbage CollectionSeveral basic algorithms, including mark-sweep, mark-compact, semi-space, generational, mark-region, and so on, each performance, and why the simple reference counting is Incomplete. Know why finalizer performance is poor, and the standard does not require finalizer to be executed before the program Exits.
* If You're comfortable, find out how to set the heap size limit for Java virtual machines (such as the-xmx option for a hotspot virtual machine).
* Learn about WeakReference in Java and SoftReference and phantomreference, and when they are useful, and why they are difficult to implement.
* If you have the energy, find out what the memory management algorithm of the hotspot virtual machine is.
Dynamic loading of the Java dynamic loading (class Loading)
* If You're comfortable, learn about OSGi and its implementation (such as Felix or Equinox)
* If you are still comfortable, learn to write programs based on the Eclipse PLATFORM. Not the Eclipse integrated development environment, just use their graphics framework to write their own applications.
* If you still feel comfortable, write a plugin for the Eclipse integrated Development Environment.
Local/foreign Language interface Learn about Java Native Interface (JNI) and try to write a Java and C language mixed programming Program.
* If you feel uncomfortable or feel like dying, learn java Native Access (JNA), try to load the C library directly from Java without any glue code, and call the C function directly.
* If even JNA do not bother to learn, learn swig, automatically generate bindings.
* If you feel comfortable, learn Java Virtual machine tooling Interface (JVMTI) and use the C program to monitor the state of the JVM.
Cryptography learns cryptography, including coding, cryptanalysis, attacks, symmetric keys, public key systems, digital signatures, hashing algorithms, and so on, to see if Java is Implemented.
* If you feel a bit uncomfortable (you should not feel comfortable, unless you are learning cryptography, or you will always feel that your program has a security vulnerability), write a "character calculator" to relax, ask each time to enter the same name, get the character value is fixed, But it is also impossible to use other People's character value to guess their personality values.
"mobile terminal" Learn one learn Android Development.
* If you have the energy, look at the Dalvik virtual machine is going on.
* Suggest buying an iphone or ipad, or you may never want to use an Android phone or tablet.
"history" If you feel a little bored, dig into the history of the possibility of fire and java-related technologies, such as:
* AWT, Swing, Think about why very few people write GUI programs in Java. Do you think Swing's program looks comfortable? Do Chinese and disabled people like to use swing programs?
* JNDI, think of it in comparison to the shortcomings of spring Bean Container.
* JSP, think of it compared to the shortcomings of the MVC Structure.
* wsdl/soap, compare them to xml-rpc, RESTful Web service.
* XSLT, and why it is Turing-complete. But is it really better than Java itself?
* log4j, java.util.logging, Apache Commons logging, What are their problems, and why did the log4j author develop slf4j and logback?
* Why was Java originally designed?
* Type Erasure What's Going on? Why can't arraylist<int>, but arraylist<integer> can? Dig a dig in history.
Reprinted from BYRBSS Java Learning Roadmap
and some personal notes.
And if all is done ...???
<Java>< Learning route Map >
Start building with 50+ products and up to 12 months usage for Elastic Compute Service