• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Incompatible magic value 188741100

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic