• 0

Simple Java help


Question

I am in a very basic class, and reviewed through the TREMENDOUSLY LARGE book, anyone help?

There are suppose to be 5 syntax errors in this short code, I ran the debugger and couldn't find them.

public class LetUsDebug{
public static void main(String[] args){
int height = 3; width;
width=4
System.out.Println("Area = " \t +
height * width);
}

::BUMP::

I attempted to compile, knowing it was faulty.

This is what was returned to me, can anyone explain, my teacher has a VERY hands off approach.

 ----jGRASP exec: java -Xnoagent -Djava.compiler=NONE -Xdebug -Xrunjdwp:transport=dt_socket,suspend=y,server=y LetUsDebug

 ----jGRASP: connected to debugger.
java.lang.NoClassDefFoundError: LetUsDebug
Caused by: java.lang.ClassNotFoundException: LetUsDebug
	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: LetUsDebug.  Program will exit.
Exception in thread "main" ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]

 ----jGRASP wedge2: exit code for process is 1.
 ----jGRASP: operation complete.

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0
public class LetUsDebug{

public static void main(String[] args){

int height = 3;

int width=4

System.out.Println("Area = " \t +height * width);

}

}

answer^^

Link to comment
Share on other sites

  • 0

Help! =)

Entering:

public class LetUsDebug_Fix{
public static void main(String[] args){
int height = 3;
int width=4;
System.out.Println("Area = /t" + height * width);
}
}

Still leave the compiling error:

 ----jGRASP exec: javac -g C:\Documents and Settings\Administrator\My Documents\LetUsDebug_Fix.java

LetUsDebug_Fix.java:5: cannot find symbol
symbol  : method Println(java.lang.String)
location: class java.io.PrintStream
System.out.Println("Area = /t" + height * width);
		  ^
1 error

 ----jGRASP wedge2: exit code for process is 1.
 ----jGRASP: operation complete.

What is the "/t" even mean?

Link to comment
Share on other sites

  • 0

\t is a tab

There is no Println, it's println

public class LetUsDebug{
	public static void main(String[] args){
		int height = 3;
		int width = 4;
		System.out.println("Area =\t" + height * width);
	}
}

Edited by MkFly
Link to comment
Share on other sites

  • 0

System.out.println needs a lower case p on println.

public class LetUsDebug
{
    public static void main(String[] args)
    {
        int height = 3;
        int width = 4;
        System.out.println("Area =  \t" +height * width);
    }
}

That compiles ^^

JamesCherrill beat me to it :p

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.