SWT: Method Monitor#getZoom() cannot be found - java

The org.eclipse.swt.widgets.Monitor class is supposed to have an instance method called getZoom, which should return the zoom factor set on the particular monitor. It is documented here (after clicking on "Monitor"):
https://help.eclipse.org/2021-03/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/package-summary.html
However, when trying to compile the following code...
Monitor monitor = Display.getDefault().getPrimaryMonitor();
int zoom = monitor.getZoom();
..., I get an error saying:
java: cannot find symbol
symbol: method getZoom()
location: variable monitor of type org.eclipse.swt.widgets.Monitor
The method is documented to exist since SWT version 3.107, and I'm using version 4.6.1. All other methods of the Monitor class work as expected.
What am I missing here?
(If there is further information needed to answer this question, please feel free to ask.)

SWT versions do not match Eclipse versions. 4.6.1 is your Eclipse version (Eclipse Neon), this contains SWT version 3.105.1 which is too old.
SWT 3.107 was first included in Eclipse 4.8 (Eclipse Photon). I think later versions extend the platforms on which zoom is supported so you should try to move to the current Eclipse 2021-03 (2021-06 shortly)

Related

FONT_HERSHEY_SIMPLEX is deleted from Imgproc class in JAVA

I'm working on a face recognition project using opencv and opencv contrib libraries, and when I do run my code, it gives me this error :
java: cannot find symbol
symbol: variable FONT_HERSHEY_SIMPLEX
location: class org.opencv.imgproc.Imgproc
and when I search into the Imgproc class I discovered that FONT_HERSHEY_SIMPLEX field didn't include in the class !!
Please if can you help me !!
The location of this depends on the version of opencv you are using. For example, in version 3.4 it can be found in org.opencv.core.Core (documented here), and in version 4.2 it can be found in the class you are expecting it (documented here)
Since you are presumably following instructions based on a later version I suggest you use version 4.2 at least.

IntelliJ IDEA - GUI Designer - Cannot load Preview form

I have a real trubble for a beginner)
When I try to see Preview while working in GUIform (even when class is empty), I see an error:
Cannot preview form '.../SimpleG.form'
Reason: cannot load /com/intellij/uiDesigner/FormPreviewFrame.class
// I have installed plugin JFormDesigner and didn't find how/where to install UIDesigner plugin.
Project SDK 1.8;
Project language level SDK default (8)
Looks like IDEA-237293. Will be fixed in the next release (around May 26th).

Eclipse 4.5.1. (MARS.1) Method not found: setDefaultEditor

I have a plugin that used to work with Eclipse Indigo, Kepler,Luna and Mars (4.5). It supports the Frege programming language (http://www.frege-lang.org/fregide/). It is based on the IMP framework, which is, unfortunately, not maintained anymore (and I don't have the source code).
Tonight I checked for updates, and it found Eclipse 4.5.1.
After updating, eclipse had a fancy new splash screen that says "MARS.1".
Yet it can't initialize the plugin anymore!
In the Error Log, I get the message:
Plug-in "frege.ide" was unable to instantiate class "frege.imp.builders.FregeBuilder".
and the stack trace seems to indicate that some method has vanished from the Eclipse API:
java.lang.NoSuchMethodError: org.eclipse.ui.internal.registry.FileEditorMapping.setDefaultEditor(Lorg/eclipse/ui/internal/registry/EditorDescriptor;)V
at org.eclipse.imp.language.LanguageRegistry.addUniversalEditorMappings(LanguageRegistry.java:393)
at org.eclipse.imp.language.LanguageRegistry.initializeRegistryAsNeeded(LanguageRegistry.java:268)
at org.eclipse.imp.language.LanguageRegistry.findLanguage(LanguageRegistry.java:206)
at frege.imp.builders.FregeBuilderBase.<clinit> (FregeBuilderBase.java:53)
...
Here are my questions:
Does anybody know why this method is gone?
How can I restrict installation of my plugin to LUNA, KEPLER and INDIGO only?
Would it be possible to supply a fake setDefaultEditor method that does whatever must be done now to register the Editor for the plugin?
The setDefaultEditor method does still exist in FileEditorMapping but it now takes an IEditorDescriptor argument instead of EditorDescriptor. This will cause the NoSuchMethodError. Since this class is an internal class and therefore not part of the API this is a valid change.
According to the IMP Wiki the IMP project has moved to a github project, you may be able to get up to date code from there (or at least get the source).

Calling C++ from Java, but Java loads the wrong Glibc version

I am trying to call a C++ library from java side and have written necessary jni code. However, when my java code tries to load my C++ library via System.loadLibrary, it complains the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: libmylib.so: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by libmylib.so)
I later found that it is because I have two different GLIBC versions on my system, and the default one is the older one, while libmylib.so is required to built from the newer GLIBC. As a result, java links to the wrong GLIBC.
I tried the following things, but it does not work :(.
The first one is to try to load correct library manually via System.load in my java code. Specifically, I added the following codes before it loads my library:
static {
System.load("/usr/local/gcc-4.8.1-glibc-2.17/lib/libc.so.6");
System.load("/usr/local/gcc-4.8.1-glibc-2.17/lib/libstdc++.so.6.0.18");
System.loadLibrary(mylib);
}
The libc.so.6 is also added because libstdc++ depends on it (otherwise java will load the wrong libc and complains another error). However, this time java complains the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
/usr/local/gcc-4.8.1-glibc2.17/lib/libc-2.17.so:
__vdso_time: invalid mode for dlopen(): Invalid argument
And this error is caused by mixing two versions of GLIBC as described in this question.
The solution to that question is for building C++ program with -Wl,--dynamic-linker set properly (also described here). However, I don't know how to do that in Java.
I tried to set LD_LIBRARY_PATH to the newer version, but the situation is just the same :(.
Can I know how to make java link to the correct library?
(PS: a solution without make install newer version of glibc is preferred, since many other applications in my machine rely on the current default glibc)
I have been searching and trying solutions to my problem for days, but none of them succeed :(
Stackoverflow, you're my only hope :~.
System.load("/usr/local/gcc-4.8.1-glibc-2.17/lib/libc.so.6");
As I explained here, this can not possibly work.
By the time you reach above statement, the system libc.so.6 has already been loaded (at process startup), and you absolutely can not have two versions of libc.so.6 loaded into the same process.
Try using LD_PRELOAD=new_c_library.so java -javastuff

JDE for Emacs for JDK 6.10

Is there a version of JDE for emacs that supports the JDK 6.10? I haven't been able to find any information on this. While it runs, every time I attempt to compile files the JDE says that it doesn't recognize my JDK version and reverts to assuming it is a Java5 version.
I've made following customizations for JDE:
'(jde-bug-debugger-host-address "127.0.0.1")
'(jde-bug-jre-home "/usr/lib/jvm/java-6-sun")
'(jde-compile-option-debug (quote ("all" (t nil nil))))
'(jde-debugger (quote ("jdb")))
'(jde-global-classpath (quote ("." "/usr/share/java/" "/usr/lib/jvm/java-6-sun/")))
'(jde-jdk-doc-url "/usr/share/doc/sun-java6-jdk/html/api/index.html")
'(jde-jdk-registry (quote (("1.5" . "/usr/lib/jvm/java-6-sun"))))
'(jde-regexp-jar-file "/usr/share/java/regexp.jar")
'(jde-sourcepath (quote (".")))
So it compiles without complaints, although I have jdk 1.6.0.07.
You can set your paths up in the configuration settings by "registering" a JDK version using M-x customize-variable and choosing jde-jdk-registry. Save that state, then do M-x customize-variable again, customize jde-jdk and pick the one you want.
That should do it; if not, give us a little more detailed information.
Yes, I've done that. The problem is when I call 'jde-compile, The message 'The JDE does not recognize JDK6.0.10 JDK. Assume JDK 1.5 Javac?" appears. Also, It doesn't look like the Java6 constructs, such as annotations, have been defined in the syntax checking or indentation rules.

Categories

Resources