Re: [Py4j-users] How to run Stack example in the docs?
Status: Beta
Brought to you by:
barthe
From: Barthelemy D. <bar...@in...> - 2014-12-08 17:36:49
|
Hi, thanks for using Py4J! I believe the problem might be the package. If you copied/pasted the code exactly, the Java source files need to be in the appropriate directories (e.g., py4j/examples/StackEntryPoint). After compiling the classes, you need to specify the fully qualified name of the main class when invoking java: java -cp .:$JARFILE py4j.examples.StackEntryPoint I suggest though that you just remove the "package py4j.examples;" line in both files. You should then be able to compile and run the example code. Alternatively, you can use the StackEntryPoint class that is provided by py4j: java -cp $JARFILE py4j.examples.StackEntryPoint HTH, Barthelemy On Mon, Dec 8, 2014 at 11:39 AM, listserve <tom...@gm...> wrote: > Hello, > > I'm trying to run the code in the docs from here: > > http://py4j.sourceforge.net/getting_started.html#writing-the-java-program > > I'm not that experienced with Java so I may very well be making a > mistake unrelated to py4j, but I'm unable to run the code regardless. > This is what I've done: I saved the Stack code in a file called > Stack.java and the other code in StackEntryPoint.java. I compiled it at > the command line with the following: > > JARFILE=/usr/local/share/py4j/py4j0.8.2.1.jar > javac -cp $JARFILE *.java > > That gave no error. I then tried to run it with: > > java -cp $JARFILE:. StackEntryPoint > > and I get the following error: > > Exception in thread "main" java.lang.NoClassDefFoundError: > StackEntryPoint (wrong name: py4j/examples/StackEntryPoint) > at java.lang.ClassLoader.defineClass1(Native Method) > at java.lang.ClassLoader.defineClass(ClassLoader.java:800) > at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) > at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) > at java.net.URLClassLoader.access$100(URLClassLoader.java:71) > at java.net.URLClassLoader$1.run(URLClassLoader.java:361) > at java.net.URLClassLoader$1.run(URLClassLoader.java:355) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(URLClassLoader.java:354) > at java.lang.ClassLoader.loadClass(ClassLoader.java:425) > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) > at java.lang.ClassLoader.loadClass(ClassLoader.java:358) > at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) > > I am running Linux Mint 17 (which is basically Ubuntu) and the following > is my versions of java/javac: > > $ java -version > java version "1.7.0_65" > OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-0ubuntu0.14.04.1) > OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode) > > $ javac -version > javac 1.7.0_65 > > Thanks for any help. > > Cheers, > Thomas > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk > _______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users |