Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning a Compiled Java Class
    primarykey
    data
    text
    <p>I compiled two java source codes, namely version.class and open.class</p> <p>Basically, the version.class holds the public static void main clause, while the open.class is mainly a set of constructors that makes the whole program work.</p> <p>Here is how I did it: </p> <pre><code>if ("n".equalsIgnoreCase(input)) { new open(); } else if ("q".equalsIgnoreCase(input)) { System.exit(0); } </code></pre> <p>The problem is when I run it in CMD, where I did type this:</p> <pre><code>java version </code></pre> <p>it says that the command can not find or load the main class. What is the main problem why this happens? Thank you. I was hoping this would run in CMD as well when compiled, so I could make a bat file to make the program run in CMD as well. Edit:</p> <p>Here is the whole version class:</p> <pre><code>import java.util.Scanner; public class version{ public static String input; public static Scanner s = new Scanner (System.in); public static void main (String [] args ) { System.out.println("========================"); System.out.println("ANAGRAM MASTER VERSION 1.0"); System.out.println("Created by: Janrae Mendoza"); System.out.println("=========================="); System.out.println("Press the corresponding letters for your desired option: "); System.out.println("&lt;n&gt; New Game"); System.out.println("&lt;q&gt; Quit Game"); input = s.nextLine(); if ("n".equalsIgnoreCase(input)) { new open(); } else if ("q".equalsIgnoreCase(input)) { System.exit(0); } } </code></pre> <p>}</p> <p>while this is the open class:</p> <pre><code>import java.util.Random; import java.util.Scanner; public class open{ public String input; public Scanner s = new Scanner (System.in); public Random r = new Random(); //at least 25 words public String scrambled[] = {"MICSECO", "LEPAIM", "ICHORE", "MLORTA", "TIEEXSUQI", "MEERTO", "DESTOAK", "MLIBOE", "PHRAPARGA", "UALBILNGI", "DOXORTHRO", "ZEIMESREM", "OKVEPRO", "ILAPRS", "TEMOED", "QUEMSADRAE", "LSEIMUP", "CREUPRO", "BLRUNDE", "CKRENO", "UIPRSUT", "BINMEHLOGO", "DRKERA", "SEACEDAP", "SOULEAZ"}; public String scrAns[] = {"ECONOMICS", "IMPALE", "HEROIC", "MORTAL", "EXQUISITE", "REMOTE", "STOCKADE", "MOBILE", "PARAGRAPH", "BILINGUAL", "ORTHRODOX", "MESMERIZE", "PROVOKE", "SPIRAL", "DEMOTE", "MASQUERADE", "IMPULSE", "PROCIRE", "BLUNDER", "RECKON", "PURSUIT", "HEMOGLOBIN", "DARKER", "ESCAPADE", "ZEALOUS"}; public int word; public boolean stop = false; public int scrnum; public int timesplayed; public void sleep() { try { Thread.sleep(1000); } catch (Exception e) {} } public open() { while (stop == false) { sleep(); System.out.println("Guess out the scrambled word!"); word = r.nextInt(24); scrnum = word; System.out.println("ANAGRAM: " + scrambled[word]); System.out.print("YOUR ANSWER: "); input = s.nextLine(); if (input.equalsIgnoreCase(scrAns[scrnum])) { System.out.println("You guessed the word right!"); System.out.println("Continue playing? &lt;y&gt; Yes and any other keys for No"); input = s.nextLine(); if ("y".equalsIgnoreCase(input)) { timesplayed++; } else { stop = true; } } } System.out.println("Thank you for trying out version 1 of this game! You played " + timesplayed + " times! Enjoy your day, player!"); } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload