# openjdk6 fails to build (expr illegal option 1)



## x-yuri (Dec 18, 2012)

Hello everyone, I'm trying to install java/openjdk6 and here is the output it produces. I suppose it fails to build because of the errors like this one:


```
expr: illegal option -- 1
expr: usage: expr [-e] expression
```

The system is FreeBSD 9.0-RELEASE (amd64), running in VirtualBox 4.2.4 (if that matters).

The steps I take after installing FreeBSD:
`# portsnap fetch`
`# portsnap extract`
`# cd /usr/ports/java/openjdk6 && make`

After some googling I found this thread (gtk12 port expr errors). Not sure if it has something to do with my problem.

I tried skipping updating Ports Colelction, with no result. Any help appreciated.


----------



## x-yuri (Dec 19, 2012)

It doesn't compile under FreeBSD 8.3-RELEASE either. Maybe, there is a way to get last working snapshot of Ports Collection?


----------



## pkubaj (Dec 19, 2012)

There is, using devel/subversion.
You can revert to some earlier revision by`# svn up -r $REVISION /usr/ports`
You can use ports-mgmt/portdowngrade.


----------



## x-yuri (Jan 4, 2013)

The problem turned out to be that the virtual machine had insufficient memory.  VirtualBox default memory size for FreeBSD is 128MB. It builds successfully with 256MB of memory.

expr complaining about illegal option may be fixed this way:

```
--- corba/make/common/shared/Platform.gmk       2013-01-04 12:58:53.000000000 +0200
+++ corba/make/common/shared/Platform.gmk2      2013-01-04 12:58:42.000000000 +0200
@@ -495,13 +495,13 @@
     fi)
   MAX_VM_MEMORY := $(shell \
     if [ $(MB_OF_MEMORY) -le 1024 ] ; then \
-      expr $(MB_OF_MEMORY) '-' 128 ; \
+      expr -- $(MB_OF_MEMORY) '-' 128 ; \
     else \
       echo $(ABS_MAX_MEMORY); \
     fi)
   MIN_VM_MEMORY := $(shell \
     if [ $(MAX_VM_MEMORY) -le 128 ] ; then \
-      expr $(MAX_VM_MEMORY) '-' 8 ; \
+      expr -- $(MAX_VM_MEMORY) '-' 8 ; \
     else \
       echo "128"; \
     fi)
--- jdk/make/common/shared/Platform.gmk 2013-01-04 12:59:00.000000000 +0200
+++ jdk/make/common/shared/Platform.gmk2        2013-01-04 12:58:40.000000000 +0200
@@ -499,13 +499,13 @@
     fi)
   MAX_VM_MEMORY := $(shell \
     if [ $(MB_OF_MEMORY) -le 1024 ] ; then \
-      expr $(MB_OF_MEMORY) '-' 128 ; \
+      expr -- $(MB_OF_MEMORY) '-' 128 ; \
     else \
       echo $(ABS_MAX_MEMORY); \
     fi)
   MIN_VM_MEMORY := $(shell \
     if [ $(MAX_VM_MEMORY) -le 128 ] ; then \
-      expr $(MAX_VM_MEMORY) '-' 8 ; \
+      expr -- $(MAX_VM_MEMORY) '-' 8 ; \
     else \
       echo "128"; \
     fi)
```

But anyway build fails:

```
/usr/local/bootstrap-openjdk/bin/javac  -J-XX:ThreadStackSize=1536 -J-Xmx-19m -J-Xms-27m -encoding ascii -source 5 -target 5 -d /usr/ports/java/openjdk6/work/build/bsd-amd64/corba/btclasses \
     -sourcepath ../../tools/src ../../tools/src/build/tools/stripproperties/StripProperties.java
 Invalid maximum heap size: -Xmx-19m
 Could not create the Java virtual machine.
```

The only complaint about insufficient memory is this one:

```
WARNING: This machine appears to only have 109Mb of physical memory, \n         builds on this machine could be slow. \n
```

I wonder if I should file a bug report somewhere (freebsd-ports-bugs, oracle, virtualbox) or let it be?


----------

