Skip to main content

macosx problems running .class files

1 reply [Last post]
Joined: 2006-02-17

when i compile a project through drjava, it makes a .class file that i am supposed to execute. so i try it and it says to check the console. When i do it shows this:


i have no idea why it is doing this. I am in as admin, but i dont know how much longer i will have access because i am at school doing this....

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-11-27


Java produces a class file for every object defined. For a class to be executable, it must have a main method:

public static void main(String[] args)

Normally when writing a program you define several classes, each public class in its own .java file, and you have one class with a main method that you execute.


public class Hello{

public static void main(String[] args){
System.out.println("Hello world");
is saved as a file called, is compiled by java compiler javac to Hello.class and can be executed by the JVM java (from a command line you can run Hello with $ java Hello ).


class MyObject{

private int value=0;

public MyObject(int startvalue){

public int getValue(){
return value;

defines a class for MyObject which would be saved in a file called and compiled to MyObject.class but is [b]not[/b] executable.

If your class has a mian method, make sure you've named it correctly - java is case sensitive so and are different. Is your IDE set to look in right place, ie where the class files are, when running the JVM?

You can read about some basic Java stuff, try .