Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
    Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

How to run my java program from command prompt?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
    Bookmark Topic Watch Topic
  • New Topic