Running in intelij
When i try to run the .jar
Edit environment variable path
I've written my first small program in java, and want to make it into an executeable file.
I used InteliJ to generate a .Jar file out of the Main class. When i Run the Jar in Intelij it seems to work fine. However once i try to open it from my windows i get
error a jni error has occurred please check your installation and try again
Some googling told me that my JDK might not be properly set in my system properties, so i added the path to my JDK, however the error remains. Anyone have any idea what's up with this? I believe that I added my JDK through inteliJ. Why is it so difficult to simply run the program i made? Is there something wrong with my JDK? is my .jar corrupt?
Related
I created a project in eclipse and want to run my exported .jar file on an other machine. When I try to do so using "java -jar myfile.jar", I get the following message:
Error: JavaFX runtime components are missing, and are required to run this application
If I run it in eclipse (using jdk13), everything works.
On the machine where I want to run the jar file I installed openjdk and openjfx. Actually I'm not sure wether the problem has to be solved in eclipse while exporting the jar file or on the other machine while running it? And how? May anyone give me a hint?
I basically just spent the whole day trying to get a runnable .jar file from my libgdx project working. In previous projects on a diffrent pc I used to simply navigate my way into the project root folder with cmd and used "gradlew desktop:dist" command. However right now I'm getting error message whenever I try this method.
error
How do I know which folder gradle searches my "tools.jar" file from? I tried even copying it to a few places with no success. I'm using windows OS.
For IDE, I'm using intelJ idea with newest version. I tried to use the "build artifacts" method from IntelJ but what ends up happening with the generated file is that it instantly closes/crashes whenever opened. When running the generated file throught command prompt I get a huge host of errors too numerous to name let alone fix. It seems like it doesen't include the required structures / project folders properly when using artifacts build.
Seems, your environment variable points to the installed JRE(Java Runtime Environment), but has to the Java Development Kit (JDK), because tools.jar is one of the files used by the development tools. You can take a look at the JDK and JRE File Structure to figure out, where is tools.jar located.
So, you have to install JDK(if it was not installed) and make the JAVA_HOME environment variable to points to it.
I am currently having a problem running a jar file created by eclipse.
Within eclipse I can run my project using the run function and the project runs exactly as expected.
The same applies to compiling and running the code from command line using javac Menu.java to compile and java Menu to run.
Both of these run correctly and do not return the error I receive when running the jar file.
The jar file was created in eclipse by exporting the project. But when i run the jar file the application refuses to response when opening any JFrames containing Java3d. Upon debugging the jar file i receive the error
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: javax/media/j3d/Canvas3D
This normally would lead me to believe that my CLASSPATH is incorrect but since the project runs from command line this doesn't seem likely.
Any help or pointers would be very helpful.
Thanks.
Found a solution which works.
Instead of simply creating a jar file, you can created a runnable Jar file.
When asked under library handling in the export process, selecting 'package required libraries into generated JAR' solves this issue and allows it to run on all computers, even ones without Java3D installed.
I'm at my wits end. I can't create a jar file (manually or through Eclipse). I've followed instructions for creating the manifest and jar file manually. The end result is that I get an error saying "The JavaJAR file 'widgetSamples.jar' could not be launched. Please check the console for possible errors." The console doesn't register anything when I launch the jar file or when the error message pops.
In eclipse when I create the jar I do get warnings:
Exported with compile warnings: SWT Resources/src/widgetSamples.java
I created a separate simple program to see if it might have been something with my code but I can't even get a simple SWT display to open; I get the same error. The code executes properly in Eclipse.
I have the 64 bit SWT installed as far as I know. Any help is much appreciated. Thanks.
Creating jar file using eclipse IDE
http://www.tutorialspoint.com/eclipse/eclipse_create_jar_files.htm
Creating jar using CMD
http://www.wikihow.com/Create-JAR-File
I'm a beginner in Java so this question might seem a little stupid, my JDK and JRE are installed in C:\program files. I write my program and save it in in my folder, G:\start.
Now my program compiles without any error (the .class file is also generated), but when I run my program it says "unable to locate G:\lib\amd64\jvm.cfg", so I copy the 'lib' folder from my JDK folder and paste it in G:. Again program compiles without any error, but when I run it, it gives me a new error saying "unable to locate G:\bin\server\jvm.dll", so I copy the 'bin' folder to g:, but now when I run, it gives me the same error again "unable to locate G:\bin\server\jvm.dll". Where am I going wrong?
Create an environment variable called JAVA_HOME and point it to the bin directory of your Java installation. Also add the same directory to your PATH variable. This should solve your problem.
PS: JAVA_HOME may not be required, but it will help if you have tomcat and stuff installed.
try to save it as a .jar, go to your cmd and use:
java -jar G:\bin\server\jvm.jar
this should work.
The best advise I can give you is to download an IDE to get started. BlueJ is an IDE aimed at getting people started using java and is used in many universities world wide.
take a look at www.bluej.org and you should be up and running in seconds.
Karl