Reputation: 12436
I am developing my first Java web application (Spring/Hibernate/Freemarker) and my only concern is development speed.
I used to develop in PHP, where it was sufficient just to reload the browser to see the result. With Java, I need to always click on "update resources" in my IDE just to see changes done to templates. It seems to me that this way of developing is really inefficient as the redeployment takes up to seconds.
Also, I am not the one who will be preparing the templates - it will be just a graphic guy and he will want to test them as well. Does he need to have its own application server and keep redeploying the application or is there some more "PHP" way where you just "reload" the page?
Upvotes: 2
Views: 204
Reputation: 340933
Yes, development speed is a major concern and drawback compared to dynamic languages and platforms like PHP or Rails. Obviously Java wins in different areas, but here are few tips:
Prefer unit-testing to redeployment - if you feel comfortable with unit testing, you greatly reduce the amount of redeployments. I found myself deploying complete feature only once, when it's done. All the logic is already tested so I don't have to deploy over and over, wasting seconds or minutes.
Also when I start to work on GUI, I don't have to back to the back-end, since I now it works. Once I see repetitive redeployments I try to test it using JUnit instead.
Use better frameworks. Spring MVC is very conservative, albeit being very good and pure. I've heard Play! framework can reduce turnaround time by recompiling classes on the fly.
On the other hand modern JVM frameworks like Grails can speed-up your development because they create domain, CRUD and GUI for you.
Some frameworks promote loose-coupling of templates. If you are using Freemarker or plain JSPs, it is hard to work separately on GUI. But frameworks like Wicket decouple to a great degree Java code from templates written in plain HTML. Also I am currently working on an application that is only serving static HTML and the dynamic content is updated via AJAX/REST services and JavaScript.
Consider purchasing JRebel and have a look at built-in hot-swapping features in the JVM. Sometimes changing the code does not mean redeployment.
IntelliJ IDEA can update modified resources (HTML, JavaScript) on the fly when the window goes background. This means that your resources are updated the moment you switch window from IDE to the browser. Probably other IDEs can do this as well.
Upvotes: 6
Reputation: 1543
You can customize your IDE to update your deployment automatically. Changes to web pages does not really require to redeploy an application, because Java servers updates them on-the-fly. Regarding your second question - you can create some common installation visible on number of computers, and customize IDE (or write scripts) that copy new pages to the deployment.
Upvotes: 2
Reputation: 2624
You might want to take a look at the Play framework which does just that - it lets you update your code (HTML, CSS, Java) and see the results immediately after pressing the refresh button in your browser, without the need to redeploy you application.
Upvotes: 1