Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How can I control system's volume with java?

Squall867May 12 2012 — edited Apr 12 2013
Hi, I'm trying to make a remote audio control and I need a way to set current volume by code.

After looking at java sound APIs I came up with this:
line = mixer.getLine(lineInfo);
boolean opened = line.isOpen() || line instanceof Clip;
if(!opened){
	System.out.println("Line is not open, trying to open it...");
	line.open();
	opened = true;
}
if(line.isControlSupported(FloatControl.Type.VOLUME)){
		FloatControl volumeCtrl = (FloatControl)line.getControl(FloatControl.Type.VOLUME);
               System.out.println("Current volume is: "+volumeCtrl.getValue());
}
I tried this code with every mixer I have (althought I think it's the "SPEAKER" one...) but I always get 1.0 as current volume, no matter what.
So, I'm getting something wrong..can you help me?:(

Comments

Timo Hahn
>
C:\ADF\Infrastructure\DBSchema\build.xml:28: C:\ADF\Infrastructure\Ant\wlserver_10.3\server\lib not found.
>
the path to the wlserver_10.3\server\lib folder is wrong. It should be
C:\oracle\Middleware\jdeveloper\wlserver_10.3\server\lib
if your properties are right.

Timo
Tony007
where must i set the path to the wlserver_10.3
Timo Hahn
Check the build.properties. This is all you need to do.
# Base Directory for library lookup
jdeveloper.home=C:\oracle\Middleware\jdeveloper
should be
# Base Directory for library lookup
jdeveloper.home=C:/oracle/Middleware/developer
and check if this is reals the path where you installed jdev.

Timo
Tony007
the path i install jdeveloper is C:\oracle\Middleware\jdeveloper
Tony007
i change my build path to
# Master Ant properties file for Fusion Order Demo
# All build files refer to this master list of properties
# Continuous builds override these settings
# $Id: build.properties 812 2007-02-20 07:14:33Z lmunsing $

# Base Directory for library lookup
jdeveloper.home=C:\oracle\Middleware\wlserver_10.3\server\lib
src.home=..//..


# JDBC info used to create Schema
jdbc.driver=oracle.jdbc.OracleDriver
jdbc.urlBase=jdbc:oracle:thin:@localhost
jdbc.port=1521
jdbc.sid=orcl

# Information about the default setup for the demo user.
db.adminUser=system
db.demoUser=FOD
db.demoUser.tablespace=USERS
db.demoUser.tempTablespace=TEMP

but am still geting Buildfile: C:\ADF\Infrastructure\Ant\build.xml

init:
[javac] Compiling 1 source file to C:\ADF\Infrastructure\Ant\classes

setProperties:

createDatabase:

refreshSchema:

BUILD FAILED
C:\ADF\Infrastructure\Ant\build.xml:51: The following error occurred while executing this line:
C:\ADF\Infrastructure\DBSchema\build.xml:100: The following error occurred while executing this line:
C:\ADF\Infrastructure\DBSchema\build.xml:63: The following error occurred while executing this line:
C:\ADF\Infrastructure\DBSchema\build.xml:28: C:\ADF\Infrastructure\Ant\wlserver_10.3\server\lib not found.

my build xml is
<?xml version="1.0" encoding="windows-1252" ?>
<!-- Master Ant Buildfile for Fusion Order Demo -->
<!-- $Id: build.xml 872 2007-02-28 20:14:00Z lmunsing $ -->
<project default="buildAll">
<property file="build.properties"/>
<property name="build.output.dir" value="Output"/>
<property name="archive.work.dir" value="${temp.dir}/FODPackage"/>
<property name="buildNumber" value="${local.buildNumber}"/>
<property name="jdev.ant.port" value="2249"/>
<property name="ant.home" value="${jdeveloper.home}/ant"/>
<!-- <property name="java.security.policy" value="java.policy"/> -->

<!-- Top level build targets -->

<target name="buildAll"
description="Master build target"
depends="setProperties, createDatabase">
</target>

<target name="dropAll"
description="Master target used to drop demo"
depends="setProperties">
<ant antfile="build.xml" dir="../DBSchema"
target="dropSchema" />
</target>

<target name="packageRelease"
description="A task that just ensures that we have a zip file of the source no actual building is done"
depends="createSrcZip"></target>
<target name="refreshSchema"
description="Used to re-create the database schema - see build.poperties for info on username, connect info etc."
depends="setProperties, createDatabase">
</target>
<!-- Called targets. These should not be called individually-->
<target name="init">
<javac destdir="classes" source="1.5" target="1.5"
deprecation="false" optimize="true" failonerror="true">
<src path="src/masterbuildscript"/>
</javac>
</target>

<target name="setProperties" depends="init">
<input message="Enter password for the database system user:"
addproperty="db.adminUser.password">
<handler classpath="classes" classname="masterbuildscript.FODInputHandler"/>
</input>
</target>

<target name="createDatabase">
<ant antfile="build.xml" dir="../DBSchema"
target="createDatabase" inheritrefs="true"/>
</target>



<target name="invokeBuildAll">
<ant antfile="build.xml" dir="src/admin" target="buildAll"/>
<delete>
<fileset dir="../buildOutput" includes="**/*.zip"/>
</delete>
<copy todir="../buildOutput">
<fileset dir="src/admin/output"/>
</copy>
<copy todir="../buildOutput">
<fileset dir="src/packaging/JDeveloperExtension/output"/>
</copy>
</target>
<target name="createSrcZip">
<mkdir dir="${build.output.dir}"/>
<delete dir="${archive.work.dir}"/>
<copy todir="${archive.work.dir}" includeemptydirs="true">
<fileset dir="../..">
<exclude name="**/classes/*"/>
<!-- <exclude name="**/*.ear"/> -->
<exclude name="**/*.war"/>
<exclude name="**/*.zip"/>
<exclude name="**/Thumbs.db"/>
</fileset>
</copy>
<zip basedir="${archive.work.dir}"
destfile="${build.output.dir}/${archive.src.zip}.${buildNumber}.zip"/>
</target>
</project>


Total time: 12 seconds

Edited by: user603350 on 2011/12/18 4:28 PM
Timo Hahn
OK, I have a typo in my last post. I delete the 'j' from jdeveloper.
# Base Directory for library lookup
jdeveloper.home=C:/oracle/Middleware/jdeveloper
Please see that I use '/' instead of your '\' you use. I tested the scripts an they work if you set the properties to the correct values.

Timo
Tony007
hi enter my system password but am getin this error
Buildfile: C:\ADF\Infrastructure\Ant\build.xml

init:
[javac] Compiling 1 source file to C:\ADF\Infrastructure\Ant\classes

setProperties:

createDatabase:

refreshSchema:
[sql] Executing resource: C:\ADF\Infrastructure\DBSchema\Scripts\SQLRunner1937101885.sql
[sql] Failed to execute: DROP USER FOD CASCADE
[sql] java.sql.SQLSyntaxErrorException: ORA-01918: user 'FOD' does not exist

[sql] Failed to execute: CREATE USER FOD IDENTIFIED BY ${db.demoUser.password} DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP QUOTA UNLIMITED ON USERS
[sql] java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

[sql] Failed to execute: GRANT create session TO FOD
[sql] java.sql.SQLSyntaxErrorException: ORA-01917: user or role 'FOD' does not exist

[sql] Failed to execute: GRANT alter session TO FOD
[sql] java.sql.SQLSyntaxErrorException: ORA-01917: user or role 'FOD' does not exist

[sql] Failed to execute: GRANT create table TO FOD
[sql] java.sql.SQLSyntaxErrorException: ORA-01917: user or role 'FOD' does not exist

[sql] Failed to execute: GRANT create trigger TO FOD
[sql] java.sql.SQLSyntaxErrorException: ORA-01917: user or role 'FOD' does not exist

[sql] Failed to execute: GRANT create view TO FOD
[sql] java.sql.SQLSyntaxErrorException: ORA-01917: user or role 'FOD' does not exist

[sql] Failed to execute: GRANT create sequence TO FOD
[sql] java.sql.SQLSyntaxErrorException: ORA-01917: user or role 'FOD' does not exist

[sql] Failed to execute: GRANT create synonym TO FOD
[sql] java.sql.SQLSyntaxErrorException: ORA-01917: user or role 'FOD' does not exist

[sql] Failed to execute: GRANT create type TO FOD
[sql] java.sql.SQLSyntaxErrorException: ORA-01917: user or role 'FOD' does not exist

[sql] Failed to execute: GRANT create procedure TO FOD
[sql] java.sql.SQLSyntaxErrorException: ORA-01917: user or role 'FOD' does not exist

[sql] 0 of 11 SQL statements executed successfully
[delete] Deleting: C:\ADF\Infrastructure\DBSchema\Scripts\SQLRunner1937101885.sql
[echo] Warning: An unlocked database user 'FOD' has been created, with create session, table, and sequence privileges.

createSchemaObjects:

BUILD FAILED
C:\ADF\Infrastructure\Ant\build.xml:51: The following error occurred while executing this line:
C:\ADF\Infrastructure\DBSchema\build.xml:106: The following error occurred while executing this line:
C:\ADF\Infrastructure\DBSchema\build.xml:28: java.sql.SQLException: ORA-01017: invalid username/password; logon denied


Total time: 9 seconds

Edited by: user603350 on 2011/12/19 12:13 AM
Timo Hahn
Looks like you have not used three right credentials for the SYSTEM user of the db.
Check if you have the right password and try again.

Timo
Tony007
i did use the right password because when i run drop all i get this massage but when i run buildall all i get the other error
Buildfile: C:\ADF\Infrastructure\Ant\build.xml

init:
[javac] Compiling 1 source file to C:\ADF\Infrastructure\Ant\classes

setProperties:

dropAll:

dropSchema:
[sql] Executing resource: C:\ADF\Infrastructure\DBSchema\Scripts\SQLRunner641975019.sql
[sql] Failed to execute: DROP USER FOD CASCADE
[sql] java.sql.SQLSyntaxErrorException: ORA-01918: user 'FOD' does not exist

[sql] 0 of 1 SQL statements executed successfully
[delete] Deleting: C:\ADF\Infrastructure\DBSchema\Scripts\SQLRunner641975019.sql
[echo] Warning: The database user 'FOD' has been dropped.

BUILD SUCCESSFUL
Total time: 8 seconds

i what to paste my build/xml but having error Sorry, this content is not allowed

Edited by: user603350 on 2011/12/19 10:24 AM
Timo Hahn
Not sure what went wrong but
[sql] Failed to execute: CREATE USER FOD IDENTIFIED BY ${db.demoUser.password} DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP QUOTA UNLIMITED ON USERS
[sql] java.sql.SQLSyntaxErrorException: ORA-00911: invalid character>
points to an error in your set up or your properties.

Which db are you using?

Timo
vinod_t_krishnan
can u paste the build.xml in this location
C:\ADF\Infrastructure\DBSchema\build.xml
Tony007
there is build.xml in C:\ADF\Infrastructure\DBSchema\build.xml
Tony007
there is build.xml in C:\ADF\Infrastructure\DBSchema\build.xml

my build.propeties is
# Master Ant properties file for Fusion Order Demo
# All build files refer to this master list of properties
# Continuous builds override these settings
# $Id: build.properties 812 2007-02-20 07:14:33Z lmunsing $

# Base Directory for library lookup
jdeveloper.home=C:/oracle/Middleware/jdeveloper
src.home=..//..


# JDBC info used to create Schema
jdbc.driver=oracle.jdbc.OracleDriver
jdbc.urlBase=jdbc:oracle:thin:@localhost
jdbc.port=1521
jdbc.sid=smsdev

# Information about the default setup for the demo user.
db.adminUser=system
db.demoUser=FOD
db.demoUser.tablespace=USERS
db.demoUser.tempTablespace=TEMP

Edited by: user603350 on 2011/12/19 1:53 PM
Timo Hahn
User,
this is not going further if you don't try to find out what is responsible this invalid 'character error'. It is definitely something on your machine as I can run the buildAll target without any error.
If our are sure us used the right credentials, check that you did not add a special (may be invisible) character to the FOD user or password.
Again I'll ask fro information about the db you are using?
Do you use any special language settings?


Timo
Tony007
the db is oracle enterprise 11g if i may ask where is the detail of user FOD the password how is this created

Edited by: user603350 on 2011/12/19 4:50 PM
Timo Hahn
This is all part of the build.properties...

Timo
Tony007
its not done i can only create the user not the objects

Edited by: user603350 on 2011/12/19 5:53 PM
Tony007
am able to create user but no objects has been created must i do this manually
Tony007
am geting this error logs
Buildfile: C:\ADF\Infrastructure\Ant\build.xml

init:
[javac] Compiling 1 source file to C:\ADF\Infrastructure\Ant\classes

setProperties:

createDatabase:

refreshSchema:
[sql] Executing resource: C:\ADF\Infrastructure\DBSchema\Scripts\SQLRunner228475356.sql
[sql] 11 of 11 SQL statements executed successfully
[delete] Deleting: C:\ADF\Infrastructure\DBSchema\Scripts\SQLRunner228475356.sql
[echo] Warning: An unlocked database user 'FOD' has been created, with create session, table, and sequence privileges.

createSchemaObjects:

BUILD FAILED
C:\ADF\Infrastructure\Ant\build.xml:51: The following error occurred while executing this line:
C:\ADF\Infrastructure\DBSchema\build.xml:106: The following error occurred while executing this line:
C:\ADF\Infrastructure\DBSchema\build.xml:28: java.sql.SQLException: ORA-01017: invalid username/password; logon denied


Total time: 10 seconds

Edited by: user603350 on 2011/12/19 5:47 PM
Timo Hahn
Man, reading is difficult...
C:\ADF\Infrastructure\DBSchema\build.xml:28: java.sql.SQLException: ORA-01017: invalid username/password; logon denied
You changes the defaults so now the script can't log in into the new schema.

Timo
Tony007
yes i did see that but now am geting this error
Buildfile: C:\ADF\Infrastructure\Ant\build.xml

init:
[javac] Compiling 1 source file to C:\ADF\Infrastructure\Ant\classes

setProperties:

createDatabase:

refreshSchema:

BUILD FAILED
C:\ADF\Infrastructure\Ant\build.xml:51: The following error occurred while executing this line:
C:\ADF\Infrastructure\DBSchema\build.xml:100: The following error occurred while executing this line:
C:\ADF\Infrastructure\DBSchema\build.xml:63: The following error occurred while executing this line:
C:\ADF\Infrastructure\DBSchema\build.xml:28: C:\oracle\Middleware\wlserver_10.3\wlserver_10.3\server\lib not found.

Total time: 8 seconds
and my build.properties is
# Master Ant properties file for Fusion Order Demo
# All build files refer to this master list of properties
# Continuous builds override these settings
# $Id: build.properties 812 2007-02-20 07:14:33Z lmunsing $

# Base Directory for library lookup
jdeveloper.home=C:/oracle/Middleware/wlserver_10.3/server
src.home=..//..


# JDBC info used to create Schema
jdbc.driver=oracle.jdbc.OracleDriver
jdbc.urlBase=jdbc:oracle:thin:@localhost
jdbc.port=1521
jdbc.sid=smsdev

# Information about the default setup for the demo user.
db.adminUser=system
db.demoUser=FOD
db.demoUser.password=fusion
db.demoUser.tablespace=USERS
db.demoUser.tempTablespace=TEMP

where does directroy C:\ADF\Infrastructure\DBSchema\build.xml:28: C:\oracle\Middleware\wlserver_10.3\wlserver_10.3\server\lib define

Edited by: user603350 on 2011/12/20 3:03 PM
Tony007
i make home C:\oracle\Middleware\wlserver_10.3

Edited by: user603350 on 2011/12/20 5:07 PM
rava
Hi Timo,

I've the same problem!
props:
# Base Directory for library lookup
jdeveloper.home=E:/oracle/middleware111210/jdeveloper
src.home=..//..


# JDBC info used to create Schema
jdbc.driver=oracle.jdbc.OracleDriver
jdbc.urlBase=jdbc:oracle:thin:@localhost
jdbc.port=1521
jdbc.sid=orcl

# Information about the default setup for the demo user.
db.adminUser=system
db.demoUser=FOD
db.demoUser.password=fusion
db.demoUser.tablespace=USERS
db.demoUser.tempTablespace=TEMP

buildAll:
[WARN ][osal ] Could not enumerate processes (1) error=-1073738819
[WARN ][osal ] Could not add counter (null)\ for query
[WARN ][osal ] Failed to init virtual size counter.
Buildfile: E:\projects\fod\Infrastructure\Ant\build.xml

init:

BUILD FAILED
E:\projects\fod\Infrastructure\Ant\build.xml:37: destination directory "E:\projects\fod\Infrastructure\Ant\classes" does not exist or is not a directory

Total time: 0 seconds

What are we doing wrong or it as usual will not work as it says in readme and promo? :)))
Or maybe as usual I miss something from userguide :)
1 - 23
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 10 2013
Added on May 12 2012
4 comments
9,508 views