Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Maven and JavaProgram using random access file

 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am now able to create a an executable jar for  stand alone application programme in java which normally
works on double click.
I  tried on same lines for a an application prg in java using similar pom

But this program is  using randomaccesfile that uses a .bin file to run the program is a misnomer
for creating by maven since the MANIFEST.MF does include only mainClass Attribute and does not bother to
include the essential file viz .bin  file without which the java program does not work.
Will any one help to make  the pom  with this attribute (additional data file ) enabling such files  inclusion
in the pom.xml
thanks
As
CRMK






















 
Sheriff
Posts: 6270
167
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you put viz.bin in the src/main/resources directory, you should get it copied to your jar file "for free", that is, without any extra configuring.
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Indeed,the jar is now able to function(as per your  suggestion) with the following command
java -jar target/jupiter.jar
With this jar  double clicking does not produce any result,probably because of its non syncronisation inside the jar between the source file amd  bin file that is though include inside the jar as per your suggestion.Neverth-less for me the jar is ok with its content no matter how  how it is opened.May I say,
this jar conveys(due to its richness with contents)  lot of laurel and cheers with thanks as well

As
CRMK
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am now at the start of creating a site formation for my previously developed jupiter.jar
.My pom and mvn commands are as given below.Des my pom really have a hurdle if so how do i remove the same.
Though with a little knowledge of java, and some practice  formation jar etc was quite hardship with success.
Also i went through the forum at ant  maven etc of ranch but did not get a clear cut example that deployed full fleged site
for a particular pom,may i be rendered some  tips to enable site formation especially so for the distribution attribute.also my ref last line of the output that is not continuing.

this is just to complete my goal fully.
Thanks
AS
CRMK



 
Knute Snortum
Sheriff
Posts: 6270
167
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I'm confused.  First, what was the command given to create this output?  Is it your intention to start Jetty?  If so, I don't think any more output is necessary.  Did you try going to your browser and typing

http://localhost:8080/manager/text

or just

http://localhost:8080/
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:I guess I'm confused.  First, what was the command given to create this output?  Is it your intention to start Jetty?  If so, I don't think any more output is necessary.  Did you try going to your browser and typing

http://localhost:8080/manager/text

or just

http://localhost:8080/



Hi
For the pom given above i used the command :
mvn post-site
then i used the command
mvn  site:run
for which the output was as mentioned
Shall be thankfull if corrected
As
CRMK
 
Knute Snortum
Sheriff
Posts: 6270
167
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's your goal?  Is it to deploy the project?  Then type:

mvn deploy

If you type mvn site:run, you are starting a container sever (Jetty, Tomcat, etc.)  That is good for running your project, but not deploying.
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:If you put viz.bin in the src/main/resources directory, you should get it copied to your jar file "for free", that is, without any extra configuring.



Hi


The solution for a double click using randomaccesfile  is still not obtained .the latest error is as under.
There ought to be a method viz classifier usage that makes the pom non default as per maven

*****************************************************************************
classifier:

Classifier to add to the artifact generated. If given, the artifact
will be attached as a supplemental artifact. If not given this will create
the main artifact which is the default behavior. If you try to do that a second time without
using a classifier the build will fail.
•Type: java.lang.String
•Required: No

--------------------------------------------------------------------------------

Please try  and render help
Thanks
As
CRMK


                             

                             
                             
                             
                       
     
 
Knute Snortum
Sheriff
Posts: 6270
167
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks like the salient error message:

So your manifest file has an invalid header field, it would seem.
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:This looks like the salient error message:

So your manifest file has an invalid header field, it would seem.



Hi

   Atlast i tried this classifier method and included it in my main pom.but still requires some more corrections
   I am sure you would help as to whether or not what i have used for classifier is ok or not .Also suggest alternate manifestFile
since it has the freedom to write our own manifestFile as per maven
   Please give feedback apporpriately
   Thanks
   As
   CRMK
   




 
Knute Snortum
Sheriff
Posts: 6270
167
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's see if we can focus things a bit:

Your goal is to create an executable jar file that contains your bin file that can be double-clicked to launch. To do this, follow these steps:

1) Your bin file should be in the default Maven resource folder, which is <project-folder>/src/main/resources.  If you have your bin file in src/main/resources, you do not need the <resources> section in your pom file.  Remove it.

2) You should have a Maven plugin that creates the executable jar.  You have two options: Shade or Assembly.  If you don't specifically need Assembly, use Shade.  Remove the Assembly section in your pom and add a Shade section following this pattern.

3) Everything else that you don't specifically need should be removed from your pom file.

4) Execute mvn package at the command line.

If the build fails, post your entire pom file, properly formatted, and the output from Maven.
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I tried your way and obtained  result as under which obliges to mouse-operation only with in
the target area that contains my .bin(data file via random acces file) being dumped during the pom  execution.
So i now say any additional random access file is required for the maven created executable file , needs  itself for the the existence of the same otherwise it will not work


*************

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: admin
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_101
Main-Class: sitemanager.SiteManager

*****************************************
<build>
   <sourceDirectory>src/main/resources/logging/sitemanager</sourceDirectory>
   <scriptSourceDirectory>C:\Program Files\java\bin\apache-maven-3.3.9-bin\bin\src\main\scripts</scriptSourceDirectory>
   <testSourceDirectory>src\test\resources</testSourceDirectory>
   <outputDirectory>C:\Program Files\java\bin\apache-maven-3.3.9-bin\bin\target</outputDirectory>
     <testOutputDirectory>C:\Program Files\java\bin\apache-maven-3.3.9-bin\bin\target\test-classes</testOutputDirectory>
 
  <directory>C:\Program Files\java\bin\apache-maven-3.3.9-bin\bin\target</directory>
 
 ********************************
 But neverthless the motivating point that boosts the mouse work still there since the bin file was made available in the target though  not in inside the jar My thanks are also for the same
 Thanks
 As
 CRMK









*******

 
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Comal Rajagopalaratnam Muthukumar wrote:But this program is  using randomaccesfile that uses a .bin file to run the program...



A RandomAccessFile? Then you won't be able to access it that way if it's deployed inside the jar file. No amount of Mavening and pomming will change that. It needs to be in the file system in the place where the jar is deployed, not inside the jar.

A common way to deal with that is for the application, when it first starts up, to read the .bin file as a resource from the jar and to write it to the user's home directory. Then it can access it as a random-access file from there. There are more details about how to do that which you may not be familiar with, but it's possible that I have misunderstood your problem so I won't go into them yet.
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
while i agree in total to the point of RandompAccessFile usage that invariably requires the RAF file to be accompanied to enable proper working of jar file so created by maven,but there has to be a method as for example creating a Manifest File for a stand aloneapplication whose familiarity is so far not discussed  here and shall be helpful if the same
is tutored with  an example.
Please note that this manifest file is different from the regular manifest attributes we normally place in the pom file to make it fetch the mainclass etc.this special one seems to include another Class-Path for  jar file that carries the model with interface magic to indicate the availabilty of RAF file  for easy ccess etc etc
Hope this may be considered and high lighted
Thanks
AS
CRMK
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:

Comal Rajagopalaratnam Muthukumar wrote:But this program is  using randomaccesfile that uses a .bin file to run the program...



A RandomAccessFile? Then you won't be able to access it that way if it's deployed inside the jar file. No amount of Mavening and pomming will change that. It needs to be in the file system in the place where the jar is deployed, not inside the jar.

A common way to deal with that is for the application, when it first starts up, to read the .bin file as a resource from the jar and to write it to the user's home directory. Then it can access it as a random-access file from there. There are more details about how to do that which you may not be familiar with, but it's possible that I have misunderstood your problem so I won't go into them yet.



Hi

I have java application as well as a bin file for the application
The name of the bin file :ramanavami.bin
The name of application: JavaExam.java
When i open this java file it requires this bin file in the same directoy
But in the maven way   please tell me how do i include it as per your suggestion
in my pom I am able to write pom in such a way that it
places the bin file in the target after the mvn command eventualy makig the jar file which is
also in the  target folder  is able to execute itself since binfile is placed But this is not what i want ,the jar file
should carry this bin file and it should work on doubleclick  at any location without depending for the bin file


Alternatively could you write the code of pom  briefly to read this bin file during the application processing as per your ref
This would enable to go further .I hope this is very valuable suggestion

Thanks
As
CRMK
 
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!