Home Answers Viewqa Java-Beginners Core java Basic

 
 


Robin Sharma
Core java Basic
1 Answer(s)      2 years and 4 months ago
Posted in : Java Beginners

How to compile a program using the package statement at the first line.Do I have to create a a Seperate Folder with the name of the package in my directory.Please tell me the steps?

View Answers

January 14, 2011 at 3:53 PM


Hi Friend,

Follow these steps:

1)Create folder named form in C:/Examples/ folder.

2)Create a java class Calculate inside the form folder:

package form;
public class Calculate
{
public int a;
public int b;

public int add(int a,int b){
    return a+b;
}
}

3)Now to check this, create another class CallClass inside the Examples folder that will call the Calculate class.

public class CallClass{
    public static void main(String[] args) 
    {
        form.Calculate c=new form.Calculate();
        System.out.println(c.add(5,6));
    }
}

4)Compile the Calculate and CallClass class with the following statements:

C:\Examples\form>javac Calculate.java
C:\Examples>javac CallClass.java
C:\Examples>java CallClass

Thanks









Related Pages:
Core java Basic
Core java Basic  How to compile a program using the package statement at the first line.Do I have to create a a Seperate Folder with the name of the package in my directory.Please tell me the steps
core java
core java  basic java interview question
basic
basic  thank you sir for your nice reply . ......sir my next que, if java program is modified,if the program is compiled & executed without saving it again,its previous execution takes place,why
Core Java - Java Beginners
talk about core java, we means very basic or from the scratch where you learn about...Core Java  What is Java? I am looking for Core Java Training  Hi friendThe Core Java Technologies and application programming interface
core
core  where an multythread using   Please go through the following link: Java Multithreading
Core Java - Java Beginners
Core Java  How can we explain about an object to an interviewer  Hi friend, Object : Object is the basic entity of object oriented... information that is to be passed to the recipient object. Objects are the basic
java basic
java basic  Java Basics tutorials
java basic
java basic  java program for finding LCM and HCF
java basic
java basic  write java program to evaluate 1+x^2+x^3+x^4+............+x^n
Java basic
Java basic  How can I Use Eclipse to create a project and write a hello world java application
java basic
java basic  i need to give a hexadecimal input (0x71014802 and 0x8c2a0000) and want to get a MIPS instruction code(assembly level lang.):the output is not a matter... i want to create a package and then input converted converted
core java - Development process
core java  Hi i want core java code for this problem.its urgent ,waiting for your answer PROBLEM ONE: SALES TAXES Basic sales tax is applicable... to : http://www.roseindia.net/java/ Thanks
basic program
basic program  hii actully i am goin for technical interview on java as fresher so please tell me what these two basic lines means : public static void main(String arg) and System.out.print(); please give me meaning of each
core java
core java  how to display characters stored in array in core java
core java
core java  i need core java material   Hello Friend, Please visit the following link: Core Java Thanks
CORE JAVA
CORE JAVA  CORE JAVA PPT NEED WITH SOURCE CODE EXPLANATION CAN U ??   Core Java Tutorials
Core Java
Core Java  what is a class
basic java - Java Beginners
basic java  oops concept in java ?  Hi Friend, Please visit the following links: http://www.roseindia.net/java/beginners/oop-in-java.shtml http://www.roseindia.net/java/learn-java-in-a-day/oops.shtml Thanks
core java - Java Interview Questions
core java - Use of polymorphism in object oriented programming   Hi... programming ? using Overloading and Overriding ConceptPolymorphismIt is a basic feature... languages .In java it states using of one single interface with a set of actions
core java
core java  Hi, can any one expain me serialization,Deseralization and exterenalization in core java
core java
core java  Hi, can any one exain me the concept of static and dynamic loading in core java
Basic Java Tutorial
Basic Java Tutorial  Hi, Where is the url of Basic Java Tutorials on roseindia.net? Thanks   Hi, You can Learn Java in a Day also? Thanks
java and visual basic
java and visual basic  Hello, Please how does java and visual basic interact or talk
core java
core java  surch the word in the given file
CORE JAVA
CORE JAVA  What is called Aggregation and Composition
core java
core java  how can we justify java technology is robust
core java
core java  what is the use of iterator(hase next
core java
core java  please give me following output
BASIC Java - Java Tutorials
Basic Java Syntax This tutorial guide you about the basic syntax of the java... of the java which is applicable to all java program : Case Sensitive Java Java... letter and lover case. For example, case and Case are different words in java
Java basic question...
Java basic question...   Design a Java Application project...), emp_desig as String (To hold designation of the employee) and basic as Integer (To hold the basic salary of the employee). (iii) Define and declare a method
core java
core java  write a java program to view product details from product table
Core Java
Core Java  How to execute cmd command through java?? Give Code of them
core java
core java  its compulsory to save file name and class name is same in java
CORE JAVA
CORE JAVA  What is Garbage collection in java? What is the role of a developer for garbage collection
core java
core java  In java primitive variables will get its default value automatically after declaration. Then why it is mandatory to initialize a variable before using
Core Java
Core Java  Please write a Java Program to design login form and store the values in file & validate and display the MainForm
Core Java
Core Java  Hi, Can any one please share the code for Binary search in java without using builtin function
core java
core java  Hello sir,What is logic behinde the core java programms,How may programmas are there,for example,sorting of two numbers,grade of the student details,fibonice serice,paldroma,incremting of the program,asscedding
core java
core java  Hello sir,What is logic behinde the core java programms,How may programmas are there,for example,sorting of two numbers,grade of the student details,fibonice serice,paldroma,incremting of the program,asscedding
Core Java
Core Java  What is the significance of static synchronized method? Why do we have the method declared as static synchronized
core java
core java  how to compare every character in one string with every character in other string
core java
core java  what is the max size of array?   You can declare up to maximum of 2147483647
Core Java
Core Java  Write a Program to add given number of days to the current system date and display the same
Core Java
Core Java  have to find the prime numbers which is less than the current prime numbers using loops
core java
core java  can i use native keyword with abstract method ? if yes explain and if no please explain
core java
core java  Hi, Can any one please share a code to print the below: 1 121 12321 1234321
CORE JAVA
CORE JAVA  Tell me some Scenarios why you go for Abstract Class and Interface
Core Java
Core Java  How to load class dynamically in java ?   To load class dynamically you can use Class class method Class.forName("abc.xyz.MyClass"); This method load the given class at run time
Core Java
Core Java  Hi, can any one please tell me the uses of return type,"Super" and "this" calling statement in Java?? why do we required this,super calling statement?? why return type is required
Core Java
Core Java  Hi, Can any one please expain me why derived data types are required in java as we have primitive data types with us

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.