I'm using Visual Studio Code with the Java Extension Pack for a java application.
As you can see in the image above, the downwards facing arrow button exports my project to a Jar, which is saved to the project folder.
Is there an option anywhere I can set the export location, or post-build events where I can copy the jar to another location?
No, it does not contains this feature and the settings to configure it for now. You can copy the jar file to anywhere you want and if it forces users to choose a place to put the jar file before creating it, that's tedious and a waste of time.
Related
I have added a jar named freetts in Libraries in my Project, I copied the whole netbeans java project to another system but I could not compile it as the freetts library was missing there. So how do I locate the library on disk so that I can copy it to the system I have copied the project to.
Right click on the folder/JAR and click on edit
and in there you will be able to see where the folder/JAR is located on your disk
So my problem is that I want to export my libgdx desktop project as a runnable .jar file. I already made this work and it is working fine when I open the .jar file from my desktop. However, if I put the .jar file into my Dropbox or in any other directory other than my Desktop, it won't work anymore. The Gameframe opens for like 0.2sec, stays black and closes again immediatly. If I then pull the .jar back to my Desktop it works fine.
I've seen other people ask this before, but none of the answers helped me with my problem.
If you need any more info please let me know!
Try opening the exported JAR in (for example) 7-zip and then adding the 'res' folder manualy. I don't really understand, why Eclipse didn't put the 'res' folder in it. But adding it manualy worked for me.
In eclipse, make sure to right-click the whole project and click export. In library handling, click on "Package required libraries into generated JAR". Then click finish. If that does not work, make sure your build path includes everything.
Can I have access to the .jar file so I can look what is missing inside it?
Most likely you got some additional libraries in your output directory which are missing when you place your jar in dropbox. To confirm this try to start your application via command line. Java will then print a stacktrace with the exception. Example:
java -jar yourjarinthisdirectory.jar
As a side note I would recommend to use maven in the future maven libgdx. In this case you just can say "package" and maven produces complete jar with all libs inside it without further configuration.
I'm currently writing a program dependent on LWJGL. Adding the library to my project was easy enough, but I'm having trouble exporting my project as a standalone JAR that the user can simply double-click for a finished product.
WHAT I HAVE TRIED:
File -> Project Structure... -> Modules -> Dependencies tab -> Add -> Jars or directories -> (insert path to natives here) -> Option "classes" in the dialog. -> Check the box under "Export"
DESIRED RESULT: A runnable JAR with no dependency on the command line to open properly. Other JARs and directories being included with my project are fine, but I'd like IntelliJ to export them WITH my project automatically if possible, so that I don't have to manually drag the needed files into the output directory and make a script to run the JAR with the correct natives.
I'm very new to IntelliJ, coming from Eclipse (although I never had to do this in Eclipse, either), and am still coming to grips with the new (to me) terminology used by the program. I'm sure there is a very easy solution I am just overlooking. Thank you in advance.
I was able to get around the issue by using JarSplice to make a Windows EXE that includes the natives within.
I also use IntelliJ, and I've had a similar issue. If you put your natives into a folder somewhere near you, use something like the following at the start of your public static void main method:
System.setProperty("org.lwjgl.librarypath", PATH_TO_LIBS);
Note that you may have to prepend System.getProperty("user.dir") to the front of PATH_TO_LIBS, I'm not certain.
ADDENDUM: You said you'd like any additional files to automatically be created with your jar? Check out IntelliJ's Artifacts. Go to project settings, select artifacts, and add one with the plus button. Once you get an artifact added you can mess around with the file structure on the side, adding in other folders (such as the natives folder, or a resources folders). Once you're done there, you can click Build>Artifacts and it automatically packages them for you, and puts them in a directory (which you can specify on the Artifact window).
I don't know what IntelliJ is so I'm not sure how helpful this will be, but I did do something like this with LWJGL a couple of years ago.
LWJGL depends on native libraries, and the operating system depends on loading those from real native files. You can't load them from inside a jar. So, you can put them in the jar, but you'll have to write some code (which runs before you try to call any LWJGL stuff) which will extract the needed native(s) from the jar at run time and save them in the system temporary directory (or wherever) then load them with System.load.
Then you have to remove/comment out the normal library loading code from org.lwjgl.Sys (the functions doLoadLibrary and loadLibrary). That should do it.
Edit: A similar question is here: How to make a JAR file that includes DLL files?
I am writing a Java program in eclipse that will read in a PDF file and analyze lines of the PDF report and spit out statistics about what was read in. In order to read in the PDF file (by extracting the text), I am using PDFbox. The goal of this project is just to automate a manual process.
Two questions:
I've taken some java programming classes but don't have much experience in linking external binary files to eclipse.
Will the PDFbox library I add to eclipse transfer over with the jar file I make? The intention is to email this jar file to a collegue to use in his day to day job to make his life easier. I just want to make sure the packaged jar file keeps the PDFbox library.
How do I add the PDFbox library to eclipse so I can use the library's methods?
You will need to send both the jar you produce (from building your project) and the PDFbox jar. The PDFbox far file must be in the CLASSPATH when you run your application.
Add a jar (for the purpose of building only) as follows: select the project, type ALT-Enter (or right-mouse on the project and select properties), click on "Java Build Path", click the "Add External Jars..." button, browse to the PDFbox jar file, click the "open" button, then click the "OK" button (on the properties window). The PDFBox jar file is now in the build CLASSPATH of your project. See step run concerning the runtime CLASSPATH.
On Mac, For me it worked when I did:
Java Build Path -> Add External Jars ->
And the location was:
/Users/yourname/.m2/repository/org/apache/pdfbox/pdfbox/1.8.x/pdfbox-1.8.x.jar
I have made a java application in Eclipse and it has a Main class which has the main method from which the application runs. I want that i should be able to run the application from outside the eclipse maybe by clicking on some icon.
Can anyone guide how that might be possible?
Create a Java .exe/.jar file
Create JAR file in Java & Eclipse
JAR file using Eclipse IDE
Right click on your project, which you want to create a JAR file of. And select Export from the context menu.
Select JAR file from Java folder and click Next.
Provide the Destination path and click on Finish to create the JAR.
You should build the application first,then you'll find a file with the extension ".jar" in the project's directory
you can run this jar anywhere
Once you have a Jar, you might also deploy the app. using Java Web Start.
JWS can do desk-top integration tasks like providing a desktop icon (with customized icon) and/or menu item. JWS also offers many other nice features like configurable automatic update & file associations, and offers a comprehensive API that is only available to JWS apps. The JNLP API makes persistence, single instance code and other things easy.