Skip to main content



      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 16:26 Go to next message
Eclipse UserFriend
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 17:46 Go to previous messageGo to next message
Eclipse UserFriend
When does it(?) give you that error message? Have you tried putting your class in a package?

[Updated on: Mon, 30 March 2015 17:46] by Moderator

Re: Error: Could not find or load main class ScopeApp [message #1690734 is a reply to message #1690732] Mon, 30 March 2015 18:14 Go to previous messageGo to next message
Eclipse UserFriend
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 18:34 Go to previous messageGo to next message
Eclipse UserFriend
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 19:27 Go to previous messageGo to next message
Eclipse UserFriend
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 19:28 Go to previous messageGo to next message
Eclipse UserFriend
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 19:58 Go to previous messageGo to next message
Eclipse UserFriend
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] Mon, 30 March 2015 20:05 Go to previous messageGo to next message
Eclipse UserFriend
What should the package name be?
Re: Error: Could not find or load main class ScopeApp [message #1690753 is a reply to message #1690744] Mon, 30 March 2015 23:46 Go to previous messageGo to next message
Eclipse UserFriend
Short answer: make one up for now, you can always change it later. Long answer: http://www.oracle.com/technetwork/java/codeconventions-135099.html .
Re: Error: Could not find or load main class ScopeApp [message #1690755 is a reply to message #1690753] Tue, 31 March 2015 00:05 Go to previous messageGo to next message
Eclipse UserFriend
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 00:46 Go to previous message
Eclipse UserFriend
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?
Previous Topic:Class issues???
Next Topic:C/C++/Lua/AKS/RE2C files in a single project
Goto Forum:
  


Current Time: Fri May 23 05:44:42 EDT 2025

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

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

Back to the top