• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using IntelliJ to type the code. Can't run Main.class file  RSS feed

 
narendra nath
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good Morning folks,

As I introduced myself recently, I am a complete newbie to Java

I installaed JDK on windows 8 OS. I installed JDK on C:\Programfiles\Java

I used IntelliJ tool to write HelloWorld program. The name of the class is Main.class.

When I compile, no errors and I can even run it from Intelli. But when I try to run it from command prompt using "java" command, it says can't find Main

The Main. class is not at C:\Programfiles\java\jdk folder. It is at somewhere else on C drive.

I even copied just the Main.class file to C:\Programfiles\Java\jdk.xx\bin and run it as java Main
It still can't work.

I understand from that error that the JVM is not able to find Main method/function which is the starting point in Main.class file. But don't know how to make it run from command prompt.

Any suggestions my good folks?
thanks
nath

 
Charles D. Ward
Ranch Hand
Posts: 99
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, don't use an IDE if you're new to Java. Use a decent text editor like Notepad++ and compile and run from the command line.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
basam nath wrote: . . .
I even copied just the Main.class file to C:\Programfiles\Java\jdk.xx\bin and run it as java Main
. . .
Don't. Leave that folder for installation files. As well as agreeing with the recommendation to use Notepad++, I have my own suggestions about folders. Look here. It is much easier like that.

If you have managed to lose your file, you can always use the search option on Windows to find it.
 
Knute Snortum
Sheriff
Posts: 4274
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In order to answer your question fully, we need three things:

  • The name of the Java program
  • The folder you put it in
  • If your program has a package statement, post that too
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!