Java, Where To Start? 558
I'm a web developer who has design and programming experience. So, VB, ASP, PHP, Coldfusion, Perl, even C and C++ I have in my belt. I also use Dreamweaver and/or do a lot of my HTML/XHTML/JavaScript coding by hand. So, the DOM, DHTML, etc, all good to me and even OOP thinking and design I have when I code. And I even have MySQL and other databases, again, not an issue here. So, my weak point is — Java — I see so many jobs out there with J2EE, Hibernate, Eclipse, Netbeans. Beside the obvious, which is to learn Java the core language, I don't know where else to go from there. There is so much! What should I read? in what order? What software do I require? UML? Swing? I mean, what is the curriculum required for someone to say they are a solid Java developer? Even assuming I have to go through Java itself, what are the good books out there?
Wrox Press (Score:5, Informative)
I started Visual C++ 5 with a book called "Beginning Visual C++ 5" by Ivor Horton from Wrox Press. When I started in Java I bought a book titled "Beginning Java" by Ivor Horton.
I would start there. Java is really straight forward OO language. The only issue you will have coming from C++ is to let go of destructors and realize Java does not use them. Many from C++ take about 6 months to stop tryng to make a finalizer into a destructor.
Thinking in Java (Score:5, Informative)
Thinking in Java is nice. And it's free. http://www.mindview.net/Books/TIJ/ [mindview.net]
If you have ColdFusion (Score:1, Informative)
You have Java. You could start by figuring that out.
Re:Good place to start... (Score:2, Informative)
I never really liked NetBeans, I tried it with ver 5 and decided to stick with IntelliJ and Eclipse.
Recently I decided to give NetBeans 6.1 a try and was quite impressed. There was little/no noticeable lag, unless I was coding while I was "running/debugging" a long-running process.
There are many things it does that I like over Eclipse.
Thinking in Java (Score:5, Informative)
Thinking in Java is a good book on the Java language. You can read it online at the author's web site: http://www.mindview.net/Books/TIJ/ [mindview.net]
Try javabat.com (Score:5, Informative)
For basic coding practice, try the free http://javabat.com/ [javabat.com] -- it has little coding problems (logic, strings, arrays, recursion) that run right in the browser, so you get immediate feedback. It's great for building skill in the basics, but it's no substitute for building larger programs. Disclaimer: I built it
Comment removed (Score:2, Informative)
Re:What about C# (Score:3, Informative)
Dice.com -
Search Java - 14480 hits
Search C# - 7146 hits
Re:In the same boat... (Score:5, Informative)
Ummm, what? Eclipse is an IDE, Tomcat is a container for web servers. Tomcat and Apache can be used with Eclipse with a nice little plugin [eclipse.org] for testing.
sun certified developer. (Score:4, Informative)
Sun has developed a program to train for java.
read at the sun site [sun.com]
java is relative simple. Those certification programs give you a guideline what is involved in certain roles. But java is MUCH and lots of simple libraries. that is what people underestimate.
I understand you might not need certification, but the knowledge described there gives a good idea what you need/can put on your CV.
Head first (Score:4, Informative)
My first Java book was: head first. http://oreilly.com/catalog/9780596004651/ [oreilly.com]
This great if you have little experience with an object oriented language. They state that they are funny...Well sometimes they are :-).
Another way to learn java is to code a little Java mobile App. This is fun, the API is quite limited usually and so you don't need hours of documentation before seeing something nice.
The blackberry IDE was free and really nice to use back in my early days. You get the basic before heading to more serious things.
Don't use Java (Score:4, Informative)
Unfortunately Sun, in its infinite wisdom, has no idea at all how to patch. They have security vulnerabilities all the time and they make you install a completely new version of Java in a new folder each time. Their "updates" leave the older vulnerable versions behind (and still accessible by malicious code). Their updates break applications all the time. We are constantly having to deal with issues like the current one we have: there are known vulnerabilities in JVM 1.6.0_05b13, but there are some serious problems with deploying the "fixed" version as it causes bizarre error messages and slows Internet Explorer down. Both are acknowledged bugs, but won't be fixed soon. So you end up stuck between securing the systems and having the systems actually work right.
Sun Java is a continual nightmare.
I'll say one thing from Microsoft - when you could use MS Java it never (not once in the several years we supported it) broke apps and patches were actually PATCHES and not whole new broken versions.
Java - just say no until they actually learn how to update and patch correctly.
Re:In the same boat... (Score:5, Informative)
Ok, you're missing my point, which is that Eclipse and Tomcat have absolutely nothing to do with each other. You don't need to "switch" from one to the other because they are used for entirely different purposes. Yes, they're both tools, but it doesn't make any sense to tell the parent that you switched because one is used to write code and the other is used to serve applications. It makes you sound like you don't know what you are talking about, and will only confuse new developers.
Re:Don't (Score:5, Informative)
As someone who's worked in Java with some of those 100.000 guys in India, they may know Java, but most don't know java well. The vast majority of programmers either here or there can solve a problem, but not consider the security risks in their solution, nor necessarily come up with an elegant design for doing so.
Having said that, I've used hibernate (once, to get it set up and configured, it works well enough we didn't have to go back and change it), struts/struts2, and tiles. Most of these are XML configuration rather than coding. If you can do make files, and handle any markup language, these won't be a problem.
It sounds like your main concern is learning java itself. Since you know C/C++ the syntax and conceptualizations won't jump out and bite you. I'd recommend grabbing a project that interests you (or that needs to be done), and just doing it. Use Eclipse, its tools will make your life MUCH easier (unless you like coding c/c++ in a vi-like environment, in which case by all means use emacs/vi/editor of choice). I'll probably get slammed for saying this, but learning java isn't any harder than learning VB, (easier than C/C++ which is what I'm currently picking up), it uses a different namespace, and slightly different approach, that's all. If you're a competent programmer (and from your post, it sounds like you are) then it's just going to take some time/hard work to get used to the new language's quirks.
One book: Effective Java (Score:4, Informative)
Once you get the basic Java syntax (which will not take long looking at the langages you already know), read this book: Effective Java [sun.com] , by Joshua Bloch.
There is also a video on YouTube: Effective Java Programming with Joshua Bloch [youtube.com].
And you can read it on Google Books [google.fr].
My own recommendations (Score:5, Informative)
Ensure your concurrency skills are up to snuff. Read about the newer (1.5+ so not that new admittedly) ways of handling concurrency in Java - a lot of older books will miss the java.util.concurrent frameworks.
Persistance frameworks are all well and good, but understand the fundamentals of how things work at the database level inside Java.
Although this changed a little with the latest rev of EJB, many sites simply dumped it and went with Spring. Worth knowing.
Pick one and know one, use that to extrapolate to the rest. My own advice is to look at Tomcat, but just knowing the basic concepts behind them is a start.
There's probably a lot I've missed, but right now I'd consider looking at those.
Cheers,
Ian
Books (Score:2, Informative)
- Effective Java from Joshua Bloch (second edition is available)
- Java concurrency in practice
- Head first series.
After that, you can chose books depending on what you want to do. And trust me you cannot find any platform/language having more resources and tools available than java.
Frameworks Are Important (Score:2, Informative)
From a 6-year Java Developer (Score:2, Informative)
Eclipse RCP is growing in popularity and is built on the OSGi service framework, which is also gaining popularity on the server side. I'd highly recommend looking into Eclipse RCP. It has a vibrant open-source community that is eager for new helpers.
Fail (Score:5, Informative)
You need to encapsulate that in a class. And your main method signature is wrong -- needs to take a String array as an argument, or else the program will say "No such method found (main)" and die.
Honestly, its almost like no one on Slashdot programs in Java some days... ;)
Re:One book: Effective Java (Score:2, Informative)
Second that, those books by Joshua Bloch are excellent! What I would recommend also is:
1. Get Java 1.6 JDK
2. Get Eclipse and get used to it as your IDE
3. Write some basic code that outputs text to your screen / console
4. Follow the Hibernate tutorials; and then use it against a database which you are familiar with
5. Buy Java Concurrency in Practice (http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/dp/0321349601/ref=pd_bbs_sr_2?ie=UTF8&s=books&qid=1220285205&sr=8-2) and implement your own multithreaded web server
6. Serve pages from your own web server, with values from your database (you will learn threading and client server programming in java which is fun)
Then familiarize your self with Swing: I wouldn't spend to much time on it - you only need to know how things work. The Concurrency book has a nice chapter on threading in Swing, which is very important.
This should take a week or two.. after that, you should be able to handle most java jobs :)
Java setup hell sucks, stay away from enterprise things until you wanna try out specific features..
Two words (Score:3, Informative)
Re:Wrox Press (Score:5, Informative)
Does Java uses finalizers? If so, how do they differ from C++ destructors?
Yes, it does. They differ from C++ destructors as they are not called explicitly(or implicitly when variables get out of scope, as in C++). Rather, finalizers are called when an object is garbage collected.
The usual advice is not to use finalizers, except to make sure that underlying native resources are released(ie. file handles, sockets, etc.). Even then, there should be a mechanism to release those resources without relying on the finalizer being called, such as a close() method or an equivalent. The finalizer is only guaranteed to be called when the object is GC'ed, which may happen much later than expected if there is not a lot of pressure on the memory system or if there is still a reference to the object.
There is no guarantees that finalizers will ever be called for an object, as the VM can be forcibly interrupted via Runtime.halt() and finalization of all objects on VM shutdown can be disabled.
Just two links (Score:2, Informative)
Re:Wrox Press (Score:2, Informative)
Re:Wrox Press (Score:4, Informative)
In a garbage-collected environment you typically don't provide the allocator or destructor. Similarly, you don't need your finaliser to handle destruction of instance variables, since the garbage collector will do this for you. The only thing you need a finaliser to do is release any resources that are not managed by the garbage collector. This includes locks, I/O handles, and so on. In Java these are typically wrapped in an object of some kind, so you don't need to explicitly release them either, since the object encapsulating them does this. You would use a finaliser in a class which used the native code interface to acquire resources from the operating system or some other source outside the JVM. Without doing this, you would leak.
Re:Wrox Press (Score:3, Informative)
There's a useful trick with finalizers:
public class Something implements Closeable
{
public Throwable stack;
public Something()
{
try
{
throw new IllegalStateException();
} catch(Throwable t) {stack=t};
}
public void close() //...
{
stack=null;
}
public void finalize()
{
if (stack!=null) stack.printStackTrace();
}
}
So you can use finalizers to detect 'leaked' objects. I.e. objects which must be explicitly closed/disposed/whatever but you forgot to do it.
Suggested books and tools (Score:3, Informative)
BOOKS
-----
Learning Java (O'Reilly) - one of their better books in recent years, and actually kept up to date with new editions
Effective Java (Addison Wesley) - preferably the second edition, which covers generics
J2EE Design And Development (Wrox) - heavy going, but it's simply the best book on J2EE development
ANT In Action (Manning) - describes the de-facto build tool in the Java world, which can also automate things like deployment
TOOLS
-----
Checkstyle http://checkstyle.sf.net/ [sf.net] - a basic static analysis tool
PMD pmd.sf.net - a more advanced static analysis tool
THINGS TO AVOID
---------------
EJB - it's gotten better in version 3.0, but a lightweight framework like Spring is still a better choice for almost every project
Maven - it might be great for some Apache hosted projects, but it's caused more problems than it solves on every system I've worked on with it
Re:Start simple. (Score:4, Informative)
Many people seem to fancy rolling their own when they need something, without realising that it's already in the standard library. For instance, a couple of years went by before I realised that there's a Logger class to handle all logging needs.
Logging's a bad example. There were a ton of logging libraries around because Sun didn't bother adding logging until Java 1.4, and even then, their logging implementation is subpar compared to some other packages out there.
Speaking of exceptions, do not catch Exception, and do not catch Throwable, unless you know exactly why you should do that.
Oh God yes. I've forgotten the number of times I've seen the anti-pattern:
The great thing about that is that it means that there's no way to tell the difference between "an error occurred" and "the object doesn't exist."
I'd like to say this is less common now, but the last time I ran into it was last Friday, i.e., the last time I was at work. I spent a good chunk of time making methods throw exceptions.
This isn't to say that catching exceptions and ignoring them is never safe, sometimes it is. But unless you can come up with a good justification (and then leave a comment explaining it!), don't do it. It'll just piss off other developers when the applications randomly stops working for no readily apparent reason.
The point I miss is the "why?" (Score:4, Informative)
So, while I get that the asker of the question is very serious, and some people answering him also, I don't get what the motivation about questions like this are. I mean: the guy tells us he basically knows everything (languages, tools, concepts) that is important about "programming".
So I would ask the asker: why do you want to learn/use Java?
So, the simple answer to his question is: ;D and a very short introduction into the syntax of Java)
just start coding. Besides an IDE you don't need anything for starting to work with Java (probably knowing how to browse Java Doc
The more complex answer: ... you don't really specialize your skills and neither you really broaden your skills (Java, C# etc. don't really add anything you don't already know from C++). You only add some TLAs to your skill set and you fit "at a first glance" better to job descriptions.
If you add Java to your language zoo
UML ... not MDA, that is to complex) will broaden your spectrum. Hint: Eclipse + OAW might be interesting to you. OAW is a MDSD tool chain, based on Java (if you use that, you will program a little bit in Java). With OAW you basically write your own generators, to transform specifications from UML into your language of choice (via templates and "Scripting" in Java)
If you did not use UML so far, you don't need it for Java either. However: learning UML and something about Model Driven Software Development (MDSD
Databases, Hibernate, MySQL ... but it goes to far to discuss this here) and also don't dig into JDO (Java Data Objects, a Java API) while the base idea is not to bad, most implementations just suck.
If you want to work with DBs you need a very basic knowledge about JDBC (a standard Java API) because all DB Frameworks use JDBC under the hood somehow / somewhere and the configuration of your DB access (URLs, Users, Passwords, Connection Pooling) will be always very similar regardless what framework you use. Besides Hibernate I would suggest to look at iBATIS, also (you will need the iBATIS book). EJB 3.0 is overkill IMHO (yeah it is not only persistence but also services etc.
Swing
First, a lot of people out there find Swing over complex and prefer SWT. I strongly suggest that you stick to Swing for several reasons. The complexity of Swing might increase your learning curve a bit. However, sooner or later you will need the features Swing gives you. And when you are a bit experienced in Swing, you will be very fluent with it. Note: Swing will be greatly improved in Java 7, when the "Swing Application Framework" is integrated (beta of that is available for Java 6 right now).
Similar to Swing and probably interesting for you is googles GWT (Google Web Toolkit). The programming model is very close to Swing. GWT is used to program (preferred in Eclipse, using the GWT Plugin) in Java, having Server side Code in Java, running on a Web Container (e.g. Tomcat) and having client side code programmed in Java, but cross compiled into Java Script running in a Web Browser (AJAX style).
Beyond Java ;D).
Just learn enough Java to be able to compile simple programs (well, 2 days or something
Then learn Groovy. Groovy is a "dynamic" language, that compiles to Java Byte Code and integrates into the Java Platform. Groovy is mainly used for scripting, but it is a serious platform for development as well. Groovy is also used to develop Domain Specific Languages(DSLs), one thing that will become a future market.
Dig into Ant, a "XML based scripting language", mainly used for build files. But don't be tempted to use it for to much. If you find Ant useful, and if you got a grip on Groovy, then use gant.
Groovy uses a concept of builders which is used e.g. to program Swing UIs, to "build up" Ant-Scripts (gant), to "invent" DSLs (for configuration of your Java/Groovy programs) which can be adapte
Re:I beg to disagree (Score:5, Informative)
Doing java dev for more than 10 years, I think this is a valid question. Java is not about the core J2SE anymore, I was fortunate that java evolved along with my career, so i picked things up as they came to market. Further google is excellent if you know what you are looking for, however in this case, the author does not even know what he is looking for.
Now to answer the question.
First read Just Java by Peter van der Linden (if I spelled the name correct). Excellent book.
Get Eclipse IDE and learn jdbc, JSP/servlets, and struts preferable in that order. Except for struts Just Java should give you a primer on each, struts has a decent website with tutorials.
I would skip EJB/J2EE for now and jump to spring and later hibernate. You will find great tutorials on their websites.
Somewhere along the process also introduce yourself to JNDI, particularly JNDI when it talks to LDAP, this is a given when u are coding an enterprise app.
At this point you would know enough to do a decent job as a java developer, more importantly you would know what to do next.
This is what I can think of on labour day long weekend :)
Re:Avoid persistence frameworks (Score:2, Informative)
Yes and not. All the O/R mapping layers have known good things and drawbacks (The Vietnam of CS [tedneward.com]) but specifically Hibernate it is a very wide deployed technology and ergo, recommended to the OP. Sadly, their "official" documentation sucks (apparently most was written by the original head developer): in many instances the javadocs do not explain the exact or complete semantics (apparently they assume you will be checking their source code all time); the confusing issue of their "default and broken connection pool", etc. Anyway, despite parent comments, they let you run plain SQL querys if you want or need.
Re:One book: Effective Java (Score:3, Informative)
That version on Google Books is the first edition, from 2001. It only covers feature from 1.3 and earlier.(Only a handful of 1.4 features were touched on).
The second edition was released last month and now covers up through 1.6.
http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683 [amazon.com]
Re:I beg to disagree (Score:5, Informative)
You have to start somewhere. Just like if you wanted to learn PHP, the PEAR toolkit, and Drupal or some other 'framework' for Web applications in PHP, or whatever. Or, as an example I'm more immediately familiar with would be knowing Python, mod_python, Django, WSGI and a database like MySQL or Postgres.
You start by learning Python. Then you move on to MySQL. And then you might learn mod_python and finally WSGI and then Django. But you have to start with one concept and move on the next and the next and the next until you have enough knowledge to cover what you need to know.
So with Java, you might start with Java, move on to Netbeans, etc. Learn any frameworks, etc. You start with one thing and move on to the next. YOu need to learn increasing levels of complexity. SO obviously you need to have a grounding in Java before you learn Swing. And Java basics before J2EE. And so forth.
Re:I beg to disagree (Score:5, Informative)
As regards frameworks, take a look a Spring - but not until you understand core Java (the principles, not the libraries). Spring has a Web Container but Tomcat is better if starting from first principles (or, at least, it used to be good. It's the "reference" Servlet container, for what it's worth). EJB container: do it with Spring (or some such). JBoss has (is? I don't know any more) an EJB container. EJBs are low-priority: they're really just a kind of "sandbox" environment where resources are closely managed. Thankfully, that environment has just become easy to program.
As regards IDEs, Eclipse is what I use ATM. Most vendors' IDEs (IBM, Oracle) are built around Eclipse. It's pretty easy to run simple programs there but the interface isn't very familiar (jargon-wise) to newcomers. I hear that NetBeans is very good these days.
Re:I beg to disagree (Score:5, Informative)
That should give you enough to get started and maybe even get your first Java gig. Hibernate's good to learn, too, but on most of the projects I've been on, you don't use it in day-to-day development (that is, you don't have to reconfigure or redeploy anything, unless your data model changes). With Spring, just about everything you write will require that you modify a context file or two, so you need to know what's going on.
Re:Don't (Score:5, Informative)
Portability is a nice word that Java people like to throw around, but in my experience, the program has to be set up separately for just about every target. You can do that just as well with C (Brew, as far as phones are concerned), and without a handful of different project files to include or not include target-specific files.
Not to mention that, on comparable phones, Java performace is abysmal compared to Brew. Not fast.
Java has its place, where its benefits can be well exploited. That place is, as far as I've seen, largely restricted to situations where the systems it'll be running on are not terribly diverse, e.g. Linux servers, where portability really isn't that much of a concern.
Sun Java Tutorial (Score:3, Informative)
Wow, what a load of advice to launch into frameworks, buy books, get certification etc.
Start with what's authoritative, basic, and free. That's the Sun Java Standard Edition tutorials
http://java.sun.com/docs/books/tutorial/ [sun.com]
Or download from:
https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=tutorial-2008_03_14-oth-JPR@CDS-CDS_Developer [sun.com]
The web and persistence frameworks are important. They're over-engineered and I hate them but if you don't know them you won't get work. (Without them it'd be very much like trying to become a game developer knowing only ANSI standard C and no frameworks). They're what you need to learn second. Possibly on a smaller project where you're not the lead. However learn to crawl before walking or flying.