does 'java' command compile the java program?Is Java “pass-by-reference” or “pass-by-value”?How do I...

Creating specific options in `Manipulate[]`

Why such a singular place for birding?

Was the ruling that prorogation was unlawful only possible because of the creation of a separate supreme court?

Did Tolkien ever write about a Heaven or Hell for Men?

How do we know neutrons have no charge?

Why aren't faces sharp in my f/1.8 portraits even though I'm carefully using center-point autofocus?

If a spaceship ran out of fuel somewhere in space between Earth and Mars, does it slowly drift off to the Sun?

I transpose the source code, you transpose the input!

What action is recommended if your accommodation refuses to let you leave without paying additional fees?

Lost passport and visa, tried to reapply, got rejected twice. What are my next steps?

How can I visualize an ordinal variable predicting a continuous outcome?

How many stack cables would be needed if we want to stack two 3850 switches

Why is the population of post-Soviet states declining?

How do my husband and I get over our fear of having another difficult baby?

Would a horse be sufficient buffer to prevent injury when falling from a great height?

Calculate the Ultraradical

How deep is the liquid in a half-full hemisphere?

Why most footers have a background color has a divider of section?

GPLv3 forces us to make code available, but to who?

Realistically, how much do you need to start investing?

How to work around players whose backstory goes against the story?

What is the logical distinction between “the same” and “equal to?”

Smallest PRIME containing the first 11 primes as sub-strings

Should I be an author on another PhD student's paper if I went to their meetings and gave advice?



does 'java' command compile the java program?


Is Java “pass-by-reference” or “pass-by-value”?How do I efficiently iterate over each entry in a Java Map?Does a finally block always get executed in Java?What is the difference between public, protected, package-private and private in Java?How do I read / convert an InputStream into a String in Java?When to use LinkedList over ArrayList in Java?How do I generate random integers within a specific range in Java?How do I convert a String to an int in Java?Creating a memory leak with JavaCan't start Eclipse - Java was started but returned exit code=13






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







14















Any website in Internet says: we should use 'javac; to compile a .java file and then run it by 'java' command. but today i tried to run java program without 'javac' and i got a strange result.



my file name is hello.java
and it includes below lines:



public class Myclass {
public static void main(String[] args){
System.out.println("hello world");
}
}


when i execute below command:



$ javac hello.java


it gives me below error which is reasonable:



$ hello.java:1: error: class Myclass is public, should be declared in a file named Myclass.java
public class Myclass {
^
1 error


but then i run it without 'javac' and it executed without any error!!!



$ java hello.java
$ hello world


Now my question is: does 'java' command compile the program too? and if the answer is yes why we need the 'javac' command?





Edit:





the version of my java is:



$ java -version
openjdk version "12.0.2" 2019-07-16
OpenJDK Runtime Environment (build 12.0.2+10)
OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)


so according to answers it is allowed in this version to run one source file using 'java' command.
thank youuuuu all:)










share|improve this question






















  • 4





    Which version are you using? I think they introduced Java Console in Java 9, and that might be what you experienced.

    – Matthieu
    8 hours ago











  • You need to match the class name with its filename - that's the Java standard. Just change the file name to Myclass.java and then from the command line compile it like this javac Myclass.java and then run it like this java Myclass.

    – unnsse
    8 hours ago








  • 1





    yes, javac still used to compile if you don't want to deploy source code, or you have more than a single file (documentation of java for source-file option: Only used to launch a single source-file program.)

    – Carlos Heuberger
    8 hours ago













  • @Matthieu the output of "java -version" is: openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+10) OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)

    – milad
    8 hours ago













  • @unnsse thanks for your attention but I know how to fix it, please read the last part of my question

    – milad
    8 hours ago


















14















Any website in Internet says: we should use 'javac; to compile a .java file and then run it by 'java' command. but today i tried to run java program without 'javac' and i got a strange result.



my file name is hello.java
and it includes below lines:



public class Myclass {
public static void main(String[] args){
System.out.println("hello world");
}
}


when i execute below command:



$ javac hello.java


it gives me below error which is reasonable:



$ hello.java:1: error: class Myclass is public, should be declared in a file named Myclass.java
public class Myclass {
^
1 error


but then i run it without 'javac' and it executed without any error!!!



$ java hello.java
$ hello world


Now my question is: does 'java' command compile the program too? and if the answer is yes why we need the 'javac' command?





Edit:





the version of my java is:



$ java -version
openjdk version "12.0.2" 2019-07-16
OpenJDK Runtime Environment (build 12.0.2+10)
OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)


so according to answers it is allowed in this version to run one source file using 'java' command.
thank youuuuu all:)










share|improve this question






















  • 4





    Which version are you using? I think they introduced Java Console in Java 9, and that might be what you experienced.

    – Matthieu
    8 hours ago











  • You need to match the class name with its filename - that's the Java standard. Just change the file name to Myclass.java and then from the command line compile it like this javac Myclass.java and then run it like this java Myclass.

    – unnsse
    8 hours ago








  • 1





    yes, javac still used to compile if you don't want to deploy source code, or you have more than a single file (documentation of java for source-file option: Only used to launch a single source-file program.)

    – Carlos Heuberger
    8 hours ago













  • @Matthieu the output of "java -version" is: openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+10) OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)

    – milad
    8 hours ago













  • @unnsse thanks for your attention but I know how to fix it, please read the last part of my question

    – milad
    8 hours ago














14












14








14


1






Any website in Internet says: we should use 'javac; to compile a .java file and then run it by 'java' command. but today i tried to run java program without 'javac' and i got a strange result.



my file name is hello.java
and it includes below lines:



public class Myclass {
public static void main(String[] args){
System.out.println("hello world");
}
}


when i execute below command:



$ javac hello.java


it gives me below error which is reasonable:



$ hello.java:1: error: class Myclass is public, should be declared in a file named Myclass.java
public class Myclass {
^
1 error


but then i run it without 'javac' and it executed without any error!!!



$ java hello.java
$ hello world


Now my question is: does 'java' command compile the program too? and if the answer is yes why we need the 'javac' command?





Edit:





the version of my java is:



$ java -version
openjdk version "12.0.2" 2019-07-16
OpenJDK Runtime Environment (build 12.0.2+10)
OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)


so according to answers it is allowed in this version to run one source file using 'java' command.
thank youuuuu all:)










share|improve this question
















Any website in Internet says: we should use 'javac; to compile a .java file and then run it by 'java' command. but today i tried to run java program without 'javac' and i got a strange result.



my file name is hello.java
and it includes below lines:



public class Myclass {
public static void main(String[] args){
System.out.println("hello world");
}
}


when i execute below command:



$ javac hello.java


it gives me below error which is reasonable:



$ hello.java:1: error: class Myclass is public, should be declared in a file named Myclass.java
public class Myclass {
^
1 error


but then i run it without 'javac' and it executed without any error!!!



$ java hello.java
$ hello world


Now my question is: does 'java' command compile the program too? and if the answer is yes why we need the 'javac' command?





Edit:





the version of my java is:



$ java -version
openjdk version "12.0.2" 2019-07-16
OpenJDK Runtime Environment (build 12.0.2+10)
OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)


so according to answers it is allowed in this version to run one source file using 'java' command.
thank youuuuu all:)







java javac






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 8 hours ago







milad

















asked 8 hours ago









miladmilad

1238 bronze badges




1238 bronze badges











  • 4





    Which version are you using? I think they introduced Java Console in Java 9, and that might be what you experienced.

    – Matthieu
    8 hours ago











  • You need to match the class name with its filename - that's the Java standard. Just change the file name to Myclass.java and then from the command line compile it like this javac Myclass.java and then run it like this java Myclass.

    – unnsse
    8 hours ago








  • 1





    yes, javac still used to compile if you don't want to deploy source code, or you have more than a single file (documentation of java for source-file option: Only used to launch a single source-file program.)

    – Carlos Heuberger
    8 hours ago













  • @Matthieu the output of "java -version" is: openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+10) OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)

    – milad
    8 hours ago













  • @unnsse thanks for your attention but I know how to fix it, please read the last part of my question

    – milad
    8 hours ago














  • 4





    Which version are you using? I think they introduced Java Console in Java 9, and that might be what you experienced.

    – Matthieu
    8 hours ago











  • You need to match the class name with its filename - that's the Java standard. Just change the file name to Myclass.java and then from the command line compile it like this javac Myclass.java and then run it like this java Myclass.

    – unnsse
    8 hours ago








  • 1





    yes, javac still used to compile if you don't want to deploy source code, or you have more than a single file (documentation of java for source-file option: Only used to launch a single source-file program.)

    – Carlos Heuberger
    8 hours ago













  • @Matthieu the output of "java -version" is: openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+10) OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)

    – milad
    8 hours ago













  • @unnsse thanks for your attention but I know how to fix it, please read the last part of my question

    – milad
    8 hours ago








4




4





Which version are you using? I think they introduced Java Console in Java 9, and that might be what you experienced.

– Matthieu
8 hours ago





Which version are you using? I think they introduced Java Console in Java 9, and that might be what you experienced.

– Matthieu
8 hours ago













You need to match the class name with its filename - that's the Java standard. Just change the file name to Myclass.java and then from the command line compile it like this javac Myclass.java and then run it like this java Myclass.

– unnsse
8 hours ago







You need to match the class name with its filename - that's the Java standard. Just change the file name to Myclass.java and then from the command line compile it like this javac Myclass.java and then run it like this java Myclass.

– unnsse
8 hours ago






1




1





yes, javac still used to compile if you don't want to deploy source code, or you have more than a single file (documentation of java for source-file option: Only used to launch a single source-file program.)

– Carlos Heuberger
8 hours ago







yes, javac still used to compile if you don't want to deploy source code, or you have more than a single file (documentation of java for source-file option: Only used to launch a single source-file program.)

– Carlos Heuberger
8 hours ago















@Matthieu the output of "java -version" is: openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+10) OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)

– milad
8 hours ago







@Matthieu the output of "java -version" is: openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+10) OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)

– milad
8 hours ago















@unnsse thanks for your attention but I know how to fix it, please read the last part of my question

– milad
8 hours ago





@unnsse thanks for your attention but I know how to fix it, please read the last part of my question

– milad
8 hours ago












2 Answers
2






active

oldest

votes


















12
















Prior to Java 11, to run your code you have to first compile it, then you can run it. Here's an example:



javac test.java
java test


Since Java 11, you can still do javac + java, or you can run java by itself to compile and auto-run your code. Note that no .class file will be generated. Here's an example:



java test.java


If you run java -help, you'll see the various allowed usages. Here's what it looks like on my machine. The last one is what you ran into: java [options] <sourcefile> [args] which will "execute a single source-file program".



$ java -help
Usage: java [options] <mainclass> [args...]
(to execute a class)
or java [options] -jar <jarfile> [args...]
(to execute a jar file)
or java [options] -m <module>[/<mainclass>] [args...]
java [options] --module <module>[/<mainclass>] [args...]
(to execute the main class in a module)
or java [options] <sourcefile> [args]
(to execute a single source-file program)





share|improve this answer























  • 3





    introduced in Java 11: What's New or/and JEP 330: Launch Single-File Source-Code Programs

    – Carlos Heuberger
    8 hours ago











  • thanks @CarlosHeuberger for the additional details. I made a small edit in my answer to reflect that it was introduced in Java 11.

    – kaan
    8 hours ago



















5
















If you are running Java 11, there is a new feature called Java scripting that allows single source file execution. The single source compiler is more promiscuous in terms of class name versus file name, so that is how you are able to run but not succesfully compile.
https://docs.oracle.com/en/java/javase/11/scripting/java-scripting-api.html#GUID-C4A6EB7C-0AEA-45EC-8662-099BDEFC361A



If you are on a previous version of Java, then your current hello.java does not compile, because of compile errors, specifically around the class name. So there's absolutely no way that calling java hello.java compiled your code, because it does not compile.



It seems most entirely likely that you were running some previously compiled code when executing the java command.






share|improve this answer




























  • thank you, java version is: openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+10) OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)

    – milad
    8 hours ago








  • 1





    check Using Source-File Mode to Launch Single-File Source-Code Programs: "The compiler does not enforce the optional restriction defined at the end of JLS ??7.6, that a type in a named package should exist in a file whose name is composed from the type name followed by the .java extension."

    – Carlos Heuberger
    8 hours ago











  • Thanks for the link Carlos, updated my answer accordingly.

    – Evan
    8 hours 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/4.0/"u003ecc by-sa 4.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%2f58086412%2fdoes-java-command-compile-the-java-program%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









12
















Prior to Java 11, to run your code you have to first compile it, then you can run it. Here's an example:



javac test.java
java test


Since Java 11, you can still do javac + java, or you can run java by itself to compile and auto-run your code. Note that no .class file will be generated. Here's an example:



java test.java


If you run java -help, you'll see the various allowed usages. Here's what it looks like on my machine. The last one is what you ran into: java [options] <sourcefile> [args] which will "execute a single source-file program".



$ java -help
Usage: java [options] <mainclass> [args...]
(to execute a class)
or java [options] -jar <jarfile> [args...]
(to execute a jar file)
or java [options] -m <module>[/<mainclass>] [args...]
java [options] --module <module>[/<mainclass>] [args...]
(to execute the main class in a module)
or java [options] <sourcefile> [args]
(to execute a single source-file program)





share|improve this answer























  • 3





    introduced in Java 11: What's New or/and JEP 330: Launch Single-File Source-Code Programs

    – Carlos Heuberger
    8 hours ago











  • thanks @CarlosHeuberger for the additional details. I made a small edit in my answer to reflect that it was introduced in Java 11.

    – kaan
    8 hours ago
















12
















Prior to Java 11, to run your code you have to first compile it, then you can run it. Here's an example:



javac test.java
java test


Since Java 11, you can still do javac + java, or you can run java by itself to compile and auto-run your code. Note that no .class file will be generated. Here's an example:



java test.java


If you run java -help, you'll see the various allowed usages. Here's what it looks like on my machine. The last one is what you ran into: java [options] <sourcefile> [args] which will "execute a single source-file program".



$ java -help
Usage: java [options] <mainclass> [args...]
(to execute a class)
or java [options] -jar <jarfile> [args...]
(to execute a jar file)
or java [options] -m <module>[/<mainclass>] [args...]
java [options] --module <module>[/<mainclass>] [args...]
(to execute the main class in a module)
or java [options] <sourcefile> [args]
(to execute a single source-file program)





share|improve this answer























  • 3





    introduced in Java 11: What's New or/and JEP 330: Launch Single-File Source-Code Programs

    – Carlos Heuberger
    8 hours ago











  • thanks @CarlosHeuberger for the additional details. I made a small edit in my answer to reflect that it was introduced in Java 11.

    – kaan
    8 hours ago














12














12










12









Prior to Java 11, to run your code you have to first compile it, then you can run it. Here's an example:



javac test.java
java test


Since Java 11, you can still do javac + java, or you can run java by itself to compile and auto-run your code. Note that no .class file will be generated. Here's an example:



java test.java


If you run java -help, you'll see the various allowed usages. Here's what it looks like on my machine. The last one is what you ran into: java [options] <sourcefile> [args] which will "execute a single source-file program".



$ java -help
Usage: java [options] <mainclass> [args...]
(to execute a class)
or java [options] -jar <jarfile> [args...]
(to execute a jar file)
or java [options] -m <module>[/<mainclass>] [args...]
java [options] --module <module>[/<mainclass>] [args...]
(to execute the main class in a module)
or java [options] <sourcefile> [args]
(to execute a single source-file program)





share|improve this answer















Prior to Java 11, to run your code you have to first compile it, then you can run it. Here's an example:



javac test.java
java test


Since Java 11, you can still do javac + java, or you can run java by itself to compile and auto-run your code. Note that no .class file will be generated. Here's an example:



java test.java


If you run java -help, you'll see the various allowed usages. Here's what it looks like on my machine. The last one is what you ran into: java [options] <sourcefile> [args] which will "execute a single source-file program".



$ java -help
Usage: java [options] <mainclass> [args...]
(to execute a class)
or java [options] -jar <jarfile> [args...]
(to execute a jar file)
or java [options] -m <module>[/<mainclass>] [args...]
java [options] --module <module>[/<mainclass>] [args...]
(to execute the main class in a module)
or java [options] <sourcefile> [args]
(to execute a single source-file program)






share|improve this answer














share|improve this answer



share|improve this answer








edited 8 hours ago

























answered 8 hours ago









kaankaan

6121 silver badge17 bronze badges




6121 silver badge17 bronze badges











  • 3





    introduced in Java 11: What's New or/and JEP 330: Launch Single-File Source-Code Programs

    – Carlos Heuberger
    8 hours ago











  • thanks @CarlosHeuberger for the additional details. I made a small edit in my answer to reflect that it was introduced in Java 11.

    – kaan
    8 hours ago














  • 3





    introduced in Java 11: What's New or/and JEP 330: Launch Single-File Source-Code Programs

    – Carlos Heuberger
    8 hours ago











  • thanks @CarlosHeuberger for the additional details. I made a small edit in my answer to reflect that it was introduced in Java 11.

    – kaan
    8 hours ago








3




3





introduced in Java 11: What's New or/and JEP 330: Launch Single-File Source-Code Programs

– Carlos Heuberger
8 hours ago





introduced in Java 11: What's New or/and JEP 330: Launch Single-File Source-Code Programs

– Carlos Heuberger
8 hours ago













thanks @CarlosHeuberger for the additional details. I made a small edit in my answer to reflect that it was introduced in Java 11.

– kaan
8 hours ago





thanks @CarlosHeuberger for the additional details. I made a small edit in my answer to reflect that it was introduced in Java 11.

– kaan
8 hours ago













5
















If you are running Java 11, there is a new feature called Java scripting that allows single source file execution. The single source compiler is more promiscuous in terms of class name versus file name, so that is how you are able to run but not succesfully compile.
https://docs.oracle.com/en/java/javase/11/scripting/java-scripting-api.html#GUID-C4A6EB7C-0AEA-45EC-8662-099BDEFC361A



If you are on a previous version of Java, then your current hello.java does not compile, because of compile errors, specifically around the class name. So there's absolutely no way that calling java hello.java compiled your code, because it does not compile.



It seems most entirely likely that you were running some previously compiled code when executing the java command.






share|improve this answer




























  • thank you, java version is: openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+10) OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)

    – milad
    8 hours ago








  • 1





    check Using Source-File Mode to Launch Single-File Source-Code Programs: "The compiler does not enforce the optional restriction defined at the end of JLS ??7.6, that a type in a named package should exist in a file whose name is composed from the type name followed by the .java extension."

    – Carlos Heuberger
    8 hours ago











  • Thanks for the link Carlos, updated my answer accordingly.

    – Evan
    8 hours ago
















5
















If you are running Java 11, there is a new feature called Java scripting that allows single source file execution. The single source compiler is more promiscuous in terms of class name versus file name, so that is how you are able to run but not succesfully compile.
https://docs.oracle.com/en/java/javase/11/scripting/java-scripting-api.html#GUID-C4A6EB7C-0AEA-45EC-8662-099BDEFC361A



If you are on a previous version of Java, then your current hello.java does not compile, because of compile errors, specifically around the class name. So there's absolutely no way that calling java hello.java compiled your code, because it does not compile.



It seems most entirely likely that you were running some previously compiled code when executing the java command.






share|improve this answer




























  • thank you, java version is: openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+10) OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)

    – milad
    8 hours ago








  • 1





    check Using Source-File Mode to Launch Single-File Source-Code Programs: "The compiler does not enforce the optional restriction defined at the end of JLS ??7.6, that a type in a named package should exist in a file whose name is composed from the type name followed by the .java extension."

    – Carlos Heuberger
    8 hours ago











  • Thanks for the link Carlos, updated my answer accordingly.

    – Evan
    8 hours ago














5














5










5









If you are running Java 11, there is a new feature called Java scripting that allows single source file execution. The single source compiler is more promiscuous in terms of class name versus file name, so that is how you are able to run but not succesfully compile.
https://docs.oracle.com/en/java/javase/11/scripting/java-scripting-api.html#GUID-C4A6EB7C-0AEA-45EC-8662-099BDEFC361A



If you are on a previous version of Java, then your current hello.java does not compile, because of compile errors, specifically around the class name. So there's absolutely no way that calling java hello.java compiled your code, because it does not compile.



It seems most entirely likely that you were running some previously compiled code when executing the java command.






share|improve this answer















If you are running Java 11, there is a new feature called Java scripting that allows single source file execution. The single source compiler is more promiscuous in terms of class name versus file name, so that is how you are able to run but not succesfully compile.
https://docs.oracle.com/en/java/javase/11/scripting/java-scripting-api.html#GUID-C4A6EB7C-0AEA-45EC-8662-099BDEFC361A



If you are on a previous version of Java, then your current hello.java does not compile, because of compile errors, specifically around the class name. So there's absolutely no way that calling java hello.java compiled your code, because it does not compile.



It seems most entirely likely that you were running some previously compiled code when executing the java command.







share|improve this answer














share|improve this answer



share|improve this answer








edited 8 hours ago

























answered 8 hours ago









EvanEvan

9715 silver badges21 bronze badges




9715 silver badges21 bronze badges
















  • thank you, java version is: openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+10) OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)

    – milad
    8 hours ago








  • 1





    check Using Source-File Mode to Launch Single-File Source-Code Programs: "The compiler does not enforce the optional restriction defined at the end of JLS ??7.6, that a type in a named package should exist in a file whose name is composed from the type name followed by the .java extension."

    – Carlos Heuberger
    8 hours ago











  • Thanks for the link Carlos, updated my answer accordingly.

    – Evan
    8 hours ago



















  • thank you, java version is: openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+10) OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)

    – milad
    8 hours ago








  • 1





    check Using Source-File Mode to Launch Single-File Source-Code Programs: "The compiler does not enforce the optional restriction defined at the end of JLS ??7.6, that a type in a named package should exist in a file whose name is composed from the type name followed by the .java extension."

    – Carlos Heuberger
    8 hours ago











  • Thanks for the link Carlos, updated my answer accordingly.

    – Evan
    8 hours ago

















thank you, java version is: openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+10) OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)

– milad
8 hours ago







thank you, java version is: openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+10) OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)

– milad
8 hours ago






1




1





check Using Source-File Mode to Launch Single-File Source-Code Programs: "The compiler does not enforce the optional restriction defined at the end of JLS ??7.6, that a type in a named package should exist in a file whose name is composed from the type name followed by the .java extension."

– Carlos Heuberger
8 hours ago





check Using Source-File Mode to Launch Single-File Source-Code Programs: "The compiler does not enforce the optional restriction defined at the end of JLS ??7.6, that a type in a named package should exist in a file whose name is composed from the type name followed by the .java extension."

– Carlos Heuberger
8 hours ago













Thanks for the link Carlos, updated my answer accordingly.

– Evan
8 hours ago





Thanks for the link Carlos, updated my answer accordingly.

– Evan
8 hours 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%2f58086412%2fdoes-java-command-compile-the-java-program%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

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...