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

Pubblicato il: 30 ottobre 2014
sul canale di: 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


In questa pagina del sito puoi guardare il video online Java packages executed- How to import other java programs in a main program della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Themultiomniman 30 ottobre 2014, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 23,242 volte e gli è piaciuto 53 spettatori. Buona visione!