Exception in thread "main" java.lang.NoClassDefFoundError: shoogle/services

Hi

i'm having a problem with this and am not sure why i'm getting this error,

here my code

/*

* XMLCache.java

*

* Created on 21 April 2006, 16:47

*

* To change this template, choose Tools | Template Manager

* and open the template in the editor.

*/

package shoogle.services;

/**

*

* @author gerard

*/

import shoogle.Global;

import shoogle.CrossQuery;

import shoogle.DateTime;

import java.util.ArrayList;

import java.sql.*;

import java.io.*;

import java.net.*;

/**

*

* @author Gerard

*/

publicclass XMLCache{

/** Creates a new instance of XMLCache */

public XMLCache(){

}

publicvoid updateRSS()

{

Global global =new Global();

ArrayList RSSList =new ArrayList();

Connection dbconn;

ResultSet results;

PreparedStatement sql;

try

{

Class.forName("com.mysql.jdbc.Driver").newInstance();

try

{

String sql_string;

dbconn = DriverManager.getConnection(global.ShoogleDBURL, global.ShoogleDBWriteUser, global.ShoogleDBWritePassword);

sql_string ="SELECT RSSURL FROM rss_store";

sql = dbconn.prepareStatement(sql_string);

results = sql.executeQuery();

while(results.next())

{

RSSList.add(results.getString("RSSURL"));

}

dbconn.close();

}

catch (SQLException s)

{

System.out.println("updateRSS: " + s);

}

}

catch (Exception ex)

{

System.out.println("updateRSS: " + ex);

}

for (int i=0; i < RSSList.size(); i++)

{

String RSSURL = (String) RSSList.get(i);

fetchRSS(RSSURL);

System.out.println(RSSURL);

}

}

publicboolean createRSSEntry(String RSSURL)

{

Global global =new Global();

boolean RSSCreated =false;

Connection dbconn;

PreparedStatement sql;

try

{

Class.forName("com.mysql.jdbc.Driver").newInstance();

try

{

String sql_string;

dbconn = DriverManager.getConnection(global.ShoogleDBURL, global.ShoogleDBWriteUser, global.ShoogleDBWritePassword);

sql_string ="INSERT INTO rss_store (RSSURL) VALUES ('" + RSSURL +"')";

sql = dbconn.prepareStatement(sql_string);

sql.executeUpdate();

RSSCreated =true;

dbconn.close();

}

catch (SQLException s)

{

System.out.println("createRSSEntry: " + s);

}

}

catch (Exception ex)

{

System.out.println("createRSSEntry: " + ex);

}

System.out.println("RSSCreated");

return RSSCreated;

}

publicboolean fetchRSS(String RSSURL)

{

Global global =new Global();

CrossQuery crossquery =new CrossQuery();

DateTime datetime =new DateTime();

boolean RSSFetched =false;

String CurrentDateTime = datetime.returnCurrentYearMonthDayHoursMinutesSeconds();

int ItemCheck = crossquery.countItems("RSSURL","rss_store","RSSURL", RSSURL);

if (ItemCheck == 0)

{

createRSSEntry(RSSURL);

}

try

{

URL url =new URL(RSSURL);

URLConnection c = url.openConnection();

InputStream in = c.getInputStream();

ByteArrayOutputStream baous =new ByteArrayOutputStream();

byte[] buf =newbyte[1<<9];

for(int read; (read = in.read(buf)) != -1; baous.write(buf, 0, read));

buf =null;

byte[] data = baous.toByteArray();

Connection dbconn;

PreparedStatement sql;

try

{

Class.forName("com.mysql.jdbc.Driver").newInstance();

try

{

String sql_string;

dbconn = DriverManager.getConnection(global.ShoogleDBURL, global.ShoogleDBWriteUser, global.ShoogleDBWritePassword);

sql_string ="UPDATE rss_store SET XMLBlob=?, LastUpdateDateTime='" + CurrentDateTime +"' WHERE RSSURL='" + RSSURL +"'";

sql = dbconn.prepareStatement(sql_string);

sql.setBytes(1,data);

sql.executeUpdate();

dbconn.close();

}

catch (SQLException s)

{

System.out.println("fetchRSS\\updateItem: " + s);

}

}

catch (Exception ex)

{

System.out.println("fetchRSS: " + ex);

}

}

catch (Exception e)

{

}

RSSFetched =true;

return RSSFetched;

}

}

then when i call it i'm using a little comand prompt i had created

d:

cd\

cd sites

cd shoogle.shinelimited.com

cd root

cd web-inf

cd classes

java -classpath .;D:\Sites\shoogle.shinelimited.com\ROOT\WEB-INF\lib\mysql-connector-java-3.1.11-bin.jar shoogle.services.XMLCache

but i keep getting

D:\Sites\shoogle.shinelimited.com\ROOT>java -classpath .;D:\Sites\shoogle.shinelimited.com\ROOT\WEB-INF\classes\shoogle\services.shoogle.services.XMLCache

Exception in thread "main" java.lang.NoClassDefFoundError:shoogle/services/XMLCache

i'm not sure what the error is and y? please help thanks

[8860 byte] By [Shamz84a] at [2007-10-3 8:47:26]
# 1

> then when i call it i'm using a little comand prompt

> i had created

>

> d:

> cd\

> cd sites

> cd shoogle.shinelimited.com

> cd root

> cd web-inf

> cd classes

> java -classpath

> .;D:\Sites\shoogle.shinelimited.com\ROOT\WEB-INF\lib\m

> ysql-connector-java-3.1.11-bin.jar

> shoogle.services.XMLCache

>

>

>

> but i keep getting

>

> D:\Sites\shoogle.shinelimited.com\ROOT>java

> -classpath

> .;D:\Sites\shoogle.shinelimited.com\ROOT\WEB-INF\class

> es\shoogle\services.shoogle.services.XMLCache

> Exception in thread "main"

> java.lang.NoClassDefFoundError:shoogle/services/XMLCac

> he

>

You posted two different Classpaths and two different directories from which you are trying to launch this application. So it's a little confusing.

The bottom line is, your class' fully qualified class name is shoogle.services.XMLCache so the command must provide this name as an argument. The XMLCache.class file must be in some_directory_path/shoogle/services/. The Classpath must contain some_directory_path that contains shoogle/service/XMLCache.class

For example, if you have this path: D:\Sites\shoogle.shinelimited.com\ROOT\WEB-INF\classes\shoogle\services\XMLCache.class then this command should workjava -cp D:\Sites\shoogle.shinelimited.com\ROOT\WEB-INF\classes shoogle.services.XMLCache If you need other classes, for example classes in a jar, then you need to include the jar in the Classpath as well.

atmguya at 2007-7-15 3:56:26 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2

Hi thanks mate,

im calling a class which is part of a package which is within another package

i have two packages

Shoogle and shoogle services

i need to call the XMLCache class within shoogle services package

i need the jar file which is mysql-connector-java-3.1.11-bin.jar which is in the libry folder hope this cleared it for ya.

So when i call the class i need to eunsre i user the mysql jar to update the database

so everytime i call the class i get this error

Exception in thread "main" java.lang.NoSuchMethodError: main

Shamz84a at 2007-7-15 3:56:26 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3
the anoying thing is that i can use the class in the web application, but calling it in comand propt seems to be a problem.I haven't used the comand promt in ages, so i'm not sure if i've been doing somthing wrong!
Shamz84a at 2007-7-15 3:56:26 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 4

> so everytime i call the class i get this error

>

> Exception in thread "main"

> java.lang.NoSuchMethodError: main

This is not the error you originally posted so it appears you have made some progress.

When you launch a java application from a command line, you specify a class and the JVM looks inside the class for a method with this signature:public static void main(String[] args)

This method signature must be exactly as shown above (except that you can use any valid variable name for 'args'). The error you are getting is saying the JVM can not find such a method in the class you specified.

Of course, this method has to have code that begins the execution of your application.

atmguya at 2007-7-15 3:56:26 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 5
thanks mate i'll give that a go!!
Shamz84a at 2007-7-15 3:56:26 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 6
Thanks matie that worked!!!!
Shamz84a at 2007-7-15 3:56:26 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...