I want to run a java program using shell script. The java program is in p2 directory and its name is maxconnect4 and I have already compiled it, the class name is maxconnect4. I write the shell commands like this:
java p2/maxconnect4 arg1 arg2 arg3
This shell command does not work.
It give an error: Exception in thread “main” java.lang.NoClassDefFoundError: p2/maxconnect
However, I compile the java program in this way:
javac p2/*.java, and it works.
Just use
java -cp p2 maxconnect4 arg1 arg2 arg3. -cp sets the classpath of the JVM. Edit: I assume you don’t use a package for maxconnect4.