Archive for the ‘en-US’ Category
Mount a shared drive with VirtualBox
Case
You have to share some content between the host (eg: Linux Mint) and the resident (eg: Windows 7) systems, with Virtual Box.
Solution
- In the resident system, go to Virtual Box, then:
Machine
>Settings
> SharedFolders
> on the right:Add
> checkautomount
andpermanent
, browse to the folder, let’s sayD:\sharedFolder
- Launch the VM.
- Execute a terminal in host system:
- Grant rights of group
vboxsf
to usermint
:
sudo gpasswd -a mint vboxsf
- Create a “local” folder:
mkdir ~/sharedFolder
- Mount the folder
sharedFolder
on/home/
:
sudo mount -t vboxsf -o uid=1000,gid=1000 sharedFolder ~/sharedFolder
(long tweet) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘type=InnoDB’ at line 1
Stacktrace
[java]org.hibernate.tool.hbm2ddl.SchemaExport – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘type=InnoDB’ at line 1[/java]
Quick fix
In JPA configuration, replace:
datasource.dialect = org.hibernate.dialect.MySQLInnoDBDialect
with:
datasource.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
Actually, Java driver for MySQL 5.5+ is not backward compatible with the SQL dialect MySQLInnoDBDialect
.
(long tweet) Run MS-DOS command as super user
How to run a MS-DOS command terminal with administrator priviledges, in Windows 7?
Let’s say you need execute cmd
with the account admin
: launch runas /user:admin cmd
.
Windows will ask you to enter the admin password and then will open a CMD
prompt in admin mode.
“Apache Maven Dependency Management” by Jonathan Lalou, was published by Packt
Abstract
I am glad and proud to announce the publication of “Apache Maven Dependency Management”, by Packt.
Direct link: https://www.packtpub.com/apache-maven-dependency-management/book
Alternate locations: Amazon.com, Amazon.co.uk, Barnes & Noble.
On this occasion, I’d like to thank all Packt team for allowing me achieving this project.
What you will learn from this book
- Learn how to use profiles, POM, parent POM, and modules
- Increase build-speed and decrease archive size
- Set, rationalize, and exclude transitive dependencies
- Optimize your POM and its dependencies
- Migrate projects to Maven including projects with exotic dependencies
In Detail
Managing dependencies in a multi-module project is difficult. In a multi-module project, libraries need to share transitive relations with each other. Maven eliminates this need by reading the project files of dependencies to figure out their inter-relations and other related information. Gaining an understanding of project dependencies will allow you to fully utilize Maven and use it to your advantage.
Aiming to give you a clear understanding of Maven’s functionality, this book focuses on specific case studies that shed light on highly useful Maven features which are often disregarded. The content of this book will help you to replace homebrew processes with more automated solutions.
This practical guide focuses on the variety of problems and issues which occur during the conception and development phase, with the aim of making dependency management as effortless and painless as possible. Throughout the course of this book, you will learn how to migrate from non-Maven projects to Maven, learn Maven best practices, and how to simplify the management of multiple projects. The book emphasizes the importance of projects as well as identifying and fixing potential conflicts before they become issues. The later sections of the book introduce you to the methods that you can use to increase your team’s productivity. This book is the perfect guide to help make you into a proud software craftsman.
Approach
An easy-to-follow, tutorial-based guide with chapters progressing from basic to advanced dependency management.
Who this book is for
If you are working with Java or Java EE projects and you want to take advantage of Maven dependency management, then this book is ideal for you. This book is also particularly useful if you are a developer or an architect. You should be well versed with Maven and its basic functionalities if you wish to get the most out of this book.
Table of content
- Preface
- Chapter 1: Basic Dependency Management
- Chapter 2: Dependency Mechanism and Scopes
- Chapter 3: Dependency Designation (advanced)
- Chapter 4: Migration of Dependencies to Apache Maven
- Chapter 5: Tools within Your IDE
- Chapter 6: Release and Distribute
- Appendix: Useful Public Repositories
- Index
How to compile both Java classes and Groovy scripts with Maven?
Case
Your project includes both Java classes and Groovy scripts. You would like to build all of them at the same time with Maven: this must be possible, because, after all, Groovy scripts are run on a Java Virtual Machine.
Solution
In your pom.xml
, configure the maven-compiler-plugin
as follows:
[xml] <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<source>1.6</source>
<target>1.6</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.8.0-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.1.5-03</version>
</dependency>
</dependencies>
</plugin>[/xml]
With such setup, default compiler (which cannot compile Groovy scripts parallelly of Java sources) will be replaced with Eclipse’s one (which can).
How to know which versions of Xerces and Xalan are run in the JDK?
Run this command:
[java]java com.sun.org.apache.xalan.internal.xslt.EnvironmentCheck[/java]
(long tweet) How to make ChromeOS work in VirtualBox without Wifi?
Case
How to make ChromeOS work in VirtualBox without Wifi, ie on an ethernet/wired local network, or even offline?
Quick Fix
Shutdown the VM > Select it > Settings > Network > Advanced > Adapter Type > select “Paravirtualized Network (virtio-net)”
(long tweet) Virtual Box / PAE processor
Case
On booting ChromeOS Vanilla within Virtual Box, I got the following error:
[java]This kernel requires the following features not present on the CPU: pae
Unable to boot – please use a kernel appropriate for your CPU.[/java]
(Actually, the problem occured with ChromeOS but may have appened with another system)
Quick Fix
In Virtual Box, select the VM > Settings > Processor > check “Enable PAE/NX”.
(long tweet) A story of return in try/catch/finally
A short reminder: in a try/catch/finally
section, the block in the finally is always executed. “Always” means “even if a return
statement is reached in the try
or catch
“.
A short piece of code shows more than a long speech. The following JUnit test ends with no error:
[java]package com.stepinfo.poc.cartography;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
/**
* Created with IntelliJ IDEA 12 "Leda" CE
* User: Jonathan LALOU
* Date: 08/Apr/13
* Time: 22:41
*/
public class TestTryCatchFinally {
public static final String TRY = "try";
public static final String CATCH = "catch";
public static final String FINALLY = "finally";
private String tryVersusFinally() {
try {
return TRY;
} catch (Exception e) {
return CATCH;
} finally {
return FINALLY;
}
}
private String catchVersusFinally() {
try {
throw new RuntimeException();
} catch (Exception e) {
return CATCH;
} finally {
return FINALLY;
}
}
@Test
public void testTryFinally() {
assertNotSame(TRY, tryVersusFinally());
assertEquals(FINALLY, tryVersusFinally());
}
@Test
public void testCatchFinally() {
assertNotSame(CATCH, tryVersusFinally());
assertEquals(FINALLY, catchVersusFinally());
}
}
[/java]
(long tweet) java.lang.SecurityException: Prohibited package name
Case
Here is a case of stupid error. I started up a new project in IntelliJ IDEA, laying on a Maven archetype. On launching the first unit test, I got the following error:
[java]Cannot instantiate test(s): java.lang.SecurityException: Prohibited package name: java.lalou.jonathan.multiposts[/java]
Quick fix
As you may have noticed, the package name was prefixed with java.
… which is prohibited by the JDK. An immediate fix is to restore a package name not starting with java.
.
The code in the JDK is explicit: the exception with such a message is raised in a unique occasion:
[java] if ((name != null) && name.startsWith("java.")) {
throw new SecurityException
("Prohibited package name: " +
name.substring(0, name.lastIndexOf(‘.’)));
}
[/java]