[java] probs w/ my first java app
hi there!
today i converted my c++ game ai main routines to java. i installed the latest j2se sdk from sun and could compile it w/ javac. when i started java i got the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: myApp
i''ve win2000 and the latest sun sdk
where''s the problem? i experimented w/ the classpath but nothing worked.
can anybody help me please...
here''s a part of my code:
/***********************************************************************************
* lettermix class - implements all game functionality *
***********************************************************************************/
package LetterMix;
import LetterMix.Dict;
import LetterMix.Cubes;
import LetterMix.Board;
import LetterMix.Word;
import java.io.*;
public final class LetterMix
{
private static final int COUNT_OF_CUBES = 13;
private static final int BOARD_WIDTH = 13;
private static final int BOARD_HEIGHT = 13;
private static final int NOT_USED = 0;
private static final int LEFT_TO_RIGHT = 1;
private static final int UP_TO_DOWN = 2;
private static final int EASY = 0;
private static final int NORMAL = 1;
private static final int HARD = 2;
private static final int AI_MODE_ONE = 0;
private static final int AI_MODE_TWO = 1;
private static final int AI_MODE_THREE = 2;
private static final int COUNT_OF_AI_MODES = 3;
private static Dict dict;
private static Cubes cubes;
private static Board board;
private static Word words[];
private static int difficulty,
wordCount;
private static String bestWord;
public static void main(String argv[])
{
if(init(argv))
{
startThinking();
showResults();
}
else
{
System.out.println("init failed...");
}
}
public static boolean init(String argv[])
{
dict = new Dict();
cubes = new Cubes();
board = new Board();
words = new Word[COUNT_OF_CUBES];
//no parameters...
if(argv.length==0)
{
System.out.println("LETTERMIX ai_mode [cubes_init_string]");
return false;
}
//select difficulty
if(argv.length>0)
{
switch(argv[0].charAt(0))
{
case ''E'': difficulty=EASY;
break;
case ''N'': difficulty=NORMAL;
break;
case ''H'': difficulty=HARD;
break;
default : System.out.println("unsupported difficulty...");
return false;
}
}
//have we a second parameter?
if(argv.length>1)
{
//this cube init string sux...
if(argv[1].length()!=COUNT_OF_CUBES)
{
System.out.println("cube init string wrong...");
return false;
}
//initialize cubes w/ init string
cubes.init(argv[1]);
}
//ok, then we...
else
{
//...let the random play
cubes.init("");
while(!cubes.roll());
}
//initialize dictionary
try
{
dict.init();
}
catch(IOException e)
{
System.out.println("dictionary init failed...");
return false;
}
board.init();
wordCount=0;
return true;
}
Maybe its because you''re using a package...
What is myApp? The class must be declared in a .java file of the same name, and compiled to a class file of the same name.
What is myApp? The class must be declared in a .java file of the same name, and compiled to a class file of the same name.
Hi
If you say something like: public class yourName the java file has to be the same as that name. Example:
public class Test
is in the file Test.java and when compiled it's called Test.class. So you use java test to start it
Hope this can help you
Wesley
[edited by - wicked_wesley on February 7, 2004 5:17:47 PM]
If you say something like: public class yourName the java file has to be the same as that name. Example:
public class Test
is in the file Test.java and when compiled it's called Test.class. So you use java test to start it
Hope this can help you
Wesley
[edited by - wicked_wesley on February 7, 2004 5:17:47 PM]
quote:Original post by Anonymous Poster
Maybe its because you''re using a package...
What is myApp? The class must be declared in a .java file of the same name, and compiled to a class file of the same name.
yeah you need to do java LetterMix.LetterMix to run the program i think
thanx 4 all!
i''ve found the problem. it was not the classpath but the wrong import path - i dropped the package statement and put the main class to the parent folder and the rest in the actual. sometimes it''s so easy...
i thought that there must be something wrong with win2000 and the new j2se sdk. i tried everything with the classpath but nothing happened. damn. it costed me 3 hours to run it.
but now it''s fine :-)
i''ve found the problem. it was not the classpath but the wrong import path - i dropped the package statement and put the main class to the parent folder and the rest in the actual. sometimes it''s so easy...
i thought that there must be something wrong with win2000 and the new j2se sdk. i tried everything with the classpath but nothing happened. damn. it costed me 3 hours to run it.
but now it''s fine :-)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement