I started to write code in Java few weeks ago. I use IntelliJ Idea (the latest version) on Win10x64.
I realized a little hangman game (as a Windows command line app) that uses a text file with the words and I have put this text file in a folder called 'assets' inside the project folder (at the same level of 'src' folder). The game works great in the IDE environment but I still don't know how to realize a standalone app and running it outside IntelliJ.
I tried also to compile from command line using javac.exe and it seems that compilation works well but when I try to execute the program from command line using java.exe I get an error that says that the text file I use as vocabulary is not found (java.nio.file.NoSuchFileException).
I have also followed the instructions on Jet Brains site about How to create a JAR file but with no results. Is there a simple way to deploy a Java desktop application so that people (who obviously have JRE) have just to make a double click on an icon and use it?
Related
I thought I could find an answer for this question because as i think it is popular problem.But unfortunately I did not find the answer
I have an application written with Java and JavaFX
and i built it using eclipse and it worked perfectly there
but when I export the project as a .jar(executable jar file) file so it runs when it is double clicked it doesn't work
I tried a lot of things and I could approve that their is no exceptions or errors in the jar file by running it from the cmd and it worked perfectly but i still need it to be run by clicking a shortcut like an .exe file or any kind of such a thing and it should run when it is sent to another computer
this image proves it is working in the cmd
Image
I recently wrote an application that is packaged as a .jar file. When I run the application from the command line via "java -jar MyProject.jar" everything looks perfect, just as it does when run from within eclipse. However when I go to the file location in the file explorer and double clock the file, it doesn't quite work. All of the functionality is there, but the GUI is not quite right. All text is much larger, despite the application not changing size, when run like this, to the point where much of it is cut off.
Anyone know whats going on? Thanks!
The cause of this issue was that when being run from the command line, the program was being run with JRE 1.8.0_172, however when being run from the file explorer, the program was using JDK 10.0.1
My windows machine is at the tech support, meanwhile my substitute laptop is a macbook. I am not familiar with the system and I am having trouble to make Netbeans run java code.
If i try to import .zip java projects, it says "No Netbeans projects added".
When i look if i have a JDK in Tools --> java platforms I have default 1.8jdk
with a lot of files listed, so i do not think the JDK is the problem?
I downloaded netbeans with a JDK in a bundle as well.
I am unable to run any java code, the buttons are simply just grey instead of colored and if i try to use keyboard commands to make the laptop execute the code it comes with a error sound.
I read something about it could be ant variables, but not much information was given. But when i go tools --> ant variables it shows nothing.
When i try to create new files it only gives me two options: XML and other. In the other category there is; SQL, HTML and CSS. So no option for creating java files either.
Answers to comments:
I just trying deleting it at reinstalling from this domain http://www.oracle.com/technetwork/articles/javase/jdk-netbeans-jsp-142931.html
I cannot show you the command line, since i do not know the commands in Terminal. But in the JDK it says: /Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home
I cannot run ANY java code, since I cannot create java files. If i try to run a simple program in an empty file I cannot run it.
I'm sure the answer is really obvious and right in front of my nose, but I am writing programs in Eclipse and I'd like to be able to run them outside of the workspace. (Like on the command line.)
Problem is I can't find the executable file in the file explorer. So I have to ask....
How do you run programs you write in Eclipse OUTSIDE Eclipse? (Program is in java.)
I just recently switched from Visual Studios to Eclipse so I don't really know Eclipse well. Most of the time figuring out the IDE is more hard to actual coding really.
The executable can be created by Clicking: file -> Export -> As Runnable Jar File
Then make sure launch configuration is set to the correct project, and that the export destination is where you want it to be. Then Click finish, and your runnable jar file should appear where you specified.
If the program has a GUI, it can be run like a regular exe file (double clicking, etc.) if it does not have a GUI it will need to be launched from the command line (ie, by navigating to it with CMD, or with a batch file).
I've created a game project in NetBeans 6.9, and I want to run the project on another computer. The problem is if NetBeans is not installed on the other computer then surely I cannot run the project.
Therefore I have to convert my project into a .exe that can be run on other computers without having to install NetBeans.
Is there a free application that can convert .java to .exe?
Please help me to convert my project into a .exe file. Thanks.
Check out these official netbeans article for Packaging and Deploying Desktop Java Applications and Developing General Java Applications.
From the article
Running the Application Inside of the IDE
When developing applications in the IDE, typically you will need to test and refine them before distributing them. You can easily test an application that you are working on by running the application from the IDE.
To run the AnotherGrep project in the IDE, right-clicking the project's node (AnotherGrep) in the Projects window and choose Run Project.
The xGrep window should open. You can click the Browse button to choose a file in which to search for a text pattern. In the Search Pattern field, type text or a regular expression pattern that you would like to match, and click Search. The results of each match will appear in the xGrep window's Output area.
Information on regular expressions that you can use in this application are available here and in many other places on the World Wide Web.
Running the Application Outside of the IDE
Once you have finished developing the application and before you distribute it, you will probably want to make sure that the application also works outside of the IDE.
You can run the application outside of the IDE by following these steps:
In your system's file manager (for example, in the My Computer window on Windows XP systems), navigate to PROJECT_HOME/dist and double-click the AnotherGrep.jar file.
You will know that the application has started successfully when the xGrep window opens.
If the xGrep window does not open, your system probably does not have a file association between JAR files and the Java Runtime Environment. See Troubleshooting JAR File Associations.
Distributing the Application to Other Users
Now that you have verified that the application works outside of the IDE, you are ready to distribute it.
You can distribute the application by following these steps:
1: Create a zip file that contains the application JAR file (AnotherGrep.jar) and the accompanying lib folder that contains swing-layout-1.0.jar.
2: Send the file to the people who will use the application. Instruct them to unpack the zip file, making sure that the AnotherGrep.jar file and the lib folder are in the same folder.
The users of your application should be able to run it by double-clicking the JAR file. If this does not work for them, show them the information in the Troubleshooting JAR File Associations section.
Also some third party tools like Launch4j may do the trick. For more information see this article on java-to-exe
See Launch4j. I dislike starting java apps with a batch file. This wraps anything from the root jar all the way up to a complete Java environment in an exe. You get your own icon in the system tray rather than the generic coffee cup. I've used it successfully on a project that has about 300,000 downloads, and it's never been the source of a reported bug. NB It does take some careful reading to pick the right options for your project. But you can set it up with the Ant build script in Netbeans to make the .exe automatically. Very nice and clean. My project includes native libraries. They work fine as well.
I think the NSIS will help you . Most of the applications using NSIS. Because it is open source.
Also there is a Eclipse plugin for NSIS to make the process easy.
http://hmne.sourceforge.net/