0

This is basically a code development question that deals with frequent changes to one or more java files among many thousands.

A few years ago, as a software intern, I was given a large java / jsp code base and my mentor set me up using intellij IDE to build a WAR file for a web application (a student portal). I would then copy the War file to the tomcat container and launch it. I don't recall, but I recall to the effect that all I had to do was to press that one button (build?) to generate the WAR file. It took a long while to generate this War file. Intellij used an Ant file to build the war file. The team later migrated to Maven, but that's when my term was up.

Software development was very slow because I wanted to write code, compile and test code often in the web browser. There wasn't unit code testing.

So here's my question:

What does the industry do (for example FANG) where if I wanted to just modify ONE java file, how would I go about in a much faster fashion to compile that one file instead of recompiling every file to create a WAR file and then put it into the tomcat container and run it?

I just want to minimize the amount of time from inserting code to checking out how it behaves.

I tried to write my own batch script but taking into account all the thousands of java dependency was a nightmare. this this post. This is my first post since many years ago. I appreciate for someone to shed light on how I can approach this.

I wasn't happy with using this IDE solution because there was a very senior software engineer who didn't use an ide, isntead, used emacs on his mac. He got things done fast, but I didn't understand how he would go modify a few files and got it to run on tomcat. I can't imagine that he'd recompile everything. So please share with me some work flow using IDE and also preferably not to use an IDE.

I did my research and google but couldn't find an examnple tutorial of how such would be done. One reason I ask this question is because if I ever get a software engineering job, I would not want to modify one file and take forever to recompile everything.. it just doesn't sound like the way to go. This wasn't taught in school.

If there is a git project that deals with the above.. I'd be grateful if someone can send me an exampile git project that deals with the above webapp scenario.

Thank you. Gordon

asked Aug 2, 2019 at 23:30
8
  • Learn to use make Commented Aug 3, 2019 at 9:13
  • Please take time to read norvig.com/21-days.html Commented Aug 3, 2019 at 9:43
  • Read much more about build automation tools. You could use ninja Commented Aug 3, 2019 at 9:47
  • @BasileStarynkevitch I'm not sure whether make or ninja are a good replacement for Java-specific tools like ant, maven, or gradle. Commented Aug 4, 2019 at 16:55
  • I am not sure neither. I never coded serious stuff in Java. Commented Aug 4, 2019 at 16:56

1 Answer 1

1

It took a long while to generate this War file.

The Java compiler (javac) runs very quickly even on large projects. Related build tools such as maven or gradle not necessarily, even on small projects. Using them is still a good idea.

I just want to minimize the amount of time from inserting code to checking out how it behaves.

Some IDEs integrate a servlet container with hot-reloading and background compilation. The result is that you can quickly run the changes in a local environment, without having to build a WAR file first.

Where this isn't available, it may be possible to embed a server like Jetty into the application, so that it can be tested without deploying to Tomcat.

What does the industry do (for example FANG)

How large companies do software development often has little bearing on how you should do development. Large companies can be surprisingly dysfunctional, and sometimes they just put up with such frustrations. For many build-related problems, more hardware might be the cheapest answer. Keeping application smallish is another popular approach (→ microservices).

I wasn't happy with using this IDE solution because there was a very senior software engineer who didn't use an ide, isntead, used emacs on his mac. He got things done fast

IntelliJ is a great Java IDE. There's no better environment for writing Java code. Emacs is, well, Emacs. People who are productive with Emacs or Vim aren't productive because that software leaks magic ×ばつ engineer juice, but because those people have spent a lot of time familiarizing themselves with these tools, sometimes to the point of writing their own plug-ins. In both IntelliJ and Emacs, you can compile the project with a single keyboard shortcut – the Emacs user is just more likely to know that shortcut.

You are also missing the possibility that the very senior engineer isn't productive because they don't use IntelliJ, but despite using Emacs. Knowing what you're doing is more important than the tools you're using, but using good tools is still good.

answered Aug 3, 2019 at 7:44
5
  • If I could upvote 10 times, I would. Bravo! And yes, I am still using emacs to code my Bismon GPLv3+ project. Hopefully for not too long ... Commented Aug 3, 2019 at 9:41
  • And emacs 26 is still e good enough tool! Commented Aug 3, 2019 at 9:45
  • I'm an emacs user too! One emacs editor is better than juggling five different IDEs, but let's face it: IntelliJ is a much more productive environment for Java. Commented Aug 4, 2019 at 16:59
  • @amon none of these comments help. I said IF the company produces a WAR file. Pls guys, stick to answering the question how I can compile one file without recompiling every file. You've mentioned ant, maven, etc, but can it just recompile that one file instead of recompile everything? If so how? Commented Aug 4, 2019 at 18:57
  • @gordonprog I understand your frustration, but just because you deploy via WAR does not mean you have to test via WAR. Commented Aug 4, 2019 at 19:02

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.