Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get first application running

 
Patrick Smith
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i am new to Java and have problems running my first application. Here's what i did:
- jdk and jre are installed,
- i've set the path variabe as prescribed
- i wrote a small programm, this one:

public class meineersteanwendung {
public static void main (String[] args) {
System.out.println("Ich hersche!");
System.out.println("´┐Żber die Welt");
}
}

- when i execute the javac command, it's all ok, my .class file gets created.
- but then, when i want to start "java meineersteanwendung.java", it tells me the following:

C:\Documents and Settings\Patrick\MyDocuments\Patrick\Aarbecht\Programming\Java
\Java VKBF\Self>java meineersteanwendung.java
Exception in thread "main" java.lang.NoClassDefFoundError: meineersteanwendung/java

Any idea what to check for?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12183
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when you start java, you give it the name of the class, not a name of a file. So, your command should be

java meineersteanwendung
 
Campbell Ritchie
Sheriff
Pie
Posts: 49751
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

There is a list of common errors here. The mistake is adding the extension. Try
java meineersteanwendung
rather than
java meineersteanwendung.java
CR
 
Patrick Smith
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that was it, thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic