How to get the mac address

Here using this code you will be able to get the mac address of your machine. So save this code named as “macAddress.java”:

<pre>import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;

public class macAddress{

   public static void main(String[] args){

	InetAddress ip;
	try {

		ip = InetAddress.getLocalHost();
		System.out.println("Current IP address : " + ip.getHostAddress());

		NetworkInterface network = NetworkInterface.getByInetAddress(ip);

		byte[] mac = network.getHardwareAddress();

		System.out.print("Current MAC address : ");

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < mac.length; i++) {
			sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
		}
		System.out.println(sb.toString());

	} catch (UnknownHostException e) {

		e.printStackTrace();

	} catch (SocketException e){

		e.printStackTrace();

	}

   }

}</pre>

BorderLayout örneği

Java da awt kütüphanesinde ki başka bir nese BorderLayout. BorderLayout eklenen simgeleri kuzey, güney, doğu, batı ve merkez olarak yerleştirir. Şimdi bu konumuzu yine bir örnek ile süslendirelim:

aşağıdaki dosyası BrdrLayout.java olarak kaydedin:

package GUI;

import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;

public class BrdrLayout extends JFrame{

public BrdrLayout(){

BorderLayout layout = new BorderLayout(40,40);
setLayout(layout);

add(new JButton("WEST"),BorderLayout.WEST);

add(new JButton("SOUTH"),BorderLayout.SOUTH);

add(new JButton("NORTH"),BorderLayout.NORTH);

add(new JButton("EAST"),BorderLayout.EAST);

add(new JButton("CENTER"),BorderLayout.CENTER);

}

}

 

şimdide bu dosyamızı BrdrLayoutMain.java olarak kaydedelim:

 


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package GUI;

/**
*
* @author tugrulaslan
*/
import javax.swing.JFrame;
public class BrdrLayoutMain {

public static void main(String[] args){

BrdrLayout pencere = new BrdrLayout();
pencere.setSize(400,300);
pencere.setTitle("Pencere");
pencere.setLocationRelativeTo(null);
pencere.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pencere.setVisible(true);
}

}

GridLayout örneği

Javada AWT kütüphanesi ile birlikte gelen bir nesne olan Grid Layout eklenen komponentlerin dizilişlerini satır ve sütunlar halinde yerleştirir. Buna bir örnek ile süslendirelim, ben compiler olarak NetBeans’i kullanıyorum:

aşağıda ki dosyası GrdLayout olarak yeni bir JavaClass dosyası olarak kaydedin. Benim paket adım GUI dir aynı paket ismi kullanırsanız herhangi bir sorun olmaz eğer başka bir paket adı kullanırsanız dosyalarda ki paket adını değiştirmeyi unutmayın. Şimdi GrdLayout.java dosyamızın kodlarını yazalım:


package GUI;

/**
*
* @author tugrulaslan
*/
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class GrdLayout extends JFrame{

public GrdLayout(){

GridLayout layout = new GridLayout(3,2,3,2);

setLayout(layout);
add(new JLabel("isim"));
add(new JTextField(25));
add(new JLabel("soyisim"));
add(new JTextField(25));
add(new JLabel("yaş"));
add(new JTextField(3));
}

}

GrdLayoutMain.java dosyamız:

package GUI;

import javax.swing.JFrame;
public class GrdLayoutMain {

public static void main(String[] args){

GrdLayout pencere = new GrdLayout();
pencere.setSize(400,200);
pencere.setTitle("Pencere");

pencere.setLocationRelativeTo(null);
pencere.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

pencere.setVisible(true);
}

}

ColdFusion 8 not working or not starting after the installation

The major reason why ColdFusion 8 does not work on your fedora server is that, after we enter the details of our Apache Web Server, the installation won’t enter them onto the connector file!

To fix this issue run your terminal and execute the cod below:


sudo gedit /opt/coldfusion8/bin/connectors/apache_connector.sh

And then replace these lines:


../../runtime/bin/wsconfig \
-server coldfusion \
-ws apache \
-dir /usr/local/apache2/conf \
-bin /usr/local/apache2/bin/httpd \
-script /usr/local/apache2/bin/apachectl \
-coldfusion

with these lines:


../../runtime/bin/wsconfig \
-server coldfusion \
-ws apache \
-dir /etc/httpd/conf \
-bin /usr/sbin/httpd \
-script /etc/rc.d/init.d/httpd \
-coldfusion

and then go on to your terminal and execute this code:


cd /opt/coldfusion8/bin

./coldfusion start

After you make this change on your “apache_connector.sh” file then you will be able to connect to your ColdFusion 8 application.