• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Wont Compile

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

public class firstapp {

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

}




I just started today but when I tried to compile it it comes up with errors. and anything that is compiled cant run in jvm


Errors:

/Users/chriswoodall/Desktop/firstapp.java:4: cannot resolve symbol
symbol : method printIn (java.lang.String)
location: class java.io.PrintStream
System.out.printIn ("I Rule!");
^
/Users/chriswoodall/Desktop/firstapp.java:5: cannot resolve symbol
symbol : method printIn (java.lang.String)
location: class java.io.PrintStream
System.out.printIn ("The World");
^
2 errors

 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
println means "print line". Looks like you have printIn and in "print in".
 
Chris Woodall
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh. See In my book I coulcn't tell I's from L's.
 
Chris Woodall
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
K, It compiled.

but, when I type in java nameofapp it gives me this error

$ java /Users/username/Desktop/firstapp.class
Exception in thread "main" java.lang.NoClassDefFoundError: /Users/chriswoodall/Desktop/firstapp/class


[ January 07, 2006: Message edited by: Chris Woodall ]
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you run the compiled file, you do not include a file extension. Try it without ".class" at the end...

java /Users/username/Desktop/firstapp
 
Chris Woodall
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nope. Aint working. Not even a day in and already trouble. Though, I have to sya it is still fun.

java /Users/chriswoodall/Desktop/firstapp
Exception in thread "main" java.lang.NoClassDefFoundError: /Users/chriswoodall/Desktop/firstapp

 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chris Woodall:
nope. Aint working. Not even a day in and already trouble...


Unfortunately, it's fairly common to have a few glitches like this at first.

Have you verified that there is, in fact, a compiled class file (firstapp.class) under the Desktop directory?
 
Chris Woodall
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what do yo mean I am looking at it on my desktop right now
 
Marshal
Posts: 27214
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Normally you would change your current directory to /Users/chriswoodall/Desktop and then type "java firstapp". But you would probably benefit from reading the classpath tutorial anyway. It looks like you are working in Unix, so here's the link:

http://java.sun.com/docs/books/tutorial/getStarted/cupojava/unix.html

Follow one of the links in that document if you're actually working in some other platform.
 
Chris Woodall
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no I am actually using OS X and a terminal (which is based on BSD)

Woot I got it. Thnx. Instead of giving the path I just cd to it and then type the app.
[ January 07, 2006: Message edited by: Chris Woodall ]
 
Patrick Williams
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have a package statement at the top of your program? I would agree that you probably need to read the tutorial and a beginner's java book. I'm not trying to be mean, but you're "Hello World" program is now a 10 post (and probably more coming) thread. You should focus at how 'javac' and 'java' works, how java works in an IDE and through a command line. I would also suggest that you focus your reading on how the CLASSPATH variable works. Please feel free to ask more questions, but also take a little initiative to find the answer before asking. It's not that we don't want to answer you (we do), but "where to find the answer" is one of the most important aspects of being a successful developer. Good luck!
 
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic