Showing posts with label JAVA. Show all posts
Showing posts with label JAVA. Show all posts

Tuesday, June 4, 2013

How to start a java program without the console in windows?

Write the following code in a "bat" file. Now double click on the batch file to run the jar.



PS: replace the path of jar with your desired jar path.

AUTHOR: OBSCURE

Monday, June 3, 2013

View PIDs and command lines of all running Java processes in Windows

The following line will shows PIDs of all running Java processes in cmd:


and to kill a process from windows cmd:




AUTHOR: OBSCURE

Wednesday, December 5, 2012

Serial Port Communication From Java - RxTx Installation.

Want to communicate with serial port using Java? You may want to try RxTx library. It's easy to use.
To install follow the instruction below:

The official RxTx binary pack is available here. The provided link will download the distro with some standard binaries (for linux 32bit, 64 bit, etc). If binaries for your specific operating system are not included, you may consider recompiling RxTx yourselves.
For a custom Win64 RxTx distro, have a look at the CloudHopper's web site.
To install it, unzip the distribution file in a temporary place and do the following copies:
  • File RXTXcomm.jar should go under JDKDIR/jre/lib/ext/
  • The necessary library( .so for linux, .dll for windows) should go under JDKDIR/jre/bin/
AUTHOR: OBSCURE

Saturday, October 13, 2012

Installing Apache Maven-Java tool

Download maven.

Windows OS:


  1. Unzip the distribution archive, i.e. apache-maven-3.0.4-bin.zip to the directory you wish to install Maven 3.0.4. These instructions assume you chose C:\Program Files\Apache Software Foundation. The subdirectory apache-maven-3.0.4 will be created from the archive.
  2. Add the M2_HOME environment variable. [almost similar as this]: adding the M2_HOME variable in the system variables with the value                                                                                      C:\Program Files\Apache Software Foundation\apache-maven-3.0.4. Be sure to omit any quotation marks around the path even if it contains spaces.
  3. In the same dialog, add the M2 environment variable in the system variables with the value %M2_HOME%\bin.
  4. In the same dialog, update/create the Path environment variable in the system variables and prepend the value %M2% to add Maven available in the command line.
  5. In the same dialog, make sure that JAVA_HOME exists in your system variables and it is set to the location of your JDK, e.g.C:\Program Files\Java\jdk1.5.0_02 and that %JAVA_HOME%\bin is in your Path environment variable.
  6. Open a new command prompt and run mvn --version to verify that it is correctly installed.



Linux based/Ubuntu Operating Systems:


  1. Extract the distribution archive, to the directory you wish to install Maven 3.0.4. These instructions assume you chose /home/username/java/tools/maven.
  2. Open terminal and type:  gedit ~/.bashrc
  3. Set environment variable by adding the following lines at the bottom of .bashrc :
    •  export M2_HOME=/home/username/java/tools/maven
    • export M2=$M2_HOME/bin
    • export PATH=$M2:$PATH
    • export JAVA_HOME=/usr/lib/jvm/jdk-default #if JAVA_HOME not exist.
  4. Run mvn --version to verify that it is correctly installed.

Thursday, September 20, 2012

How to create non-editable JTable:

Override the method "isCellEditable" and implement as needed, such as:

//instance table model
DefaultTableModel tableModel = new DefaultTableModel(){
    @Override
    public boolean isCellEditable(int row, int column) {
        return false;
    }
};
//...other codes
table.setModel(tableModel);

Tuesday, September 18, 2012

System.getProperty(key) key list for Java with value:

System.getProperty(key) key list for JAVA:

java.versionJava Runtime Environment version
java.vendorJava Runtime Environment vendor
java.vendor.urlJava vendor URL
java.homeJava installation directory
java.vm.specification.versionJava Virtual Machine specification version
java.vm.specification.vendorJava Virtual Machine specification vendor
java.vm.specification.nameJava Virtual Machine specification name
java.vm.versionJava Virtual Machine implementation version
java.vm.vendorJava Virtual Machine implementation vendor
java.vm.nameJava Virtual Machine implementation name
java.specification.versionJava Runtime Environment specification version
java.specification.vendorJava Runtime Environment specification vendor
java.specification.nameJava Runtime Environment specification name
java.class.versionJava class format version number
java.class.pathJava class path
java.library.pathList of paths to search when loading libraries
java.io.tmpdirDefault temp file path
java.compilerName of JIT compiler to use
java.ext.dirsPath of extension directory or directories
os.nameOperating system name
os.archOperating system architecture
os.versionOperating system version
file.separatorFile separator ("/" on UNIX)
path.separatorPath separator (":" on UNIX)
line.separatorLine separator ("\n" on UNIX)
user.nameUser's account name
user.homeUser's home directory
user.dirUser's current working directory



Friday, June 15, 2012

Installing Oracle-JDK in Ubuntu

Download JDK from ORacle. Run Terminal:

chmod u+x jdk-6u31-linux-i586.bin
./jdk-6u31-linux-i586.bin
sudo mv jdk1.6.0_31 /usr/lib/jvm/


#Next line will add java to symlink

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_31/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_31/bin/javac" 1

Or, better if you can set environment variable by adding the following lines at the bottom of .bashrc by "gedit ~/.bashrc":

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_03
export PATH=$PATH:$JAVA_HOME/bin

You can now check if the java is installed properly in terminal:

java -version
javac -version

These will return the version of java and javac.

Monday, April 9, 2012

Generics are not supported in -source 1.3 error in Maven Project

When compiling via maven project, you may have encountered following error:
generics are not supported in -source 1.3 error in Maven Project. use -source 5 or higher to enable generics.

Annotation is not allowed in -source 1.3 use -source 5 or higher to enable annotation.

To solve this you must add the below lines at your pom.xml :


    
        
            org.apache.maven.plugins
            maven-compiler-plugin
            
                1.5</source>
                1.5
            
         
    

Thursday, December 15, 2011

RMI plug-in for Eclipse

RMI plug-in from Genady. This tool is for the development of RMI in eclipse.

How to install Genady plug-in:

  1. Save your work and exit  from Eclipse.

  2. Delete previous version if installed any.

  3. Download the plug-in zip from here.

Monday, July 18, 2011

How to Set Path Variable in Windows 7

a. Checking  if java is set as path environment variables:

1. Go to Start-> Run-> cmd

2. write: java -version and hit Return/Enter. If the path variable set properly it will show your java version.


b. Setting path variable in windows 7:

1. Go to start menu -> control panel -> system and security -> System.
or simply paste this in your windows explorer address bar-->
Control Panel\System and Security\System

2. Now select "Advanced system settings" from the left panel.

3. A new window appears. Click on "Environment variables..."
4. under System Variables, find PATH, and click on it.
 
5. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value. 

6. the location looks like: "C:\Program Files (x86)\Java\jdk1.6.0_23\bin;" end it with a semicolon.

7. Click ok. 

8. Close all these windows.

C. Check if path variable is set properly:

1. Go to command prompt/cmd.

2. write: "java -version" end hit Return/Enter. if the path variable set properly it will show your java version.

3. If it still not working reboot your computer and try step c1 & c2.

Hope, now your path variable for java is set. Else read steps of "b" carefully.