Is there a way to add a standard header comment in one place and it will apply to all my source files in my project? the header would contain my name, contact details, company, license etc.
6 Answers
If you are looking for a tool with a good Eclipse integration (and a nice GUI), I suggest: Eclipse Copyright Generator
This adds:
- a new Panel in the preferences (global or project based) with: Menu > Windows > Preferences > General > Copyright.
- a Menu Menu > Project > Apply Copyright...
- a realy nice Wizard with a lot of options and some default template for Open-Source licence (Apache, EPL, ...)
I just tried it with eclipse 3.6 and it work fine.
There is an update site to install it:
https://dl.bintray.com/jmini/Eclipse-Copyright-Generator/

- 9,189
- 2
- 55
- 77
-
1
-
It works pretty well but with one annoying caveat on Windows: It disregards the current line endings and converts files to CRLF. – Trevor Robinson May 06 '14 at 04:18
-
5
-
1@rec: Source seems still available on sourceforge. Lets hope someone will looks into it, compile the project and publish it to an update site somewhere else. This is one of the problem with open-source software. – Jmini Jun 27 '14 at 13:13
-
1Imagine it wasn't open-source - then it would be gone for good. Like this, at least somebody could re-post it or even take over the project on sourceforge. – rec Jun 27 '14 at 16:36
-
@rec: Absolutly agree with you... I wrote "Problem", I meant "Property" of oss. This would has been more neutral. I am user of open-source software and also a contributor. – Jmini Jun 30 '14 at 09:42
-
-
The project and the source are still available (see the discussion we had with "rec" in the previous comment). Maybe someone will step up and continue to maintain the project. – Jmini Dec 08 '14 at 07:57
-
Instructions to build from the source as well as a compiled binary are available [here](https://www.eclipse.org/forums/index.php/t/796282/) – hendalst Nov 30 '15 at 07:04
-
2New version published on GitHub/Bintray: https://jmini.github.io/Eclipse-Copyright-Generator/ – Jmini Apr 01 '17 at 12:07
-
-
This should no longer be marked as an answer because plugin can no longer be installed via market place as bintray removed support for the hosting. FYI: @Jmini – Sergey Karpushin Nov 13 '21 at 10:39
Window > Preferences > Java > Code Style > Code Templates > Comments > Files

- 588,226
- 146
- 1,060
- 1,140
-
2Similar to this `Window > Preferences > Java > Code Style > Code Templates > Code > New Java Files` can be used to set a standard comment header for new Java code – RobV Feb 06 '13 at 17:16
-
5In addition, make sure the checkbox 'Automatically add comments for new methode' is enabled in the lower part of the Java - Code Style - Code Templates section. – dschulten Dec 19 '13 at 08:58
In addition to the answer provided by Bozho, there are the releng tools provided by eclipse, which give you some menu item commands to fix copyrights in existing files. You can install the releng tools from this update site:
The Eclipse Project Updates - http://download.eclipse.org/eclipse/updates/4.3
And there is a small bit information available on it here:
https://wiki.eclipse.org/Development_Resources/How_to_Use_Eclipse_Copyright_Tool

- 15,694
- 5
- 73
- 72

- 28,387
- 9
- 92
- 148
-
-
Am using 3.8.1, but the update for this version probably did not exist. Hence tried with lower version 3.7 update. http://download.eclipse.org/eclipse/updates/3.7 did work for me of installation. @Andrew: any reference for the list of "variables" supported in this copyright text, like ${date} was one. I need to know, some like ${file}, ${user}, date-in-dd/mm/yyyy format, etc. – parasrish Apr 13 '16 at 05:16
-
This works for java but not for scala. Any options for scala files? – Prabodh Mhalgi Feb 01 '17 at 10:29
In addition to Andrew Eisenberg's reply, here's what I found out about the Eclipse copyright tool. I found this to work best from all suggested solutions.
Pluses:
- Easy to update copyright years or licence header.
- Easy to apply to the whole project or just parts of it.
Minuses:
- Does not work on all types of files. At least didn't work on JSP files for me.
- You can not set up multiple licenses and apply them as you wish. There's only one licence.
Customization (from preferences):
You can apply the license at the file or package level

- 1,343
- 15
- 17
-
-
@SergeyKarpushin You'll have to configure it from an older update site. I installed mine from the 4.19 Eclipse Update Site and it works fine. – Nzall Mar 07 '22 at 15:59
The project that @Jmini link (Eclipse Copyright Generator) seems dead, you can use this plugin to add the headers: JAutoDoc, it's very easy to use and have a lot of utilities for javadoc.
You need to specify a licence in project|general > Preferences > java > JAutodoc > FileHeader
and later in the project use: project > JAutodoc > Add Header
, make sure the option Replace Existing Header
is on.
The template is writing using Velocity, so you can add all the information you need as variables.

- 3,442
- 3
- 25
- 40
this is my setting under Window > Preferencers > Java > Code Style > Code Template > Code > New Java files
:
/*
* Copyright (c) 20XX XXXXXXXXX. All rights reserved. Whatever......
*/
${filecomment}
${package_declaration}
${typecomment}
/**
*
* @author ${user}
*
*/
${type_declaration}

- 20,520
- 23
- 96
- 132

- 189
- 1
- 3
- 8