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.
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 problem with getting the Application to run on other People's machines.
I have tested a self contained and the normal .jar file.
When i pass them to a friend of mine who has java installed, when he opens the .jar file, there is an Error: "Java Exception has occured".
When i run both the .jar and the .exe off the self contained one, both do work on my PC.
So the actual question is:
Why isn't it working just like that?
Can't i just run JavaFX applications without installing the whole JDK?
Thanks for your help :)
Since Java 7 there exists the "javafxpackager", renamed to "javapackager" on Java 8 which uses some xml-configuration for generating your wanted "Installer"/distribution-package.
As this does not fit some peoples need, there exists a way to use maven:
the javafx-maven-plugin, you can find some examples about the usage of that plugin as linked.
Disclaimer: I'm the maintainer of the javafx-maven-plugin.
I installed Eclipse IDE for C/C++ Linux Developers to write some cpp codes. As I understood it, no matter which version of Eclipse I use, it always can be used to writing some java source codes.
I did this:
File->New>Java Project->...
Wrote a simple "hello world". I have confidence that my hello world is correct.
When I wrote my code, Everything went well.
But when I right clicked my new project, I found there was no "Run as","Debug as"
Press Ctrl+F11. It said "the selection cannot be launched, and there are no recent launches"
Run->Run Configurations. I double clicked Java Application. It said "No tab group defined for launch configuration type org.eclipse.jdt.launching.localJavaApplication"
What should I do?
How can I run my java applications?
Quite contrary to what you assume, eclipse isn't a Java IDE with some other addons. Eclipse is just a platform. As the package comparison shows, the C/C++ package doesn't come with the Java development tools.
Make sure you have correct eclipse version is downloaded? There will be separate eclipse version available for Eclipse for java.
http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/indigor
Hope this help.
If you have the JDT installed, then make sure you are in the Java perspective. Either:
Window->Open Perspective->Java (default)
Use the perspective switching tab, usually the top-right of your code editor
You can install the JDT, if you don't have it by using:
Help->Install New Software...
Try to install follow this link http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/indigor if it's work. i think your eclipsec/c++ may be have a problems while install java. You can reinstall or using eclipse for java.
I am trying to embed (internalize) java into the installation directory of my application. Looking at the documentation and all other help available that I could go through I copied the java directory to the application one and then set all the environment variables and paths as prescribed. However, when I launch the application using this new java directory it gives java not found error. Can someone give me some tips?
Thanks in Advance!
However, when I launch the application using this new java directory it gives java not found error. Can someone give me some tips?
You've obviously not set up the %PATH% environment correctly. That's what is causing whatever is launching Java to say "java not found".
You could:
modify whatever is trying launching Java to print out the environment variables, or
change whatever is trying launching Java to use the absolute pathname for the "java" command.
I wish you good luck in this task but may I ask you why do you want to do this? If you really wish to put java under your application install java there. You can use silent mode of installation. I do not remember the syntax right now but if you are on windows, java is installed by Windows installer, so search for "run windows installer silently" and follow the instructions. I believe that this approach will work on better and easier.
Download the source to WinRun4J (alternative to javaw on windows) and see how they initialize the JVM.
When editing Java code in Eclipse I can modify the code while it's running in various ways and have those changes take effect without restarting my program.
What is the technology underlying this feature? Is it part of Eclipse, or is it something I can do with the command line tools and the tools that come with the JDK?
Its part of the JVM and its called HotSwap.
http://download.oracle.com/javase/1.4.2/docs/guide/jpda/enhancements.html
This feature is usually called "hot code replace" and was introduced in Java 1.4 - it's part of the Java Virtual Machine Debug Interface and various APIs on top of that.
So it's not specific to Eclipse, but I don't think any of the command line tools that come with the JDK support it.