• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

java compiler not creating class files on Mac in terminal

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two files in two folders, in a folder named tmp on my desktop: /tmp/packagea/ClassA.java and /tmp/packageb/ClassB.java.
When I compile:
  $ javac package/ClassA.java packageb/ClassB.java

I get no errors but when I run:
  $ java packageb.ClassB

I get "Error: Could not find or load main class package.ClassA"
When I look in the folders there are no class files, just the .java files
Anybody know why the .class files are not being created or if they are, where they might be? I've searched and nothing.
P.S. I'm new so I apologize if I did this wrong...
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
apart from picking the wrong forum, it's actually a pretty decent post...I'll go ahead and move it to a better location.

for what it's worth, this forum is for aksing questions about the site itself.  
 
Sheriff
Posts: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Weaver wrote:I have two files in two folders, in a folder named tmp on my desktop: /tmp/packagea/ClassA.java and /tmp/packageb/ClassB.java.
When I compile:
  $ javac package/ClassA.java packageb/ClassB.java

I get no errors but when I run:
  $ java packageb.ClassB

I get "Error: Could not find or load main class package.ClassA"


Which one is it exactly, "package" or "packagea"?
 
Junilu Lacar
Sheriff
Posts: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...and Welcome to the Ranch!
 
William Weaver
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Junilu! It is packagea and packageb  
 
William Weaver
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is my terminal.

Williams-Pro:tmp spolio$ javac packagea/ClassA.java packageb/ClassB.java
Williams-Pro:tmp spolio$ java packageb.ClassB
Error: Could not find or load main class packageb.ClassB
Williams-Pro:tmp spolio$
 
Junilu Lacar
Sheriff
Posts: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well... is what you posted exactly what you typed or did you use "packagea" consistently and just mistype what you posted?
 
Junilu Lacar
Sheriff
Posts: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post your code for ClassB.java, the problem might be in your main() method signature.
 
Junilu Lacar
Sheriff
Posts: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And please UseCodeTags (←click that link) when you post code. Thanks.
 
William Weaver
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found my problem. I didn't import the package. I'm very sorry for the newbie posting, and I thank you for your patience and guidance. I will certainly review how to post actual code before my next question. Thank you again!
reply
    Bookmark Topic Watch Topic
  • New Topic