On May 28, 2012, at 10:29, Mark Finkelstein <finkel.m...@gmail.com> wrote:

> It is with that last stated command prompt entry that I get the exception. 
> The thing is, the vast majority classes in the jar (which is made up of 
> several packages) I do not need in order to run this one class, but I think 
> it's failing with the exception because it's trying to wrap these other 
> classes in the jar that I would rather not have wrapped.

Then just list that classname on the jcc command line (no flag needed) and move 
that jar file to your classpath or to --include.

Andi..

>  
> On Mon, May 28, 2012 at 7:10 PM, Andi Vajda <va...@apache.org> wrote:
> 
> On Mon, 28 May 2012, Mark Finkelstein wrote:
> 
> Thank you, the examples work great! I was able to get basic functionality
> going, but when I tried to wrap a different jar file I got the following
> exception:
> 
> jcc.cpp.JavaError: java.lang.ExceptionInInitializerError
> Java stacktrace:
> java.lang.ExceptionInInitializerError
> Caused by: java.lang.NullPointerException
>       at org.micromanager.utils.ImageUtils.<clinit>(ImageUtils.java:23)
> 
> JCC uses Java's reflection API to determine the signatures of methods to 
> wrap. Thus, it needs to load all classes it processes.
> 
> This particular class has a static initializer that is failing. You need to 
> look at that static initializer's code and modify it so that plainly loading 
> the class can work. Currently, something else is needed by this class at load 
> time that JCC cannot provide. Maybe it's possible to pass some extra command 
> line arguments, maybe you need to change its code to let that null pointer 
> pass for the sake of being able to plainly load this class like JCC is trying 
> to to.
> 
> For example, wrapping AWT classes fails in a similar way and there is a 
> command line flag to work that around (and it is passed to the JVM by JCC by 
> default, -Djava.awt.headless=true).
> 
> 
> There's actually one class that I really want to wrap, it's located in a
> jar file that I have in my classpath. I have also tried using --package
> org.micromanager, since this is the package the class resides in, but it
> seems as if this gets ignored.
> 
> Having a class on your classpath is not enough to have it wrapped by JCC. You 
> need to put its classname onto the JCC command line or pass its jar file with 
> --jar.
> --package is different. It is used to wrap dependent classes found in the 
> signatures of methods of classes you explicitely asked to have wrapped. 
> Without --package, these methods would be skipped instead.
> 
> Run the command below to get more details about all of JCC's command line 
> arguments:
> 
>  $ python -m jcc.__main__
> 
> 
> Right now the command I'm using is:
> 
> C:\Users\avastmatey>python -m jcc.__main__ --find-jvm-dll --package
> java.lang --package java.util --package java.io --jar "C:\Program
> Files\Micro-Manager-1.4\plugins\Micro-Manager\MMCoreJ.jar" --jar
> "C:\Program
> Files\Micro-Manager-1.4\plugins\Micro-Manager\MMJ_.jar" --classpath
> %CLASSPATH% --python CMMCore3 --version 2.6 --build --compiler msvc
> --install
> 
> where MMJ_ is the jar which contains the class I would like to wrap. I
> think that the other classes in this jar are perhaps stopping this from
> happening? I tried to extract this jar, but got a bunch of classes with
> $1.class at the end, which I dont think represent the class I would like to
> wrap.
> 
> So you are explicitely requesting with via --jar. Good. Thus it must be 
> wrapped. How do you determine that it's not being wrapped ?
> Because of missing methods ? Look at their signatures and be sure that all 
> classes they mention at least be listed via their package with --package.
> 
> $1.class class names are due to anonymous inner classes in your classes. This 
> is a normal Java thing, nothing to do with JCC.
> 
> Andi..
> 
> 
> 
> Many thanks!
> 
> Mark.
> 
> On Sun, May 27, 2012 at 8:18 PM, Andi Vajda <va...@apache.org> wrote:
> 
> 
> On May 27, 2012, at 6:30, Mark Finkelstein <finkel.m...@gmail.com> wrote:
> 
> That solved it; I worked through and set up everything to work
> consistently
> with msvc. It now compiles, but I'm having trouble finding any good jcc
> examples. I tried the following:
> 
> Take a look at PyLucene test cases and examples.
> 
> import jcc
> 
> Not necessary. Only used for building your extension. Especially if you
> didn't build your extension with --shared mode.
> 
> import CMMCore3
> 
> vm=jcc.initVM()
> 
> Use CMMCore3.initVM() instead.
> 
> vm.attachCurrentThread()
> 
> Not necessary from main thread.
> 
> print vm.isCurrentThreadAttached()
> 
> core=CMMCore3.CMMCore() # this is the jcc wrapped class
> 
> 
> It prints out True, but immediately afterwards gives out the
> error: RuntimeError: initVM() must be called first
> 
> Because your extension isn't initialized as you didn't call initVM() on it
> (but on jcc instead).
> 
> Which leads me to assume that the vm intialization is not global, which
> seems contrary to the description?
> 
> It is global (there can only be one Java VM instantiated per process) but
> must be called on your extension, not jcc.
> 
> Andi..
> 
> Again, many thanks for the amazing support!
> 
> Mark.
> 
> On Sun, May 27, 2012 at 1:42 AM, Bill Janssen <jans...@parc.com> wrote:
> 
> Andi Vajda <va...@apache.org> wrote:
> 
> 
> On Sat, 26 May 2012, Mark Finkelstein wrote:
> 
> That solved it; apparently it wasnt using the CLASSPATH variable to
> get
> this information, but specifying it directly solved this. Hopefully
> this
> will be one of the last errors; after pushing forward, I found myself
> 
> C:\MinGW\bin\gcc.exe -mdll -O -Wall -DPYTHON -DJCC_VER="2.13"
> -D_java_generics -IX:\Java16/include -IX:\Java16/include/win32
> -Ibuild\_CMMCore2 -IC:\Python26\lib\site-packages\jcc\sources
> -IC:\Python26\include -IC:\Python26\PC -c build\_CMMCore2\CMMCore2.cpp
> -o
> build\temp.win32-2.6\Release\build\_cmmcore2\cmmcore2.o /EHsc
> /D_CRT_SECURE_NO_WARNINGS
> gcc: error: /EHsc: No such file or directory
> gcc: error: /D_CRT_SECURE_NO_WARNINGS: No such file or directory
> error: command 'gcc' failed with exit status 1
> 
> Perhaps this is more meant for a cygwin installation, but is there a
> way to
> make this work for the cmd prompt?
> 
> You've configured JCC to work with a Microsoft Visual C++ compiler but
> you're using gcc via MinGW. I can't help you with that configuration
> as I don't have it but MinGW has been used with JCC before and someone
> on this list should be able to help you.
> 
> Yes, consistency is important here.  Those flags (/EHsc and
> /D_CRT_SECURE_NO_WARNINGS) look like Microsoft compiler directives to
> me, and won't work with GCC.
> 
> In case it's of help, this is my build script for mingw and JCC 3.x.
> I haven't tried this recently, but it should still work.
> 
> Bill
> 
> export JCC_ARGSEP=";"
> export JCC_JDK="$WINSTYLEJAVAHOME"
> export JCC_CFLAGS="-fno-strict-aliasing;-Wno-write-strings"
> export JCC_LFLAGS="-L${WINSTYLEJAVAHOME}\\lib;-ljvm"
> export
> 
> JCC_INCLUDES="${WINSTYLEJAVAHOME}\\include;${WINSTYLEJAVAHOME}\\include\\win32"
> export JCC_JAVAC="${WINSTYLEJAVAHOME}\\bin\\javac.exe"
> ${python} setup.py build --compiler=mingw32 install
> --single-version-externally-managed --root /c/ --prefix="${distdir}"
> if [ -f jcc/jcc.lib ]; then
> cp -p jcc/jcc.lib "${sitepackages}/jcc/jcc.lib"
> fi
> # for 3.x compiled with MinGW GCC 4.x and "--shared", we also need two
> # GCC libraries
> if [ -f /mingw/bin/libstdc++-6.dll ]; then
> install -m 555 /mingw/bin/libstdc++-6.dll "${distdir}/bin/"
> echo "copied libstdc++-6.dll"
> fi
> if [ -f /mingw/bin/libgcc_s_dw2-1.dll ]; then
> install -m 555 /mingw/bin/libgcc_s_dw2-1.dll "${distdir}/bin/"
> echo "copied libgcc_s_dw2-1.dll"
> fi
> 
> 
> 
> You might want to search the list archives, this question has come up
> before.
> 
> Andi..
> 
> 
> Also, so many thanks in regards to the help you've given me; I
> definitely
> wouldnt have been able to move forward without it.
> 
> On Sat, May 26, 2012 at 6:24 PM, Andi Vajda <va...@apache.org> wrote:
> 
> 
> On May 26, 2012, at 1:30, Mark Finkelstein <finkel.m...@gmail.com>
> wrote:
> 
> Apparently the correct (I think) command is:
> 
> python -m jcc.__main__ --find-jvm-dll
> 
> But if I use this I get:
> 
> C:\Users\avastmatey>python -m jcc.__main__ --find-jvm-dll --jar
> "C:\Program
> Files\Micro-Manager-1.4\plugins\Micro-Manager\MMCoreJ.jar"
> MMCoreJ.jar path = C:\Program
> Files\Micro-Manager-1.4\plugins\Micro-Manager\MMCo
> reJ.jar
> C:\Program Files\Micro-Manager-1.4\plugins\Micro-Manager
> C:\Program Files\Micro-Manager-1.4\plugins
> C:\Program Files\Micro-Manager-1.4\plugins\mm\win32
> C:\Program Files\Micro-Manager-1.4
> C:\Program Files\Micro-Manager-1.4\mm\win32
> Traceback (most recent call last):
> File "C:\Python26\Lib\runpy.py", line 122, in _run_module_as_main
>  "__main__", fname, loader, pkg_name)
> File "C:\Python26\Lib\runpy.py", line 34, in _run_code
>  exec code in run_globals
> File "C:\Python26\lib\site-packages\jcc\__main__.py", line 104, in
> <module>
>  cpp.jcc(sys.argv)
> File "C:\Python26\lib\site-packages\jcc\cpp.py", line 632, in jcc
>  generics, _dll_export)
> File "C:\Python26\lib\site-packages\jcc\cpp.py", line 766, in header
>  for method in cls.getDeclaredMethods():
> jcc.cpp.JavaError: java.lang.NoClassDefFoundError:
> org/json/JSONObject
> 
> Where is the org.json.JSONObject class defined ? If it's not in
> MMCoreJ.jar then you need to tell jcc via the --classpath flag, for
> example, so that it can find it.
> 
> Andi..
> 
> Java stacktrace:
> java.lang.NoClassDefFoundError: org/json/JSONObject
>      at java.lang.Class.getDeclaredMethods0(Native Method)
>      at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
>      at java.lang.Class.getDeclaredMethods(Unknown Source)
> Caused by: java.lang.ClassNotFoundException: org.json.JSONObject
>      at java.net.URLClassLoader$1.run(Unknown Source)
>      at java.net.URLClassLoader$1.run(Unknown Source)
>      at java.security.AccessController.doPrivileged(Native Method)
>      at java.net.URLClassLoader.findClass(Unknown Source)
>      at java.lang.ClassLoader.loadClass(Unknown Source)
>      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>      at java.lang.ClassLoader.loadClass(Unknown Source)
>      ... 3 more
> 
> I tried --package org.json, but this did not work?
> 
> On Sat, May 26, 2012 at 10:09 AM, Mark Finkelstein <
> finkel.m...@gmail.com>wrote:
> 
> It is at C:\Python26\Lib\site-packages\jcc.dll. I can also show you
> my
> installation log:
> 
> *** Installation started 2012/05/14 13:29 ***
> Source: C:\Users\avastmatey\Downloads\JCC-2.13.win32-py2.6.exe
> 999 Root Key: HKEY_LOCAL_MACHINE
> 020 Reg DB Key:
> [Software\Microsoft\Windows\CurrentVersion\Uninstall]JCC-py2.6
> 040 Reg DB Value:
> 
> 
> 
> [Software\Microsoft\Windows\CurrentVersion\Uninstall\JCC-py2.6]DisplayName=Python
> 2.6 JCC-2.13
> 040 Reg DB Value:
> 
> 
> 
> [Software\Microsoft\Windows\CurrentVersion\Uninstall\JCC-py2.6]UninstallString="C:\Python26\RemoveJCC.exe"
> -u "C:\Python26\JCC-wininst.log"
> 200 File Copy: C:\Python26\Lib\site-packages\jcc.dll
> 100 Made Dir: C:\Python26\Lib\site-packages\jcc
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\config.py
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\cpp.py
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\jcc.lib
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\python.py
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\windows.py
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\_jcc.pyd
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\__init__.py
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\__main__.py
> 100 Made Dir: C:\Python26\Lib\site-packages\jcc\classes
> 100 Made Dir: C:\Python26\Lib\site-packages\jcc\classes\org
> 100 Made Dir: C:\Python26\Lib\site-packages\jcc\classes\org\apache
> 100 Made Dir:
> C:\Python26\Lib\site-packages\jcc\classes\org\apache\jcc
> 200 File Copy:
> 
> 
> 
> C:\Python26\Lib\site-packages\jcc\classes\org\apache\jcc\PythonException.class
> 200 File Copy:
> 
> C:\Python26\Lib\site-packages\jcc\classes\org\apache\jcc\PythonVM.class
> 100 Made Dir: C:\Python26\Lib\site-packages\jcc\patches
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\patches\patch.4195
> 200 File Copy:
> C:\Python26\Lib\site-packages\jcc\patches\patch.43.0.6c11
> 200 File Copy:
> C:\Python26\Lib\site-packages\jcc\patches\patch.43.0.6c7
> 100 Made Dir: C:\Python26\Lib\site-packages\jcc\sources
> 200 File Copy:
> C:\Python26\Lib\site-packages\jcc\sources\functions.cpp
> 200 File Copy:
> C:\Python26\Lib\site-packages\jcc\sources\functions.h
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\sources\JArray.cpp
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\sources\JArray.h
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\sources\jcc.cpp
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\sources\JCCEnv.cpp
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\sources\JCCEnv.h
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\sources\jccfuncs.h
> 200 File Copy:
> C:\Python26\Lib\site-packages\jcc\sources\JObject.cpp
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\sources\JObject.h
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\sources\macros.h
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\sources\types.cpp
> 100 Made Dir: C:\Python26\Lib\site-packages\JCC-2.13-py2.6.egg-info
> 200 File Copy:
> 
> 
> 
> C:\Python26\Lib\site-packages\JCC-2.13-py2.6.egg-info\dependency_links.txt
> 200 File Copy:
> C:\Python26\Lib\site-packages\JCC-2.13-py2.6.egg-info\not-zip-safe
> 200 File Copy:
> C:\Python26\Lib\site-packages\JCC-2.13-py2.6.egg-info\PKG-INFO
> 200 File Copy:
> C:\Python26\Lib\site-packages\JCC-2.13-py2.6.egg-info\SOURCES.txt
> 200 File Copy:
> C:\Python26\Lib\site-packages\JCC-2.13-py2.6.egg-info\top_level.txt
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\__main__.pyc
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\__init__.pyc
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\windows.pyc
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\python.pyc
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\cpp.pyc
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\config.pyc
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\__main__.pyo
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\__init__.pyo
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\windows.pyo
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\python.pyo
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\cpp.pyo
> 200 File Copy: C:\Python26\Lib\site-packages\jcc\config.pyo
> 
> I also updated my PATH to be "C:\Program Files
> (x86)\Java\jdk1.7.0_04\bin";"C:\Program Files
> 
> 
> 
> (x86)\Java\jdk1.7.0_04\lib";C:\Python26;C:\Python26\Lib\site-packages;C:\Python26\Lib\site-packages\PyQt4;"C:\Program
> Files (x86)\MiKTeX 2.9\miktex/bin/";"C:\Program
> Files\TortoiseSVN\bin";"C:\Program Files (x86)\CMake
> 2.8\bin";"C:\Program
> Files (x86)\Java\jdk1.7.0_04\jre\bin\client"
> 
> Again, many thanks for the help.
> 
> On Sat, May 26, 2012 at 9:59 AM, Andi Vajda <va...@apache.org>
> wrote:
> 
> 
> On May 25, 2012, at 22:57, Mark Finkelstein <
> finkel.m...@gmail.com
> 
> wrote:
> 
> Hello everyone!
> 
> I hope this is a relevant question. I was trying to use jcc to
> create
> a
> wrapper for a different project's library but when I try to run
> python
> -m
> jcc.main
> I get the error C:\Python26\python.exe: DLL load failed: The
> specified
> module could not be found.
> I'm not sure why this is since I put the directory containing
> jcc.dll
> into
> my PATH. I am not sure if it will help, but the following is my
> PATH:
> 
> 
> 
> 
> C:\Python26;C:\Python26\Lib\site-packages;C:\Python26\Lib\site-packages\PyQt4;"C:\Program
> Files (x86)\MiKTeX 2.9\miktex/bin/";"C:\Program
> Files\TortoiseSVN\bin";"C:\Program Files (x86)\CMake
> 2.8\bin";"C:\Program
> Files (x86)\Java\jdk1.7.0_04\jre\bin\client"
> 
> I don't think jcc.dll is likely to be in any of the directories of
> the
> PATH you show. What is the full path of the directory containing
> jcc.dll on
> your system ?
> 
> Andi..
> 
> 
> Any help would be very much appreciated.
> 
> Thank you in advance,
> 
> Mark.
> 
> 
> 
> 
> 
> 
> 
> 
> 

Reply via email to