Sistema de blogs Diarium
Universidad de Salamanca
Pablo Gallardo's Blog
My professional web log about IT, Cybersecurity & Project Management
 
Tag Archives | java

Possible Values of OS-dependent Java System Properties

There are some system properties that can be obtained from Java code. Some of these examples are: Code example: System.getProperty(“os.name”)   List of possible os values This is not a complete list. os.name values: Windows NT Windows 98 Windows XP Windows 2000 Windows ME Windows 2003 Windows 8.1 Windows 10 Linux SunOS FreeBSD Mac OS […]

Comments { 0 }

How to modify Java Compiler Version

  Why would I need to change the Java compiler version? We may tend to think that we should always use the latest version of the Java compiler. However, if the compiler version is newer than the virtual machine version, system will trigger an error when trying to run. So we may want to modify […]

Comments { 0 }

How to install JRE or JDK in Ubuntu

This post explains how to install or update Java components JRE or JDK in operating system Ubuntu. It may be compatible with other Debian-like or Ubuntu-like Linux distros, like Linux Mint, etc.   Step-by-step Procedure 1. Install repository Open a terminal. Install repository from command line: sudo add-apt-repository ppa:<repositoryaddress> The repositories I found were (you […]

Comments { 0 }

Understanding Java Components like JVM, JRE, JDK and OpenJDK

This post explains the most relevant concepts around the software needed to run and/or compile Java in a computer. Java Virtual Machine Java Virtual Machine (JVM) is the virtual machine that runs the Java bytecodes. The JVM doesn’t understand Java source code; that’s why you need compile your *.java files to obtain *.class files that […]

Comments { 0 }

How to reference a File on a Java Application

When referencing resources in a Java project, as for example photos, sound clips, video, etc., it is important to do it correctly because otherwise we may find errors when executing the application out of the IDE from a JAR file or on a different operating systems. Method getResource on each class allows to retrieve a […]

Comments { 0 }

How to check if User is admin from a Java Application

This post is about summarizing different ways to check if user is admin in JAva   Use system calls to check if user is admin A Java application can call system command through the class Runnable You can see this post about ways to know if from command line. The code to execute a command […]

Comments { 0 }

How to call native code from a Java application

      Methods to call a native function Method 1. Use Runtime class Runtime class contains the exec method that allows the application to run an operating system command. An example of how to use this method: String command = “echo \”Hello World!\”"; Runtime.getRuntime().exec(command);   Method 2. Use JNI Java Native Inteface (JNI) is […]

Comments { 0 }

How to package a Java App for Distribution

  Packaging a Java App for Distribution on Windows <pending> Packaging a Java App for Distribution on Mac OS X Follow the instructions by Oracle: https://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html Packaging a Java App for Distribution on Linux <pending> External References Max Sauer & Patrick Keegan; “Packaging and Deploying Desktop Java Applications [with NetBeans]“; NetBeans “How to change Java […]

Comments { 0 }

How to add an Icon to a Java application

This are the instructions to add an icon the a Java Swing application. Icon is loaded from an image. In order to load this image we make use of File and Buffered Image classes. Icon can be shown in different places, depending on operation system: On a corner of the window bar, like in Windows. […]

Comments { 0 }

How to display an image on Java Swing

Images can be displayed in Java Swing using object JLabel. This is the partial code: JLabel label = new JLabel(); try { BufferedImage img = ImageIO.read(new File(IMG_FILES_PATH + IMG_FILENAME)); ImageIcon icon = new ImageIcon(img); label.setIcon(icon); } catch (IOException ex) { Logger.getLogger(SwingGUIMainScreen.class.getName()).log(Level.SEVERE, null, ex); } If I need the image to have an specific size, what […]

Comments { 0 }
Política de privacidad
Studii Salmantini. Campus de excelencia internacional