Created a project in NetBeans
(according to the book by P. Naughton, G. Shildt "Java2. The most complete guide").
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package example2; /** * * @author Asus */ /* * ΠΡΡΠ³ΠΎΠΉ ΠΊΠΎΡΠΎΡΠΊΠΈΠΉ ΠΏΡΠΈΠΌΠ΅Ρ. * Π€Π°ΠΉΠ» "Example2.java" */ public class Example2 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here int num; //ΠΎΠ±ΡΡΠ²Π»ΡΠ΅Ρ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ Ρ ΠΈΠΌΠ΅Π½Π΅ΠΌ num num=100; //ΠΏΡΠΈΡΠ²Π°ΠΈΠ²Π°Π΅Ρ num Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ 100 System.out.println("ΠΠ½Π°ΡΠ΅Π½ΠΈΠ΅ num: "+num); num*=2; System.out.print("Π£Π΄Π²ΠΎΠ΅Π½Π½ΠΎΠ΅ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ num: "); System.out.println(num); } }
When creating a project, the class example2.Example2
was created with the project folder D:\ExamplesFromBook\Example2\Example2
(and the project location is D:\ExamplesFromBook\Example2
). Created bytecode using the command line
D:\ExamplesFromBook\Example2\Example2\src\example2>javac Example2.java
as a result, the file Example2.class
was created. Example2.class
I tried to launch a .class file from the command line in a variety of ways, including, for example:
D:\ExamplesFromBook\Example2\Example2>java example2.Example2
resulting in an error
Error: Could not find or load main class example2.Example2
Which command should I use and from which folder should I run?
java example2/Example2
- I don't know, I don't have any Windows). And in the package, it seems that the way is given.) - alexlz/
also does not work. If there isNetBeans
, then having done everything from the very beginning (having set the location and the same path and name of the project in the project settings), you can make sure that it does not work and gives the same error. - ivan89