Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java API
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Other JSE/JEE APIs
c++ throw exception java catch
Andrzej Borucki
Ranch Hand
Posts: 101
1
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I write special classes for exception in C++
#ifndef BINDEXCEPTION_H_ #define BINDEXCEPTION_H_ #include <stdlib.h> #include <windows.h> #define EXCEPTION_MESSAGE_MAX_SIZE 4000 class BindException { private: wchar_t * _message; HRESULT _hresult; public: BindException(const wchar_t * fmt); BindException(HRESULT hresult, const wchar_t * fmt); virtual ~BindException() { if (_message) { free(_message); } } wchar_t * GetMessage() { return _message; } HRESULT GetHResult() { return _hresult; } }; #endif /*BINDEXCEPTION_H_*/
#include <stdlib.h> #include <cstdio> #include "BindException.h" BindException::BindException(const wchar_t *arg) { BindException(0, arg); } BindException::BindException(HRESULT hresult, const wchar_t *arg) { _message = (wchar_t *)malloc(EXCEPTION_MESSAGE_MAX_SIZE*2); wcsncpy(_message, arg, EXCEPTION_MESSAGE_MAX_SIZE); _message[EXCEPTION_MESSAGE_MAX_SIZE - 1] = 0; _hresult = hresult; }
Exception is throw while DLL is loading:
throw BindException(L"Can't load UnAceV2.Dll");
In side of
Java
is catch:
static { try{ System.loadLibrary("junace"); } catch(Throwable e) { System.err.printf(e.getMessage()); System.exit(1); } }
But I see only: "D:\code\junace.git\java\junace.dll: " <---square char at end
Andrzej Borucki
Ranch Hand
Posts: 101
1
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Examples from
samplecodebank
works only form native functions, but if I want exception from DLL load?
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
KISS or KILL?
JNI - dll method invocation not working despite correct signature
Thread not starting after calling Java method from C
Problem in running JNI with in servlet
Swig
More...