How can I sandbox Python in pure Python?

This is really non-trivial. There are two ways to sandbox Python. One is to create a restricted environment (i.e., very few globals etc.) and exec your code inside this environment. This is what Messa is suggesting. It’s nice but there are lots of ways to break out of the sandbox and create trouble. There was … Read more

javax vs java package

I think it’s a historical thing – if a package is introduced as an addition to an existing JRE, it comes in as javax. If it’s first introduced as part of a JRE (like NIO was, I believe) then it comes in as java. Not sure why the new date and time API will end up as javax following this logic … Read more

What’s the simplest way to print a Java array?

Since Java 5 you can use Arrays.toString(arr) or Arrays.deepToString(arr) for arrays within arrays. Note that the Object[] version calls .toString() on each object in the array. The output is even decorated in the exact way you’re asking. Examples: Simple Array:String[] array = new String[] {“John”, “Mary”, “Bob”}; System.out.println(Arrays.toString(array)); Output:[John, Mary, Bob] Nested Array:String[][] deepArray = new String[][] {{“John”, “Mary”}, {“Alice”, “Bob”}}; System.out.println(Arrays.toString(deepArray)); //output: … Read more

“Char cannot be dereferenced” error

The type char is a primitive — not an object — so it cannot be dereferenced Dereferencing is the process of accessing the value referred to by a reference. Since a char is already a value (not a reference), it can not be dereferenced. use Character class:

Can’t execute jar- file: “no main manifest attribute”

First, it’s kind of weird, to see you run java -jar “app” and not java -jar app.jar Second, to make a jar executable… you need to jar a file called META-INF/MANIFEST.MF the file itself should have (at least) this one liner: Where com.mypackage.MyClass is the class holding the public static void main(String[] args) entry point. Note that there are several ways to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)