wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes problems with javac Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problems with javac" Watch "problems with javac" New topic
Author

problems with javac

Paola Galass
Greenhorn

Joined: Oct 21, 2008
Posts: 4
Hi,

I'm not really a beginner with java, I took a class a couple of years ago at University of Milan (Italy) and enjoyed it a lot

I upgraded to windows vista. Javac used to work yesterday, but today not anymore. I've set correctly path variables (I see this message when I type path from command prompt:

[/CODE]PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem; C:\Program Files\Java\jdk1.6.0_07\bin\[/CODE])

When I try to compile a file with: [/CODE]javac MyProgramm.java[/CODE] it gives no errors. But when I try to run the same file: [/CODE]java MyProgramm[/CODE] it shows this error:
[/CODE]Exception in thread "main" jva.lang.NoClassDefFoundError: MyProgramm
Caused by: java.lang.ClassNotFoundException: MyProgramm
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)[/CODE]

It doesn't compile (no file .class created) but doesn't show any error message during compilation. It's so wired!!

Can anyone help me please? This thing is driving me crazy...
Paola Galass
Greenhorn

Joined: Oct 21, 2008
Posts: 4
Oups sorry, a little confusion with CODE tags. The message had to look like this:



Hi,

I'm not really a beginner with java, I took a class a couple of years ago at University of Milan (Italy) and enjoyed it a lot

I upgraded to windows vista. Javac used to work yesterday, but today not anymore. I've set correctly path variables (I see this message when I type path from command prompt:

)

When I try to compile a file with: it gives no errors. But when I try to run the same file: it shows this error:


It doesn't compile (no file .class created) but doesn't show any error message during compilation. It's so wired!!

Can anyone help me please? This thing is driving me crazy...
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

"Green Fairy," please check your private messages by clicking on My Private Messages. Thanks!


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

One thing I see in your PATH is a space before the C:\Program Files\Java\jdk1.6.0_07\bin\. Try removing that space, and see if that's the problem. (You will need to open a new Command Prompt for the change to take effect.)

But it's odd there are no errors. I would expect something like "javac not recognized."
[ October 21, 2008: Message edited by: marc weber ]
Rasath Umar
Greenhorn

Joined: Oct 06, 2008
Posts: 8
Where did you have your program file (My Program.java)? Add classpath=root\....\ your java .class file path.
Paola Galass
Greenhorn

Joined: Oct 21, 2008
Posts: 4
Hi, thanks for replying. There's no space in the path, I didn't know how to change it after posting... Anyway, I'm surprised too that it gives no errors. Yesterday it worked just fine, I compiled and ran a lot of mini-programs written by me, but today... I think I'm going to reinstall java again and see what happens. It's the only solution I can think right now..
Ls chin
Ranch Hand

Joined: Jun 28, 2008
Posts: 99
Hi there,

Could you try typing this line:-

java -cp . MyProgramm

(There is a space before and after the dot). Does it work?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
And try the "dir" command to see whether there is an appropriately named file with .class in your current directory. The NoClassDefFoundError means the java command can't find a file of that name.

If the javac command doesn't show any errors, then it has compiled. Have you got a package declaration in MyProgramm?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

Paola,

Next time you see something wrong with your post you can use the edit () button to edit it.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Paola Galass
Greenhorn

Joined: Oct 21, 2008
Posts: 4
Hi everyone,

Thanks for all your replies. Actually the problem still persists. I moved all my java files and libraries in the bin directory of JDK but no changes at all. I uninstalled and reinstalled JDK and JRE again, but no way. Sorry, but I decided to go back to xp, I have a project to finish and don't know how to solve this problem.

Thanks guys, you're amazing
Bye
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
Don't put your own files in the bin directory. That is reserved for files for the Java Virtual Machine etc.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Like Campbell said, mixing your own files with Java's "inner workings" eventually leads to , followed by .
 
 
subject: problems with javac