# Running a Java program on Linux

**URL:** <https://community.unix.com/t/running-a-java-program-on-linux/308954>\
**Category:** Programming\
**Created:** [April 24, 2012, 5:33am UTC](https://community.unix.com/t/running-a-java-program-on-linux/308954 "2012-04-24T05:33:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chercheur857](https://community.unix.com/letter_avatar/chercheur857/32/6_449c533f586939b6e5f246632a46421f.png) [@chercheur857](https://community.unix.com/u/chercheur857)\
**Post date:** [April 24, 2012, 5:33am UTC](https://community.unix.com/t/running-a-java-program-on-linux/308954/1 "2012-04-24T05:33:39Z")

</div>

Hello,

I have a project directory in /home/researcher  
I have in my project/src three packages:A (contains the main class), B and C and I have 2 jar-files file1.jar file2.jar files in the project/my-jars  
In Class A I import other classes from the other packages  
I compiled as follows: package per package

> [@](#):
>
> javac-classpath / home/researcher/file1.jar:/home/researcher/file2.jar:/home/ researcher/src \*. java  
> -\> It works (i have the. Class in each package)

I run as follows:

> [@](#):
>
> cd /home/researcher/project/src/A  
> java-cp / home/researcher/file1.jar:/home/researcher/file2.jar:/home/researcher /src Main

it does not work! have you any idea?

Exception in thread "main" java.lang.NoClassDefFoundError: Main  
Please, how to export. class in packages and all in one. jar file so I can do java-jar project.jar?

---

<div class="post-metadata">

**Author:** ![fpmurphy](https://community.unix.com/user_avatar/community.unix.com/fpmurphy/32/110_2.png) [@fpmurphy](https://community.unix.com/u/fpmurphy)\
**Post date:** [April 24, 2012, 10:48am UTC](https://community.unix.com/t/running-a-java-program-on-linux/308954/2 "2012-04-24T10:48:49Z")

</div>

What is the value of your CLASSPATH environmental variable?

---

<div class="post-metadata">

**Author:** ![chercheur857](https://community.unix.com/letter_avatar/chercheur857/32/6_449c533f586939b6e5f246632a46421f.png) [@chercheur857](https://community.unix.com/u/chercheur857)\
**Post date:** [April 24, 2012, 11:00am UTC](https://community.unix.com/t/running-a-java-program-on-linux/308954/3 "2012-04-24T11:00:02Z")

</div>

I typed the following:

> [@](#):
>
> echo $ CLASSPATH

but it shows me nothing!

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/6_449c533f586939b6e5f246632a46421f.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [April 24, 2012, 11:14am UTC](https://community.unix.com/t/running-a-java-program-on-linux/308954/4 "2012-04-24T11:14:10Z")

</div>

Try it without the extra space.

---

<div class="post-metadata">

**Author:** ![chercheur857](https://community.unix.com/letter_avatar/chercheur857/32/6_449c533f586939b6e5f246632a46421f.png) [@chercheur857](https://community.unix.com/u/chercheur857)\
**Post date:** [April 24, 2012, 11:25am UTC](https://community.unix.com/t/running-a-java-program-on-linux/308954/5 "2012-04-24T11:25:55Z")

</div>

> [@](#):
>
> echo $CLASSPATH

same it shows me nothing!
