Welcome to the Ranch
You need
the code button to maintain the indentation. I have edited your post with the code button and doesn't it look better
If you are still at the hello world stage, then using packages simply makes things more difficult for you. The thing about packages is that they require a certain directory structure and they change the name of your class. In the first code snippet, the class name is not Test; it is myPackage.Test. Try it:-
In order to run it you have to call it by its correct name.
java myPackage.Test
… and that name must correspond to the directory structure. When you say myPackage.... you must find the Test.class file inside the myPackage folder. You must be able to do
… and get myPackage as part of the output. You will probably have to write
cd ..
first. The .. bit is universal shorthand for one directory towards the root, i.e. the parent directory of wherever you start off.
So, to get that to run, you can do lots of different things. An easy way:-
1: Make sure there is a directory called myPackage.2: Put the Test.java file in that directory.3: Navigate to the myPackage directory, and use the following three instructions in that order:-
javac Test.java
cd ..
java myPackage.Test
You can read about packages in the
Java™ Tutorials. Note there is a rather strange convention for package names.