Thursday, November 23, 2023

Wednesday, June 15, 2011

Building the OpenJDK on Linux x86 with logs

Some have had difficulty building the OpenJDK. The OpenJDK build system is designed for different operating system platforms, different architectures, and different host configurations so there are some steps that aren't entirely intuitive. Here is a full listing of the commands I used to build on x86 Linux. Ubuntu 10.04 as of June 2011.

sudo apt-get install gawk alsa alsa-base alsa-utils alsa-tools libasound2-dev
sudo apt-get install libx11-dev libxt-dev x11proto-xext-dev libxext-dev x11proto-input-dev libxi-dev sudo apt-get install libxtst-dev libmotif-dev xutils-dev libfreetype6-dev
sudo apt-get install libcups2-dev ant g++ libxrender-dev libfreetype6 libfreetype6-dev freetype2-demos
sudo apt-get install x11proto-print-dev

# Run these at the command line:

export LANG=C
export ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk
export ALT_JDK_IMPORT_PATH=$ALT_BOOTDIR
export ALLOW_DOWNLOADS=true

make sanity
make


Using OpenJDK version:
openjdk-6-src-b22-28_feb_2011.tar.gz

Additional Command History:
------
bbrown@bbrown-laptop:~/src/openjdk/openjdk6$ export ALLOW_DOWNLOADS=true

apt-file search extensions/Print.h
x11proto-print-dev: usr/include/X11/extensions/Print.h

----------


310 mv openjdk-6-src-b22-28_feb_2011.tar.gz ../
311 ls
312 make
313 sudo apt-get install gawk alsa alsa-base alsa-utils alsa-tools libasound2-dev
314 sudo apt-get install libx11-dev libxt-dev x11proto-xext-dev libxext-dev x11proto-input-dev libxi-dev sudo
315 sudo apt-get install libx11-dev libxt-dev x11proto-xext-dev libxext-dev x11proto-input-dev libxi-dev
316 sudo apt-get install libxtst-dev libmotif-dev xutils-dev libfreetype6-dev
317 sudo apt-get install libcups2-dev ant g++ libxrender-dev libfreetype6 libfreetype6-dev freetype2-demos
318 ls
319 make
320 export LANG=C
321 make
322 whereis java
323 javac
324 ls
325 make
326 echo JAVA_HOME
327 whereis javac
328 ls -lta /usr/bin/javac
329 export JAVA_HOME=/etc/alternatives/javac
330 ls /etc/alternatives/java
331 ls /etc/alternatives/java -lta
332 ls /usr/lib/jvm/java-6-openjdk/
333 ls /usr/lib/jvm/java-6-openjdk/bin
334 export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/
335 make
336 export JAVA_HOME=
337 make
338 export ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk/
339 export ALT_JDK_IMPORT_PATH=$ALT_BOOTDIR
340 chmod +x ./jdk/make/jdk_generic_profile.sh
341 sudo ./jdk/make/jdk_generic_profile.sh
342 echo $ALT_BOOTDIR
343 sudo make sanity
344 sudo make
345 echo $ALT_BOOTDIR
346 echo $ALT_JDK_IMPORT
347 export ALT_JDK_IMPORT_PATH=$ALT_BOOTDIR
348 sudo make sanity
349 sudo make
350 sudo ./jdk/make/jdk_generic_profile.sh
351 sudo make
352 echo $ALT_BOOTDIR
353 sudo Gmake
354 sudo gmake
355 export ALT_JDK_IMPORT_PATH=$ALT_BOOTDIR
356 export NO_BOOTDIR=$ALT_BOOTDIR
357 sudo make
358 ls
359 CD MAKE
360 cd make
361 ls
362 grep -r BOOTDIR *
363 ls
364 cd scripts
365 ls
366 cd ..
367 ls
368 cd ..
369 ls
370 cd langtools/
371 ls
372 cd src
373 ls
374 cd. .
375 ls
376 cd ..
377 ls
378 cd ..
379 ls
380 grep -r BOOTDIR *
381 cd jdk
382 ls
383 cd make
384 ls
385 vi jdk_generic_profile.sh
386 grep ALT_BOOT *
387 ls
388 vi jdk_generic_profile.sh
389 ls
390 vi jdk_generic_profile.sh
391 echo $ALT_BOOTDIR
392 vi jdk_generic_profile.sh
393 ls
394 cd ..
395 ls
396 cd ..
397 ls
398 make
399 export ALLOW_DOWNLOADS=true
400 make
401 sudo apt-get install x11proto-print-dev
402 sudo make
403 ls
404 cd make
405 ls
406 cd ..
407 ls
408 cd jdk
409 s
410 ls
411 cd make
412 ls
413 ./jdk_generic_profile.sh
414 cd .
415 cd ..
416 ls
417 make
418 history
----
Output after build:

You should see the following output after the build has completed.

>>>Making sec-files-win @ Sat Jun 11 18:34:30 EDT 2011 ...
>>>Making jgss-files @ Sat Jun 11 18:34:30 EDT 2011 ...
>>>Finished making images @ Sat Jun 11 18:34:30 EDT 2011 ...
make[2]: Leaving directory `/home/bbrown/src/openjdk/openjdk6/jdk/make'
make[1]: Leaving directory `/home/bbrown/src/openjdk/openjdk6'
Control linux i586 1.6.0-internal build_product_image build finished: 11-06-11 18:34
Control linux i586 1.6.0-internal all_product_build build finished: 11-06-11 18:34
Control linux i586 1.6.0-internal all build finished: 11-06-11 18:34



----

If you receive BOOTDIR/bin/java errors then you may need to edit the jdk_generic_profile.sh file. Edit the file and place the export's configuration to the jdk on your system and then run the shell script manually.

sudo ./jdk/make/jdk_generic_profile.sh
sudo make sanity && make
Edit jdk_generic_profile.sh and add the 'export' commands from the top of this blog post to the script file. You can add the export settings at the end of the script.

Saturday, June 11, 2011

Simple OpenJDK compiler build

If you are interested in a simple build for the open jdk compiler.

See this mirror project:

http://jvmnotebook.googlecode.com/svn/trunk/javac_compiler/JavaSource

To build, type:

mvn package

To run the compile:

mvn exec:java -e -Dexec.mainClass="berlin.com.sun.tools.javac.MainJavac" -Dexec.args="Test.java"

Saturday, May 7, 2011

Basic Math : Basic Summation

Given the basic expression for summation:
\[ \begin{align}
\sum_{i=1}^n i
\end{align}
\]
Calculating the scalar sum:

1 + 2 + 3 + 4 ...

public class ScalarSum {
public int sum(final f f, int j, int n) {
int sum = 0;
for (int index = j; index <= n; index++) {
sum = sum + f.$(index);
}
return sum;
}
public interface f {
public int $(final int x);
}
public static class Fx implements f {
public int $(int x) {
return x;
}
}
public static class Fx2 implements f {
public int $(int x) {
return x*x;
}
}
public static class Fx3 implements f {
public int $(int x) {
return x*x*x;
}
}
}
System.out.println("Sum: " + new ScalarSum().sum(new ScalarSum.Fx(), 1, 100));

With haskell:

summation1 :: Integer -> Integer -> Integer
summation1 x y = summation' x y 0
summation' :: Integer -> Integer -> Integer -> Integer
summation' x y sum = if (y<x) then sum else summation' x (y-1) (sum+y)

sum2 :: [Integer] -> Integer -> Integer
sum2 xs y = foldl (+) 0 xs

main :: IO ()
main = print("Output : " ++ show(summation1 0 100) ++ " sum2= " ++ show(sum2 [0..100] 0))


sum(n=1 to 100) = 5050

MathJax Test - Looks like it is working


\[
\begin{align}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}
{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = 0
\end{align}
\]
\[
\begin{align}
\sum_{k=0}^n a

\end{align}
\]
\[
\displaystyle \sum_{j=1}^n a_j = \left({a_1 + a_2 + \cdots + a_n}\right)
\]
\[
\displaystyle \sum_{k=m}^n f_k \left({g_{k+1} - g_k}\right) = \left({f_{n+1} g_{n+1} - f_m g_m}\right) - \sum_{k=m}^n \left({f_{k+1}- f_k}\right) g_{k+1}
\]