I have a great idea and I want to build a flex application around a .jar file. Is there a way I can go by embedding a jar file into the flex application?
There are ways to embed assets into a Flex application, however most people use this for images or other visual assets. I do not believe that jar is supported. Java and ActionScript are very different and you wouldn't be able to load a jar inside the flash player and execute it as a program or run commands against it.
If this is an AIR application, you may be able to do something using NativeProcess. But, such an approach is not the same as embedding a jar file in a Flex Application. It is taking your file and wrapping it up in an AIR installer and then communicating with that file as it runs natively on the machine.
Related
I made a text editor in java. It has a FileExplorer class which allows me to read and write to a file. Now I would like to know how I could open said file (text.txt) with my editor application from outside my application. Basically when I double-click on the file (text.txt) it should start my application and pass some variables(like name and path). The application is a .jar file.
I am not going to bother anyone to go through the 2k lines of code, so I won't post it in here. But it is just a JTextPane in a JFrame and a PrintWriter/BufferedReader reading and writing to the file.
PS: should preferably work cross-platform.
Thanks
This question is not about java. It is about mapping files to specific application using you OS tools.
If you are on Windows you have to map extension *.txt to your application. Take a look on this article for details.
Please note that your application must accept file path in command line.
To make association easier I'd recommend you to writer batch file that runs your application and also accepts file name in command line. Then you just have to associate your batch file with *.txt extension.
If you are on Linux association technique depends on your flavor, but you can google it. Obviously you will have to create shell script instead of batch file.
EDIT
Actually your question is mostly about installation process. There are a lot of installation tools that can do this work for you. Some of the tools are even cross platform (I can remember "install anywhere"). There are both commercial and free tools that do this.
I have developed an application with Netbeans (Using Java, JSP and JQuery) in Windows environment. Now I am ready to transfer the application to a web host so that the application can be available on the Web and I am told that the application would have to be moved to a linux environment (hosting service already bought). Here are my concerns:
How to convert my code to Linux? Is there an automatic tool for this?
How to deploy my application to the server online (what do I need to copy and to what directory on the web?)
My application writes to a directory on c:drive on my laptop, what should I do to make the application write to correct directory a designated directory on the web server?
I have read here and there online but just haven't got specific solutions to this.
How to convert my code to Linux? Is there an automatic tool for this?
One of the Java key features is portability, so as far as you haven't used any OS-specific code like running a program using CMD or similar or a library that is OS-dependant (which is rare in these times but there are some yet), then you don't have anything to do.
How to deploy my application to the server online (what do I need to copy and to what directory on the web?)
You need to generate a WAR file. This file will zip all your web pages (JSPs) and web resources (js, css, image files) along with the Java binaries (*.class) and libraries (that must be on WEB-INF/lib folder).
Since you're working with NetBeans, here's a Q/A to generate the war file: How can I create a war file of my project in NetBeans?
This war file must be placed in the deploy folder of your web application server. Usually, the hosting provides you the tools (generally a link on the web with user and password) to administrate the host, based on this you should ask (or find it by yourself) the option to upload the war file.
My application writes to a directory on c:drive on my laptop, what should I do to make the application write to correct directory a designated directory on the web server?
You need to configure this path as a constant in your application, or even better, configure it in a properties file (or somewhere else) in order to be read and use it by your application easily. Remember that the path should be generic to be supported in almost every OS. For example, if you use a path with name
C:\some\path\for\files
Its generic form will be:
/some/path/for/files
Since you're going to work on Linux, make sure the user who executes the Tomcat (or the web application server you will use on production) have enough permissions to write on that folder. This can be easily done (and somebody here can fix this please) using the chown command:
#> chown -R user /some/path/for/files
Here's another Q/A to manage files and path on Java web applications: How to provide relative path in File class to upload any file?
OK, first a few thoughts:
Convert code to Linux. Once you have your ear of war file, you can just deploy them. It's best if you use UTF8 enconding in your files, specially if you use special characters, but that would be an issue you could test out when you deploy, could also be dependant on the Linux configuration. Having that said, Java is portable and you only have to be sure that the archive you create is compatible with the AppServer that's installed on the Linux hosting. You should get all the information you need about the deployment environment from the hosting site / company.
Deployment will depend from site to site, they should give you all instructions.
Here you might have a problem. I would say that the easiest way is to just map the directory in a properties file and customize it on every machine you use it. That's the easy part so far. However, you should check if your site will give you access to a directory, and be aware of space limitations and cleanup of the files. If you get, let's say, 100MB and you use 10MB a day, you might end up with trouble after 10 days...
I am planning to develop a swing application tool ie. Expense calculator or software for personal use.
Is it possible to create such application so that I will talk with MS Access database to store data and once it is developed and i will be bundling it into jar or exe file.
So when copying the jar or exe file to some other laptop or system I dont want to configure the DSN name or connection setting to MS Access in each system where i am going to put the file.
instead on click of the exe or jar file the connection will be set automatically I mean the exe or jar should independently on each system where i am going to run it
( Is it feasible in Java )
I'm developing some client based application and one of my projects needs to access a file and than move this file to another folder over the network.
I've written an ActiveX for this problem but some of my customers said that they didn't use Internet Explorer so I've decided to move my program into Java.
Today I read a news: Apple removes Java from all OS X Web browsers, they are still supporting Java but they stopped including pre-installed versions of Java in OS X.
So I want to know that Is there any way to solve this problem with Javascript or something else? I don't want to use external plug-ins.
There is no way to ask a web browser to move a file without using a plugin.
An <input type="file"> will suffice for uploading a file to the server. The File API will allow you to do more than just upload it, but that doesn't extend to moving it.
I made a simple java desktop application using embedded database. I wanted to package all files into a single file like exe so that client can click just on one file and use the application. I made the jar file and its working fine on my system when double clicking. I wanted to package the DB file along with jar because the data is shown only when the DB file is in the same folder of jar file.
I came across several tools like launch4j, install4j etc. but I didn't find where to include the DB file along with the package.
It sounds like you want an installer of some description, such as IzPack. This would allow you to package both jar and database together, and install them on a client system.
A good way to deploy rich client (e.g. Swing/AWT) apps. that require some set-up (as in, installing a DB) is by using Java Web Start.
JWS offers the ExtensionInstallerService which..
..is used by an extension installer to communicate with the JNLP Client. It provides the following type of functionality:
Access to prefered installation location, and other information about the JNLP Client
Manipulation of the JNLP Client's download screen
Methods for updating the JNLP Client with the installed code
Here is a demo. of the EIS (with code, build file etc.).