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 ScopeApp
Error: Could not find or load main class ScopeApp [message #1690726] Mon, 30 March 2015 20:26 Go to next message
Logan King is currently offline Logan KingFriend
Messages: 6
Registered: March 2015
Junior Member
I have just recently typed the code below, and it keeps giving me the the error message: Error: Could not find or load main class ScopeApp. I have looked all over the internet for the internet for the solution but I can't find it. So can someone please help me.
Code:

public class ScopeApp
{
static int x;
public static void main(String[] args)
{
x = 5;
System.out.println("main: x = " + x);
myMethod();
}
public static void myMethod()
{
int y;
y = 10;
if (y == x + 5)
{
int z;
z = 15;
System.out.println("myMethod: z = " + z);
}
System.out.println("myMethod: x = " + x);
System.out.println("myMethod: y = " + y);
}
}
Re: Error: Could not find or load main class ScopeApp [message #1690732 is a reply to message #1690726] Mon, 30 March 2015 21:46 Go to previous messageGo to next message
Nitin Dahyabhai is currently online Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

When does it(?) give you that error message? Have you tried putting your class in a package?

_
Nitin Dahyabhai
Eclipse Web Tools Platform

[Updated on: Mon, 30 March 2015 21:46]

Report message to a moderator

Re: Error: Could not find or load main class ScopeApp [message #1690734 is a reply to message #1690732] Mon, 30 March 2015 22:14 Go to previous messageGo to next message
Logan King is currently offline Logan KingFriend
Messages: 6
Registered: March 2015
Junior Member
It gives me the error message after i try to run the code
Re: Error: Could not find or load main class ScopeApp [message #1690735 is a reply to message #1690734] Mon, 30 March 2015 22:34 Go to previous messageGo to next message
Logan King is currently offline Logan KingFriend
Messages: 6
Registered: March 2015
Junior Member
And i am 99.9% certain that the class is in a package
Re: Error: Could not find or load main class ScopeApp [message #1690740 is a reply to message #1690735] Mon, 30 March 2015 23:27 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 03/30/2015 04:34 PM, Logan King wrote:
> And i am 99.9% certain that the class is in a package

Yes, likely it's in what's called the "default package."
Re: Error: Could not find or load main class ScopeApp [message #1690741 is a reply to message #1690734] Mon, 30 March 2015 23:28 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 03/30/2015 04:14 PM, Logan King wrote:
> It gives me the error message after i try to run the code

Yes, but how are you trying to run the code?

Are you right-clicking ScopeApp.java in the Project or Package Explorer
view and choosing Run/Debug As... ?
Re: Error: Could not find or load main class ScopeApp [message #1690743 is a reply to message #1690740] Mon, 30 March 2015 23:58 Go to previous messageGo to next message
Logan King is currently offline Logan KingFriend
Messages: 6
Registered: March 2015
Junior Member
Yes its in the "default package", what package should i put it in
Re: Error: Could not find or load main class ScopeApp [message #1690744 is a reply to message #1690743] Tue, 31 March 2015 00:05 Go to previous messageGo to next message
Logan King is currently offline Logan KingFriend
Messages: 6
Registered: March 2015
Junior Member
What should the package name be?
Re: Error: Could not find or load main class ScopeApp [message #1690753 is a reply to message #1690744] Tue, 31 March 2015 03:46 Go to previous messageGo to next message
Nitin Dahyabhai is currently online Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Short answer: make one up for now, you can always change it later. Long answer: http://www.oracle.com/technetwork/java/codeconventions-135099.html .

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Error: Could not find or load main class ScopeApp [message #1690755 is a reply to message #1690753] Tue, 31 March 2015 04:05 Go to previous messageGo to next message
Logan King is currently offline Logan KingFriend
Messages: 6
Registered: March 2015
Junior Member
Ok I have put it in a package called com.example.scope_app. But after I click on the 'run' button to try running the code below, the computer output says Error: Could not find or load main class com.example.scope_app.ScopeApp. So what do I do now?
Code:
package com.example.scope_app;

public class ScopeApp
{

static int x;

public static void main(String[] args)
{
x = 5;
System.out.println("main: x = " + x);
myMethod();
}

public static void myMethod()
{
int y;
y = 10;
if (y == x + 5)
{
int z;
z = 15;
System.out.println("myMethod: z = " + z);
}
System.out.println("myMethod: x = " + x);
System.out.println("myMethod: y = " + y);
}

}
Re: Error: Could not find or load main class ScopeApp [message #1690758 is a reply to message #1690755] Tue, 31 March 2015 04:46 Go to previous message
Nitin Dahyabhai is currently online Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Was a ScopeApp.class file created (check from outside of Eclipse)? Are you using something else to do the compilation like Ant or Maven? Are there any messages in the Problems or Markers views?

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:Class issues???
Next Topic:C/C++/Lua/AKS/RE2C files in a single project
Goto Forum:
  


Current Time: Tue Apr 16 20:48:10 GMT 2024

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

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

Back to the top