• 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

Stuck with my first Program

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI guys , I am a newbie trying to learn java programming here. I have successfully installed JDK on my WINDOWS 7 machine.. seem to have set up right " the environment variables" .But when i try to compile and execute my first program :"MooseGreetings",.I get error messages such: "could not create the Java Virtual Machine", " a fatal exception has occurred.Program will exit.". What am i doing wrong?
I have tested "javac & java" in the command line and both spit out good outputs , not error messages.So why am i stuck with error messages when executing the program? Being a first time java learner.. want to start up right before moving on to the next level..Any help will be greatly appreciated..

Thanks in advance ~Paul~
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

The error you get isn't an expected kind of error; it sounds like the Java virtual machine crashes for some reason. Can you give us some more information on your Java installation: in which directory did you install Java, what environment variables did you set, and to which values? What is the output you get when running the commands:

java -version
javac -version

Did you just install the JDK with the standard Windows installer .exe?
 
Marshal
Posts: 79466
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Tanoh wrote: . . . I have tested "javac & java" in the command line and both spit out good outputs , not error messages. . . .

Neither java nor javac ever spits out good output. If you get anything from those programs at all, it is an error message. If they work correctly, they respond with stony silence.
Please tell us where you installed the Java® installation (folder name), and the response to the following instructions at a command line (Windows®)

java -version
javac -version
echo %CLASSPATH%
echo %PATH%

I think from the errors you are getting, that you might have to uninstall and reinstall Java®.

And welcome to the Ranch

[edit]Remove Unix instructions as unnecessary[/edit]
 
Greenhorn
Posts: 29
Mac IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add a special environment variable called _JAVA_OPTIONS with the value -Xmx512M and try again. Good luck!
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sveto Koychev wrote:Add a special environment variable called _JAVA_OPTIONS with the value -Xmx512M and try again. Good luck!


No, don't do this. This is not a solution to the problem the OP is seeing.
Also I seriously doubt a newbie, writing a HelloWorld type application, requires anything other than the default memory allocation.
 
Campbell Ritchie
Marshal
Posts: 79466
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tony Docherty wrote: . . . This is not a solution to the problem the OP is seeing. . . .

Adding such an environment variable may (under certain circumstances) actually be harmful.
 
Paul Tanoh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello again! guys. am back.Here are my outputs at the command prompt: javac -version-> 1.7.0_45
java -version-> 1.7.0_45: java(TM) SE Runtime Environment build(1.7.0_45 -b18)
: java HotSpot(TM) 64-bit Server VM build(25.45-b08 mixed mode)
it seems both" java & javac" have the same output...i still cannot figure out those error messages ..
Also java is in this folder: c:\program files\java\ jdk 1.7.0_45.
Please help me guys...
 
Campbell Ritchie
Marshal
Posts: 79466
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is about the one place where you get output which isn't an error message. Sorry I forgot about -version when I said stony silence. Those are normal outputs; one says 1.7.0_45 and HotSpot and the other simply says 1.7.0_45.
If you get that sort of output it suggests you have set your PATH environment variable correctly.
Can you compile and run anything? Try the following instructions (the name of the folder can be anything you like)

mkdir java
cd java
javac Foo.java
java Foo

… where Foo.java is a .java file with a main method in. Note you miss out .java in the last instruction.
 
Paul Tanoh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Mr. Ritchie , I thank you! ...I think we have a Winner here !..I successfully compiled & executed my first program in command prompt.
Thanks for your tips BROS! Really appreciate it! ~Paul~
 
Campbell Ritchie
Marshal
Posts: 79466
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
reply
    Bookmark Topic Watch Topic
  • New Topic