How to create Project, Package, Class and their Naming conventions, Literals

In this article, I will explain about how to create project, package, built-in-package and user defined package, class and naming conventions in java, with example. Also what is method, camel case in java, how java works, Access modifiers in java and literals in Java.

Java is a high-level object-oriented programming language developed by the Sun Microsystems.
In 1991, Sun Microsystem has team which was led by James Gosling. Team wanted to create platform independent language. So they created new language called as 'Oak'.
In 1995, they wanted to make patent of this language. But due to name issue they rename it to 'Java'.

To begin with java programming we need to create projects, packages, classes and methods.
First install JDK and eclipse.

How to create new Java project?

  • Open Eclipse.
  • Click on File menu.
  • Click on New -> Java Project option.
  • Following popup will be displayed.
    Create Project
  • Enter Project name. Here I have entered 'BasicCommands' as my project name.
  • Click on Finish button.
Our project 'BasicCommands' gets created.
After that we will create package.


Package is collection of classes, interfaces, Enum, Annotation, files etc.
If we did not create package then class get create in default package.

Basically, packages are used to avoid conflicts, to control access, use of classes, interfaces and for searching purpose.
Packages are divided into two categories.
  1. Built-in Package
    These are existing java packages which are already defined.
    In built Packages

  2. User defined package
    These packages are created by users.
    How to create package in Java
    Right click on created java project.
    Click on New->Package as shown in below image.
    It will display below screen.
    Enter package name. It should start with lower case letter. So here we have created package named 'basicCommands_package'.
    Click on Finish button.
    Syntax: package ;


Class is template from which objects are created. It contains data members, variables, methods, constructor, block, class and interface.
How to create class
  • Right click on created package.
  • Click on New->Class. Following window will get open.
  • Enter Class name. Class and Interface name should start with Upper case letter.
  • Click on Finish button.
  • Our class named 'Basic' gets created under 'basicCommands_package' package.
  • Syntax :
    public class Class_name


Method is a program module that contains a series of statements that carry out a task. To execute a method, you need to invoke or call it from another method.
Any class can have unlimited number of methods and each method can be called unlimited number of times.
Public int addition(int a, int b)

Method should start with Lower case letter and at the end will have pair of simple braces ().
Example: main(), println() etc.

Camel case in Java

In Java, camel Case syntax is followed. If any variable or method has two words then second word will be written in Upper Case.
Example: variable studentName or method charAt() etc.

Variables:Variables should start with Lower Case letter.
Example: studentName, studentID etc.
Keywords: Keywords should have all Lower Case letter.

How Java works?

  • To work with any software you need to create source file.
  • Then you need to compile that source file to convert it into byte code.For this we will require compiler.
  • Now to run this byte code we need platform i.e. Java Virtual Machine (JVM). Virtual machine only works with byte code.
  • Java is platform independent because for each platform Java provides different JVM so we can execute our byte code directly on any platform.

How Java works


Literal means value which is directly stored in variable in program.
Types of literal
  • Integer literals: It will store integer values like 45, 98345, -34567 etc.
    Example: int I = 3456;
  • Float literals: It will store decimal point numbers like 43.256
    Example: float f = 26.12;
  • Character literals: Character literal includes General character, Special character, Unicode character etc.
    Example: char attendance = 'Y';
  • String literals: It is object of String class.
    Example: String name = "Geeta";
  • Boolean literals: It can stores only two values, either true or false.
    Boolean state = true;

Access modifiers in Java

It sets the level of access you want for your class, variables as well as methods.
Four access modifiers
  1. Public: It will be accessible throughout the package.
  2. Protected: For inherited class, protected object will be accessible.
  3. Private: If defined in method, accessible only in method.
  4. Default: If any modifier is not specified then default is access modifier.

Access ModifiersSame classSame PackageSub ClassOther Packages

Related Articles

How to prevent acne scars?

This article explains various measures which keep acne under control. This decreases inflammation and consequently chances of formation of acne scars too decreases. Actions like not picking at skin, proper hydration, using sunscreen lotions, proper skin care regime etc prevent formation of acne scars.

How To Control Anger?

Have you ever been angry and later on felt sad for being angry on some one or something? Do you want to control your anger ? Is anger good or not ? The following article will discuss about anger and measures through which we can control our anger.

How to remove blood stains from delicate fabrics and specific surfaces?

This article explains various tips and methods to get rid of blood stains from delicate fabrics like silk, satin, woolen, linen etc and from specific surfaces like concrete, hardwood floors, mattress, quilt, leather, carpets etc. These methods used can make them free from blood stains.

Top 9 tips and exercises to sharpen the mind and boost brainpower

The brain needs constant stimulation to remain alert and active. Practice good habits that can sharpen your memory and help you stay alert and on top of your game at all times. Simple lifestyle changes that involve the number of you sleep or what you eat or how you relax can play a great role in how your brain functions. Find out what you need to do right, to get the best out of your grey cells.

How to become a pathologist with top hospitals in India

Are you looking for a career in medicine as a clinical pathologist? Need to know how to start a pathology lab? This article provides complete information on the different specializations in pathology and a career guide on starting a career as a pathologist. You will also get a general idea on the approximate costs of setting up your own path lab.

More articles: How to


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: