Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. error: could not find or load main class

error: could not find or load main class

Scheduled Pinned Locked Moved Java
helpjavaasp-netlinux
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 11047610
    wrote on last edited by
    #1

    0 down vote favorite on my ubuntu terminal i was trying to compile and run the program like this javac -cp "/usr/lib/jvm/jdk1.8.0_20/lib/gs-core-1.2.jar" GraphExplore.java successfully compiled.now to run java -cp "/usr/lib/jvm/jdk1.8.0_20/lib/gs-core-1.2.jar" GraphExplore I got error saying Error: Could not find or load main class GraphExplore I am newbee in java.please someone help me to resovle this issue.thanks in advance.what i tried to resolve this error.i kept .class file in one folder and run i mean i kept in one path and tried to execute in that path only but it didnt work.please help me

    L T U 3 Replies Last reply
    0
    • U User 11047610

      0 down vote favorite on my ubuntu terminal i was trying to compile and run the program like this javac -cp "/usr/lib/jvm/jdk1.8.0_20/lib/gs-core-1.2.jar" GraphExplore.java successfully compiled.now to run java -cp "/usr/lib/jvm/jdk1.8.0_20/lib/gs-core-1.2.jar" GraphExplore I got error saying Error: Could not find or load main class GraphExplore I am newbee in java.please someone help me to resovle this issue.thanks in advance.what i tried to resolve this error.i kept .class file in one folder and run i mean i kept in one path and tried to execute in that path only but it didnt work.please help me

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You need to show us where, in your program, the main method is.

      U 1 Reply Last reply
      0
      • L Lost User

        You need to show us where, in your program, the main method is.

        U Offline
        U Offline
        User 11047610
        wrote on last edited by
        #3

        import org.graphstream.graph.*;
        import org.graphstream.graph.implementations.*;
        import java.util.Iterator;

        public class GraphExplore {
        public static void main(String args[]) {
        new GraphExplore();
        }

        public GraphExplore() {
            Graph graph = new SingleGraph("tutorial 1");
        
            graph.addAttribute("ui.stylesheet", styleSheet);
            graph.setAutoCreate(true);
            graph.setStrict(false);
            graph.display();
        
            graph.addEdge("AB", "A", "B");
            graph.addEdge("BC", "B", "C");
            graph.addEdge("CA", "C", "A");
            graph.addEdge("AD", "A", "D");
            graph.addEdge("DE", "D", "E");
            graph.addEdge("DF", "D", "F");
            graph.addEdge("EF", "E", "F");
        
            for (Node node : graph) {
                node.addAttribute("ui.label", node.getId());
            }
        
            explore(graph.getNode("A"));
        }
        
        public void explore(Node source) {
            Iterator k = source.getBreadthFirstIterator();
        
            while (k.hasNext()) {
                Node next = k.next();
                next.setAttribute("ui.class", "marked");
                sleep();
            }
        }
        
        protected void sleep() {
            try { Thread.sleep(1000); } catch (Exception e) {}
        }
        
        protected String styleSheet =
            "node {" +
            "   fill-color: black;" +
            "}" +
            "node.marked {" +
            "   fill-color: red;" +
            "}";
        

        }

        L O 2 Replies Last reply
        0
        • U User 11047610

          0 down vote favorite on my ubuntu terminal i was trying to compile and run the program like this javac -cp "/usr/lib/jvm/jdk1.8.0_20/lib/gs-core-1.2.jar" GraphExplore.java successfully compiled.now to run java -cp "/usr/lib/jvm/jdk1.8.0_20/lib/gs-core-1.2.jar" GraphExplore I got error saying Error: Could not find or load main class GraphExplore I am newbee in java.please someone help me to resovle this issue.thanks in advance.what i tried to resolve this error.i kept .class file in one folder and run i mean i kept in one path and tried to execute in that path only but it didnt work.please help me

          T Offline
          T Offline
          TorstenH
          wrote on last edited by
          #4

          Eclipse for Ubuntu[^] Have fun!

          regards Torsten I never finish anyth...

          1 Reply Last reply
          0
          • U User 11047610

            import org.graphstream.graph.*;
            import org.graphstream.graph.implementations.*;
            import java.util.Iterator;

            public class GraphExplore {
            public static void main(String args[]) {
            new GraphExplore();
            }

            public GraphExplore() {
                Graph graph = new SingleGraph("tutorial 1");
            
                graph.addAttribute("ui.stylesheet", styleSheet);
                graph.setAutoCreate(true);
                graph.setStrict(false);
                graph.display();
            
                graph.addEdge("AB", "A", "B");
                graph.addEdge("BC", "B", "C");
                graph.addEdge("CA", "C", "A");
                graph.addEdge("AD", "A", "D");
                graph.addEdge("DE", "D", "E");
                graph.addEdge("DF", "D", "F");
                graph.addEdge("EF", "E", "F");
            
                for (Node node : graph) {
                    node.addAttribute("ui.label", node.getId());
                }
            
                explore(graph.getNode("A"));
            }
            
            public void explore(Node source) {
                Iterator k = source.getBreadthFirstIterator();
            
                while (k.hasNext()) {
                    Node next = k.next();
                    next.setAttribute("ui.class", "marked");
                    sleep();
                }
            }
            
            protected void sleep() {
                try { Thread.sleep(1000); } catch (Exception e) {}
            }
            
            protected String styleSheet =
                "node {" +
                "   fill-color: black;" +
                "}" +
                "node.marked {" +
                "   fill-color: red;" +
                "}";
            

            }

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Strange, I cannot see anything wrong with your code. Are you sure that the compilation worked successfully and the class file exists in the directory where you are calling the java command from?

            1 Reply Last reply
            0
            • U User 11047610

              import org.graphstream.graph.*;
              import org.graphstream.graph.implementations.*;
              import java.util.Iterator;

              public class GraphExplore {
              public static void main(String args[]) {
              new GraphExplore();
              }

              public GraphExplore() {
                  Graph graph = new SingleGraph("tutorial 1");
              
                  graph.addAttribute("ui.stylesheet", styleSheet);
                  graph.setAutoCreate(true);
                  graph.setStrict(false);
                  graph.display();
              
                  graph.addEdge("AB", "A", "B");
                  graph.addEdge("BC", "B", "C");
                  graph.addEdge("CA", "C", "A");
                  graph.addEdge("AD", "A", "D");
                  graph.addEdge("DE", "D", "E");
                  graph.addEdge("DF", "D", "F");
                  graph.addEdge("EF", "E", "F");
              
                  for (Node node : graph) {
                      node.addAttribute("ui.label", node.getId());
                  }
              
                  explore(graph.getNode("A"));
              }
              
              public void explore(Node source) {
                  Iterator k = source.getBreadthFirstIterator();
              
                  while (k.hasNext()) {
                      Node next = k.next();
                      next.setAttribute("ui.class", "marked");
                      sleep();
                  }
              }
              
              protected void sleep() {
                  try { Thread.sleep(1000); } catch (Exception e) {}
              }
              
              protected String styleSheet =
                  "node {" +
                  "   fill-color: black;" +
                  "}" +
                  "node.marked {" +
                  "   fill-color: red;" +
                  "}";
              

              }

              O Offline
              O Offline
              Oscar0
              wrote on last edited by
              #6

              Since your main declaration looks correct, it most likely the compile was not successful. Look in the directory where you are compiling. See if the file GraphExplore.class was created. You will get that message if it is not being created as a result of an error. As a further experiment, try misspelling the name when you run it, you will see that it is the exact same error.

              1 Reply Last reply
              0
              • U User 11047610

                0 down vote favorite on my ubuntu terminal i was trying to compile and run the program like this javac -cp "/usr/lib/jvm/jdk1.8.0_20/lib/gs-core-1.2.jar" GraphExplore.java successfully compiled.now to run java -cp "/usr/lib/jvm/jdk1.8.0_20/lib/gs-core-1.2.jar" GraphExplore I got error saying Error: Could not find or load main class GraphExplore I am newbee in java.please someone help me to resovle this issue.thanks in advance.what i tried to resolve this error.i kept .class file in one folder and run i mean i kept in one path and tried to execute in that path only but it didnt work.please help me

                U Offline
                U Offline
                User 11120519
                wrote on last edited by
                #7

                in your buildpath,it need load jar ,so u upload this jar in your project, and then server will building it,

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups