Java N00b Help!

trance

Senior member
Oct 9, 1999
202
0
0
Exception in thread "main" java.lang.NoSuchMethodError: main

I think it has something to do with java not having the right path? I remembered my professor entering a command to tell java where the folder of the .javas are. Any help?
 

clamum

Lifer
Feb 13, 2003
26,252
403
126
Are you sure your main method signature looks like this?

public static void main(String [] args)
 

trance

Senior member
Oct 9, 1999
202
0
0
I'm also getting this error:

'Javac" is not recognized as an internal or external command, operable program or batch file.
 

clamum

Lifer
Feb 13, 2003
26,252
403
126
Are you using some form of Linux? I believe you have to set your path in a config file to point to the Java executables but I don't know a lot about Linux so someone else will have to help ya there.
 

trance

Senior member
Oct 9, 1999
202
0
0
I just wrote the Helloworld and it still comes up with that "Javac is not recognized":


public class Hello {

public static void main(String[] args)
{
System.out.println("Hello World!");
}

}
 

kimagurealex

Senior member
Oct 9, 1999
825
0
0
you have to change the enviroment setting in the XP in order to use the javac from anywhere. The Jcreator is a good free ware for Java programming.

Alex
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
But if you still want to do it from the commandline (very useful for learning) you will have to set your system path.

On windows the easiest way is to Rightclick on MyComputer -> Properties -> Advanced -> Environment Variables

Find "Path" in the bottom list, edit it and add the path to your java installation plus "\bin" as amdfanboy points out.

Click all the OKs, restart the command prompt and try to compile again.

The thing that makes me curious though is that you seem to be able to run java.exe but not javac.exe. Did you install java yourself? Are you sure you have the sdk installed and not just the runtime environment?
 

MartyMcFly3

Lifer
Jan 18, 2003
11,436
29
91
www.youtube.com
Hey also a noob here.. for class we are supposed to write an expression for the following:

set the value of a to the remainder of b divided by c if b*c is greater than a*c or if y is true. Otherwise, set the value of a to b*c, increment c and set the value of z to false

I have come up with:

If (b*c>a*c) a=b%c
If (y=true) a=b%c
Else

and im stuck with the rest. Im not sure if what I even have is right. The guy sucks at teaching the course so its been a struggle for me.
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Originally posted by: MartyMcFly3
Hey also a noob here.. for class we are supposed to write an expression for the following:

set the value of a to the remainder of b divided by c if b*c is greater than a*c or if y is true. Otherwise, set the value of a to b*c, increment c and set the value of z to false

I have come up with:

If (b*c>a*c) a=b%c
If (y=true) a=b%c
Else

and im stuck with the rest. Im not sure if what I even have is right. The guy sucks at teaching the course so its been a struggle for me.

Always use brakets even if you don't need the. It is much better style. You can use logical operators ( || , &&, !) to perform multiple boolean checks at the same time.

( (b*c > a*c) || y ) // means b*c is greater than a*c or y is true
 

amdskip

Lifer
Jan 6, 2001
22,530
13
81
I was just helping him on aim amdfanboy, got the same thing as you and I'm gonna help him understand it.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: trance
yeah I"m installing the JSDK

I told you guys I am a n00b.

And back to the original post: when you do get javac to work you will see a file called Hello.class in the same folder as your java file. This is the compiled output and will always have the same name as the java file (until you start putting multiple classes in one file but that's another story ). When you say "java Hello" it looks for that class file and tries to run it.
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Originally posted by: kamper
Originally posted by: trance
yeah I"m installing the JSDK

I told you guys I am a n00b.

And back to the original post: when you do get javac to work you will see a file called Hello.class in the same folder as your java file. This is the compiled output and will always have the same name as the java file (until you start putting multiple classes in one file but that's another story ). When you say "java Hello" it looks for that class file and tries to run it.

It gets even better with anonymous inner classes. Who ever thought of the naming for that should be shot.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Anonymous inner classes don't get their own file do they? And what's wrong with the naming?
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Originally posted by: kamper
Anonymous inner classes don't get their own file do they? And what's wrong with the naming?

They sure do. They get names like Class$1 and things like that.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: amdfanboy
Originally posted by: kamper
Anonymous inner classes don't get their own file do they? And what's wrong with the naming?

They sure do. They get names like Class$1 and things like that.

Right you are. So what are your suggestions for the naming?
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Originally posted by: kamper
Originally posted by: amdfanboy
Originally posted by: kamper
Anonymous inner classes don't get their own file do they? And what's wrong with the naming?

They sure do. They get names like Class$1 and things like that.

Right you are. So what are your suggestions for the naming?

I didn't say I had any better ideas . They probably should have been given the inner class name as their filename. Right now it just looks like a hack (which it is)
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Anonymous inner classes don't have names, non-anonymous classes do have the class names as part of the filename. I figure it's just the most straightforward way for the compiler and classloaders to communicate which class file should be used when needed. It's not like humans have to deal with them much.
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Originally posted by: kamper
Anonymous inner classes don't have names, non-anonymous classes do have the class names as part of the filename. I figure it's just the most straightforward way for the compiler and classloaders to communicate which class file should be used when needed. It's not like humans have to deal with them much.

I have no idea why I said that. The anonymous kind of gives that way . Yeah, I really can't think of a better way, but I still can rant, can't I ?
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |