Dynamically Loading Libraries in Eclipse - java

I'm currently working on a java project in eclipse that uses 64-bit SWT libraries. A lot of the computers this program might be used on have 32 bit operating systems, so to avoid making a 32-bit and a 64-bit version, I want to explore dynamically loading a 32-bit or 64-bit SWT library depending on the JRE being used at the time.
I found some references to using ClassLoader, ServiceLoader, and similar objects, however I'm not sure how that would fit in with eclipse's structure, and if eclipse's structure even allows for this type of loading in the first place. Additionally, I am unsure how to check which jvm is being used inside the code, which I assume would be a prerequisite for knowing which SWT libraries would load correctly.
If you guys would be able to provide any suggestions or directions in which to focus my research, that would be great. I'm currently pretty unsure on how to proceed.
Thanks!

This SO question has some answers with code that you could pilfer and adjust to your needs. By the way, Eclipse itself (actually, the OSGi runtime) could handle this for you, if you were doing an RCP app.

Related

Java behaving in a different way on arm64

I am still working on the issue Java AWT Fonts scrambled which I posted here a while ago. More Debugging has been done, and it seems like the arm64 java is the problem. When running 32 bit java on arm64 it is working fine, same on amd64, arm32 and x86.
Is arm64 Java expected to behave different with that code? Shouldn't Java react the same way on every architecture? If yes, where could I open a Bug for that? I am using Oracle Java Runtime Environment if that matters. Java is so complex that I am not sure which is the right place to open that bug so it can get adressed and investigated.
Java is supposed to be platform independent but there are limits when resources of the underlying system need to be used. In that case platform dependency comes into play and you might see different behaviors with different JDKs. Fonts are provided by the operating system so you have some kind of platform specific stuff going on here as well.
Your original question and this one lack some fundamental thing: A workable source that shows the effect on your system. With that it would be possible to try to reproduce your problem on other peoples' systems and might come up with an answer why you have this effect. Your original question e.g. lacks the information what Font you're actually using and I don't see any code where you write the text that appears scrambled.

How do you implement a programming environment in a workplace?

There are currently no development tools in the environment I work in. I am the only developer in the working environment. What are guidelines in implementing a programming/development working environment? (Example, what do I need to do, in order for me to create internal java applications, which may include tools, licenses, etc.)
As you are the only developer in your environment, there are a few things that are fortunate. You tagged this question with Java, so I will assume you want to work with this language.
Java itself, if not already installed. You can find Java at their website, and download the latest version on it on your machine. This will allow you to launch your Java applications outside the IDE (next point). To check if you have installed it, it is usually under your Program Files folder, most often: C:/Program Files/Java.
An IDE (Integrated development environment). There are a lot of them, but the most famous might be Eclipse. It often comes with an embedded Java version with it.
And that's it. Only the IDE would work pretty well. In pure theory, you could even do it with Java only and its compiler, but pretty much every Java developer uses an IDE. Licencing is an internal thing that you will need to implement.
By the way, I will let you read this, and flag it in five minutes. It should not be there. You should try Programmers' Stack platform for this kind of topic, which is not related to pure programming.

Scala or Java based on IDE and Memory footprint

We have huge stack of xml files (around 5000+ files) possibly about 80 MB when not compressed) all of them are device configurations used for read & write data & build user interfaces without any language dependencies. These XML files can be ported to any technologies like Android and Apple world. Not all the 5000+ are loaded at one shot to memory, we might load 200 files into memory based on 1 device connected. We have a .NET/WPF based application which is using those XML files to build the UI and access the device information through protocols like Modbus & Hart (Don't bother protocols now). Anywhere we need custom logic, we have written them in DLL's (in .NET) and we use the reflection & IoC to load those DLLs, create object and access them through interfaces at runtime to complete the XML configuration. On desktop, then we build UI and load configuration
Now We need to develop Android app which runs on Phone and tablet as well. I have 1 year experience working lightly in Java. We could write a core modules which can be used for both phone and tablet and UI layer which is just to render our XML as a UI elements. We know to use Java's Class Loader to create instance so that instead of DLL's we could build .jar file in Android world and load them (if possible?) and access via interfaces. When we load our XML, it will consume nearly 80 to 100 MB of RAM (in WPF & .NET).
When looking into Android world, I could not decide whether to go with Scala or Java. We do not have any Java expert to advise us. Having worked on Python, I feel like Scala is modern & good choice. Also I read that Android apps compiled using Scala is fat(big), take long time to boot up.
But coming from Visual Studio background, we are much sophisticated development team expect everything to run through IDE. Also team has to learn Java/Scala whatever our choice from start.
If we choose to work on Scala on Android, do we except the memory efficiency is near to Java? Also do we have sufficient IDE support (Eclipse or NetBeans or IdeaJ) for Scala?
I am specifically looking for Memory footprint (internals) and IDE support for building Android application. No discussion on performance or productivity..
My Scala IDE is Maven in one terminal window and Vim in another. The browser serves up help documentation. If you can base your build process on Maven, then any IDE should do fine. And since you are working a lot with XML files, I suggest that you do base your build process on Maven rather than SBT.
Of course, there is Eclipse support for Scala, Intellij supports it, there is a Netbeans plugin for Scala, even a Komodo language extension for Scala. Lots of IDE choices to try out. Only the developer knows what works for them.
Make half a dozen identical VMs. Install one IDE on each one of them. Get the developers (end users of the IDE) to test them and choose the one that they want. Do all of the build and continuous integration with SVN and Maven. Make that the boundary between the developers'personal toolset (the IDE or Emacs or Vim) and the supported development tools.
If you're coming from C#, I'd advice choosing Scala. That way you could actually preserve some of your business logic, because good C# code might probably look a bit like things are done in Scala, too. E. g. LINQ in C# and Scala's collection classes (v.s Java collections).
The syntax is a bit different compared to Java/C#, but syntax is hardly a real problem these days.
Java's IDE support is pretty good, but if you're coming from Visual Studio, Intellij (or Eclipse) + Scala plugin might be good enough for you.
If you program the same code in Java and Scala, memory consumption should be pretty the same.
You should keep in mind that you should use ProGuard to keep the size of the Android application manageable.

Implement Ahead of Time compilation (AOT) for Java based applications

We are in process of developing a commercial desktop based application in java using Rich Client Platform framework from Netbeans/Eclipse. The IDEs (Netbeans/Eclipse) provides nice inbuilt installer for packaging the application. The only problem is our end users can see jar files on deployment and we don't have enough protection of our intellectual property as reverse engineering is possible. Code obfuscation can be used to minimize the impact but can't avoid it. We were searching for open source solutions/products which can help us mitigate our problem by directly converting our application to native code something similar to what AOT is supposed to do.
Thanks in advance for ur help.
-Bhan
this was already discussed here: How do I create an .exe for a Java program?
You may transform an Eclipse RCP applications into a real EXE (or Linux binary) containing no bytecode using the product my company makes.
In general, an AOT compiler must be aware of the inner workings of such a dynamic framework or container, specifically its class loading, otherwise the original bytecode will be required at run time for consistency checks and possible JIT compilation. Our product only "knows" about Eclipse RCP and Apache Tomcat classloaders as of now (it always knew about the standard ones of course.)

Emacs and Java change propagation and errors notification

Emacs and Java change propagation
Hi,
I'm mostly used to code in IDE like Eclipse but I wanted to try emacs. Because I keep hearing about how much better it is than big IDE like Eclipse and Visual Studio.
So I was looking at what emacs provides for Java (with the JDEE extension) but it doesn't seem as complete as Eclipse.
One of the most important thing I look for in a Java editor is change propagation and error notification. For example if I rename a class, I want to be able to have all the declarations of this class renamed automatically. And if I delete a method, I want to be able to see all the place where this creates errors.
I didn't find those things in emacs, and this is a showstopper for me, I can't see how I could work on big projects without those features.
So my question is : those features don't exist or is it just me that haven't looked at the right place?
Emacs can be better that Eclipse, but the question is "for what"? Emacs (and VIM) are generally smaller, faster and optimized for text editing and navigation*. In recent versions Eclipse are quite capable for editing and navigating java code but with different "style".
If you are willing to learn Emacs then learn it. You will get experiences on your own and it is very important for a developer (you are the only one can decide what is work for you). But learning Emacs does not mean to "throw out" Eclipse, they can co-exist quite well if you use ant or maven-based project building and a source control system. You can for example do all editing in Emacs while for debugging and refactoring use Eclipse.
There are some interesting thought in this thread about Emacs and java development. Also there is an interesting read and conclusions about Emacs and Eclipse from someone who tried both environment.
If you are not an expert Eclipse user yet you should look at the powerful editing and navigating features of Eclipse before starting Emacs:
10 Eclipse navigation shortcuts every java programmer should know
Effective Eclipse: shortcut keys
Effective Eclipse: custom templates
Effective Eclipse: fix it quickly
Back to the question: there is an Emacs extension called Xrefactory for Java but it does not support Java 1.5 features so it is useful only if you use Java 1.4 or older.
(*) of course they are much more, I know :)
Emacs is an incredible editor, with good support for developing in C. For developing in Java there is much better support in one of the Java IDE's which has deep knowledge about the programs being edited. You probably want something like Eclipse, JDeveloper or Netbeans.
In my opinion you will not be satisified with developing Java with Emacs, and you should use another tool.
I don't know much about Emacs (so you may regard the following as off-topic), but I work with both Eclipse and VIM.
I use Eclipse for big Java projects, and I can't live without the large-scale features (cross-project renaming/refactoring etc.). I use VIM for small scale stuff (e.g. knocking up code for StackOverflow examples in multiple languages).
Eclipse and VIM have very different capabilities and consequently I use each bearing this in mind. I don't expect VIM to do the heavy lifting, but on the other hand I don't expect Eclipse to start in a keystroke and to be able to write a new (small) project in a few seconds (in whatever language I require - not restricted to Java). Perhaps you should look at the Emacs/Eclipse pair in a similar light ?

Categories