# Running liquibase in java code

**URL:** <https://forum.liquibase.org/t/running-liquibase-in-java-code/1650>\
**Category:** General Discussion\
**Created:** [September 28, 2011, 9:26am UTC](https://forum.liquibase.org/t/running-liquibase-in-java-code/1650 "2011-09-28T09:26:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [September 28, 2011, 9:26am UTC](https://forum.liquibase.org/t/running-liquibase-in-java-code/1650/1 "2011-09-28T09:26:00Z")

</div>

I’ve used the following example:

[liquibase.properties](http://www.liquibase.org/manual/liquibase.properties)

Can you try to run the command yourself, please?

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [September 28, 2011, 9:26am UTC](https://forum.liquibase.org/t/running-liquibase-in-java-code/1650/2 "2011-09-28T09:26:00Z")

</div>

Hello,

I’m trying to execute in Java code analogue of Ant’s “updateDatabase” task:

1. Main.main( new String[]{"--defaultsFile=db/properties/db.test.properties --logLevel=debug update"} );

First, I could not find an&nbsp;updateDatabase command.&nbsp;I’ve tried:&nbsp;update,&nbsp;updateSQL, but all the time I’m getting:

1. Errors:
2. &nbsp; Command not passed

My db.test.properties file if it may help:

1. #liquibase.properties
2. driver: org.hsqldb.jdbcDriver
3. url: jdbc:hsqldb:mem:datasourcedb
4. username: TEST
5. password: TEST
6. changeLogFile: db/changelog/db.changelog-master.xml

What am I doing wrong? Please help.

---

<div class="post-metadata">

**Author:** ![mikemil2713](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@mikemil2713](https://forum.liquibase.org/u/mikemil2713)\
**Post date:** [September 28, 2011, 9:26am UTC](https://forum.liquibase.org/t/running-liquibase-in-java-code/1650/3 "2011-09-28T09:26:00Z")

</div>

Not sure if this is the problem&nbsp; but your properties file should be format of  
  
property\_name=property\_value&nbsp; using = instead of :b (colon)  
  
Otherwise it looks correct.&nbsp; The command line parsing is done and the code doesn’t think it found a ‘command’ but update should work.

---

<div class="post-metadata">

**Author:** ![mikemil2713](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@mikemil2713](https://forum.liquibase.org/u/mikemil2713)\
**Post date:** [September 28, 2011, 9:26am UTC](https://forum.liquibase.org/t/running-liquibase-in-java-code/1650/4 "2011-09-28T09:26:00Z")

</div>

I think you’ve asked another question but I will answer this here in case anyone else runs into the same problem.&nbsp; The command line parameter you passed was seen as a single argument and instead of being broken into separate parameters.&nbsp; The result of this invocation is that Liquibase sees one parameter  
  
parameter=–defaultsFile=db/properties/db.test.properties --logLevel=debug update  
  
The code then splits the parameter to get the attribute and value:  
attribute\_name = defaultsFile  
value = db/properties/db.test.properties --logLevel=debug update  
  
As a result, Liquibase doesn’t really get the ‘update’ command, it is just part of the value of the defaultsFile string.  
  
Should be something like this:  
  
parms = new String String[]{

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “–defaultsFile=db/properties/db.test.properties”,

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “–logLevel=debug”,

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “update”} ;  
  
(found from your latest post)
