Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 15th, 2006, 4:51 AM   #1
tumbleTetris
Programmer
 
Join Date: May 2006
Posts: 39
Rep Power: 0 tumbleTetris is on a distinguished road
Sun Java Studio creator not running what another compiler does...

Basically I have two classes:

public class abc123 {
public static void main(String[] args) {

int val1 = 1, val2 = 2, sum;

cba abc = new cba();

sum = abc.xcalc(val1, val2);
}

}
____________

public class cba {
public int xcalc(int z, int y)
{
return z + y;
}
}

________________

when I compile both on Sun Java Studio creator and try to run them I get an error:
java.lang.NoClassDefFoundError: class2/abc123
Exception in thread "main"
Java Result: 1

If I run it off Jcreator it runs fine...

could someone pelase helP?
tumbleTetris is offline   Reply With Quote
Old May 15th, 2006, 9:00 AM   #2
java_roshan
Professional Programmer
 
Join Date: Mar 2005
Location: Student of University of Mumbai, Maharashtra State, India
Posts: 344
Rep Power: 4 java_roshan is on a distinguished road
What are you running through Jcreator? (the class file?)
I hope you have saved the file with the name of the class where main function resides.

This error is more common for committing mistakes with the above procedure. It shouldn't be anything else (AFAIK)
__________________
Visit: http://www.somaiya.edu
java_roshan is offline   Reply With Quote
Old May 15th, 2006, 10:06 AM   #3
tumbleTetris
Programmer
 
Join Date: May 2006
Posts: 39
Rep Power: 0 tumbleTetris is on a distinguished road
well one class is called abc123, the other is called ruff.

When I compile and run them using jcreator it works fine, when I do the same in Sun Java Studio it gives me that error...
tumbleTetris is offline   Reply With Quote
Old May 15th, 2006, 11:15 AM   #4
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 4 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
First, please you code tags for your code. second, Sun Java Studio is really slow and why are you using 2 IDE at once. Third place cba class within your main class.

Call this file "Abc.java"
[PHP]
public class Abc
{
public static void main(String[] args)
{

cba abc = new cba();
int val1 = 1, val2 = 2, sum;
sum = abc.xcalc(val1, val2);
}
private class cba
{
public int xcalc(int z, int y)
{
return z + y;
}
}
}
[/PHP]
Compile and run it, this will work fine regardless of any type of Java IDE
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Old May 15th, 2006, 8:38 PM   #5
tumbleTetris
Programmer
 
Join Date: May 2006
Posts: 39
Rep Power: 0 tumbleTetris is on a distinguished road
I'm not using 2 IDE's, I'm only using Sun's IDE, but it's not working on it, but its working on jcreator.

I also want it to run from two serperate class files, not just one...
tumbleTetris is offline   Reply With Quote
Old May 15th, 2006, 8:57 PM   #6
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 4 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
Either you must have the two files in the same directory or just define the cba class in a packages.

[PHP]
package mypackage.classes;
class cba
{
public int xcalc(int z, int y)
{
return z + y;
}
}
[/PHP]

Then import that package where you would like to use that class
[PHP]
//main class
import mypackage.classes;
public class Abc
{
public static void main(String[] args)
{

cba abc = new cba();
int val1 = 1, val2 = 2, sum;
sum = abc.xcalc(val1, val2);
}
}
[/PHP]

If this doesn't work, your IDE is f*cked up!
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Old May 15th, 2006, 9:26 PM   #7
tumbleTetris
Programmer
 
Join Date: May 2006
Posts: 39
Rep Power: 0 tumbleTetris is on a distinguished road
I just don't understand why Sun's doesn't work werein jcreator does (also the linux based compiler at school also works)...
tumbleTetris is offline   Reply With Quote
Old May 15th, 2006, 9:30 PM   #8
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 4 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
Did you do what I said to do?
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Old May 16th, 2006, 7:32 AM   #9
tumbleTetris
Programmer
 
Join Date: May 2006
Posts: 39
Rep Power: 0 tumbleTetris is on a distinguished road
well I haven't read up on packages just yet, its actually in the next chapter, so I'm going to read it and see how it works and what to do exactly.

If the packaging doesnt work I'll come back
tumbleTetris is offline   Reply With Quote
Old May 16th, 2006, 8:05 AM   #10
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 4 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
It should, if not, your IDE is the problem then.
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:38 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC