Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have recently developed a school management system in java netbeans using derby(java built in database).Now i want to make a jar file and proivide it to my client .So can this jar run on client pc without netbeans or java installed? and what about database?
You can create a jar of your source code using netbeans using How to create a Jar file in Netbeans
You cannot package the derby or what ever database into a jar. Instead you can have script to start the db.
Java must be installed with at least the version of java you used. Embedded databases need no extra installation other than in your code.
Starting from a jar is a bit different than in the IDE from a class path. A jar contains only read-only resources, and the file names in the jar (zip archive) are case-sensitive.
It could be that the software first has to use a resource file as initial template to be copied to the file system. Like a prefilled database to be written to.
Java 9 can use jlink to create your own smaller JRE, java run time. (I do not think you are using java 9 though.)
Java 8 has a javapackager.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want add a file into the jar package but this is a separate file from the java program, can I run it and if I can run it, how can I run it? Can you recomment anything?
Thanks.
Not possible; java doesn't run arbitrary executables; your OS does. Java ask your OS to run an executable, but OSes generally do not have the ability to run executables from within zip files. Let alone jmod files.
If your java application can read and process the data itself (example: Render a swing JLabel object with some PNG as its image), then you can to this:
YourClass.class.getResource("open_url.png")
Will get you an inputstream for the stated file, as long as that file is in the same place that YourClass.class is - even if it is in a jar file or jmod file.
However, if you have an .exe, you'd have to extract the executable, save it to a tmp dir, and then ask the OS to run that file. Saving executables to temp dirs is a little tricky (if it's a global temp dir, some other user could overwrite your executable in the middle, and thus run its code in your process, you see how that's security-wise quite a big issue). But, you can do it. Note that this makes your app not platform independent anymore, of course.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
This occurs with many applications, for example Microsoft Word. If I click on a word file (.doc). Microsoft Word will start or communicate with an already running process.
How do I implement this with Java? Of course with my own file extension.
A file with the custom extension would just be a json/xml text document. But obviously the custom extension part is needed so windows knows what to open it with.
Eventually it would open a new screen/page in an javaFX application.
I am not sure what to call this, and I am having trouble finding examples because of that.
This involves setting file associations in the OS your java application is running in.
Oracle provides a tutorial (pretty old at this point, it mentions it was written for 8) which is about creating self-contained application packages which bundle the code and runtime together. This has a section on Using File Associations.
When creating your bundle, you can set file associations which the installer will setup in the OS.
<fx:info title="File Association Demo"
vendor="MySamples"
description="A Demo of File Associations for Java Packager"
category="Demos"
license="3 Clause BSD">
<fx:association extension="js" mimetype="text/javascript" description="JavaScript Source"/>
<fx:association extension="groovy" mimetype="text/x-groovy" description="Groovy Source"/>
</fx:info>
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'm not sure where is the best is to place my Grunt file in my spring web application. Should it be placed at the root of the web application like so:
my-app/gruntfile.js
Or should I place it at the root of resource directory like so:
my-app/src/main/webapp/static
Both will work. Just wondering what's the best practice here. Thanks!
I think a good project structure for spring and a client side library like AngularJS is:
my-app/src/
* main
* client: gruntfile.js, bower.json, js and html files
* java: spring java code
* resources: application.properties, static folder (for compiled client)
I would also take a look at some generators such as
http://yeoman.io/ or http://jhipster.github.io/
which create new projects with best practices and tools.
The grunt file is usually not part of the deployable. So it should not be src/main/webapp folder.I usually place my gulp file (pretty mutch the same thing) in the project root folder.
If you plan do minify or compile with grunt. You usually need a folder for the original files and one for the compiled files. My experience is that it is a bad idea to compile the files directly into the src/main/webapp folder since IDE's track them and reindex them every time. So I integrated gulp into the gradle lifecycle and copy all files into the webapp folder when I create the deployable.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am unsure about the following information from this link that details the Android Build Process.
I am basically wondering why the resource files need to be cnverted to Java source files (first step), then also packaged up to a .ap_ file?
What is the difference between the two steps?
why the resource files need to be cnverted to Java source files
They are not being "cnverted to Java source files". A Java source file -- R.java -- is built using the data from the resources, and that file represents a listing of all of the available resources. This file provides constants for Android app developers to use to refer to these resources from the rest of their Java code.
To draw an analogy, the Web is not "cnverted" to Google's search engine; Google's search engine represents an index of the Web. Similarly, resources are not "cnverted to Java source files" like R.java; R.java represents an index of the resources.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm creating a servlet-based application using Tomcat.
Besides that i've some classes to acces a DB with jdbc. (present in a other folder/package)
I was asking myself how to integrate them cleanly in my servlet-based application.
What's the "cleanest" solution ?
thx
I would go with packaging as a separate JAR file and placing in WEB-INF/lib of your web app.
While it may seem easier to just put JAR to the common libraries folder so that several web apps start using it - it will result in not being able to upgrade the JAR without restarting the whole server. Also you will need to make sure that the new JAR is working fine with all of the apps. Classpath issues are possible with this approach too.
Package them in jar files and then add files to you're project.