views:

69

answers:

3

Every time I change my Java class, I have to transfer the built class file to the web server (which resides in another machine, in my case). This is not only mundane, it's too mechanical, laborious and mundane.

This IMO is THE biggest turn off with Java vis-a-vis other platforms. Especially for noobs.

There are so many smart programmers in Java and I'm sure they must have found some workaround/hacks/solutions.

Out of frustration, I wanna know. What is it?

[I know, Java is a compiled(for all practical purposes) language and so we don't have a choice.. yada wada.. any solutions?]

Edit: I'm not referring to deployment, I'm referring to development. As a developer, while fixing a bug, if I change a class, I need to transfer the class and probably restart the webserver. I need to do this for ever small change I need to test.

+3  A: 

Sounds like you are looking for a build tool like Maven, Hudson, Ant etc. I have experience with the former, and it can indeed solve the deployment problem via its various plugins, such as Cargo or JBoss.

Update

When you change even a single class, you may be tempted to do a patch by uploading only that single class file to the server. IMO that is a bad idea. The tools to (re)deploy your web app in an automated, reliable, repeatable way are there - you are better off using them rather than doing the job by hand or trying to reinvent the wheel. Trying to upload only the changed files is trading your own precious time for some network bandwidth - a very bad deal by itself. But if I add the risk of breaking the consistency of your app, it is even worse.

As a developer, while fixing a bug, if I change a class, I need to transfer the class and probably restart the webserver. I need to do this for ever small change I need to test.

In our project (a legacy app containing about 4000 classes), this exact process is working like a charm, fully automated.

In the development phase, I try to write unit tests first to verify that my code change works (since its legacy code, unit testing is not always possible, but most of the time still). Then I build the web app with Maven and it is automatically deployed to the JBoss server on my local machine, so that I can test the change.

Once I am happy to commit the change, an automated build is run by a Bamboo agent, which runs all our unit tests and also stops our Continuous Integration server instance, redeploys the freshly built EAR file, then restarts the server. Afterwards, some integration/smoke tests are run in another, dependent build. Both builds send an email report to the whole team.

Took some time to get here, but it works now :-)

Péter Török
No no, this not about deployment. I'm referring to development.
pavanlimo
Oops @Peter. Agreed. However, I need to transfer only the class I have changed, not all of 'em.
pavanlimo
This answer has nothing to do with the question, why are people upvoting it?
Esko
I agree whole heartrdly on that edit. Uploading one file is inappropriate at best
Woot4Moo
@Esko Because it answers the question adequately. And updated post answers updated question.
Nikita Rybak
Does that mean, I have to transfer 1000s of my classes for one small change? Isn't it bulky and unreasonable?
pavanlimo
You have no idea how quickly you will put your application in a disjoint state
Woot4Moo
@Peter All those steps are done for dev testing?(for the developer who's made a small humble change in the class and wants to know if his change works as expected?). The developer hasn't yet committed the code here. He is only checking if it works.
pavanlimo
@pavan, OK, dev testing is _slightly_ different, in that the web app is deployed on my local machine instead of a remote server. But by the time I deploy that change, I should already have some unit tests in place which make me reasonably confident that my code change works.
Péter Török
A: 

This can be automated with Ant. Its a matter of writing a simple script and running that script as part of your build process

Woot4Moo
But I need to transfer only the class I have changed, not all of 'em for testing.
pavanlimo
thats very bad practice
Woot4Moo
@Woot4Moo Could you elaborate, how's it a bad practice?
pavanlimo
When I get home ill edit my post for you to explain how it violates good engineering practices
Woot4Moo
+4  A: 

There's nothing that prevents you running the server on your computer inside Eclipse or any other IDE in debug mode. Yes, it's a bit cumbersome but then again, Java isn't meant to be developed in the same sense as for example PHP where you write something, see if it works and then write some more, you're expected to be a lot more professional.

I guess that also means Java isn't a "quick and easy" language to have "fun" with.

Esko
:( Don't say that!
pavanlimo
@pavan: Well, that's how things are if you're trying to do end-to-end functionality fast with pure Java. There's a plethora of options nowadays though such as Play Framework, Grails, Groovy in general, Scala, Jython... if you want to do rapid development. It all boils down to what you want to do.
Esko