<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.finkproject.org/index.php?action=history&amp;feed=atom&amp;title=Fink%3APolicy%3APackaging_Java</id>
	<title>Fink:Policy:Packaging Java - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.finkproject.org/index.php?action=history&amp;feed=atom&amp;title=Fink%3APolicy%3APackaging_Java"/>
	<link rel="alternate" type="text/html" href="https://wiki.finkproject.org/index.php?title=Fink:Policy:Packaging_Java&amp;action=history"/>
	<updated>2026-04-30T01:35:16Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.13</generator>
	<entry>
		<id>https://wiki.finkproject.org/index.php?title=Fink:Policy:Packaging_Java&amp;diff=47&amp;oldid=prev</id>
		<title>Chris01: Reverted edit of Zenek, changed back to last version by RangerRick</title>
		<link rel="alternate" type="text/html" href="https://wiki.finkproject.org/index.php?title=Fink:Policy:Packaging_Java&amp;diff=47&amp;oldid=prev"/>
		<updated>2007-02-20T14:44:00Z</updated>

		<summary type="html">&lt;p&gt;Reverted edit of Zenek, changed back to last version by RangerRick&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Fink_Header}}&lt;br /&gt;
&lt;br /&gt;
There is no official &amp;quot;policy&amp;quot; per se for packaging Java software in Fink, but there are a number of best practices that make it easier.&lt;br /&gt;
&lt;br /&gt;
== The '''''Type''''' Field ==&lt;br /&gt;
&lt;br /&gt;
By default, if you use &amp;lt;code&amp;gt;Type: java&amp;lt;/code&amp;gt; without specifying a version, Fink will use the '''lowest''' JDK found in /System/Library/Frameworks/JavaVM.framework/Versions.  So if you have a 1.3.1, 1.4.2, and 1.5.0 JDK on your system, it will use the 1.3.1.&lt;br /&gt;
&lt;br /&gt;
If you use &amp;lt;code&amp;gt;Type: java('''version''')&amp;lt;/code&amp;gt; (i.e., &amp;lt;code&amp;gt;Type: java(1.4)&amp;lt;/code&amp;gt;), it will use the '''highest''' JDK found that matches that version.  So if you have both a 1.4.1 and 1.4.2 JDK on your system, it will use the 1.4.2 JDK.&lt;br /&gt;
&lt;br /&gt;
Regardless of whether you use the versioned or unversioned field, as long as you're setting &amp;lt;code&amp;gt;Type: java&amp;lt;/code&amp;gt;, the build environment inside your package will have the following extra environment variables set:&lt;br /&gt;
&lt;br /&gt;
  JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Versions/''&amp;lt;code&amp;gt;detected_version&amp;lt;/code&amp;gt;''/Home&lt;br /&gt;
  PATH      /System/Library/Frameworks/JavaVM.framework/Versions/''&amp;lt;code&amp;gt;detected_version&amp;lt;/code&amp;gt;''/Home/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
== Using the '''''Type''''' Field Effectively ==&lt;br /&gt;
&lt;br /&gt;
There are 2 major ways it is recommended to package Java software, depending on whether you want to require a specific JDK, or you want to target a specific JDK or higher.&lt;br /&gt;
&lt;br /&gt;
=== Requiring a Specific JDK ===&lt;br /&gt;
&lt;br /&gt;
If you want to ensure your software is compiled with, say, the 1.4 JDK, use:&lt;br /&gt;
&lt;br /&gt;
  Type: java(1.4)&lt;br /&gt;
&lt;br /&gt;
This will detect a JDK of that specific major and minor version number, and set &amp;lt;code&amp;gt;JAVA_HOME&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; respectively.  If the software you are packaging uses &amp;lt;code&amp;gt;javac -target&amp;lt;/code&amp;gt; (or ant's &amp;amp;lt;javac target=&amp;quot;&amp;quot;/&amp;amp;gt; notation), it will still use the JDK that you specified, but generate bytecode compatible with the target given.&lt;br /&gt;
&lt;br /&gt;
=== Using The Available JDK (recommended) ===&lt;br /&gt;
&lt;br /&gt;
The problem with using &amp;lt;code&amp;gt;Type: java(1.4)&amp;lt;/code&amp;gt; is that it requires a specific JDK, even if later ones are available.  The primary reason to do so is to be able to create bytecode usable by older JDKs.&lt;br /&gt;
&lt;br /&gt;
Instead, it is recommended to do the following:&lt;br /&gt;
&lt;br /&gt;
  Package: myjavapackage&lt;br /&gt;
  Type: java&lt;br /&gt;
  Depends: system-java (&amp;gt;= 1.4-1)&lt;br /&gt;
  BuildDepends: system-java-dev (&amp;gt;= 1.4-1)&lt;br /&gt;
  Patch: %n.patch&lt;br /&gt;
&lt;br /&gt;
Create a patch that makes sure that javac is being called with a target of 1.4.  In the case of an ant build.xml, change any entries like:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;javac srcdir=&amp;quot;foo&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;patternset refid=&amp;quot;foo.files&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/javac&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...into...&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;javac target=&amp;quot;1.4&amp;quot; srcdir=&amp;quot;foo&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;patternset refid=&amp;quot;foo.files&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/javac&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of some other tool calling &amp;lt;code&amp;gt;javac&amp;lt;/code&amp;gt;, you can pass &amp;quot;&amp;lt;code&amp;gt;-target&amp;lt;/code&amp;gt;&amp;quot; on the &amp;lt;code&amp;gt;javac&amp;lt;/code&amp;gt; command-line.&lt;br /&gt;
&lt;br /&gt;
This lets you not care what JDK is installed, as long as it's 1.4 or newer.&lt;br /&gt;
&lt;br /&gt;
== Problems with specific JDKs ==&lt;br /&gt;
&lt;br /&gt;
; as of release 1.5, 'enum' is a keyword, and may not be used as an identifier : The 1.5 JDK adds some new keywords to the language, like &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt;.  In some cases, you might need to add &amp;lt;code&amp;gt;source=&amp;quot;1.4&amp;quot;&amp;lt;/code&amp;gt; to your build.xml (or &amp;lt;code&amp;gt;-source 1.4&amp;lt;/code&amp;gt; on the javac command-line) to make things work correctly.&lt;br /&gt;
&lt;br /&gt;
{{Fink_Header}}&lt;br /&gt;
&lt;br /&gt;
[[Category: Fink|Policy:Packaging Java]]&lt;br /&gt;
[[Category: Fink_Documentation|Policy:Packaging Java]]&lt;/div&gt;</summary>
		<author><name>Chris01</name></author>
	</entry>
</feed>