Error complie "Exception in thread "main" java.lang.NoClassDefFoundError"
Dear All,
I have the following problem can not compile the code below.
Here my settings and the code.
Thanks for the help.
My java version.
===============================================
D:\bea\jdk150_22\bin>java -version
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) Client VM (build 1.5.0_22-b03, mixed mode)
===============================================
I use a bat to compile the code
===============================================
set JDK_HOME=D:\bea\jdk150_22
set PATH=%JDK_HOME%\bin;%PATH%
set CLASSPATH=%CLASSPATH%;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.jar
rem ---- compile
javac GetDBOracle.java
rem ---- testing
java GetDBOracle
rem ---- add to jar
jar cf GetDBOracle.jar GetDBOracle.class
===============================================
My java code
===============================================
import java.sql.*;
import java.io.*;
public class GetDBOracle {
public static String GetDBOracle(String Parm1, String Parm2) throws SQLException
String myResult = "";
// Load Oracle driver
DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
// Connect to the local database
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@localhost:ORCL", "ORC", "ORC2010");
// Query the employee names
Statement stmt = conn.createStatement ();
ResultSet rset = stmt.executeQuery ("SELECT JAVA_GET_VALUE('"Parm1"','"Parm2"') FROM DUAL");
// Print the name out
while (rset.next ()) {
myResult = rset.getString (1);
//close the result set, statement, and the connection
rset.close();
stmt.close();
conn.close();
return myResult;
public static void main(String args[])
try {
System.out.println(GetDBOracle("XXI", "12000"));
} catch (Exception e) {
System.out.println(e.getMessage());
===============================================
Erro
===============================================
Exception in thread "main" java.lang.NoClassDefFoundError: GetDBOracle
===============================================
What happened to this Error complie "Exception in thread "main" java.lang.NoClassDefFoundError" ?
Similar Messages
-
I want to run an jar file so on command prompt i am giving the command
" java -jar jSimpleX_3.0.jar "
I am getting the following error:
"exception in thread "main" java.lang.NoClassDefFoundError: org/xml/sax/SAXException "
Can any body explain the reason of this exception
Thanks in advance.Hi
I am getting an exception while running code of "
Reading an XML file in Java"
The error is " Exception in thread "main"
java.lang.NoClassDefFoundError:
org/xml/sax/SAXException "
I am using j2sdk1.4.0 and j2sdk1.4.2_13 and both are
containing rt.jar file. But still i am receiving the
same Error Exception.
Can anybody there help me out.
Thanks in Advance. !!!!Please help me out. Its urgent !!!!!!!!!!!!!!!!!!!!!!! -
Exception in thread "main" java.lang.NoClassDefFoundError: base
this is my error, in my progam there is a database which has to insert the values. but is not inserting.
the error is,
Exception in thread "main" java.lang.NoClassDefFoundError: base
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
and the code for that program is as follows
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.io.*;
class base
PreparedStatement pstmt=null;
Connection con = null;
Statement stmt = null;
ResultSet rset = null;
int est_effort;
String proj_id,proj_name,client_name,strt_date,est_date,proj_mgr;
void add( )
try
String driverName = "com.mysql.jdbc.Driver";
Class.forName(driverName);
String serverName = "192.168.10.253";
String mydatabase = "Trainees";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
String username = "josep";
String password = "josep";
con = DriverManager.getConnection(url, username, password);
System.out.println("Connected");
catch(Exception e)
System.err.println("Exception: " + e.getMessage());
try{
pstmt = con.prepareStatement("INSERT INTO project(proj_id,proj_name,client_name,strt_date,est_date,proj_mgr,est_effort)VALUES
pstmt.setString (1,proj_id);
pstmt.setString (2,proj_name);
pstmt.setString (3,client_name);
pstmt.setString (4,strt_date);
pstmt.setString (5,est_date);
pstmt.setString(6,proj_mgr);
pstmt.setInt (7,est_effort);
pstmt.executeUpdate();
catch(Exception e)
System.err.println("Exception: " + e.getMessage());
finally
try
if(con != null)
con.close();
catch(SQLException e)
void modify()
void delete()
void assign()
class xx extends base
public static void main(String args[]) throws IOException
base a= new base();
a.add();
}If you are trying something like:java xxThen class xx should be public. (Also Base and Xx are better names for
classes.) -
Exception in thread "main" java.lang.NoClassDefFoundError: Files\Apache
Hi,
I am new to smart card.I have installed and configured the JCDK.When i try to run the build_sample.bat,I got the following error.
Exception in thread "main" java.lang.NoClassDefFoundError: Files\Apache
can you guys give me the solution please.Thank you.
Sankarhi
Thank you..yes really when i check the class path in my environment,i saw the spaces between the Program Files.this i was set for my tomcat server.so its taken Apache as a file.
regards
sankar -
Hi,
system i am using for Oracle SOA is :
Windows 64 Bit
i5 Processor
6 GB RAM
29 GB on C Drive is already free after installation of all SOA related products.
I have installed wlserver_10.3 for SOA 11g Development purpose and followed exact installation sequence and procedure as mention in oracle documentation
i created domain also and every thing look correct but after installation procedure there are "Additional actions required just after every thing installed" :
setting memory limit
starting weblogic server (Admin Server)
starting weblogic managed server
and so on
now Problem is when i execute C:\Oracle\Middleware\user_projects\domains\soa_div_domain\bin startWebLogic.cmd
as mention in oracle documentation i am getting following error message : (i have only included last error lines instead of complete console log)
oConsole= -Dweblogic.ext.dirs=C:\Oracle\MIDDLE~1\patch_wls1036\profiles\default\
sysext_manifest_classpath;C:\Oracle\MIDDLE~1\patch_oepe180\profiles\default\syse
xt_manifest_classpath;C:\Oracle\MIDDLE~1\patch_ocp371\profiles\default\sysext_ma
nifest_classpath;C:\Oracle\MIDDLE~1\patch_adfr1111\profiles\default\sysext_manif
est_classpath weblogic.Server
Listening for transport dt_socket at address: 8453
Exception in thread "main" java.lang.NoClassDefFoundError: vXmx512m
Caused by: java.lang.ClassNotFoundException: vXmx512m
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: ++Xmx512m. Program will exit.
Now to resolve this what i already tried are :
I change JAVA_HOME and PATH to jdk6 which came with web logic installer
Location is at :
JAVA_HOME : C:\Oracle\Middleware\jdk160_29
PATH : C:\Oracle\Middleware\jdk160_29\bin
The above dose not include any space between path
I ran the startWebLogic.cmd and got same error
After that I also added
CLASSPATH : C:\Oracle\Middleware\jdk160_29\lib\tool.jar;C:\Oracle\Middleware\wlserver_10.3\server\lib\weblogic.jar;C:\Oracle\Middleware\jdk160_29\bin
WL_HOME: C:\Oracle\Middleware\wlserver_10.3
I ran the startWebLogic.cmd and got same error
I also used earlier path which I used with eclipse when I was working on other java development.
JAVA_HOME : C:\Program Files\Java\jdk1.7.0_21
PATH : C:\Program Files\Java\jdk1.7.0_21\bin
I ran the startWebLogic.cmd and got same error
Then I also gave PATH: C:\Oracle\Middleware\wlserver_10.3\server\lib (including the existing one using ; )
I ran the startWebLogic.cmd and got same error
Now may be there is a file called setSOADomainEnv.cmd in
< C:\Oracle\Middleware\user_projects\domains\soa_div_domain\bin\ setSOADomainEnv.cmd>
That include some values for memory set :
set JAVA_OPTIONS=%JAVA_OPTIONS%
set DEFAULT_MEM_ARGS=-Xms512m –Xmx512m
set PORT_MEM_ARGS=-Xms512m –Xmx768m
if "%JAVA_VENDOR%" == "Oracle" goto OracleJVM
set DEFAULT_MEM_ARGS=%DEFAULT_MEM_ARGS% -XX:PermSize=128m -XX:MaxPermSize=768m
set PORT_MEM_ARGS=%PORT_MEM_ARGS% -XX:PermSize=256m -XX:MaxPermSize=768m
now as I change the red highlighted value to 512 value because I have less memory resource and I checked in installation documentation to change the above red highlighted value to 512 original is 1024 which is too high and it was crating problem and showing memory space problem so I change it to 512 and now I am not getting that memory space problem error but may be the above error is related with change value in setSOADomainEnv.cmd file or not
Following are my domain, weblogic and soa home directory path and all these path are exactly what it suppose to be according to Oracle Installation Documentation:
WebLogic :
C:\Oracle\Middleware\wlserver_10.3
C:\Oracle\Middleware\coherence_3.7
C:\Oracle\Middleware\oepe_11.1.1.8.0
SOA Oracle Home Directory :
C:\Oracle\Middleware\Oracle_SOA1
OSB Home Location :
C:\Oracle\Middleware\Oracle_OSB1
Domain name : soa_div_domain
Domain Location : C:\Oracle\Middleware\user_projects\domains
Application Location : C:\Oracle\Middleware\user_projects\applications
Domain Location: C:\Oracle\Middleware\user_projects\domains\soa_div_domain
form here i am trying to start weblogic : C:\Oracle\Middleware\user_projects\domains\soa_div_domain\bin\startWebLogic.cmd
Please tell me any body want more details.
Thanks.I think you are missing a character '-'
USER_MEM_ARGS="Xms512m -Xmx512m -XX:MaxPermSize=128m"Add this character like follows
"-Xms512m -Xmx512m -XX:MaxPermSize=128m" -
Hi,
I am new to SQLJ. Now, in my PC (with Win98), I have JDK 1.2 and Oracle 8i (personal edition). I have used Java and Oracle in my PC without any problem. Now, I am going to learn SQLJ in order to create a java program to access Oracle database. What I have done is to set up several classpaths in DOS:
SET classpath=C:\ora_program\sqlj\lib\translator.zip;
SET classpath=C:\ora_program\sqlj\lib\runtime.zip;
SET classpath=C:\ora_program\sqlj\lib\runtime12.zip;
SET classpath=C:\ora_program\jdbc\lib\classes12.zip;
The code of my program is:
import java.sql.Date;
import java.sql.SQLException;
import oracle.sqlj.runtime.Oracle;
import java.util.Date;
public class Hello{
public static void main(String[] args){
java.sql.Date current_date;
try{
// connect to the db
Oracle.connect(
"C:\ora_program\bin",
"system",
"manager");
// get the current date from the database
#sql{SELECT sysdate INTO :current_date FROM dual};
// display message
System.out.println("Hello, the current date is: "+ current_date);
catch(SQLException e){
System.err.println("sqlException: "+e);
finally{
try{
Oracle.close();
catch(SQLException e){
System.err.println("sqlException: "+e);
And then I compile my program in DOS with the typing: sqlj Hello.sqlj
The program cannot be compiled and the error message is:
"Exception in thread main java.lang.NoClassDefFoundError: sqlj/tools/Sqlj"
It indicates that the SQLJ translator class files cannot be found.
I have set up the classpath in DOS (see above). How does the error come? Please help. Thanks.
PC>
SET classpath=C:\ora_program\sqlj\lib\translator.zip;
SET classpath=C:\ora_program\sqlj\lib\runtime.zip;
SET classpath=C:\ora_program\sqlj\lib\runtime12.zip;
SET classpath=C:\ora_program\jdbc\lib\classes12.zip;
The above only sets the classpath to the last value. You need to use the following.
SET classpath=%classpath%;C:\ora_program\sqlj\lib\runtime.zip; -
I've just started to take on java, and some examples from my learning source
show the
javac.exe fileincluded.java
to
java.exe fileincluded
method. Although I can compile fine, when I go to run I get a java.exe error - Exception in thread "main" java.lang.NoClassDefFoundError:.
I thought it was an environment variable problem as I'm running win xp.
I've gotten the bin directory included, and I've previously had visual studio .net installed
so the INCLUDE and LIB variables are set to those directories. I've tried to attach the java /lib and /bin directories by ";C:\PROGRAM FILES\JAVA\JDK1.5.0_02\LIB" etc,
and that didn't work. What can I do to fix this problem?I get the I/O exception while reading: D:\Java\HelloApplet (The system cannot find the file specified). I have previously compiled HelloApplet.java into HelloApplet.class using javac.exe
the two include statements in the sample HelloApplet I'm using are
import java.applet.*;
import java.awt.*;
I also have a ComponentEventTest.java file which I've made into a class with these two
include statements:
import java.awt.*;
import java.awt.event.*;
I can however compile .java files which have no include statements.
I take it that my classpath is not set correctly. Like I said earlier, I'm using winxp
and trying to set the classpath variable under system. I have tried under user too. The path names I've tried setting are C:\Program Files\Java\jdk1.5.0_02\, C:\Program Files\Java\jdk1.5.0_02\lib, C:\Program Files\Java\jdk1.5.0_02\include, and C:\Program Files\Java\jdk1.5.0_02\;C:\Program Files\Java\jdk1.5.0_02\lib;C:\Program Files\Java\jdk1.5.0_02\include.
How can I correct this? If it's possible, I would like to set a variable in windows
versus having to type extra commands at the command prompt everytime I try
to run a java class with java.exe. Any help would be much appreciated -
Error: Exception in thread "main" java.lang.NoClassDefFoundError:
Hi
I have seen this problem on a few forums but have not found an answer that works for me, sorry if missed it!!
The command I am giving is:
C:\Program Files\Rococo\ImprontoSimulator\examples\echo\bin>echo-server
Exception in thread "main" java.lang.NoClassDefFoundError: com/rococosoft/impronto/examples/echo/EchoServer
this runs the following batch file:
@echo off
set CLASSPATH=
set CLASSPATH=%SIMULATOR_HOME%\lib\isim_j2se.jar;%CLASSPATH%
set CLASSPATH=%SIMULATOR_HOME%\lib\log4j.jar;%CLASSPATH%
set CLASSPATH=%SIMULATOR_HOME%\examples\echo\lib\echo.jar;%CLASSPATH%
java -classpath "%CLASSPATH%" com.rococosoft.impronto.examples.echo.EchoServer
this is where I assume all the CLASSPATH's are set.
Any help would be very much appreciated.
Thanks
NitinOnce you have defined your classpath as an environment variable, it shouldn't be necessary to include it (or quote it) within the command line. In other words,
c:\> java EchoServer
should have worked. However, I suspect the reason the batch script doesn't work might be because %SIMULATOR_HOME% isn't defined? If Java can't find any of the libraries, then it can't find a class EchoServer that contains a main() function to call, resulting in the error message you've received. -
Run time error - Exception in thread "main" java.lang.NoClassDefFoundError:
Can can one help me with this error:
Exception in thread "main" java.lang.NoClassDefFoundError: TestEnv
The program is a simple one
import java.io.*;
import java.util.*;
import java.lang.*;
import java.lang.String.*;
//A Very Simple Example
class TestEnv {
public static void main(String[] args){
System.out.println("Env is fine");
Compile the program:
javac TestEnv.java
Run the program:
java TestEnv
Error: Exception in thread "main" java.lang.NoClassDefFoundError: TestEnvTry setting the classpath properly. It seems the runtime evironment is unable to find the compiled class files. Nothing else is wrong.
--Anil -
Exception in thread "main" java.lang.NoClassDefFoundError
Am using java 1.3.1 on Red Hat Linux 7.1
i get this error
Exception in thread "main" java.lang.NoClassDefFoundError
while running a simple program HelloWorld.java
helpWhen you use the "java" command, the only required argument is the name of the class that you want to execute. This argument must be a class name, not a file name, and class names are case sensitive. For example, "java HelloWorld.java" won't work because the class name isn't HelloWorld.java, it's HelloWorld. Similarly, "java helloworld" won't work because a class defined as "public class HelloWorld {" is not named helloworld due to case sensitivity. Finally, the .class file must be in a directory that is in the Classpath - that's where java.exe searches to find the file that contains the class.
-
Hi,
I have created a class JaxmClient.java. When I compile the class with appropriate jar files assigned to -classpath it compiles successfully with no errors. But when I run the classe "java JaxmClient" it produces the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/soap/SOAPElement
Can someone help me I am knew to this technology.
Thanks in advanceI tried to use in my execution all the jar files that I used for compilation.
java -cp jaxm-jar; etc.jar Request
but it still gives me this execption
Exception in thread "main" java.lang.NoClassDefFoundError: Request
I am in the right directory where is the Request.class file is and it is present in this directory....
Thanks appreciate your help... -
I am trying to develop a web service client for amazon webservice.but i am getting this error while running the app. Can anyone please help me. I have installed the JWSDP and but could not understand why i have to locate all the jar files in the classpath?Please help.
===== error=========================================
C:\abr\classes>java -classpath c:\abr\test.jar;C:\abr\jaxrpc-api.jar;C:\abr\jaxrpc-impl.jar;C:\abr\jaxrpc-spi.jar;c:\abr\classes\amazon.jar;C:\abr\mail.jar;C:\a
br\saaj-api.jar;C:\abr\activation.jar;c:\abr\FastInfoset.jar;%classpath% Client
[b]Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/stream/XMLS
treamWriter
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at com.sun.xml.rpc.client.StreamingSender._writeRequest(StreamingSender.
java:672)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:87)
at amazon.AmazonSearchPort_Stub.authorSearchRequest(AmazonSearchPort_Stu
b.java:988)
at Client.main(Client.java:21)I'm assuming you're using JWSDP 1.6 as I see Fastinfoset.jar in your list. You are missing some jar files in your classpath there. The best way to know what you need is to look at the release notes for JWSDP 1.6. Since you're building a web serivce start with the table in there and lookup JAX-RPC. It'll show you what jar files are needed and what other libraries are needed. Now depending on what you're doing you don't really need all those.
For sure you're missing jsr173_api.jar which is where I believe that class you need is located. This is in the JWSDP_1_6\sjsxp\lib directory. You will probably need the other jar thats in there too. Best bet is to follow the dependancy chart in the release notes.
This should get you going.
Ryan -
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/xml/parser/v2/
XSLException
Hi
I have downloaded XDK and was trying to use the XSU feature..
I unzipped the XDK file, I ran the following query on SQL plus
select * from emp. It displayed the full table.
Then i set the class path for XDK,XMLparserv2,oracle JDBC driver and then ran the same query on dos prompt(that is front end command line for java in my case).
The following is the line i tried to execute on the command prompt
java OracleXML getXML -user "scott/tiger" -conn "jdbc:oracle:thin:@localhost
:1521:PomonaT" "select * from emp"
PomonaT is the db name(Host string i use to enter SQL+)
I get the following error
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/xml/parser/v2/
XSLException
at OracleXML.To_XML(OracleXML.java:1038)
at OracleXML.ExecuteGetXML(OracleXML.java:917)
at OracleXML.main(OracleXML.java:184)
IS SOMETHING MISSING IN MY CLASSPATH??
IF YES? Could anyone tell what??
KunalAdd xmlparserv2.jar to Classpath & reboot.
-
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldSwing
Hello;
I got a error to run my application, i have not problem with compile it. But it give me the following error massage when i run it.
Could anyone help me please.
E:\Java>javac HelloWorldSwing.java
E:\Java>java HelloWorldSwing
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldSwing
E:\Java>path
PATH=C:\Program Files\Java\jdk1.6.0\bin;C:\Program Files\QuickTime\QTSystem\;C:\
Program Files\Common Files\Adobe\AGL;C:\Program Files\Microsoft SQL Server\80\To
ols\BINN;C:\Program Files\Java\jre1.6.0\bin;C:\Program Files\Java\jre1.6.0\bin;C
:\Program Files\Java\j2re1.4.2_13\bin
The following are where my jdk and jre store.
C:\Program Files\Java>dir
Volume in drive C has no label.
Volume Serial Number is 3023-229B
Directory of C:\Program Files\Java
04/02/2007 12:22 AM <DIR> .
04/02/2007 12:22 AM <DIR> ..
01/02/2007 10:54 PM <DIR> j2re1.4.2_13
03/02/2007 04:54 PM <DIR> jdk1.6.0
01/02/2007 10:02 PM <DIR> jre1.5.0_06
04/02/2007 12:22 AM <DIR> jre1.6.0
0 File(s) 0 bytes
6 Dir(s) 5,761,228,800 bytes freeIt even tries to tell you what's wrong. Run class "start.HelloWorldSwing", not "HelloWorldSwing".
I bet that copying that error message without the class name into Google would have given you the answer right away. -
Exception in thread "main" java.lang.NoClassDefFoundError: Springer
Hi,
i'm trying to programm the knight-problem, but i am not sure, that the Code is right:
public class Springer {
public static int[] sx = new int[10];
public static int[] sy = new int[10];
public static int[][] feld;
public static int nquad;
// Springzuege:
void init(int[] sx,int[] sy,int[][] feld,int n,int nquad) {
//Pringerzuege
sx[1] = 2; sy [1] = 1;
sx[2] = 1; sy [2] = 2;
sx[3] = -1; sy [3] = 2;
sx[4] = -2; sy [4] = 1;
sx[5] = -2; sy [5] = -1;
sx[6] = -1; sy [6] = -2;
sx[7] = 1; sy [7] = -2;
sx[8] = 2; sy [8] = -1;
// Schachbrett Inizialisation
for(int i=0; i<8; ++i){
for(int j=0; j<8; ++j){
feld[i][j]=-1; //Umrandung = -1
for(int i=2; i<=5; ++i){
for(int j=2; j<=5; ++j){
feld[i][j]=0; //Spielfelder auf 0 setzen
nquad=n*n;
boolean zug(int x,int y,int tiefe) {
int u; // Index
int v; // Index
int k=1; //zaehlt die 8 Moeglichkeiten
boolean erg=false; //bisher keine Loesung
while(!erg && k<=8) {
u=x + sx[k];
v=y + sy[k];
if(feld[u][v]==0) {
feld[u][v]=tiefe;
if(tiefe<nquad) {
erg=zug(u,v,tiefe+1); //Rekursion
if(!erg) //ruecksetzen
feld[u][v]=0;
else
erg=true; //Loesung gefunden
++k;
return erg;
public static void main(String [] args) {
int n;
int i=1;
int j=1;
boolean okay=false;
Springer s = new Springer();
s.init(sx,sy,feld,4,nquad);
feld[i][j]=1; //Anfangsfeld besetzen
okay=s.zug(i,j,2);
if(okay)
System.out.print("Ein solches Pfad ist gefunden");
else
System.out.print("Keine Loesung gefunden");
There is no errors by the compiling. But when i want to run the application follows:
Exception in thread "main" java.lang.NoClassDefFoundError: Springer
Can someone help me??
I need that program!A few more comments on your code...
- In Java arrays index start at 0 not at 1. You may want to change your init() method accordingly.
- In init() the parameter nquad hide the field of the same name so the assignment you make at the end of the method is lost
Hope this help,
Eric
Maybe you are looking for
-
Urgent help needed: how to display a list of records on the screen
Hello, This is very urgent. Can anyone help me. I have posted this query of mine before also but still no reply came. My whole application is dependent on this problem. Actually I am developing an application for mobile phone using MIDP. I have a rec
-
Macbook Pro Retina (15") can't connect to wireless mouse and external USB keyboard
Hi All, I got my new MacBook Pro Retina (15 inch) about 3 weeks ago. It works fine. I got a 30" Dell screen that I am using via thunderbolt/usb adapter. Also, I am using a thunderbolt ethernet adapter. Both adapters work fine without any problems. I
-
Cannot install iTunes 9.0, 9.02 or any version in XP on Acer Aspire One
I am not sure why I am unable to uninstall iTunes 9.0+ on my netbook. It keeps saying... another installation is in progress and please complete the other before doing this. I removed a lot of other programs, closed auto updates for XP but still I ca
-
have just bought a secondhand macbookpro1,1 core duo, what is the fastest operating system i can upgrade to?
-
Code your GUI using source coding or drag and drop
Which is the most effective way to code/make your GUI either coding on the source code or just dragging and dropping. And who would receive or obtain best result or best web page between the dragger and the coder(source code