12 February, 2018

How to add copyright to Eclipse

How to add @copyright to your code in eclipse ?

As a developer , we mostly want to reduce few development or coding effort while working on a project. Adding @copyright to your java file or your project file is quite easy. There are few ways you can achieve these. 

First Solution :- You can use 3rd party plugin to generate the @copyright. Follow the steps to install the plugin and add copyright for your project.

 1. Go to => Help => Eclipse MarketPlace => Search for copyright generator



2. Click on => Install and proceed further for finishing the installation. After the plugin installed successfully.
3. Go to menu => Project => Apply Copyright 


4. Now , Select custom copyright and paste your copyright header text in the text area. I have used the below sample header for my blogging.


/*******************************************************************************
 * Java Developers Guide Blogging - Confidential
 * ____________________
 *
 * [2018] - [2019]  Java Developers Guide Incorporated
 * All Rights Reserved.
 * 
 * NOTICE:  All information contained herein is, and remains
 * the property of  Java Developers Guide Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to  Java Developers Guide Incorporated
 * and its posts and articles are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Java Developers Guide Blogging.
 *
 * Generated on Feb 12, 2018
 ******************************************************************************/

Then , apply the included or excluded as per your need. I have added the included in this example. That means here I want to add copyright header text for all java file (i.e. *.java).  This expression will to add all .java files. Sample image below.



 5. Next => select the project you want to apply => Then select the java files you want to apply 


6. Now you can see the java files with your header copyright text as below.




Second Solution :-


You can directly add the header copyright text into the {template} in eclipse IDE. Follow the steps below.

1. Go to => Windows => Preferences => Java => Code Style = > Code Templates => Code

Then select "New Java files" , then add your copyrights in the first line as mentioned in the image below. Then Apply and finish.




2. Now create a new file ( Go to = File => New => Java Class)



Now you can see the copyrights has been added to your java classes. Hope it will help you to improve the coding practice and coding standards.


Hope it will help you.