Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Error: Could not find or load main class(error)
Error: Could not find or load main class [message #916806] Wed, 19 September 2012 13:44 Go to next message
Greg Walker is currently offline Greg WalkerFriend
Messages: 4
Registered: September 2012
Junior Member
Hello,

I recently downloaded Eclipse on my machine and am trying to run an application. I get the following error message when I try to run the program in the console window:

Error: Could not find or load main class test_package.testClass.

testClass contains
public static void main(String[] args)


Any advice on how to get the program to run would be appreciated!


[Updated on: Wed, 19 September 2012 13:46]

Report message to a moderator

Re: Error: Could not find or load main class [message #916838 is a reply to message #916806] Wed, 19 September 2012 14:37 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
Make sure that the project is a java project and make sure that you have built the project.

Are there any errors reported on the project such as missing classpath entries in the Problems view?
Re: Error: Could not find or load main class [message #916846 is a reply to message #916838] Wed, 19 September 2012 14:45 Go to previous messageGo to next message
Greg Walker is currently offline Greg WalkerFriend
Messages: 4
Registered: September 2012
Junior Member
The project is a java project, the Build All and Build Project options are greyed out under the Project dropdown however. This may be part of the issue. Other than the previously mentioned error I have no errors in the Problems tab, only some warnings. This program compiled and ran fine on my home PC. Does it matter where I have my JDK folder? It's in my C:/ but not in the same folder as eclipse if that makes any difference.


EDIT: I have Build Automatically checked so that shouldn't be a problem I suppose.

[Updated on: Wed, 19 September 2012 14:47]

Report message to a moderator

Re: Error: Could not find or load main class [message #916863 is a reply to message #916846] Wed, 19 September 2012 15:05 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 9/19/2012 8:45 AM, Greg Walker wrote:
> The project is a java project, the Build All and Build Project options
> are greyed out under the Project dropdown however. This may be part of
> the issue. Other than the previously mentioned error I have no errors in
> the Problems tab, only some warnings. This program compiled and ran fine
> on my home PC. Does it matter where I have my JDK folder? It's in my C:/
> but not in the same folder as eclipse if that makes any difference.

It doesn't. See http://wiki.eclipse.org/Eclipse.ini. You should wire it
up according to these instructions; that way we're all on the same page
investigating what's wrong.
Re: Error: Could not find or load main class [message #916866 is a reply to message #916863] Wed, 19 September 2012 15:13 Go to previous messageGo to next message
Greg Walker is currently offline Greg WalkerFriend
Messages: 4
Registered: September 2012
Junior Member
Russell Bateman wrote on Wed, 19 September 2012 11:05
On 9/19/2012 8:45 AM, Greg Walker wrote:
> The project is a java project, the Build All and Build Project options
> are greyed out under the Project dropdown however. This may be part of
> the issue. Other than the previously mentioned error I have no errors in
> the Problems tab, only some warnings. This program compiled and ran fine
> on my home PC. Does it matter where I have my JDK folder? It's in my C:/
> but not in the same folder as eclipse if that makes any difference.

It doesn't. See http://wiki.eclipse.org/Eclipse.ini. You should wire it
up according to these instructions; that way we're all on the same page
investigating what's wrong.


there's nothing in the wiki about the .ini in that link

EDIT: I found the page in the sticky. Here's what my .ini looks like, what do I need to change? (it's all on one line when I open it, not on different lines). Also, where do I look on my machine to verify which JDK I need? (Win x86 or Win x64).


-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20120522-1813
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Dhelp.lucene.tokenizer=standard
-Xms40m
-Xmx512m

[Updated on: Wed, 19 September 2012 15:20]

Report message to a moderator

Re: Error: Could not find or load main class [message #916881 is a reply to message #916866] Wed, 19 September 2012 15:35 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 9/19/2012 9:13 AM, Greg Walker wrote:
> Russell Bateman wrote on Wed, 19 September 2012 11:05
>> On 9/19/2012 8:45 AM, Greg Walker wrote:
>> > The project is a java project, the Build All and Build Project options
>> > are greyed out under the Project dropdown however. This may be part of
>> > the issue. Other than the previously mentioned error I have no
>> errors in
>> > the Problems tab, only some warnings. This program compiled and ran
>> fine
>> > on my home PC. Does it matter where I have my JDK folder? It's in my
>> C:/
>> > but not in the same folder as eclipse if that makes any difference.
>>
>> It doesn't. See http://wiki.eclipse.org/Eclipse.ini. You should wire
>> it up according to these instructions; that way we're all on the same
>> page investigating what's wrong.
>
>
> there's nothing in the wiki about the .ini in that link

If that wiki link on eclipse.ini is insufficient for your use, then I
suggest you research how to use the -vm option in eclipse.ini, the
references and advice on the web are legion, and then act accordingly to
what you learn.
Re: Error: Could not find or load main class [message #916902 is a reply to message #916881] Wed, 19 September 2012 16:07 Go to previous messageGo to next message
Greg Walker is currently offline Greg WalkerFriend
Messages: 4
Registered: September 2012
Junior Member
Well I was looking for advice here (I understand what you're doing with the 'go figure it out yourself... don't have someone spoon feed you what you need to know' paradigm... it's extremely popular in computer science...). I just wanted to get the IDE up and running quickly and not have to research the inner workings of all the commands needed to run Eclipse.
Re: Error: Could not find or load main class [message #916913 is a reply to message #916902] Wed, 19 September 2012 16:23 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 9/19/2012 10:07 AM, Greg Walker wrote:
> Well I was looking for advice here (I understand what you're doing with
> the 'go figure it out yourself... don't have someone spoon feed you what
> you need to know' paradigm... it's extremely popular in computer
> science...). I just wanted to get the IDE up and running quickly and not
> have to research the inner workings of all the commands needed to run
> Eclipse.

No, you're getting advice here. Follow the link (you say says nothing)
especially about the -vm option. Put this in eclipse.ini just BEFORE the
-vmargs option. Option -vm takes two lines, exactly as here. (From my
two machines...)

On Windows:

-vm
C:\Users\russ\jdk1.7.0_03\bin\javaw.exe

On Linux:

-vm
/home/russ/dev/jdk1.6.0_35/bin/java

Notice that I have privately installed JDKs. You don't have to do that.
I just don't like the Java I develop with to have anything to do with
the Java my OS is running for everything else Java going on.

Yes, there are two or more other ways of accomplishing this, but it's
the most explicit way. Once you get this done, come back and we can
concentrate on your real problem knowing that what's in eclipse.ini.

I'm only giving you this advice because you asked if it mattered where
your JDK folder goes (it doesn't, but if you're using it in your Java
development, it does have to be "hooked up" properly).
Re: Error: Could not find or load main class [message #916918 is a reply to message #916806] Wed, 19 September 2012 16:38 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Can you paste the entire source?

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:Password Required Query
Next Topic:Eclipse auto complete suggestions not working properly
Goto Forum:
  


Current Time: Fri Apr 19 04:43:30 GMT 2024

Powered by FUDForum. Page generated in 0.04206 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top