I downloaded the project folder from :
https://android.googlesource.com/platform/packages/apps/Gallery2/
For some reason, when I opened it into my Eclipse environment, it is not compiling and it shows a lot of broken references. I am attaching screenshot for your reference:
Any ideas if I am doing something wrong or the code itself has issues?
This is a platform package, not a stand alone 3rd party package. It uses classes which are part of the platform, but not the Android SDK. It's built with the platform as a whole using make rather than Eclipse and ultimately is in the ROM (i.e. flash image.) You won't be able to build it with Eclipse and try to deploy it.
Many of Android's core apps depend on internal system APIs that are not available in the standard SDK that developers compile against. You can find some more information from this question.
Related
I recently downloaded VS Code for Java development. When I initially opened an existing Java Project in VS Code, it was unable to identify objects from the Selenium library. I downloaded the Java Extensions plugin and a few others, and now VS code will not recognize any of my imports as valid. Javax and Java.swing are among the now undetectable libraries. Is there a setting I missed? What do you recommend?
VSCode just an Editor, after you install some extensions, it only makes the editor more convenient, get more abilities even can help you develop the project of some kind of language through combine with the language support in your computer. Such as, you need to install JDK, then to install the 'Java' extension, then the extension to combine with the JDK and the VSCode, then you will get the ability to develop java project in VSCode.
That's means, The 'Language Support for Java(TM) by Red Hat' has nothing to do with java development. For example, after you install the JDK on your computer, you can develop java projects in the other IDEAs such as Intellij IDEA or some others. The 'Language Support for Java(TM) by Red Hat' extension just to combine the JDK with VSCode better, to make VSCode better to develop java project.
As you said, you failed to import libraries. Of course, the 'Java' extension without any libraries of java. You need to configure it by yourself. In the Explorer panel, you can find 'JAVA PROJECTS'. In it, you can find which libraries you have referenced and you can adds libraries in it. And of course, you'd better take maven to manage your project.
By the way, recommend you to install 'Java Extension Pack' extension.
You're going to need to add support through extensions because by default VS Code does not support Java. The great thing about this extension is that you get a slue of other extensions as well, such as; maven, debugging tools, support for junit, auto completion, etcetera.
On a side note, you could always use an IDE/IDEA like IntelliJ, Eclipse, or likewise. I'm definitely partial to IntelliJ but they all have their pro's and con's.
Is there a way to build Android app from Android studio to a jar file that could be run on Windows/Mac/Ubuntu? If not then why?
Despite both is Java syntax, Oracle Java and Android Java have little in common. Gradle can certainly package JAR, but the Android classes are unknown to the regular JRE. Better use the plain IntelliJ IDEA instead, which is rather suitable for desktop Java applications - else you could only run Android applications on an emulator or Anbox, which isn't too portable.
Tl;DR No you cannot run Android apps on Windows/Mac/Linux. Only emulators and Android devices can run them.
You should check the steps that Gradle performs during building before running it on the destination device.
To run on a PC (I mean Windows/Mac/Linux), you need a jar. And the closest thing that the build step comes to making jar is javac.
After javac, it performs steps to transform the java .class files into an Android readable format or the dex format and then packages the dexes into an .apk.
Android's execution environment understands dex and not .class (if it did then Android apps could have been run on all Java supported systems).
Let's say that you managed to stop after the javac and then managed to build a jar. Once you try to run it on anything other than an Android environment, you will get a ton of NoClassDefFoundErros because all Android specific classes are not there in the libraries in the usual JVMs (non-Android JVMs).
You should check this about the legal dispute between Oracle and Google. You will find that Android's Java implementation is very different that what OpenJDK offered at that time.
According to this oracle docs there is a conventional java app packaging along with runtime JRE. (Self-Contained Application Packaging)
I know that there is this thing (Launch4j gradle plugin) but I'd prefer to have a bat/sh executables along in the package.
Going through gradle docs and googling I can not seem to find is there is a way to teach gradle to package desktop app with JRE. Is there?
Have you tried this plugin yet?
https://github.com/FibreFoX/javafx-gradle-plugin
This has been a while ago, but if you're still looking for packaging Java desktop apps, have you tried Hydraulic Software's Conveyor?
https://conveyor.hydraulic.dev/
It's a commercial app, but it's free to use for Open Source projects.
There are different version of eclipse for different development environment.
My question is IF IDE remains same then why different versions, and if someone want to use all supported environments in single IDE how he/she can achieve that.
I want to use eclipse as single IDE for PHP, Java & Reports and Android development, instead of using different installation of eclipse.
Somebody helps me or refer me some link, it's quite confusing!
All the versions of Eclipse on the main site download page are the same version of Eclipse, but packaged with different sets of plugins. You can always install more features in Eclipse by installing more plugins.
You can have a single installation of Eclipse and use it for all your development needs - depending on your tastes however, it may sometimes be more manageable to have separate installations of Eclipse for different tasks (when there are a lot of plugins, Eclipse can take noticeably more time to start.)
There ARE different versions of Eclipse out there. But if we stick to one version and look at why there are different variants to download it's basically just that they come prepackaged with a specific component. So if you would like to use your Eclipse for C++ development you can get going with on single download. Instead of downloading the main IDE and then adding the module to support C++.
But after you install Eclipse, with any prepackaged modules, it's easy to add new ones. Say you have Zend Studio which is a PHP IDE based on Eclipse. You can still add all other modules supported by the version of Eclipse that Zend Studio is based on. For instance the Android SDK kit for Android development. You can add most modules by doing a search for them and finding the url to it's update site. Then click Help->Install New Software. Then you click Add and add the URL of the Update site of the module you wish to install.
Then you can select it from the Work with drop-down and it should appear in the list. Select it and click Next.
That way you can install almost all available modules for Eclipse. Note that sometimes you can run in to compatibility issues between installed modules and dependency problems. But most of the time it works fine.
They are not different versions, just the same backend with plugins for the particular language. Just that the specific versions are configured for best use with the language specified. If you want to use more languages than the default one in the eclipse you downloaded, just download the plugins you require and install in your installation of eclipse
Eclipse is plugin based IDE and these plugins may not like each other sometimes. It will be better to use more installations. In fact if you are developing Java and PHP you will need only 2 of them.
STS is a good Java toolkit especially if you work with spring.
If you new to Eclipse you should know that it can go crazy couple of times per month if you install too much and it is very annoying to see that one day your webapp is deploying and second day no...
Keeping installation separated you will have better control.
I am trying to recompile an existing Java project exported from Eclipse. It is necessary to recompile this because I am running simulations remotely on other machines where a different (older) version of Java is installed. I have tried recompiling my .java file which specifies the simulation in question. However, it appears that it is necessary to recompile all other classes etc as well. Has anyone got an idea how to do this WITHOUT using Eclipse (I am not the Admin on the other machines and thus Eclipse is unavailable to me) and not manually because the project is quite huge?
Thanks a lot for any suggestions!
I recommend you to always have an command line way to build an application. The usual way to do this in Java is using ANT (or Maven).
As #Santiago Lezica says, Eclipse can generate an Ant file.
I believe that Eclipse allows you to build for an older target platform than the one you are currently running. That way you can do all of your builds locally.
The second approach has the advantage that you can fix any problems arising from compiling for the older platforms (e.g. use of new language features, use of new classes / methods) from the comfort of your own ... workstation.
There is another option that you should consider: Tell Eclipse to generate code for the old Java version (see the compiler options). That way, you can create code that runs on Java 1.3, even if Eclipse uses Java 5.
Not sure what your requirements are, but you could set the compiler level for your projects at the (older) level of your Linux installs. This would cause Eclipse to recompile it at that version, instead of a newer version.
At my company we use IBM's Rational Application Developer (instead of pure Eclipse), but I am assuming the option is in the same spot. If you right-click on your project, you can go to the Java Compiler options and then set the compatibility to the level of that on Linux (1.3, 1.4, etc.).
Since compile Java byte-code is supposed to be portable (for the most part), this should get you past most of your problems.
Otherwise, the other option is to use something like Ant or Maven scripts (which can be kicked off by Eclipse) and then just use a property to set the compiler right before you run it. This way you don't have to switch properties on your projects all the time, if you truly do need "newer" compiled code and can't live with "older" code on both systems.