---
title: "javac and java commands"  
description: "javac and java commands"  
author: "Royce Roy"  
published: 2015-04-30  
updated: 2015-04-30  
canonical: https://www.mindstick.com/forum/23165/javac-and-java-commands  
category: "java"  
tags: ["java"]  
reading_time: 2 minutes  

---

# javac and java commands

I noticed something regarding the [java](https://www.mindstick.com/articles/12214/web-development-company-in-india-laid-on-the-foundation-of-concrete-java-programming) [command](https://www.mindstick.com/blog/178/synchronous-and-asynchronous-command-execution-in-c-sharp-dot-net) that I wanted to ask about. I created a temp folder on the root of C:\ then I created two more folders called packagea and packageb. In those folders were java [files](https://www.mindstick.com/articles/23302/the-importance-and-advantage-of-keeping-your-important-files-on-the-cloud) called ClassA and ClassB respectively. I compiled them by running javac packagea/ClassA.java packageb/ClassB.java \
So then I tested to make sure it worked by running java packageb.Classb - which is where I coded the main [method](https://www.mindstick.com/forum/166/webservice-method) - and it worked. OK, good so far. \
But then.. \
I changed my working [directory](https://www.mindstick.com/forum/226/how-to-get-application-directory-using-c-sharp-csharp) to C:\temp\packageb and then attempted to run java ClassB and that does not work. I get: \
[Error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing): Could not find or load main [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp) ClassB \
Could [anyone explain](https://www.mindstick.com/forum/34220/can-anyone-explain-me-about-off-page-activity) what is happening here?

## Replies

### Reply by Anonymous User

I would need to see the code to be sure, but you probably have a package statement at the beginning of your program. That means you have to run the program from the "root" of the project or else Java can't find the class.\
\
*package packageB*; says "look in the folder **packageB**" for the class. *import packageA*.**ClassA**; says "you can find *ClassA* in the folder *packageA*". So you need to launch the program from a folder that can see both packageA and pacakgeB, or you need to have a classpath entry to each folder. \


---

Original Source: https://www.mindstick.com/forum/23165/javac-and-java-commands

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
