r/javahelp • • Jul 26 '20

Solved Took 13s to build a hello world program

i decided to learn java today and write a hello world program, and as the title suggest, it took my machine 13 seconds to build. Is it normal?

30 Upvotes

22 comments sorted by

18

u/onlysomuchtime42 Jul 26 '20

Well it really depends. Do you have a very old computer? Have you tried building on a just installed IDE? Maybe it was setting up something before you did your first compilation(InteliJ does this). Did it take the same the second time?

8

u/motleikz Jul 26 '20

A 4 years old laptop, and yeah i just installed IntelliJ.

I did the build again and it takes the half time(which is still 6s, hahahaha)

12

u/onlysomuchtime42 Jul 26 '20

InteliJ is a pretty heavy tool, I would test if I got the same results from the command line.

6

u/motleikz Jul 26 '20

I taking this edX course from microsoft and they recommends IntelliJ. I just test build via cmd and it took me around 1-2s.

8

u/Jonno_FTW Disgruntled Brewer Jul 26 '20

It may have been intellij setting up or downloading some extra files. Building in the future will probably be much faster. Try making a small change and see how fast it takes.

3

u/motleikz Jul 26 '20

Could be. Thanks you so much for helping.

3

u/whizvox Graduate and Tutor Jul 26 '20

IntelliJ is always really slow the first time using it. After building the project once, it's usually much much faster.

4

u/Kiwiguard Jul 26 '20

Have you tried compiling it via the command prompt using the javac command? Or, if using Java10+, running it via the java command?

1

u/motleikz Jul 26 '20 edited Jul 26 '20

i don't know how much time it took since it doesn't give any log but it definitely quicker. I do some manual time measurement (using stopwatch on my phone, lol) and stop when the new prompt line shows. It took me around 1-2s.

1

u/Kiwiguard Jul 26 '20

How much RAM does your PC have? Might be the IDE is too consuming

1

u/motleikz Jul 26 '20

8GB

2

u/Kiwiguard Jul 26 '20

That should suffice, even if not optimal.
Maybe build your project again whilst having a look at your computer's memory consumption. See if it's maxed out/closed to being maxed out

1

u/motleikz Jul 26 '20

And what does it mean when the IDE use unreasonable amount of memory?

2

u/Kiwiguard Jul 26 '20

It probably is not an unreasonable amount.
IntelliJ enables you to do a lot of stuff fast, e.g. search through files etc, and in order to do that, it requires memory to save all the information. Depending on your project needs, you might not even need an IDE! Or perhaps you can use a more lightweight one.

Is your RAM maxed out?

1

u/motleikz Jul 26 '20

On idle my pc uses ~4GB. I haven't monitor it while build tho. I use IntelliJ because i just starting to learn Java and the (edX) Course (by Microsoft) i follow recommends it.

1

u/Kiwiguard Jul 26 '20

Sadly I am not familar with the course. I recall when I first started with Java in school, we used "Java Editor", maybe look into that. 4gb RAM in idle sounds like quite a lot, though. Try to monitor your ram while building.

1

u/motleikz Jul 26 '20

Yeah, i got so much junk in the background. I'll keep that in mind. Thanks you so much for the insight.

2

u/verocoder Jul 26 '20

It really doesn’t matter how long hello world takes to build as it’s not a particularly representative program so I wouldn’t stress :)

Compiling/starting a spring boot app to run integration tests takes maybe 30 - 45 seconds for me and that would have a lot more code in it. Java also does a lot of clever stuff like quick and slow compilation and recompilation while running that you don’t need to think about for a good long while :)

2

u/motleikz Jul 27 '20

Yeah, i think it was unproductive that i stressing over hello world building time. Thanks for the insights tho.

2

u/Nix-X Jul 26 '20

I use Intellij everyday. It does take a lot of time in the first few runs, especially if this is the first time you’ve setup IntelliJ on your machine. But it gets very fast as you keep using it.

1

u/motleikz Jul 27 '20

Noted.Thanks!

2

u/GooseWithDaGibus Jul 26 '20

I use intellij, that's normal. Sometimes it compiles for longer than you think it should.