Simple Java n00b help (hopefully seriously simple)

Right done that, can compile/run in the command prompt now, so i have something to show!

Eclipse is still arsing around. Could it be i've had Visual Studio installed on here, and/or GHCi and WinHugs? Or the fact i'm running vista?

Can't thank you enough for the help you're giving me, can't describe how lost i am and how this is driving me up the wall! This is meant to be a platform independent language and IDE! How can it be this hard! :D

Here's what i get from the eclipse console:

java.lang.NoClassDefFoundError: main
Caused by: java.lang.ClassNotFoundException: main
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)
Exception in thread "main"
 
Last edited:
How are you running your program? Are you right-clicking BounceMain.java in Eclipse and then doing Run As > Java Application?
 
Last edited:
Something odd is going on, I think it could be something to do with Vista because it works fine on my XP installation. I don't even have Eclipse installed on my computer, I downloaded the zipped version (no installer or shortcuts) and extracted it to my USB stick which I use on many computers and there is no problem as long as the machine has JDK installed. I don't have a Vista machine to test it on though.

Are all of your imports correct?

For BouncePanel.java
Code:
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import javax.swing.JComponent;

For BounceMain.java
Code:
import javax.swing.JFrame;

Does you code compile fine from the command prompt and run?

Netbeans is my IDE of choice, it shares most of the features that Eclipse has although it uses more resources. I'd suggest giving that a try if you absolutely can't get Eclipse to work and need an IDE. We were taught Eclipse at Uni and I started using Netbeans in my free time, I picked it up easily.
 
HelloWorld Compiles and runs from the command prompt fine, i've googled this all day, surely if this was a vista nasty it would be all over the internet by now? I'm just not sure if i'm searching for the right thing...

Anyways
I have no idea what this means, but this is what it says under import declarations (surely these where just taken from the code?) :p
BounceMain
javax.swing.*
BouncePannel
java.awt.*
java.awt.event.*
java.awt.geom.*
javax.swing.*

I may just end up using something else, although my course is taught under the EclipseIDE annoyingly so if they give any tutorials/walkthrough they're allways the Eclipse screenshots, and the lab computers only have Eclipse (although i could throw netbeans on them, it would be a pain...)
 
I have some work in for a thursday tutorial in uni, i missed the last one cause the b*****d wouldn't work, hope i can get something together for this tutorial...! Netbeans it may be.
 
Yep the imports are fine, does the Bounce program compile and run okay under the command prompt? The imports are at the very top of the code and also in the outline pane in eclipse, my imports are explicit but you can use * to import the whole package though it doesn't make much difference.

I don't think Vista can be the problem either, have you tried downloading eclipse again, I'm using Europa Version: 3.3.1.1 and it runs fine, I get the bouncing ball and GUI.
 
It compiles and runs perfectly from the command prompt, and yeah i have the latest Eclipse, and i've downloaded it quite a few times *just to make sure* :p :D Bah, i'll try netbeans and hope to christ that works!

I can't understand if the command prompt can compile and run it, what does eclipse do inbetween using the same commands?
 
Another thing to check. Goto Window > Preferences > Java > Build Path > Classpath Variables

classpath.jpg


Check that JRE_LIB is actually pointing to the correct place. Also are you running Eclipse as an admin? I know UAC causes some weird behaviour in Vista when certain things don't have the correct permissions to do stuff they need to.
 
Well like yours it says its depriciated and non modifiable, but its still pointing in the right place. I've also got UAV turned off but i didnt run as admin, i'll give that a quick go now cant see it working....

//Edit: No joy, i'm still in the middle of other things currently, so i'll have a play with netbeans and just hope that does the job, you;ve been very helpful but i dont want to waste your time anymore! Cheers anyway though!
 
Last edited:
lol... you should trying setting up Eclipse to run C++. Now that's what I call a headache. Oh.. and be thankful that your not using IBM's RSA (previously known as RAD, previously known as Websphere).. which is based on Eclipse but is a complete rubbish.

Oh, and good luck ;) (netbeans is pretty good from what my colleague tells me, so hopefully it will be ok). Your better off trying to understand it though, else you'll just say eclipse is rubbish without getting to grips with it.

Matthew
J2EE Developer lol.
 
Well i'd love to "understand it" but i'm just starting off developing in java, lets get to small grips with the language first! I feel like i'm delving deep into the depths of eclipse just to get it working in any way? Doesn't seem right something is way off...
 
Believe me, you'll spend more time ******* about with eclipse than actually writing programs. I mean that not in the way of problems, I mean with configuring it.

Make sure you learn about Hibernate and Spring (ASK THE LECTURER about it) as they are freeware and also pretty industry wide used components :)

Just get the basics of the language down first as you say. It is very much like C++ really from what I've seen, but better typed/syntax'd.

Matthew
 
Last edited:
If you get stuck with any code feel free to post it in this forum, there are a few of us who know Java to some extent and we can probably point you in the right direction. You'll always find that you spend most of your time tracking down silly mistakes in your code and trying to understand the sometimes cryptic compiler messages, I know I did. I'm by no means an expert at Java, I have 2 years of Java experiance from Uni and I'm still learning. Keep at it though because it does get easier the more you use it, I found that the tutorials at Uni sort of throw you in at the deep end. I remember using code that was explained by the lecturer but you don't fully understand how it works or why you are using it.

The good news is when you have learnt about object orintated principals and understand Java a bit better you can transfer these skills to similar programming languages such as C# or OO PHP. So if you're thinking that you don't see Java as a mainstream programming language don't worry, it teaches you valuable programming skills.
 
Yeah thats where this java is coming from now, its an OO programming course :D

Cheers guys, you've been very helpful i hope to get started on my task tonight after i've got my backup schedule sorted first, then i may be formatting this computer anyway (which may even sort out other problems with eclipse, but i shouldn't have to go to these measures!).
 
Its official! It HAS to be vista, i've just formatted completely, installed updates and few other things. First installed the latest JDK then downloaded eclipse, and still get the same error message. Its something to do with the JDK i think though because my PATH hasn't been set again for command prompt compiling...

And netbeans works like a charm
 
Last edited:
Back
Top Bottom