Exporting JAR from Eclipse (version: Kepler)

Progress reports and musings from the developers on the current gaming tools.

Moderators: dorpond, trevor, Azhrei

User avatar
Lord.Ashes
Dragon
Posts: 350
Joined: Wed Jul 03, 2013 5:58 am

Exporting JAR from Eclipse (version: Kepler)

Post by Lord.Ashes »

Azhrei wrote:Use the prebuilt configurations. If you press and hold on the Run or Debug buttons in the toolbar you'll get a drop down menu of options. You should see ones like "MapTool (Std)" and "MapTool (German)". Those will execute the main application and set the locale for whatever your system default is (English, in my case) or force it to German (if you select the second one).)
Thanks for the info. I think the first time I checked out the wrong path and thus did not have those options. I re-did the checkout and now those options are available.

I have managed to modify MapTools for my purpose. I will be using it as a virtual card game table and thus I wanted to remove most of the token context menu options and, instead, make all the token level macros available in the root of the token context menu. I have managed to do this and I am able to run the revised version of MapTools from the Eclipse IDE.

Now that I am ready to compile the results into a JAR file, I did some studying online and the answer is supposedly very obvious: Export | Jar File.

My version of Eclipse (Kepler) provides two options "Export | Jar File" and "Export | Runnable Jar File". I have tried both but in both cases the compile generates errors indicating that there are compile errors. I am not sure what the problem is since I am able to run the modified MapTool version and I am not selecting anything out-of-the-ordinary during the Export process (as far as I know).

Can anyone, please, help a struggling beginner?
MapTools - Eclipse - Export 1.png
MapTools - Eclipse - Export 1.png (16.5 KiB) Viewed 7864 times
MapTools - Eclipse - Export 2.png
MapTools - Eclipse - Export 2.png (21.8 KiB) Viewed 7864 times
MapTools - Eclipse - Export 3.png
MapTools - Eclipse - Export 3.png (95.45 KiB) Viewed 7864 times
I have enclosed screen captures of the export process so that you can see the settings I selected.
Last edited by Azhrei on Mon Jul 08, 2013 10:56 pm, edited 1 time in total.
Reason: split from main topic: Getting RPTools apps into Eclipse

Wyrframe
Cave Troll
Posts: 59
Joined: Sun Apr 14, 2013 7:52 pm

Re: How to get RPTools source via Eclipse and subversion

Post by Wyrframe »

Scroll to the errors, please; warnings are just that, but the actual errors preventing JAR creation are not shown in that screen capture.

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: How to get RPTools source via Eclipse and subversion

Post by JamzTheMan »

I get the same thing when ever I export a JAR or Runnable JAR, however it DOES generate the jar... Haven't figured out how why it does it either given it's nothing but warnings (no errors).
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
Lord.Ashes
Dragon
Posts: 350
Joined: Wed Jul 03, 2013 5:58 am

Re: How to get RPTools source via Eclipse and subversion

Post by Lord.Ashes »

Wyrframe wrote:Scroll to the errors, please; warnings are just that, but the actual errors preventing JAR creation are not shown in that screen capture.
Here is the bottom of the Export error...hope that helps identifying the problem.
MapTools - Eclipse - Export 4.png
MapTools - Eclipse - Export 4.png (104.52 KiB) Viewed 7852 times
JamzTheMan wrote:I get the same thing when ever I export a JAR or Runnable JAR, however it DOES generate the jar... Haven't figured out how why it does it either given it's nothing but warnings (no errors).
In my case, and this may not be necessarily your case, it does create a jar file but the jar file does not seem to be runnable. I placed it in the same directory as my unmodified version of MapTools and then made a copy of the BAT file that launches MapTools which I modified to launch the new JAR file instead. When I run the BAT file, it gives an error related to running the JAR file as follows:
MapTools - Eclipse - Run 1.png
MapTools - Eclipse - Run 1.png (5.29 KiB) Viewed 7852 times
Just for information, in case it is relevant, I only modified a couple of MapTool files (AbstractTokenPopupMenu.java and TokenPopupMenu.java). As I said, the modification seems to run fine when I launch it from the Eclipse IDE so I don't think it is related to the changes I made. I did not, however, try making a JAR file from the unmodified MapTools source code. If you think this would be helpful, I can try that to determine if it is or isn't related to the modification.

Once again, you patience, with a beginner like me, is most appreciated.
"We often compare ourselves to the U.S. and often they come out the best,
but they only have the right to bare arms, while we have the right to bare breasts"
The Right To Bare Breasts by Bowser & Blue

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: How to get RPTools source via Eclipse and subversion

Post by JamzTheMan »

What i currently do as a work around is i copied the manifest.mf to my conf dir. And then instead of exporting as runnable jar i just export jar using the manifest i saved. I then place in the normal mt dir and run. I don't need to update the whole zip then.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
Lord.Ashes
Dragon
Posts: 350
Joined: Wed Jul 03, 2013 5:58 am

Re: How to get RPTools source via Eclipse and subversion

Post by Lord.Ashes »

JamzTheMan wrote:What i currently do as a work around is i copied the manifest.mf to my conf dir. And then instead of exporting as runnable jar i just export jar using the manifest i saved. I then place in the normal mt dir and run. I don't need to update the whole zip then.
If you don't mind expanding on that a little, it would be much appreciated. I googled Eclipse and Manifest files and Eclipse can create manifest files for you as part of the export process. Is that how you are getting your manifest.mf file or are you creating it some other way? I didn't find one in the MapTools checked out source code. Did I not check out the correct branch?

Trying to get Eclipse to generate my manifest.mf file for me does not seem to work because it gets created as part of the export process which is currently failing (both the Export Java and Export Runnable Java options are failing).
"We often compare ourselves to the U.S. and often they come out the best,
but they only have the right to bare arms, while we have the right to bare breasts"
The Right To Bare Breasts by Bowser & Blue

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: How to get RPTools source via Eclipse and subversion

Post by JamzTheMan »

Correct, if you build using eclipse via (using ant script for mt iirc), it generates the manifest for you. But you can open a previous jar and extract the manifest out (and modify the class path if needed). You can also create it using jar commands out manually, it is just the class path and starting class info.

I heard there are a few tricks to get a full build of my done and honestly haven't messed with doing so myself.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
Lord.Ashes
Dragon
Posts: 350
Joined: Wed Jul 03, 2013 5:58 am

Re: How to get RPTools source via Eclipse and subversion

Post by Lord.Ashes »

JamzTheMan wrote:Correct, if you build using eclipse via (using ant script for mt iirc), it generates the manifest for you. But you can open a previous jar and extract the manifest out (and modify the class path if needed). You can also create it using jar commands out manually, it is just the class path and starting class info.

I heard there are a few tricks to get a full build of my done and honestly haven't messed with doing so myself.
Perfect. Sounds like extracting it out of the previous JAR file will be the easiest. I'll give that a try. Thanks for having patience with me.
"We often compare ourselves to the U.S. and often they come out the best,
but they only have the right to bare arms, while we have the right to bare breasts"
The Right To Bare Breasts by Bowser & Blue

User avatar
Lord.Ashes
Dragon
Posts: 350
Joined: Wed Jul 03, 2013 5:58 am

Re: How to get RPTools source via Eclipse and subversion

Post by Lord.Ashes »

Sorry but using the MANIFEST.MF file did not help. I still get the same (or at least similar - I did not compare) error.

Here are screen captures of the exporting process for reference in case I am selecting something wrong...

1. Export SRC portion of project...
MapTools - Eclipse Export - Screen 1.png
MapTools - Eclipse Export - Screen 1.png (50.91 KiB) Viewed 7835 times
2. Export SRC folder. I tried adding more options here but got the same results.
MapTools - Eclipse Export - Screen 2.png
MapTools - Eclipse Export - Screen 2.png (28.42 KiB) Viewed 7835 times
3. Not sure so when with defaults.
MapTools - Eclipse Export - Screen 3.png
MapTools - Eclipse Export - Screen 3.png (18.8 KiB) Viewed 7835 times
4. Select MANIFEST.MF file from previous JAR file
MapTools - Eclipse Export - Screen 4.png
MapTools - Eclipse Export - Screen 4.png (49.74 KiB) Viewed 7835 times
5. Still results in error
MapTools - Eclipse Export - Screen 5.png
MapTools - Eclipse Export - Screen 5.png (84.55 KiB) Viewed 7835 times
Any ideas?
"We often compare ourselves to the U.S. and often they come out the best,
but they only have the right to bare arms, while we have the right to bare breasts"
The Right To Bare Breasts by Bowser & Blue

User avatar
Lord.Ashes
Dragon
Posts: 350
Joined: Wed Jul 03, 2013 5:58 am

Re: How to get RPTools source via Eclipse and subversion

Post by Lord.Ashes »

Okay, I found a work around...

I figured since it ran in the Eclipse IDE, Eclipse needed to have a compiled version somewhere (i.e. Class files instead of Java files). I went searching through the settings and discovered that it puts the build in "maptools\builds". I had a look there and, low-and-behold, the builds directory had the whole build structure there. So I copied it to a different directory. I extracted the META-INF directory from a previous MapTools JAR file and placed it in the same directory, and then I zipped the whole thing up. Lastly I renamed it to JAR instead of ZIP.

I am not sure if the same process would work for significant changes to MapTools but it definitely worked for my mods. I am, now, able to launch my modified version of MapTools without issues.
"We often compare ourselves to the U.S. and often they come out the best,
but they only have the right to bare arms, while we have the right to bare breasts"
The Right To Bare Breasts by Bowser & Blue

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Exporting JAR from Eclipse (version: Kepler)

Post by Azhrei »

The warning can be ignored when building the JAR. If you've looked at the code, you know there are various warnings scattered through the source code from things like "serializable class doesn't contain version id" and similar types of warnings.

If you double-click a JAR file and it doesn't run, then follow the advice in the MapTool forum where they discuss general problem diagnosis. I would start by opening a command window and then running java -jar exported_jar_file.jar. That way instead of just getting a little dialog with "A Java exception occurred" you would actually see the stacktrace in the command window.

Last, your technique will not work in a general sense. During the ANT build process there are a couple properties files created. One is called version.txt (I think) and I believe there's another. Those files are placed deep into the build/ hierarchy and when ANT builds the final JAR the file will be there. I'm not sure what happens if the file doesn't exist (exception probably?) and since you executed MT before building the JAR that may be why it worked. (I would have expected your attempt to fail.)

In order to understand the build process and what the MT JAR normally contains you would need to browse the ANT build.xml file and see what the process is.

If you're just starting out with Java and/or Eclipse, I would recommend NOT choosing MapTool as your first project!! It's a sufficiently complex enough project that you'll get lost trying to find your way through the entire process. Heck, I've been writing Java code for years and I felt a little daunted when I started with it!

User avatar
Lord.Ashes
Dragon
Posts: 350
Joined: Wed Jul 03, 2013 5:58 am

Re: Exporting JAR from Eclipse (version: Kepler)

Post by Lord.Ashes »

Azhrei wrote: If you're just starting out with Java and/or Eclipse, I would recommend NOT choosing MapTool as your first project!! It's a sufficiently complex enough project that you'll get lost trying to find your way through the entire process. Heck, I've been writing Java code for years and I felt a little daunted when I started with it!
:D Yea, I know...at some point I am actually going to have to spend some time to understand Eclipse...Does Eclipse use the ANT Build for building the project when it is run from the IDE? When I built the JAR file contents manually I grabbed the whole NET sub-directory of {Eclipse Workspace}\maptool\build. I added the META-INF from the official JAR file and this seemed to have worked just fine. I ran the resulting JAR file both on my PC and another laptop (which does not have Eclipse or any previous version of MapTool) and it ran fine.

I am not saying that it is a correct process...all I am saying is that it seemed to have worked.

As for not starting with MapTools, that is kind of a toss up. I am a programmer and have been for years so I can handle making the changes that I want to make (and actually have already done most of them), its just this setting up of the IDE and creating build files and so on that I always have issues with because I am more used to languages which don't have crap like that.

But thanks for your advice in any case.
"We often compare ourselves to the U.S. and often they come out the best,
but they only have the right to bare arms, while we have the right to bare breasts"
The Right To Bare Breasts by Bowser & Blue

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Exporting JAR from Eclipse (version: Kepler)

Post by Azhrei »

Lord.Ashes wrote::D Yea, I know...at some point I am actually going to have to spend some time to understand Eclipse...Does Eclipse use the ANT Build for building the project when it is run from the IDE?
No.
When I built the JAR file contents manually I grabbed the whole NET sub-directory of {Eclipse Workspace}\maptool\build. I added the META-INF from the official JAR file and this seemed to have worked just fine. I ran the resulting JAR file both on my PC and another laptop (which does not have Eclipse or any previous version of MapTool) and it ran fine.
Cool. Then I guess those property files I mentioned above were put into your build/ directory. I wasn't sure they would be. :?
As for not starting with MapTools, that is kind of a toss up. I am a programmer and have been for years so I can handle making the changes that I want to make (and actually have already done most of them), its just this setting up of the IDE and creating build files and so on that I always have issues with because I am more used to languages which don't have crap like that.

But thanks for your advice in any case.
Heh, sorry for any perceived "acid" in my comments. It's just that MapTool, while it isn't as complex as some projects I've worked on, it does tend to have tendrils extending all over. That version file I mentioned above: MT expects to find it and if it doesn't it assumes a version number of "DEVELOPMENT". That affects how campaigns are loaded and saved (when running a development version of MT certain things are relaxed in order to make debugging simpler) and can affect how the Campaign object is propagated to clients (IIRC). That's all different from the -DMAPTOOL_DEV=true that can be put on the command line when MT is executed, but which has to be added to the runtime configuration properties if executing MT from within the IDE.

Too many details... Sigh.

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: Exporting JAR from Eclipse (version: Kepler)

Post by JamzTheMan »

That's good to know btw. :) I usually run with a version.txt in my src dir and change it through my iterations so I don't get lost. Didn't know with the development tag so many things changed. But I usually like running it anyways from eclipse closer to what the user experience would be anyway.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
Lord.Ashes
Dragon
Posts: 350
Joined: Wed Jul 03, 2013 5:58 am

Re: Exporting JAR from Eclipse (version: Kepler)

Post by Lord.Ashes »

Azhrei wrote: Heh, sorry for any perceived "acid" in my comments. It's just that MapTool, while it isn't as complex as some projects I've worked on, it does tend to have tendrils extending all over. That version file I mentioned above: MT expects to find it and if it doesn't it assumes a version number of "DEVELOPMENT". That affects how campaigns are loaded and saved (when running a development version of MT certain things are relaxed in order to make debugging simpler) and can affect how the Campaign object is propagated to clients (IIRC). That's all different from the -DMAPTOOL_DEV=true that can be put on the command line when MT is executed, but which has to be added to the runtime configuration properties if executing MT from within the IDE.

Too many details... Sigh.
No worries...no "acid" was perceived. I noticed that the version built from the source indicated "Development" but I didn't know that it was related to these files being missing. Just to personalize my version, I modded this to say "Card Game Edition" and I noticed that MapTools (correctly) complained about the version mismatch when I created a campaign in the regular version and then imported it into my "Card Game Edition"...but it loaded and as soon as I saved it in that version...it no longer complained. Probably not an ideal thing to do if one would expect the version to be re-integrated but mine will never be. Its just a personal version which hides most of the unnecessary options from the token context menu when using it to play card games.
"We often compare ourselves to the U.S. and often they come out the best,
but they only have the right to bare arms, while we have the right to bare breasts"
The Right To Bare Breasts by Bowser & Blue

Post Reply

Return to “Developer Notes”