Java - Does the package statement is removed in .class file?












0















As we know that the package statement is when triggered by the javac command, it creates the related directories according to the package name.



For example:



// MyClassB.java
package abc.xyz;

class MyClassA{
// ...
}

class MyClassB{
// ...
}


Now when I compile this file:



javac -d . MyClassB.java


After compilation, we will have the following directory structure having the .class files.



/
|___ abc
|___ xyz
|___ MyClassA.class
|___ MyClassB.class


Now the question is that, are these MyClassA.class and MyClassB.class contains only the MyClassA and MyClassB class's compiled bytecode?



What about the following statement?



package abc.xyz;


Is that statement removed during the compilation? Or this statement is only removed from the MyClassA class and remains in the MyClassB class because the name of the file was MyClassB.java. Or maybe the MyClassB.class file only contains the MyClassB class bytecode after compilation and the package abc.xyz; is removed during the compilation as well? If package abc.xyz; is not removed at the compilation time then it would be the problem when we will use this file at runtime because the runtime engine will also trigger the package abc.xyz; statement bytecode version, so, it would be a problem. Or it is removed during the compilation? Or the bytecode is only created for the classes but not for the file which contains the package abc.xyz; statement which results that package abc.xyz; is not become the part of the .class files.



The picture below clearly explains the question:
enter image description here



Can anyone explain what is the scenario behind this? It is my humble request to the contributors to not negative mark my question because i have some confusions regarding java, so, i want to clear my concept.If still my question is able for negative mark, then its Ok do, but at least answer as well.



Thanks !!!










share|improve this question




















  • 2





    Please could you clarify this sentence? " If package abc.xyz; is not removed at the compilation time then it would be the problem when we will use this file at runtime because the runtime engine will also trigger the package abc.xyz; statement bytecode version, so, it would be a problem." What do you mean by "trigger package abc.xyz statement bytecode version"?

    – Jon Skeet
    2 days ago











  • I mean that the objective of package abc.xyz; statement is to create directories and place the .class files inside the xyz directory, so, the run time will do the same job as the compile time? So, is this not the problem? Because the runtime will say lets create directories because of the package abc.xyz; statement, so, this is my understanding, now i don't know what is the scene behind.

    – Sunny Khan
    2 days ago













  • Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

    – Sunny Khan
    2 days ago








  • 1





    No, it's the compilation process that creates class files. That's entirely separate from what happens when you run the code.

    – Jon Skeet
    2 days ago






  • 1





    "I mean that the objective of package abc.xyz; statement is to create directories and place the .class files inside the xyz directory" - no, it's to specify the package for the classes declared in that source file. It's not "code that runs". It's the compiler that decides what it should do with class files. A different compile might not use the file system at all, but it would still need to know the package of a class.

    – Jon Skeet
    2 days ago
















0















As we know that the package statement is when triggered by the javac command, it creates the related directories according to the package name.



For example:



// MyClassB.java
package abc.xyz;

class MyClassA{
// ...
}

class MyClassB{
// ...
}


Now when I compile this file:



javac -d . MyClassB.java


After compilation, we will have the following directory structure having the .class files.



/
|___ abc
|___ xyz
|___ MyClassA.class
|___ MyClassB.class


Now the question is that, are these MyClassA.class and MyClassB.class contains only the MyClassA and MyClassB class's compiled bytecode?



What about the following statement?



package abc.xyz;


Is that statement removed during the compilation? Or this statement is only removed from the MyClassA class and remains in the MyClassB class because the name of the file was MyClassB.java. Or maybe the MyClassB.class file only contains the MyClassB class bytecode after compilation and the package abc.xyz; is removed during the compilation as well? If package abc.xyz; is not removed at the compilation time then it would be the problem when we will use this file at runtime because the runtime engine will also trigger the package abc.xyz; statement bytecode version, so, it would be a problem. Or it is removed during the compilation? Or the bytecode is only created for the classes but not for the file which contains the package abc.xyz; statement which results that package abc.xyz; is not become the part of the .class files.



The picture below clearly explains the question:
enter image description here



Can anyone explain what is the scenario behind this? It is my humble request to the contributors to not negative mark my question because i have some confusions regarding java, so, i want to clear my concept.If still my question is able for negative mark, then its Ok do, but at least answer as well.



Thanks !!!










share|improve this question




















  • 2





    Please could you clarify this sentence? " If package abc.xyz; is not removed at the compilation time then it would be the problem when we will use this file at runtime because the runtime engine will also trigger the package abc.xyz; statement bytecode version, so, it would be a problem." What do you mean by "trigger package abc.xyz statement bytecode version"?

    – Jon Skeet
    2 days ago











  • I mean that the objective of package abc.xyz; statement is to create directories and place the .class files inside the xyz directory, so, the run time will do the same job as the compile time? So, is this not the problem? Because the runtime will say lets create directories because of the package abc.xyz; statement, so, this is my understanding, now i don't know what is the scene behind.

    – Sunny Khan
    2 days ago













  • Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

    – Sunny Khan
    2 days ago








  • 1





    No, it's the compilation process that creates class files. That's entirely separate from what happens when you run the code.

    – Jon Skeet
    2 days ago






  • 1





    "I mean that the objective of package abc.xyz; statement is to create directories and place the .class files inside the xyz directory" - no, it's to specify the package for the classes declared in that source file. It's not "code that runs". It's the compiler that decides what it should do with class files. A different compile might not use the file system at all, but it would still need to know the package of a class.

    – Jon Skeet
    2 days ago














0












0








0








As we know that the package statement is when triggered by the javac command, it creates the related directories according to the package name.



For example:



// MyClassB.java
package abc.xyz;

class MyClassA{
// ...
}

class MyClassB{
// ...
}


Now when I compile this file:



javac -d . MyClassB.java


After compilation, we will have the following directory structure having the .class files.



/
|___ abc
|___ xyz
|___ MyClassA.class
|___ MyClassB.class


Now the question is that, are these MyClassA.class and MyClassB.class contains only the MyClassA and MyClassB class's compiled bytecode?



What about the following statement?



package abc.xyz;


Is that statement removed during the compilation? Or this statement is only removed from the MyClassA class and remains in the MyClassB class because the name of the file was MyClassB.java. Or maybe the MyClassB.class file only contains the MyClassB class bytecode after compilation and the package abc.xyz; is removed during the compilation as well? If package abc.xyz; is not removed at the compilation time then it would be the problem when we will use this file at runtime because the runtime engine will also trigger the package abc.xyz; statement bytecode version, so, it would be a problem. Or it is removed during the compilation? Or the bytecode is only created for the classes but not for the file which contains the package abc.xyz; statement which results that package abc.xyz; is not become the part of the .class files.



The picture below clearly explains the question:
enter image description here



Can anyone explain what is the scenario behind this? It is my humble request to the contributors to not negative mark my question because i have some confusions regarding java, so, i want to clear my concept.If still my question is able for negative mark, then its Ok do, but at least answer as well.



Thanks !!!










share|improve this question
















As we know that the package statement is when triggered by the javac command, it creates the related directories according to the package name.



For example:



// MyClassB.java
package abc.xyz;

class MyClassA{
// ...
}

class MyClassB{
// ...
}


Now when I compile this file:



javac -d . MyClassB.java


After compilation, we will have the following directory structure having the .class files.



/
|___ abc
|___ xyz
|___ MyClassA.class
|___ MyClassB.class


Now the question is that, are these MyClassA.class and MyClassB.class contains only the MyClassA and MyClassB class's compiled bytecode?



What about the following statement?



package abc.xyz;


Is that statement removed during the compilation? Or this statement is only removed from the MyClassA class and remains in the MyClassB class because the name of the file was MyClassB.java. Or maybe the MyClassB.class file only contains the MyClassB class bytecode after compilation and the package abc.xyz; is removed during the compilation as well? If package abc.xyz; is not removed at the compilation time then it would be the problem when we will use this file at runtime because the runtime engine will also trigger the package abc.xyz; statement bytecode version, so, it would be a problem. Or it is removed during the compilation? Or the bytecode is only created for the classes but not for the file which contains the package abc.xyz; statement which results that package abc.xyz; is not become the part of the .class files.



The picture below clearly explains the question:
enter image description here



Can anyone explain what is the scenario behind this? It is my humble request to the contributors to not negative mark my question because i have some confusions regarding java, so, i want to clear my concept.If still my question is able for negative mark, then its Ok do, but at least answer as well.



Thanks !!!







java javac






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









nullpointer

46.1k1198188




46.1k1198188










asked 2 days ago









Sunny KhanSunny Khan

17711




17711








  • 2





    Please could you clarify this sentence? " If package abc.xyz; is not removed at the compilation time then it would be the problem when we will use this file at runtime because the runtime engine will also trigger the package abc.xyz; statement bytecode version, so, it would be a problem." What do you mean by "trigger package abc.xyz statement bytecode version"?

    – Jon Skeet
    2 days ago











  • I mean that the objective of package abc.xyz; statement is to create directories and place the .class files inside the xyz directory, so, the run time will do the same job as the compile time? So, is this not the problem? Because the runtime will say lets create directories because of the package abc.xyz; statement, so, this is my understanding, now i don't know what is the scene behind.

    – Sunny Khan
    2 days ago













  • Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

    – Sunny Khan
    2 days ago








  • 1





    No, it's the compilation process that creates class files. That's entirely separate from what happens when you run the code.

    – Jon Skeet
    2 days ago






  • 1





    "I mean that the objective of package abc.xyz; statement is to create directories and place the .class files inside the xyz directory" - no, it's to specify the package for the classes declared in that source file. It's not "code that runs". It's the compiler that decides what it should do with class files. A different compile might not use the file system at all, but it would still need to know the package of a class.

    – Jon Skeet
    2 days ago














  • 2





    Please could you clarify this sentence? " If package abc.xyz; is not removed at the compilation time then it would be the problem when we will use this file at runtime because the runtime engine will also trigger the package abc.xyz; statement bytecode version, so, it would be a problem." What do you mean by "trigger package abc.xyz statement bytecode version"?

    – Jon Skeet
    2 days ago











  • I mean that the objective of package abc.xyz; statement is to create directories and place the .class files inside the xyz directory, so, the run time will do the same job as the compile time? So, is this not the problem? Because the runtime will say lets create directories because of the package abc.xyz; statement, so, this is my understanding, now i don't know what is the scene behind.

    – Sunny Khan
    2 days ago













  • Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

    – Sunny Khan
    2 days ago








  • 1





    No, it's the compilation process that creates class files. That's entirely separate from what happens when you run the code.

    – Jon Skeet
    2 days ago






  • 1





    "I mean that the objective of package abc.xyz; statement is to create directories and place the .class files inside the xyz directory" - no, it's to specify the package for the classes declared in that source file. It's not "code that runs". It's the compiler that decides what it should do with class files. A different compile might not use the file system at all, but it would still need to know the package of a class.

    – Jon Skeet
    2 days ago








2




2





Please could you clarify this sentence? " If package abc.xyz; is not removed at the compilation time then it would be the problem when we will use this file at runtime because the runtime engine will also trigger the package abc.xyz; statement bytecode version, so, it would be a problem." What do you mean by "trigger package abc.xyz statement bytecode version"?

– Jon Skeet
2 days ago





Please could you clarify this sentence? " If package abc.xyz; is not removed at the compilation time then it would be the problem when we will use this file at runtime because the runtime engine will also trigger the package abc.xyz; statement bytecode version, so, it would be a problem." What do you mean by "trigger package abc.xyz statement bytecode version"?

– Jon Skeet
2 days ago













I mean that the objective of package abc.xyz; statement is to create directories and place the .class files inside the xyz directory, so, the run time will do the same job as the compile time? So, is this not the problem? Because the runtime will say lets create directories because of the package abc.xyz; statement, so, this is my understanding, now i don't know what is the scene behind.

– Sunny Khan
2 days ago







I mean that the objective of package abc.xyz; statement is to create directories and place the .class files inside the xyz directory, so, the run time will do the same job as the compile time? So, is this not the problem? Because the runtime will say lets create directories because of the package abc.xyz; statement, so, this is my understanding, now i don't know what is the scene behind.

– Sunny Khan
2 days ago















Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

– Sunny Khan
2 days ago







Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

– Sunny Khan
2 days ago






1




1





No, it's the compilation process that creates class files. That's entirely separate from what happens when you run the code.

– Jon Skeet
2 days ago





No, it's the compilation process that creates class files. That's entirely separate from what happens when you run the code.

– Jon Skeet
2 days ago




1




1





"I mean that the objective of package abc.xyz; statement is to create directories and place the .class files inside the xyz directory" - no, it's to specify the package for the classes declared in that source file. It's not "code that runs". It's the compiler that decides what it should do with class files. A different compile might not use the file system at all, but it would still need to know the package of a class.

– Jon Skeet
2 days ago





"I mean that the objective of package abc.xyz; statement is to create directories and place the .class files inside the xyz directory" - no, it's to specify the package for the classes declared in that source file. It's not "code that runs". It's the compiler that decides what it should do with class files. A different compile might not use the file system at all, but it would still need to know the package of a class.

– Jon Skeet
2 days ago












2 Answers
2






active

oldest

votes


















2














It does not go anywhere, it is compiled as class abc.xyz.MyClassA. You can see that if you would decompile that .class for example using javap.






share|improve this answer
























  • But the result of the package abc.xyz; statement is to create the directories and place the .class file in the directory. So, whether the run time will also create the directory again and again when this program runs, is this not a problem? or package abc.xyz; statement is not executed in runtime?

    – Sunny Khan
    2 days ago













  • Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

    – Sunny Khan
    2 days ago













  • @SunnyKhan "runtime runs" already compiled classes, it does not compile them again. you do understand that right?

    – Eugene
    2 days ago











  • So, the package abc.xyz; is not the part of runtime?

    – Sunny Khan
    2 days ago



















0














If you open the .class file of any of your class than you can see the package details inside that. In your case if you will open MyClassA.class in text editor, then you can see something like abc/xyz/MyClassA. The the JVM will use it like abc.xyz.MyClassA. That's the reason if we need to use this class in some other class, we need to use it like import abc.xyz.MyClassA.






share|improve this answer


























  • Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

    – Sunny Khan
    2 days ago













  • Package is used for grouping java types (classes, interfaces, enums etc). So when you use the package in your java program it bind those java types in one package.

    – DK Ansh
    2 days ago











  • Please read this from oracle for more details information. Packages

    – DK Ansh
    2 days ago













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54252882%2fjava-does-the-package-statement-is-removed-in-class-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














It does not go anywhere, it is compiled as class abc.xyz.MyClassA. You can see that if you would decompile that .class for example using javap.






share|improve this answer
























  • But the result of the package abc.xyz; statement is to create the directories and place the .class file in the directory. So, whether the run time will also create the directory again and again when this program runs, is this not a problem? or package abc.xyz; statement is not executed in runtime?

    – Sunny Khan
    2 days ago













  • Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

    – Sunny Khan
    2 days ago













  • @SunnyKhan "runtime runs" already compiled classes, it does not compile them again. you do understand that right?

    – Eugene
    2 days ago











  • So, the package abc.xyz; is not the part of runtime?

    – Sunny Khan
    2 days ago
















2














It does not go anywhere, it is compiled as class abc.xyz.MyClassA. You can see that if you would decompile that .class for example using javap.






share|improve this answer
























  • But the result of the package abc.xyz; statement is to create the directories and place the .class file in the directory. So, whether the run time will also create the directory again and again when this program runs, is this not a problem? or package abc.xyz; statement is not executed in runtime?

    – Sunny Khan
    2 days ago













  • Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

    – Sunny Khan
    2 days ago













  • @SunnyKhan "runtime runs" already compiled classes, it does not compile them again. you do understand that right?

    – Eugene
    2 days ago











  • So, the package abc.xyz; is not the part of runtime?

    – Sunny Khan
    2 days ago














2












2








2







It does not go anywhere, it is compiled as class abc.xyz.MyClassA. You can see that if you would decompile that .class for example using javap.






share|improve this answer













It does not go anywhere, it is compiled as class abc.xyz.MyClassA. You can see that if you would decompile that .class for example using javap.







share|improve this answer












share|improve this answer



share|improve this answer










answered 2 days ago









EugeneEugene

69.3k999164




69.3k999164













  • But the result of the package abc.xyz; statement is to create the directories and place the .class file in the directory. So, whether the run time will also create the directory again and again when this program runs, is this not a problem? or package abc.xyz; statement is not executed in runtime?

    – Sunny Khan
    2 days ago













  • Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

    – Sunny Khan
    2 days ago













  • @SunnyKhan "runtime runs" already compiled classes, it does not compile them again. you do understand that right?

    – Eugene
    2 days ago











  • So, the package abc.xyz; is not the part of runtime?

    – Sunny Khan
    2 days ago



















  • But the result of the package abc.xyz; statement is to create the directories and place the .class file in the directory. So, whether the run time will also create the directory again and again when this program runs, is this not a problem? or package abc.xyz; statement is not executed in runtime?

    – Sunny Khan
    2 days ago













  • Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

    – Sunny Khan
    2 days ago













  • @SunnyKhan "runtime runs" already compiled classes, it does not compile them again. you do understand that right?

    – Eugene
    2 days ago











  • So, the package abc.xyz; is not the part of runtime?

    – Sunny Khan
    2 days ago

















But the result of the package abc.xyz; statement is to create the directories and place the .class file in the directory. So, whether the run time will also create the directory again and again when this program runs, is this not a problem? or package abc.xyz; statement is not executed in runtime?

– Sunny Khan
2 days ago







But the result of the package abc.xyz; statement is to create the directories and place the .class file in the directory. So, whether the run time will also create the directory again and again when this program runs, is this not a problem? or package abc.xyz; statement is not executed in runtime?

– Sunny Khan
2 days ago















Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

– Sunny Khan
2 days ago







Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

– Sunny Khan
2 days ago















@SunnyKhan "runtime runs" already compiled classes, it does not compile them again. you do understand that right?

– Eugene
2 days ago





@SunnyKhan "runtime runs" already compiled classes, it does not compile them again. you do understand that right?

– Eugene
2 days ago













So, the package abc.xyz; is not the part of runtime?

– Sunny Khan
2 days ago





So, the package abc.xyz; is not the part of runtime?

– Sunny Khan
2 days ago













0














If you open the .class file of any of your class than you can see the package details inside that. In your case if you will open MyClassA.class in text editor, then you can see something like abc/xyz/MyClassA. The the JVM will use it like abc.xyz.MyClassA. That's the reason if we need to use this class in some other class, we need to use it like import abc.xyz.MyClassA.






share|improve this answer


























  • Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

    – Sunny Khan
    2 days ago













  • Package is used for grouping java types (classes, interfaces, enums etc). So when you use the package in your java program it bind those java types in one package.

    – DK Ansh
    2 days ago











  • Please read this from oracle for more details information. Packages

    – DK Ansh
    2 days ago


















0














If you open the .class file of any of your class than you can see the package details inside that. In your case if you will open MyClassA.class in text editor, then you can see something like abc/xyz/MyClassA. The the JVM will use it like abc.xyz.MyClassA. That's the reason if we need to use this class in some other class, we need to use it like import abc.xyz.MyClassA.






share|improve this answer


























  • Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

    – Sunny Khan
    2 days ago













  • Package is used for grouping java types (classes, interfaces, enums etc). So when you use the package in your java program it bind those java types in one package.

    – DK Ansh
    2 days ago











  • Please read this from oracle for more details information. Packages

    – DK Ansh
    2 days ago
















0












0








0







If you open the .class file of any of your class than you can see the package details inside that. In your case if you will open MyClassA.class in text editor, then you can see something like abc/xyz/MyClassA. The the JVM will use it like abc.xyz.MyClassA. That's the reason if we need to use this class in some other class, we need to use it like import abc.xyz.MyClassA.






share|improve this answer















If you open the .class file of any of your class than you can see the package details inside that. In your case if you will open MyClassA.class in text editor, then you can see something like abc/xyz/MyClassA. The the JVM will use it like abc.xyz.MyClassA. That's the reason if we need to use this class in some other class, we need to use it like import abc.xyz.MyClassA.







share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago

























answered 2 days ago









DK AnshDK Ansh

176111




176111













  • Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

    – Sunny Khan
    2 days ago













  • Package is used for grouping java types (classes, interfaces, enums etc). So when you use the package in your java program it bind those java types in one package.

    – DK Ansh
    2 days ago











  • Please read this from oracle for more details information. Packages

    – DK Ansh
    2 days ago





















  • Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

    – Sunny Khan
    2 days ago













  • Package is used for grouping java types (classes, interfaces, enums etc). So when you use the package in your java program it bind those java types in one package.

    – DK Ansh
    2 days ago











  • Please read this from oracle for more details information. Packages

    – DK Ansh
    2 days ago



















Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

– Sunny Khan
2 days ago







Let says i have a statement System.out.print("Hello world");. Now when this program runs the Hello World will be printed, right? So lets say i have package abc.xyz; statement, Now when this program runs will it again create the directories and .class files? i hope you got me now!!! I am talking about runtime Ok.

– Sunny Khan
2 days ago















Package is used for grouping java types (classes, interfaces, enums etc). So when you use the package in your java program it bind those java types in one package.

– DK Ansh
2 days ago





Package is used for grouping java types (classes, interfaces, enums etc). So when you use the package in your java program it bind those java types in one package.

– DK Ansh
2 days ago













Please read this from oracle for more details information. Packages

– DK Ansh
2 days ago







Please read this from oracle for more details information. Packages

– DK Ansh
2 days ago




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54252882%2fjava-does-the-package-statement-is-removed-in-class-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Homophylophilia

Updating UILabel text programmatically using a function

Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage