Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Possible Duplicate:
Going from PHP to Java

I have been working at my current job for about 4 years. I have been doing PHP for twice as long. I am completely self taught (with lots of internet and friends help).

I recently found a job posting for a Java developer and I am wondering what I need to know about Java to prepare. I took 2 college course on Java so I am looking a little beyond Hello World stuff (actually just installed Eclipsed and wrote it again). I hear they also do Flex so anything on how Java and Flex work together would be great as well.

My first step is going to be to remake a project I built in PHP using Java.

This is similar but the answers aren't very specific. Going from PHP to Java

Thank you and I apologizes if this should be community wiki.

share|improve this question

marked as duplicate by Mark Trapp Feb 20 '12 at 23:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Why don't you want to move to Java? just because of the new job? –  Goma Jun 6 '11 at 12:58
    
@Candle You mean why do I? Mainly for the job as I can't find any PHP jobs where I live. But it also would be nice to have another tool in the toolbox. –  Samuel Jun 6 '11 at 13:04
2  
You should be commended for attempting to expand your knowledge base. Learning Java is not a condemnation of PHP, just another tool to add to your shed. –  maple_shaft Jun 6 '11 at 13:10
    
Great if you have the opportunity to learn java or re-learn java, Java works fine with php, but java carrer is well paid in the market in general context. But it all depends of your knowledge and skill in such a language, if you are php developer with large experience, why change? But if you are looking for new horizons java is a great choice! Well, think all about, changes is always great to our mind in a humam context.. Good Luck with your decision. –  B4NZ41 Jun 6 '11 at 13:14
    
@maple_shaft is quite right, indeed you should start to expand your horizons right now if you want to grow as a developer –  David Conde Jun 6 '11 at 13:27

5 Answers 5

I don't think your problem is going to be learning java, since you're probably more than capable of downloading eclipse and opening a book and reading, trying examples, etc. I think re-implementing a php project in java is a good starting point. But the problem is likely going to be finding a job in java. Er....or rather finding a job that someone will hire you for at a price you'll find acceptable.

It's like this. I was doing c for several years and I wanted to get into .NET. So I learned it on my own. I was actually pretty good at it at the end and so I started job shopping. Then I realized that there were two problems:

  • The places that wanted to hire me were not willing to pay anything close to what I was already making. They were essentially low-balling junior engineer positions. So they didn't care what I knew.

  • The places that were probably going to pay an acceptable rate started in with "On, C is a procedural language, and .NET, well it's object oriented. Are you sure this is something you can handle??" And nothing I could say in an interview was going to convince them that I was capable. In retrospect I'm not sure why they brought me in to interview, but...anyway!

So what happened? Am I still coding in c? No, but I did find a job in c++ (I was later told that even in this case they felt I was a risky hire). And then my next job after that was c++ officially, but I ended up getting moved to a java project. And now I mostly do java. I've forgotten all the .NET stuff I learned several years back.

I'm not sure what the take-away is, except that it's really hard to move from one language to another (and especially when the languages are as different as php and java). Not because you're unable to do the job, but because of the risk you represent and the biases of hiring managers.

share|improve this answer
1  
The good news is I don't get paid much where I am now. Even though I now do full-time Web Development my title is still Web Administrator. Hence my motivation to find another job. –  Samuel Jun 6 '11 at 14:28
1  
that certainly makes things easier. –  Kevin Jun 6 '11 at 14:32
    
The point Kelvin rises is prety valid, however I dont think it applies to you... A Java jr position pays better than most Proficient and even Sr positions for PHP. So I wouldn't be worried. Also, because PHP is intended for Web applications you have almost certainly developed skills that will come handy on a Java Web career. –  Chepech Oct 4 '13 at 13:25

The main problem with PHP programmers going to Java (or C#) is that with PHP you can get away without writing object oriented code, and the libraries were meant to be so modular that they may look as "random pieces of code". However, in a language like Java or C#, object orientation is everything and they have massive libraries working in sometimes a tight integration.

I'm not saying that you really shouldn't go for it, but just beware, coming from a weak typed language to a strong typed language which is also purely OO, the learning curve should be steep at best. So ,I urge you to make some real project on Java and then move into a Job (consider freelancing some Java job).

On the other hand, if you feel very confident and you see you can learn (reaally) fast, then give it go, like someone said: "You need to follow your heart" and it should be allright.

Hope I'm not too pesimistic, :)

share|improve this answer

Once you get past the syntax, there are a few more key concepts you should understand.

  1. Unit testing -- learn junit. This should be similar to phpunit (if you have been using that).

  2. Concurrency, threading, and event handling. Php does not have threading. It does permit file and record locking, so these concepts should not be entirely foreign to you. When you get faced with a situation where you have concurrency, please take the time to understand ACID, and how to do this in Java.

  3. There are many packages that provide various, useful capabilities. This concept is similar to php libraries. The equivalent in Java is packages. There are packages that handle I/O, Networking, Collections, User Interfaces, Reflection etc. At any rate, you should become familiar with the JavaDoc API documentation, the key packages, and what capabilities they provide. You do not have to understand every single class and method, but you should understand how to search and find what you need.

  4. You should get very intimate with Collections and Generics, understand jar files, and that, in addition to .class files, you can embed other types of files as well, such as images, sounds, text, XML, and any other file your package needs at run-time.

Even after years of writing Java code, I still occasionally refer to Sun^H^H^HOracle's Java Tutorial to refresh my memory on how specific packages work, or use a package I haven't had to yet. As you are learning the language, I would suggest that you go through the basics trail first, then others as you need them. For instance, if you need to read and write XML files, go through the JAXP trail.

There are also some open source frameworks that you should investigate:

share|improve this answer
3  
and actually if you're using spring you'll probably use spring-mvc rather than struts. –  Kevin Jun 7 '11 at 0:15

You will notice that they are very different animals. Java technologies encompass a wide array of software development where as PHP specializes in web development. With that being said probably the easiest thing for you to pick up will be JSP pages.

To be a good Java developer who is worth hiring I expect a thorough understanding of the following concepts.

1) The Java Runtime Environment, interpretation of byte code, garbage collection, command line interpretation, etc... 2) Java compiler, compilation of Java source code into platform independent byte code, invoking from the command line. 3) The Classpath 4) Basic syntax 5) Thorough understanding of the standard libraries

These are all vitally important to understand but are just as important as universal developer knowledge such as the SDLC, best practices, etc...

I commend you for trying something new, but with that being said you will have an uphill battle without direct Java experience on your resume. I am not making any unjust assertions about you, but their are a lot of PHP programmers who don't understand how to write software that scales to the enterprise level. I am sure that you have experienced a few in your career.

As someone who interviews Java developers and influences hiring decisions, I am very careful about evaluating candidates who have a large amount of PHP on their resumes by being very thorough in technical as well as general enterprise development knowledge.

share|improve this answer
1  
By reading your answer, I got the notion that ability to think abstract, to solve problems and to be able to find answers to solving problems is shadowed by the fact of knowing how to interpret byte code and what not. Also, I found out that PHP devs are bad because PHP is, well, "easy" and web dev toy. I also read that Java devs somehow know how to write scalable apps and PHP guys don't. I'm not trying to start a flame war, but you sound really, really subjective. I can tell you I met just as many bad PHP, C++, Java and C developers, it's not right to label devs by language they code in. –  Michael J.V. Jun 6 '11 at 13:23
    
I am not meaning to flame. There are certainly bad Java and C++ developers as well, but some important facts about PHP remain that disservice PHP developers in the Java EE world. PHP does not support strong types and does not encourage OO practices. That doesn't make PHP or PHP developers inferior but it does make it hard for them to fit in a Java EE environment where object oriented development is crucially important. Yes, yes and I know PHP supports OO but it is not widely used. Don't get me wrong, PHP is great but sometimes a clawhammer is more suitable than a mallet. –  maple_shaft Jun 6 '11 at 13:48
    
On a note to my analogy of the Mallet Vs. Clawhammer, I am not saying that a clawhammer is ALWAYS better than a mallet. Mallets make more sense for pounding things without causing damage or resealing paint cans, clawhammers are more precise, have more power and are better equipped for fixing mistakes (maintenance, Eg. pull a bent nail out). –  maple_shaft Jun 6 '11 at 13:54
1  
I'm not trying to make this PHP vs Java or something similar, but you have a lot of prejudices. Yes, PHP is both OO and procedural language, much like C++ is. However, OO programming IS NOT complex. It sounds different, but it's just another method of organizing the code, no matter how you look at it. No one will hire a PHP dev who doesn't know how to use PHP's OO capabilities and PHP does support fundamental data types, the benefit is that they don't have to be explicitly declared. I'd always look for a smart guy who can adapt rather than someone who knows lots of stuff but can't do anything. –  Michael J.V. Jun 6 '11 at 13:58
1  
Anyway, we made this into a PHP discussion - my original point was that there should be no distinction between what language spawns bad or good programmers. If one knows how to think logically - picking up another language will not be such a huge problem. –  Michael J.V. Jun 6 '11 at 14:51

I migrated from PHP to Java too. I too had some prior basic knowledge and experience with Java. I would recommend this book: http://www.amazon.com/Professional-Java-JDK-Clay-Richardson/dp/0471777102

Unlike many others, it is not written for dummies, and does not contain corny things like "What is an object" or "how to run your first program". This book is a guide for beginners who want to become professionals.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.