[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.newcomer] Re: my easy program won't run

"Jobog Lee" <jobog69@xxxxxxxxxxx> wrote in message 
news:gbnv7n$ir3$1@xxxxxxxxxxxxxxxxxxxx
> Hello all,
> I've recently downloaded Eclipse 3.4.0. My machine is running Windows XP 
> SP3.
> When i first downloaded this program, i ran the eclipse application in the 
> folder and created a program that printed "Hello World" to the screen. At 
> first it worked out fine...but the next day, i attempted to run it again 
> and i got this message:
> Launching "helloWorld" has encountered a problem.

It may help you to distinguish between what Eclipse does, and what your 
program does.

Eclipse is a tool that lets you edit and debug programs written in a variety 
of possible languages, including Java.  You can run programs from Eclipse, 
in order to test them, but you don't have to.

Once you've written and built a Java program, you should have a directory 
containing some .class files.  The .class files are the compiled versions of 
your .java source code.  If you want you can use Eclipse "File -> Export" to 
export the .class files as a .jar ("Java Archive") file, which is basically 
just a zip file.

Then, to run your program, you use a Java virtual machine ("JVM"), in your 
case javaw.exe.  You need to tell the JVM where your .class files or .jar 
file are; one way to do this is by naming a "classpath".  For instance, if 
your .class files got built into a directory named "C:\Documents and 
Settings\Joe\workspace\helloWorld\bin", and your main() method was in a 
class named HelloWorld, then you could say
  javaw -cp "C:\Documents and Settings\Joe\workspace\helloWorld\bin" 
HelloWorld
and it should find and run the program.  That's all that Eclipse is doing 
when you tell it to run a program - it just launches javaw.exe, or java.exe, 
and points it at your compiled classes.

So, what I'm saying here is that you can run your program outside of 
Eclipse.  By doing that, you can tell whether your problem is with Eclipse, 
or with the program.  That will help you figure out what direction to go.


> All i need is something simple to get me through my beginning Java class 
> at school.

Hopefully, your beginning Java class comes with a teaching assistant or 
professor who can help you?  Isn't that the point of a school?  Eclipse is a 
fine development tool, but newsgroups can only go so far - you will be much 
more successful in your endeavor if you have a classmate, TA, or prof of 
whom you can ask questions face to face.