Java packages executed- How to import other java programs in a main program

Veröffentlicht am: 30 Oktober 2014
auf dem Kanal: Themultiomniman
23,242
53

Link to complete Java tutorial with VoiceOver - http://bit.ly/1muxuWW

Here is the java program I used

// Program to create a package
import alpha.*;
class Package
{
public static void main(String args[])
{
classA a = new classA();
a.displayA();
classB b = new classB();
b.displayB();
}
}
// Codes for individual classes inside the alpha folder package
// the .class file of these classes must be placed inside the alpha folder
// for classA
package alpha;
public class classA
{
public void displayA()
{
System.out.println("This is classA.");
}
}
// for classB
package alpha;
public class classB
{
public void displayB()
{
System.out.println("This is classB.");
}
}

After opening command prompt, firstly we need to set the path of bin java directory, done by
set path="bin path here"
Then we change directory to where our program is located, by
cd JavaProgramPathHere
Then we have to compile classA and classB and put their .class files in a folder named alpha
We run
javac -d . classA.java classB.java
A new folder named alpha is created, and class file is directly sent there.
Now all we need to do is compile the main program, Package.java
Delete classA.java and classB.java if it throws up some errors.
Compile using javac Package.java
Run using java Package

Thats it guys..!
Refer the youtube video to know more and learn how to execute exactly :D

Link to full video course with voiceover - http://bit.ly/1muxuWW


Auf dieser Seite können Sie das Online-Video Java packages executed- How to import other java programs in a main program mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Themultiomniman 30 Oktober 2014 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 23,242 Mal angesehen und es wurde von 53 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!