Bookmark Topic Watch Topic
  • New Topic

How to run my java program from command prompt?  RSS feed

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi, I have just finished writing a program in NetBeans & everything's works fine when I run it. But when I try to run from from command prompt in the classes directory it says it cannot find the main class. I am currently following a book on how to do it which doesn't seem to work for me. Any help would be greatly appreciated!

 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Zukias Trunchbull wrote:Hi, I have just finished writing a program in NetBeans & everything's works fine when I run it. But when I try to run from from command prompt in the classes directory it says it cannot find the main class. I am currently following a book on how to do it which doesn't seem to work for me. Any help would be greatly appreciated!

First: What have you tried? And what message are you getting (the exact message please).

Winston
 
Zukias Trunchbull
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Report post to moderator
Winston Gutkowski wrote:
Zukias Trunchbull wrote:Hi, I have just finished writing a program in NetBeans & everything's works fine when I run it. But when I try to run from from command prompt in the classes directory it says it cannot find the main class. I am currently following a book on how to do it which doesn't seem to work for me. Any help would be greatly appreciated!

First: What have you tried? And what message are you getting (the exact message please).

Winston


Thanks for replying so fast and sorry I didn't elaborate enough.

My generated class files (from netbeans) are in C:\java\InputGraph\build\classes\inputgraph
So I set the path in command prompt using cd C:\java\InputGraph\build\classes\inputgraph
and then on the next line I try "java InputGraph.class", which is the main class.

I get: "Error: Could not find or load main class InputGraph.class"
 
Zukias Trunchbull
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Report post to moderator
oops there's no subdirectory after classes btw, wasn't meant to type 'inputgraph' after it
 
Zukias Trunchbull
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Report post to moderator
Update: I've just tried to run my program from command prompt in the source code directory too which also doesn't work.
I set the path where the main class is and try "javac InputGraph.java", which comes up with the errors:

C:\java\InputGraph\src\inputgraph>javac InputGraph.java
InputGraph.java:23: error: cannot find symbol
ArrayList<Vertex> VS;
^
symbol: class Vertex
location: class InputGraph
InputGraph.java:24: error: cannot find symbol
ArrayList<Edge> ES;
^
symbol: class Edge
location: class InputGraph
InputGraph.java:26: error: cannot find symbol
Vertex tempVertex;
^
symbol: class Vertex
location: class InputGraph
InputGraph.java:50: error: cannot find symbol
VS= new ArrayList<Vertex>();
^
symbol: class Vertex
location: class InputGraph
InputGraph.java:51: error: cannot find symbol
ES = new ArrayList<Edge>();
^
symbol: class Edge
location: class InputGraph
InputGraph.java:72: error: cannot find symbol
Vertex currentVertex = VS.get(0);
^
symbol: class Vertex
location: class InputGraph.myRunnable
InputGraph.java:134: error: cannot find symbol
Edge e = ES.get(i);
^
symbol: class Edge
location: class InputGraph.MyDrawPanel
InputGraph.java:142: error: cannot find symbol
Vertex v = VS.get(i);
^
symbol: class Vertex
location: class InputGraph.MyDrawPanel
InputGraph.java:173: error: cannot find symbol
VS.add(new Vertex((int)(e.getX() - 0.5*vertexSize),(int)(e.getY() -
0.5*vertexSize),Color.BLACK));
^
symbol: class Vertex
location: class InputGraph
InputGraph.java:195: error: cannot find symbol
Vertex v2 = VS.get(i);
^
symbol: class Vertex
location: class InputGraph
InputGraph.java:198: error: cannot find symbol
ES.add(new Edge(tempVertex,v2));
^
symbol: class Edge
location: class InputGraph
11 errors
 
Zukias Trunchbull
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Report post to moderator
ive made too many mistakes on this thread, can a mod close it please? I'm going to remake!
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Zukias Trunchbull wrote:ive made too many mistakes on this thread, can a mod close it please? I'm going to remake!

Done.

Winston
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!