• Post Reply Bookmark Topic Watch Topic
  • New Topic

new to java and my first problem with executing my java app occurs  RSS feed

 
chris verhoeven
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

my name is Chris from the Netherlands and im starting out with the book Head First Java.

i installed java sdk 7 se and everything went ok.

i had to write my first program.

this is my code:


public class MyFirstApp {

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

}


when im trying to run it using CMD inside windows command prompt it gives me an error.

what i try to do is compile my class

javac MyFirstClass.java

it gives me this error:


A fatal error has been detected by the java runtime environment:

exception_access_violation <0xc0000005> at pc=0x000000060e71d75, pid=1376, tid=145516

jre version: 7.0_25-b17

failed to write core dump. minidumps are not enables by default on client versions of windows.


can anybody tell me what i do wrong?
i already set the path in windows system environments correct.

thanks in advance

Chris Verhoeven
 
chris verhoeven
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind people,

i already solved my problem. I rebooted my computer after resetting my path directory and it all works fine now.

I wish we can all learn from each other now and in the future and i will come here online often to catch up with all of you.

Have a great weekend.

Chris
 
Ashish Dutt
Ranch Hand
Posts: 172
Java MySQL Database Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Chris,
Welcome to Java Ranch.
I'm glad to know that your program worked however the reason for writing this is to highlight
what i try to do is compile my class

javac MyFirstClass.java
while your program is named MyFirstApp, i wonder how did it even compile on rebooting your computer, but if it did its good :-)
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chris verhoeven wrote:i already solved my problem. I rebooted my computer after resetting my path directory and it all works fine now.

Ugh. Windows, no doubt. Can't change anything without rebooting, so the lurking registry monster has a chance to update a million things you know absolutely nothing about.

Winston
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chris verhoeven wrote:I rebooted my computer after resetting my path directory and it all works fine now.

It certainly doesn't HURT to reboot, but it's possible you just needed to close your cmd window and open a new one.

In other words, an open cmd window will not pick up changes to your PATH (or really any other) environment variable. This isn't really any different from updating your .profile (or whatever is appropriate for your flavor) in unix and then having to re-source the file.

There may be a way in a windows cmd to reload the properties, but I don't know what it is.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:It certainly doesn't HURT to reboot...

Ooof. I hope you're talking about this specific case, because power cycles are actually quite wearing on components.

In fact, I often wonder if MS don't get kickbacks from hardware manufacturers due to the number of times you have to reboot their darn system.

Winston
 
chris verhoeven
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi my java friends,

thanks for your responses.
Why would my app not work? yes i just rebooted my pc and it all worked fine then.
I know windows is just like that. for lots of stuff you need to reboot, to make things work. Maybe in the future i will start work more with Linux. i know Linux works great too. But for now i will use windows.

I started the book Head First Java because its used for the degree bachelor of information technology. And that is what i would like te get in the future. And i like to get used to programming and i know java is a good language to start with.

Right now im working in a warehouse/production company but in the future i would like to go back to school and get my degree.
i think it would be great to write my own software in the future. alone or with some other people.

see you guys and girls around.

Chris
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chris verhoeven wrote:Why would my app not work? yes i just rebooted my pc and it all worked fine then.
I know windows is just like that. for lots of stuff you need to reboot, to make things work.

Unfortunately, in this case, that may be all it was. Windows just needed to sync everything up.

Maybe in the future i will start work more with Linux. i know Linux works great too. But for now i will use windows.

I quite understand. And familiarity IS important; you don't want to be struggling with a new OS when you're also trying to learn a new language. I was a Unix/Linux admin for 15 years, but didn't actually get rid of my Windows "security blanket" until it finally died on me about three weeks ago.

I started the book Head First Java because its used for the degree bachelor of information technology. And that is what i would like te get in the future. And i like to get used to programming and i know java is a good language to start with.

It's a good book. And when you get more familiar with the language, I'd also recommend this one; but stick with HFJ for the moment.

You may also find this article useful.

Good luck.

Winston
 
chris verhoeven
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi winston,

thanks for the tip.
i just downloaded the book. and looks good. i just started out with java, so its probably going to take some time, but i think its very interesting.

it would be awsome if in the future ill be able to create a good program or game that millions of people will use. but i guess, that's the dream of every programmer, right?

chris
 
Kalin Stoev
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chris, great that you have started learning Java - I am at the same level learning everything from scratch. Something in relation to your previous question: when you begin, in the examples I have from Java A Beginner's Guide by Herbert Schildt the name of the txt file is always the same as the name of the declared class in the code. For example if I would like to write a program printing hello world, I would declare class helloworld and then I would name the file helloworld.java and when it compiles it would generate helloworld.class. Is that necessary and why?

I tried using different names for the txt file and the class and program still compiles and runs.
 
chris verhoeven
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there and welcome too.

Im just a beginner but as far as I know is you can name the class whatever you want. But the name you save the file with, so the .java file will have the same .class name yes.but I believe you can give it another class name as far as I know. But maybe someone else more experienced can verify that.

Chris
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Kalin and Chris.

You can have at most one public class or interface in a source file, and the source file must have the same name as that public class or interface. Why this must be like that, it just a design choice that the people who invented the Java programming language have made. It help you to organize your code and makes it easy to find the source file if you're searching for the file that contains a specific class.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!