Hello world programme is not executing

39 Views Asked by At

PS C:\Users\PARKHAR AGARWAL\Desktop> cd "JavaProgramming.java" //written by me in terminal. cd : Cannot find path 'JavaProgramming.java' because it does not exist. // error

At line:1 char:1
+ cd "JavaProgramming.java"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (JavaProgramming.java:String) [Set-Location], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

// what should i do now because i have checked that my file is present in desktop.

I m not getting Hello world as a output.

1

There are 1 best solutions below

0
Emanuel On

You cannot run JavaProgramming.java with CD.

Files with .java extensions are not compiled programs. You need, first of all, to compile it with some compiler, like javac. It will generate a .jar file.

After that, you can use the java command in the terminal to run this program. Example: java ./JavaProgramming.jar