i have a java application which uses netbeans' Java DB/Derby.
i have "clean and build" the project creating a jar file, but it'll only run if i explicitly run netbeans and start database there.
how can i set the DB to start up automatically along with jar file and also, that if i sent that jar file to someone else, that database goes along with that(i have read it's possible to do that with derby. not sure though)
any help is appreciated
you need to include sql resources and create the database with these on running the project for the first time . This is a cumbersome process and platform depending ...
there are solutions available that allow for creation of a dictionary in a java project , hence making this platform independ. SAP NetWeaver has this but I'm sure there are others ..
Related
I'm gaining my first experience with Git and its hosting platforms (GitHub etc).
Say, I create a JSP project in Eclipse with some custom files (*.jsp and *.java) and a bunch of auto-generated project files. I need to install an application server as well.
This is an example JSP project in Eclipse. Only the yellow marked files were generated by me:
My colleague wants to contribute to that project. I don't know, what system and what IDE he is going to use.
What exactly do I need to push to Git?
Are only my own files enough? Or do I need to push the entire project, including the files generated by Eclipse?
What if my colleague uses a different operating system, IDE or application server?
Would it make sense to only push the following files?
StudentsBean.java
index.jsp
How would he then need to import them, so that they become executable?
Try creating a new repo and then while creating a repo select git ignore file and type of that file is java or jsp. Then while pushing it will automatically ignore files which are not needed.
I have created a simple springboot application with inbuild tomcat which works fine when I am running it as JAVA Application in Eclipse. I tried to export this as a WAR file and tried to run it in Windows command line and also in UNIX box. I tried to execute it like below,
java -jar C:\Users\Iam\Documents\SpringHelloWorld.war main.java.com.controller.SpringBootWebApplication
Error: An unexpected error occurred while trying to open file C:\Users\Iam\Documents\SpringHelloWorld.war
java -cp C:\Users\Iam\Documents\SpringHelloWorld.war main.java.com.controller.SpringBootWebApplication
Error: Could not find or load main class main.java.com.controller.SpringBootWebApplication
I just export it as a WAR file, should i need to define anything before exporting it as WAR in Springboot ( note: i am not using maven or gradle )
Below is my project structure :
enter image description here
Probably it is possible to do this without Maven/Gradle, but I would never take this approach.
Even considering the best case, you will end up re-creating what others have created in the Spring Boot parento pom.xml or in his Gradle equivalent, so why you would waste a lot of time recreating what is already created by someone else? If you really want to know how the war is created, then take a look in Spring Boot parent pom, but you should limit your work to wrap what is ready for production in order to compose your solution.
Also consider that Maven and Gradle are constantly developed and updated, along everything belongs to their ecosystems. If you plan to replace them, then you should be prepared to mantain and develop alone your own build platform, which is a non-trivial effort.
Better include Maven or Gradle, you'll be more productive.
I have a desktop Java application that I'm developing that has an embedded Apache Derby database (Link) . Now, when I run the application through my IDE, everything works great and functions as expected. However when I create the fat jar (including all the dependencies), when I launch the application it boots fine, but I get the following error message:
java.sql.SQLSyntaxErrorException: Schema 'TDB' does not exist
To me, this suggests that the schema I have created has not been copied across into my new jar file, but in that case I'm not sure if I'm creating my jar correctly.
What I would like it to do is when I run the package goal of my pom, it will create a new jar, with all of the dependencies included, that I could effectively give to someone else and they could run it as a fully functional desktop application (in the same way I can run it through my IDE, just without the IDE).
Any help would be massively appreciated, I've been banging my head against this one for a few days now.
Stu
The way I see it there are two approaches to this:
You determine the file system location of your database files and make sure it is included in your deployment - this should be do-able from within the IDE
You include a start-up process that check if the database is present, and if not creates the schema on the fly
I developed simple Window application using java.
I used Eclipse Juno as my IDE.
I used Hibernate to do database operations.
Now i want to create the complete setup of this project how can i do it?
I know we can create JAR file using Eclipse using Export option.
But i mean to say i want to create setup in such a way it must include all the things like my database, imported jar files and any other files that are used in my project.
I think it already gets the imported jar file but it is not including database how to include it?
In Visual Studio it remains easy to create setup it gives all the options to include database or not and many other.
How can we do it using Eclipse?
You can try exe4j, installer4j kind of tools to create an .exe or a setup.
But I'm not quite sure whether you can pack your database with the application.
I've finally managed to create a Netbeans project out of an old standalone (not Web-) Java application which consisted only out of single .java sources. Now I have basically two questions regarding Netbeans Subversion interaction and application deployment:
Do you check in all the Netbeans project files into the repository, normally?
If I build the project using Netbeans (or ant) I get a .jar file and some additional jar libraries. In order for the app to run properly on the server, some additional config files and directories (log/ for example) are needed. The application itself is a J2SE application (no frameworks) which runs from the command line on a Linux platform. How would you deploy and install such an application? It would also be nice if I could see what version of app is currently installed (maybe by appending the version number to the installed app path).
Thanks for any tips.
No, not usually. Anything specific to NetBeans (or Eclipse, IntteliJ, etc), I don't check in; try to make it build from the command line with your ant script and produce exactly what you want. The build.xml is something that can be used for other IDEs, or in use with Anthill or CruiseControl for automated builds/continuous integration, so that should be checked in. Check in what is needed to produce/create your artifacts.
You don't specify what type of server, or what exact type of application. Some apps are deployed via JNLP/WebStart to be downloaded by multiple users, and have different rules than something deployed standalone for one user on a server to run with no GUI as a monitoring application. I cannot help you more with that unless you can give some more details about your application, the server environment, etc.
Regarding the config files, how do you access those? Are they static and never going to change (something you can load using a ResourceBundle)? ? You can add them to the jar file to look them up in the ResourceBundle, but it all depends on what you are doing there. If they have to be outside the jar file for modification without recompiling, have them copied with an installer script.
As for directories, must they already exist? Or does the application check for their existence, and create them if necessary? If the app can create them if absent, you have no need to create them. If they need to be there, you could make it part of the install script to create those folders before the jar files are installed.
Version number could be as simple as adding an about box somewhere in the app, and looking up the version string in a config/properties file. It has to be maintained, but at least you would be able to access something that would let you know you have deployed build 9876.5.4.321 (or whatever version numbering scheme you use).
Ideally, you should not tie down your application sources and config to a particular IDE.
Questionwise,
I suggest you do not. Keep you repository structure independent of the IDE
You might have to change your application so that it's structure is very generic and can be edited in any IDE.
Is this a web app? A standalone Java app? If you clarify these, it would be easier to answer your query.
We don't check in the /build or the /dist directories.
We tend to use this structure for our Netbeans projects in SVN:
/project1/
/trunk
/tags/
/1.0
/1.1
/binaries/
/1.0
/1.1
When a change is need we check out the netbeans project from trunk/ and make changes to it and check it back in. Once a release of the project is needed we do an SVN copy of the netbeans project files to the next tag version. We also take a copy of the deployable (JAR or WAR) and place it in the version directory under binaries along with any dependencies and config files.
By doing this we have a clean, versioned deployable that is separate from the source. Are deployables are version in the name - project1-1.0.jar, project1-1.1jar and so on.
I disagree with talonx about keeping your source non-IDE specific - by not storing IDE files in SVN along with you source you are adding extra complication to the checkout, change, checkin, deploy cycle. If you store the IDE project files in SVN you can simply check out the project, fire up the IDE and hit build. You don't have to go through the steps of setting up a new project in the IDE, including the files you SVNed, setting up dependencies etc. It saves time and means all developers are working with the same setup, which reduces errors and discrepancies. The last thing you want is for a developer to check out a project to make a small bug fix and have to spend time having to find dependencies and set stuff up.
To answer question #2 -- who's your consumer for this app?
If it's an internal app and only you (or other developers) are going to be deploying it, then what you have is perfectly all right. Throw in a README file explaining the required directories.
If you're sending it out to a client to install, that's a different question, and you should use an installer. There are a few installers out there that wrap an ant script and your resources, which is a nice approach particularly if you don't need the GUI... just write a simple ant script to put everything in the right place.
Version number is up to you -- naming the JARs isn't a bad idea. I also have a habit of printing out the version number on startup, which can come in handy.