• Post Reply Bookmark Topic Watch Topic
  • New Topic

java compiler not creating class files on Mac in terminal  RSS feed

 
William Weaver
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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...
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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. 
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and Welcome to the Ranch!
 
William Weaver
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Junilu! It is packagea and packageb 
 
William Weaver
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your code for ClassB.java, the problem might be in your main() method signature.
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!