I'm using ImageJ for image processing for a class, and I've been creating small plugins for a few weeks. It's been frustrating for me because I never saw any java error messages, such as syntax error on line 3 blah blah. When my plugins don't compile (due to some compile time error), all I see is "class not found", or if a plugin had compiled in the past and there is a class file available it will run the old compiled version and not give me any error.
I thought this was normal until I met up with my friend and he had been getting error messages the whole time.
Any idea why this is? I'm using windows (tried on windows 10, 8, and 7), he's using some osx distribution (most likely the latest). I've tried all available versions of ImageJ from the website, so I don't think it's a version issue. Is this the norm on windows for some reason?
I suspect you are using ImageJ 1.x, e.g. downloaded from here? And trying to compile via Plugins>Compile and Run...?
In general, I would recommend developing Java code in Eclipse - as having a proper IDE is vastly more powerful than what you can get in ImageJ.
If all you need to do is write simple Macros calling existing ImageJ functions then writing them in the various non-Java scripting languages within ImageJ is perfectly sufficient.
If you decide Eclipse isn't your thing and you want to continue developing within ImageJ, I would strongly recommend using the Fiji distribution of ImageJ - as it includes a robust script editor.
If you use this editor to write Java code, it will save your scripts to disk as .java files and then call the Java compiler (javac) on them, which will give you a more complete picture of any compilation problems.
Related
Im new to app development and was wondering if it would be possible to include another jdk. For example java 17 and run a jar that needs to be run in this exact version? I think termux has an api that you may use for these purposes but is there another possibility? These jars are only console based and without any gui.
I first tried to use the jar as a android library inside the app, which did not work since it was compiled in java version 17. I tried decompiling the jar and recompiling it with the version I was using. The problem is that all the libraries used are on other versions than I need them to be and so I could not recompile it. I also thought about writing the application in c# but I am not used to it at all, which would throw many new problems that I would be willing to take if it would be a possibility to work out my project.
Q: Is loading the code into your Android application an option?
A: No.
Android loads code from ".dex" files not ".class" files.
The ".class" files would need to be translated using dx.
The Android dx command doesn't understand Java 17 ".class" file format.
Also the code in the JAR is likely to depend on classes in the Java SE class library that the Android doesn't provide.
Q: What about running it in a separate Android VM?
A: No.
An Android VM requires ".dex" files; see above.
Also, the Java SE class library issue; see above.
Q: What about launching an OpenJDK or Oracle Java 17 JVM on the Android device to run the JAR?
A: In theory Yes, but in practice No. As far as I am aware, there is no port of OpenJDK Java SE to the Android OS platform.
Q: What about using Termux?
A: OK ... that might work. See Is it possible to install the JDK on an android device?.
I have no experience with this, and don't know what problems you may run into doing this. But I suspect that you wouldn't be able to distribute something that relies on Termux via the Google Playstore.
Another option is to download the source code1 for the application and try to build it in your Android dev environment
If the code uses Java classes / packages / libraries that are not available for Android, recode the relevant parts of the application to use Android equivalents instead.
Ditto if the code uses Java language features that are not yet supported in Android Java.
It probably won't be easy. It may turn out to be impractical.
1 - You said in a comment that the code your are trying to use is "open source". So the "download source and build it" option is available to you. I'm puzzled why you tried to decompile and recompile it instead ...
I have a java application that consists of various files and I need to run my project. I have jdk 14 installed and have also set the Environment Variables. But when I click on Launch project, it just keeps loading and loading and nothing else happens. It does not show me any error log or anything. I am really confused and been trying to solve this for a week. In launch, it does not give me any option of java. It says Launch in angular. Any help would be appreciated?
VS Code is basically an editor for sourcecode files of different languages. As such, it does have any inbuilt Java execution options.
To debug your Java programs, you will need to install the appropriate Java extensions for VS Code.
Having Jdk installed is a prerequisite to use Java on VS Code but it alone is not enough.
I am currently taking a class that requires me to use code created by the professor, but I've run into an issue. Whenever I try to run code that uses the professor's code, i get the following message:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: cs/comsc331/ppm/PPM has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the Java Runtime only recognizes class file versions up to 52.0
I know what's causing this, as it tells me - my Java needs to be updated. However, when I go to do so, both Eclipse and the Java Control Panel tell me that I'm all set with the most recent version. I went looking, and on java.com it told me to download Version 8 Update 241, which I did, but nothing changed. When I started looking online for solutions, I came across a post that briefly mentioned that Eclipse would not run with a more recent Java on my system then Java 8.
It seems that I'm at an impasse - I either need a way to update Java without breaking my setup (I tried downloading a more recent version than Java 8 and Eclipse wouldn't start), or I need a way to run newer code on my older system, potentially by recompiling it myself (I tried doing this once and I couldn't figure it out so I could use some advice if this is the best way forward). If I have to recompile the code myself that's okay as there aren't a huge amount of files, but the more efficient the method, the better.
Updating to a newer OS is not an option (if that would even help) because when I've tried to do so in the past, my laptop had to be completely reset (something about it being to hold to handle the new way that files were being done? the explanation I received was unclear).
In the super short term, I've just been straight up copying the code into new files and compiling it on my own, but my professor wants us to work within the existing packages, so that is a bandaid more than anything else. Long term, I need a new laptop that can be fully updated (I got my current one in 2015) but I would assume that there's a more reasonable solution out there.
Thanks!
I've been reading up on PhoneGap and really like it. I'd like to see if I can use it with GWT to write Java apps that deploy to many different platforms (web, mobile web, android, iphone, winphone, etc.).
It looks like the PhoneGap SDK comes with different versions of cordova.js for each native platform you want to support. So it looks like the Ant build will have to somehow package the GWT-generated JavaScript to the correct version of cordova.js:
3098DJU39I4F9IF9.html + cordova-android.js
3098DJU39I4F9IF9.html + cordova-iphone.js
3098DJU39I4F9IF9.html + cordova-windows-phone.js
I'm generalizing here, and I know those aren't the correct file names (although, obviously, 3098DJU39I4F9IF9.html is the GWT-generated code).
But then something has to kick-off PhoneGap's ability to take each of those pairings and produce the correct packaged container: an APK, IPA or XAP for each platform respectively.
So I first ask: how does a PhoneGap developer normally go from 3098DJU39I4F9IF9.html + cordova-android.js to having a myapp-android.apk, or from 3098DJU39I4F9IF9.html + cordova-iphone.js to having a myapp-iphone.ipa? Does the PhoneGap SDK have a command-line tool that does this?
Once I understand that much, I'm trying to figure out how to automate this packaging/binding process from an Ant build. Are there any known Ant tasks that already do this? Or do I need to kick off a shell from inside Ant and just run the shell commands? Thanks in advance!
#rooftop is right, you have to build the native app using native SDK even if you are using Phonegap. The benefit lies in creating the UI and behavior of the app using HTML5, CSS and JS.
So, if you are not using any of the native functionality or custom Phonegap plugins, you can just have a bare minimum package structure of native apps for each of the platforms and then simply move the correct files into the concerned folders (in Android it is assets folder) of those package structures using copy task of ant. Thereafter, you can use command line compile and build tools specific to each platform to build and package the app.
Hope this helps.
EDIT: Added more details about other platforms
Basically, all SDKs contains command line tools. In fact I used to compile and build from command line, to automate the process, even for standard Windows apps (Console, Web Apps etc) which are usually performed via Visual Studio's easy to use environment. You can see this for extended tools over standard SDK for Windows phone development.
Similarly iOS is based on UNIX so there we get the power of majority of command line tools for compile, build and automation and XCode provides command line tools for building.
Further for Android, you may find this helpful.
You should really be using Cordova, the renamed version of PG that is an Apache project now. Command line tools were recently released for Cordova. I have not used them so I am not sure if they will help you with building or not. Typically the way you woul create the binary for the device, say an IPA file for iOS would be to actually use Xcode and the native SDK to compile and package your app. This means you need all of the native tools and SDK for each platform. There is also a hosted service from Adobe that will build the native bits for you for a fee. It used to be called phone gap build, not sure if that is still the name. You might want to look at IBM Worklight, as it does many if the things you asked about. The developer edition is free an Eclipse based for the IDE.
I am working on Eclipse IDE for Java (Indigo). My project is using CDT in addition to Java source. I frequently get this error message from Eclipse, although everything works fine.
What is C/C++ indexer? What is the actual source of this error and how to remove it?
The C/C++ indexer parses your source code file to gather information used for auto completion, syntax highlight and so on.
You said you are using CDT in addition to Java source. Sounds to me as if you are using C/C++ and Java code in the same Eclipse Project. My guess would be that the C/C++ indexer accidentally tries to parse a Java source file and is confused. If so, use different Eclipse projects for your Java and for your C/C++ code.