i am new in java programming
i am trying it through windows platform and ubuntu platform
in c, c++, c#, VB.Net the executable file is .exe
i want to know what is the executable file for java is it .jar ?
and if i want to run my program in my friend computer i only take the .jar file?
how to make it protected?
if the executable file is .jar exactly why i find executable files in ubuntu wuth no extension or .sh and how to make it?
this my code i created the .jar file for it
it works fine but JOptionpane donot work when call it using java -jar database_con.jar in windows and ubuntu
package database_con;
import adding.adding;
import com.mysql.jdbc.Statement;
import com.sun.corba.se.spi.orbutil.fsm.Input;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
public class Database_con {
public static void main(String[] args) {
System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "test";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "globalamirtarek";
com.mysql.jdbc.Statement st=null;
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
System.out.println("Connected to the database");
st=(Statement) conn.createStatement();
ResultSet rs;
st.executeUpdate("Delete from name where name_id=2");
rs=st.executeQuery("Select* from name");
int name_id;
String name;
while(rs.next())
{
name_id=rs.getInt("name_id");
name=rs.getString("name");
System.out.printf("%d %s\n",name_id,name);
}
System.out.println("Disconnected from database");
}
catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException e)
{
System.out.println(e.getMessage());
}
int z=adding.add(5, 6);
System.out.print(z);
z=JOptionPane.showConfirmDialog(null,"is the number of the result is 11?","The result",1);
String name=JOptionPane.showInputDialog("what is your name?");
if(z==0)
{
System.out.printf("thanks %s the result is great", name);
}
else if(z==1)
{
System.out.printf("thanks %s but the result is wrong", name);
}
else if(z==2)
{
System.out.printf("go to hell %s", name);
}
}
}
the lib folder with the .jar file contain the jar file of the driver of mysql com.mysql.jdbc.Driver
and the jar of the class library project adding