Monday, 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.




Sunday, 28 January 2018

How to add formatter in eclipse

How to add my own or your company specified code formatter into eclipse ? 


Everyday we are facing lots of issues with development environment and its quite genuine. I though to share this steps also to help you to format your code with best practice. Usually, we need to develop a clean, and most readable code. You can add your own formatter into eclipse IDE (I am using Eclipse Mars in my example). But, You can use any other eclipse release version.

Normally we use the formatter with .xml file format. Its, nothing but a set of rules defined in XML. It defines how your code should look like as a structure.

1. Go to ==> Windows ==> Preference 

The below screen will appear.




2. Select ==> Java ==> Code Style ==> Formatter

The below screen will appear.




3. Now click on ==> Import button to import your formatter xml .

 The below screen will appear.




Now you can see the active formatter in eclipse, please see the below image with highlighted area.



The above image shows your selected formatter, now you are ready to do the code formatting as per your defined rule in the formatter xml , that you have just now imported. Now, you can  see the active profile as your formatter. You can use your keyboard shortcut key (Ctrl+Shift+F) for format the code or you can use the code format option from menu options.

In my next post I will post how to define the rules for write your own formatter. So, please keep following me.



Hope it will help you.



Wednesday, 11 October 2017

Write your first Java program.

This is very basic startup for your learning java programming language. Before writing and executing this you should make sure that you have installed the expecting JDK. This JDK is mandatory, apart from this JDK you need some IDE (i.e. Eclipse,Netbean, Jboss developer studio etc). These IDE are not mandatory ,but now-a-days these are very common to make your development easy. 

You can run the below java program on command line also  by using any text editor (i.e. notpad,textpad etc). I have used here Eclipse IDE (Oxygen) for development.

Below is the example :-

package com.javadevelopersguide;
/**
 *
 * @author javadevelopersguide
 *
 */
public class FristJavaProgram {
public static void main(String[] args) {
System.out.println("Welcome To Java");
}
}


OutPut :-
First Java Project



Reverse a String in Java - Java API

Reverse a string using java existing api is really very easy. Below example will show you how to reverse the string using StringBuilder class.


package com.javadevelopersguide.www;
/**
 * This example will help you to reverse a string using StringBuilder.
 *
 * @author manojkumar.bardhan
 *
 */
public class ReverseString {
/**
* @param args
*/
public static void main(String[] args) {
String inputString = "javadevelopersguide";
System.out.println("Before Reverse::" + inputString);
//You can do this using StringBuffer also, based on your requirement. If you really worried about thread saftey
StringBuilder builder = new StringBuilder(inputString).reverse();
// After Reverse using StringBuilder
inputString = builder.toString();
System.out.println("After Reverse:: " + inputString);
}
}


Output :-

Before Reverse::javadevelopersguide
After Reverse:: ediugsrepolevedavaj


Hope it will help you.


Friday, 17 February 2017

Recover Missing Or Unallocated Space On A USB Drive

Recover Missing Or Unallocated Space On A USB Drive - using diskpart


Are you worried about your USB Drive? You are thinking you have lost your USB. But, this is quite obvious when you have done something with your USB drive. What happend to your USB Drive ?

Normally when you are playing with file systems , you should bit aware about the pros and cons. However, you no need to worry . You can recover your USB Drive memory space once again.

Every Operating System(OS) has different file systems. When you use your USB Drive cross platform purpose, It mean you are playing with different file systems. What happened to your USB Drive ? Why its not allowing/showing you to the original space/capacity ? 


Let's Assume..... with few below points.

1. May be you have deleted the partition. It means Unallocated space.
2. May be you have burned your space with some different file system , which is not supported by your current OS file system.
3. May be some other reason.


Here, In this post I have lost my memory space . I have burned my USB Drive space, because I was creating bootable Linux Installation drive.I will post in my next article
how to create a bootable USB drive. I have used the below USB Drive for this Post.

USB Drive Details:-

SanDisk , 16 GB Capacity

You need to just check with Windows Disk Management. You will find all information about your computer/desktop drive. Below disk management image shows the disk status.
This will show you the disk allocation , disk space usage, and some other helpful information.
 
java developers guide - disk managment tool
Disk Management - Windows


As I mentioned above, I have lost my pendrive. Its not useful for me until I recover the memory. I am using here Windows 10 OS to recover my lost space.

Windows OS is providing feature to manage your disk partitions using diskpart command.

Open command line or run command and type diskpart.

java developers guide- diskpart
diskpart - open by run command


Now, just simply follow the below commands one-by-one.

1. Check the list of disks in your computer.

          list disk

2. Select your disk that you want to recover. You need to be very careful here , because if you choose the wrong disk you might loose some other data. So, here I am choosing disk 1. Because, its a common sense  my USB Drive capacity is 16 GB.

       select disk 1

3. Now , do clean for your chosen disk.

       clean

4. Now, you have already got successfully cleaning the disk message. Now you need to create a partition for your disk . This is the primary partition, though you are creating only one drive.

     create partition primary

5. If you got succeeded, then you are done. Just exit.

    exit


Below Image will help you to get the commands easily. 



java_developers_guide_diskpart console
diskpart console


Your USB Drive is not yet ready to use. You have just recovered your space, but you need to format the USB Drive. Being I am using Windows 10 , I need to format this USB Drive
to Windows compatiable. Windows OS compatiable file systems are NTFS,FAT/FAT16/FAT32. Below image will show you ....





java developers guide - formatting
Formatting - recovered

Hope you are happy now :) You got your USB Drive back.. and same some Dollars :)


Hope it will help you.
Follow for more details on Google+ and @Facebook!!!

Find More Posts :-

Tuesday, 31 January 2017

Weblogic Error : unable to get file lock, will retry ...



unable to get file lock, will retry ...


This is a common issue for weblogic user/developer. Developers are always facing this issue with file lock.Something went wrong.

Weblogic Console Error Log -


<31/01/2017 2:25:12 PM EST> <Info> <Security> <BEA-090906> <Changing the default Random Number Generator in RSA CryptoJ from ECDRBG to FIPS186PRNG. To disable this change, specify -Dweblogic.security.allowCryptoJDefaultPRNG=true>
<31/01/2017 2:25:12 PM EST> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) Client VM Version 17.0-b17 from Sun Microsystems Inc.>

<31/01/2017 2:25:23 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:25:33 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>
<31/01/2017 2:25:43 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:25:53 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:26:03 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:26:13 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:26:23 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:26:33 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:26:43 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:26:53 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:27:03 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:27:13 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:27:23 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:27:33 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:27:43 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:27:53 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:28:03 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:28:13 PM EST> <Info> <Management> <BEA-141281> <unable to get file lock, will retry ...>

<31/01/2017 2:28:18 PM EST> <Critical> <WebLogicServer> <BEA-000362> <Server failed. Reason:

There are 1 nested errors:

weblogic.management.ManagementException: Unable to obtain lock on /usr/java/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/tmp/AdminServer.lok. Server may already be running
    at weblogic.management.internal.ServerLocks.getServerLock(ServerLocks.java:206)
    at weblogic.management.internal.ServerLocks.getServerLock(ServerLocks.java:67)
    at weblogic.management.internal.DomainDirectoryService.start(DomainDirectoryService.java:74)
    at weblogic.t3.srvr.ServerServicesManager.startService(ServerServicesManager.java:461)
    at weblogic.t3.srvr.ServerServicesManager.startInStandbyState(ServerServicesManager.java:166)
    at weblogic.t3.srvr.T3Srvr.initializeStandby(T3Srvr.java:881)
    at weblogic.t3.srvr.T3Srvr.startup(T3Srvr.java:568)
    at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:469)
    at weblogic.Server.main(Server.java:71)

>
<31/01/2017 2:28:18 PM EST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to FAILED>
<31/01/2017 2:28:18 PM EST> <Error> <WebLogicServer> <BEA-000383> <A critical service failed. The server will shut itself down>
<31/01/2017 2:28:18 PM EST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to FORCE_SHUTTING_DOWN>



Solutions :-

You can fix the by simple one step. Just delete the AdminServer.lok file from  your domain.

I have deleted below , check the below commands ..

Go to the /tmp directory inside your weblogic domain.


cd  /usr/java/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/tmp




Checking the existing files inside /tmp directory.


dev@jdg-desktop /usr/java/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/tmp $ ls
AdminServer.lok  WebServiceUtils.ser  _WL_internal  _WL_user


 

Now delete the AdminServer.lok file from this /tmp directory.
 
dev@jdg-desktop /usr/java/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/tmp $ rm -rf AdminServer.lok




Hope it will help you.




Follow for more details on Google+ and @Facebook!!!

Find More Issues & Solutions -





Wednesday, 25 January 2017

Write your first Groovy Program

Write your first Groovy Program



If you remember we already discussed in my previous post about adding Groovy to your resume. Adding new skills will always help and increase your chance of getting your dream job.

Before everything you should have hands on experience on groovy programming. Lets see how to write a simple groovy program. As a newbie for groovy , you should start a basic hello world program.


Before start your first groovy program , you should make sure you have groovy installed in your machine (Desktop/Laptop). I am using Linux (ubuntu) here to demonstrate this example.

You can check in your terminals and I have already installed Groovy. Below command I have used to check whether groovy is installed and what version of groovy I am using.


root@jdg-HP-ProBook-6450b:~/grovytest$ type groovy
groovy is hashed (/usr/bin/groovy)
root@jdg-HP-ProBook-6450b:~/grovytest$ groovy -version
Groovy Version: 1.8.6 JVM: 1.7.0_121 Vendor: Oracle Corporation OS: Linux


Now, we can write our first groovy program. Usually groovy files are saved with extension xxx.groovy. Groovy program doesn't required semicolon (;) to close like java.This is very simple and reduce the developer effort of coding.


Open vi editor or text pad. Lets start writing your first program. 


Below is a Sample groovy program :-

HelloWorld.groovy



println "Say Hello to Groovy"


Now save this file with extension .groovy. In this example I have given the file name as HelloWorld.groovy.

Now you need to execute this .groovy file using below command  on terminal and check the output. 

root@jdg-HP-ProBook-6450b:~/grovytest$ groovy HelloWorld.groovy
Say Hello to Groovy

Now you can see the output I have highlighted in color. This is a simple groovy program. Find more programs on my subsequent posts.


Hope this will help you!!!





Follow for more details on Google+ and @Facebook!!!

Find More :-