Running a Java program on Linux


 
Thread Tools Search this Thread
Top Forums Programming Running a Java program on Linux
# 1  
Old 04-24-2012
Running a Java program on Linux

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
Quote:
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:
Quote:
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?
# 2  
Old 04-24-2012
What is the value of your CLASSPATH environmental variable?
# 3  
Old 04-24-2012
I typed the following:

Quote:
echo $ CLASSPATH
but it shows me nothing!
# 4  
Old 04-24-2012
Try it without the extra space.
# 5  
Old 04-24-2012
Quote:
echo $CLASSPATH
same it shows me nothing!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

java compile and run program help

What is the trick to get a java program to run and compile? I can't even get a basic skeleton to run and compile. What packages do I need? I figured the java-gcj and gcc-java packages was enough. Do I need any other packages? I thought I had to do this and it would work but its not. javac... (1 Reply)
Discussion started by: cokedude
1 Replies

2. Programming

Program java arguments

Hello, The arguments are strings. In my code I need them to be a different type, I do the cast but it is not feasible ... Have you any idea? Thank you (8 Replies)
Discussion started by: chercheur857
8 Replies

3. Programming

need logic for java program

Hi All, I need to to wright a java programm for the following query. Qus: output need to genarate a number+ alphnumric sequence in java and get converted into ASCII code so that i can use mod logic on that. example Output: like 10 digit number 1AAAAAAAAA 1AAAAAAAAB 1AAAAAAAAC . .... (4 Replies)
Discussion started by: Ganesh Khandare
4 Replies

4. UNIX for Dummies Questions & Answers

Help needed to run simple java program in linux

Hi guys , This is the first time i m running java application inside linux. i have installed jdk-6u20-linux-i586-rpm.bin jre-6u20-linux-i586-rpm.bin in my linux machine. and set JAVA_HOME and JRE_HOME variables respectively. # echo $JAVA_HOME /usr/java/jdk1.6.0_20/ # echo $JRE_HOME... (6 Replies)
Discussion started by: pinga123
6 Replies

5. Shell Programming and Scripting

Executing a Java Program

I am entirely new to shell scripting and would like to create a script to execute a java program called Main. I've already compiled it and placed the .java and .class files at /root/javaTest. Next I made a shell script that simply contained: java /root/javaTest/Main . I made the script... (2 Replies)
Discussion started by: hypnotic_meat
2 Replies

6. Linux

running java program question

hi, i have just written a simple hello world java program in my linux server, installed jdk ... and tried to compile and run it and it gave me some errors. please details below: # cat HelloWorld.java import java.util.*; import java.io.*; public class HelloWorld { public static void... (4 Replies)
Discussion started by: k2k
4 Replies

7. Shell Programming and Scripting

How to execute java program from perl

hello all how can i run the java command that can eccept N numbers of args for example : java -cp .;foo.jar myApp 1 "ww" or java -cp .;foo.jar myApp 1 2 3 "ww" or java -cp .;foo.jar myApp "args1" "args2" "args3" Thanks (1 Reply)
Discussion started by: umen
1 Replies

8. Shell Programming and Scripting

how can i run java program from any where

Hello all sorry didnt know where to post it i compiled simple program that using "System.getProperty("user.dir");" now i compiled the program under directory foo and and its running great when i do "java myapp" i included this directory in the $PATH env variable so i could see it fro any where... (1 Reply)
Discussion started by: umen
1 Replies

9. Shell Programming and Scripting

Invoke java program in script

Hey all, My boss tasked me with the job to write a script which would invoke various java programs, the thing is I don't know much about shell scripting so would you experts help me out? Here is the requirement - 2 applications written in java: App_A and App_B -... (0 Replies)
Discussion started by: mpang_
0 Replies

10. Programming

Communication between a java and c++ program

Hi, I have the following problem. I have 2 programs, a java program and a c++ program. These 2 programs have to communicate with each other in full duplex mode. I want to use pipes for this communication. So when the c++ program pust something on the stdout the java program must be able to read... (4 Replies)
Discussion started by: lmnt22
4 Replies
Login or Register to Ask a Question