How to force a jar to use(or the jvm that jar runs in) utf-8 instead of the system’s default encoding

When you open a file for reading, you need to explicitly specify the encoding you want to use for reading the file: Reader r = new InputStreamReader(new FileInputStream(“myfile”), StandardCharsets.UTF_8); Then the value of the default platform encoding (which you can change using -Dfile.encoding) no longer matters. Note: I would normally recommend to always specify the … Read more

Creating a jar file from a Scala file

Sample directory structure: X:\scala\bin X:\scala\build.bat X:\scala\MANIFEST.MF X:\scala\src X:\scala\src\foo X:\scala\src\foo\HelloWorld.scala HelloWorld.scala: //file: foo/HelloWorld.scala package foo { object HelloWorld { def main(args: Array[String]) { println(“Hello, world!”) } } } MANIFEST.MF: Main-Class: foo.HelloWorld Class-Path: scala-library.jar build.bat: @ECHO OFF IF EXIST hellow.jar DEL hellow.jar IF NOT EXIST scala-library.jar COPY %SCALA_HOME%\lib\scala-library.jar . CALL scalac -sourcepath src -d bin src\foo\HelloWorld.scala CD … Read more

How to create my own java library(API)?

Create a JAR. Then include the JAR. Any classes in that JAR will be available. Just make sure you protect your code if you are giving out an API. Don’t expose any methods / properties to the end user that shouldn’t be used. Edit: In response to your comment, make sure you don’t include the … Read more

Where can I download mysql jdbc jar from? [closed]

Go to http://dev.mysql.com/downloads/connector/j and with in the dropdown select “Platform Independent” then it will show you the options to download tar.gz file or zip file. Download zip file and extract it, with in that you will find mysql-connector-XXX.jar file If you are using maven then you can add the dependency from the link http://mvnrepository.com/artifact/mysql/mysql-connector-java Select … Read more