Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Test Program on java.activation.DataSource
How to write a simple test program on java.activation.DataSource? I want to try the JAF (JavaBeans Activation Framework) included in JDK.
✍: FYIcenter.com
JAF (JavaBeans Activation Framework) API 1.1 has been included in JDK 6 to 8. You can use the following simple test program, ActivationTest.java, to try it:
// Copyright (c) FYIcenter.com import javax.activation.*; public class ActivationTest { public static void main(String[] args) throws Exception { String filename = args[0]; DataSource ds = new FileDataSource(filename); System.out.println("getName() = "+ds.getName() ); System.out.println("getContentType() = " +ds.getContentType() ); } }
For JDK 9 and newer, you need to specify javax.activation-1.2.0.jar in the classpath:
fyicenter> java -version java version "17.0.5" 2022-10-18 LTS fyicenter> javac ActivationTest.java ActivationTest.java:2: error: package javax.activation does not exist import javax.activation.*; ^ ... fyicenter> javac -classpath .:javax.activation-1.2.0.jar ActivationTest.java fyicenter> java -classpath .:javax.activation-1.2.0.jar ActivationTest ActivationTest.java getName() = ActivationTest.java getContentType() = application/octet-stream
The output shows that the MIME type of "ActivationTest.java" is "application/octet-stream", which is the default for any file with an unknown file name extension.
For JDK 6 to 8, you can use the JAF code included inside JDK:
fyicenter> java -version java version "1.7.0_45" fyicenter> javac -classpath . ActivationTest.java fyicenter> java -classpath . ActivationTest ActivationTest.java getName() = ActivationTest.java getContentType() = application/octet-stream
⇐ What Is JAF (JavaBeans Activation Framework)
⇑ Downloading activation.jar - JavaBeans Activation Framework
2016-07-09, 2862🔥, 0💬
Popular Posts:
JDK 11 jdk.jshell.jmod is the JMOD file for JDK 11 JShell tool, which can be invoked by the "jshell"...
How to download and install ojdbc5.jar for Oracle 11g R1? ojdbc5.jar for Oracle 11g R1 is a Java 5 J...
iText is an ideal library for developers looking to enhance web- and other applications with dynamic...
What Is log4j-1.2.15.jar? I got the JAR file from apache-log4j-1.2.15.zip. log4j-1.2.15.jar is the v...
How to display XML element type information with the jaxp\TypeInfoWriter.java provided in the Apache...