• Post Reply Bookmark Topic Watch Topic
  • New Topic

Incompatible magic value 188741100  RSS feed

 
Justinian Smith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I just started reading Head First Java and this was my first error that irked me for hours.

The project is called GuessGame, and inside you create 3 class files that can interact with each other. There is "GuessGame.class", "Player.class", and "GameLauncher.class" (this one has the main).

But whenever I run java GameLauncher from the prompt I get the message:

Exception in thread "main" java.lang.ClassFormatError: Incompatible magic value
1886741100 in class file GameLauncher
at java.lang.ClassLoader.defineClass1<Native Method>
at java.lang.ClassLoader.defineClassCond<Unknown Source>
at java.lang.ClassLoader.defineClass<Unknown Source>
at java.security.SecureClassLoader.definteClass<Unknown Source>
at java.net.URLClassLoader.defineClass<Unknown Source>
at java.net.URLClassLoader.access$000<Unknown Source>
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>
Could not find the main class: GameLauncher.

The location for all my classes reside in C:\Users\Justinian\Documents\Head\GuessGame\

Their following code:







If there is any more information that maybe helpful if provided I will provide it ASAP!
Any input is greatly appreciated.

-Java Newbie
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the source- .java files and then compile them in to .class files using javac and then use java to launch the program.



You read this FAQ for more information.
Dont know the exact reason why this is happening. Looks like it wasnt able to load the Class as a result it complained of not finding the main class.
 
Kurt Van Etten
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to expand on what Mohamed already said, those three program files should have a .java filetype. You then create the .class files by compiling them with the javac command - do this for each of the three files, and then try running GameLauncher with the java command. You apparently saved your program files with the .class extension, and java was trying to read the not-yet-compiled source code.

By the way, you've got "slanty" quotes in your program files, so I'm guessing you used a word processor to create those. You need to change those to plain ascii quote marks and save your file as plain text. (And in the future, save yourself the trouble and use a text editor instead of a word processor!)
 
Justinian Smith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are the best.

I just downloaded TextPad, fixed those quotation marks, compiled my .java files and ran the GameLauncher. Boom. Working perfectly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!