Most website visitors don’t have Java enabled

So, for the first time ever, I had a look at the "Java Support" dimension in Google Analytics. According to that, most of our visitors don’t seem to have Java enabled (115,844 vs. 7,540 page views). I’ve read stats that approx. 1-3% of people have Java disabled in their browser, so what’s going on on my website? How shall I interpret this data from Google Analytics?!

Our website is based on Javascript and won’t work without it. That’s why I find it odd that visitors without Java support would spend an average of 2:45 minutes on it. Any explanation or advice is greatly appreciated!

enter image description here

Why is PHP still mostly used to make browser games rather than Python or Java? [closed]

I am a Computer Science student and I have been playing to Travian for years.Travian is a browser based MMOG where you have to build your village and compete for resources. There is no animation, there is 3 main views which is the map, your village and your fields.

I was looking at some Travian clones on GitHub and I found 3 clones, all of them using PHP. Travian has itself build using PHP.

I am wondering if PHP is better in some way than Python for example for building this kind of games? And if so, why would be the reason?

Java stored procedure or user-defined function could not call Java method

After I created a Java external stored procedure in DB2 as in my previous question, the call

call user1.send_mail(    P_TO          => 'me@domain.com'   ,P_CC          => NULL   ,P_BCC         => NULL   ,P_FROM        => 'me@domain.com'   ,P_SUBJECT     => 'db2 java subject'   ,P_TEXT_MSG    => 'db2 java test'   ,P_HTML_MSG    => null   ,P_ATTACH_NAME => null   ,P_ATTACH_MIME => null   ,P_ATTACH_BLOB => null   ,P_SMTP_HOST   => 'domain.com'   ,P_SMTP_PORT   => 465   ,P_USER_NAME   => 'me@domain.com'   ,P_PASSWORD    => 'secret'); 

fails it due to the following error:

Java stored procedure or user-defined function "USER1.SEND_MAIL", specific name "SQL201208113215436" could not call Java method "send_mail", signature "(Ljava/lang/String".. SQLCODE=-4306, SQLSTATE=42724, DRIVER=3.68.61

I made sure that all parameters that have no default values receive non-NULL values. What else is necessary for this to work?

Java simple dusk cleaner game simulator

I am working on a dusk cleaner simulator on Java, in this case the shape of the cleaner is a circular ball.

The program is quite simple, the user puts in the width and length of the "room" and coordinates x and y.

What I want to do and cannot is create a series of commands, each represented by a character. There are three commands that I want to imnplement:

  1. char ‘A’ = Move forward 1 meter

  2. char ‘L’ = Turn left 90 degrees

  3. char ‘R’ = Turn right 90 degrees

Example of user input AALA, in this case the expected output is that the machine moves 2 meters and then turns left 90 degrees and then moves 1 meter again. Hope I am clear.

As you can see in the code, I have tried to create an array of chars but I dont know what the next step should be…

The code:

public class Cleaner extends JPanel { /* int lx = 1, ly = 1; int x = 200, y = 250;  */ int x, y; int width = 52, height = 50; // width and height of the "dust sucker" int lx , ly;   // an array of chars char[] charArray ={ 'A', 'L', 'R'};       java.util.Timer move; // making the instance of Timer class from the util package static JFrame frame;   Cleaner() {          frame = new JFrame ("Cleaner started!"); // passing attributes to our fame     frame.setSize (400, 400); // setting size of the starting window     frame.setVisible (true);          setForeground(Color.black); // setting color          move = new java.util.Timer();          move.scheduleAtFixedRate(new TimerTask()     {                       public void run()          {             if(x<0)                 lx = 1;             if(x>=getWidth()-45)                 lx = -1; // -1 sets boundry for the dusk sucker             if(y<0)                 ly = 1;             if(y>=getHeight()-45)                 ly = -1; // -1 sets boundry for the dusk sucker                          x+=lx; // to make the machine move             y+=ly;                          repaint();         }              }, 0, 5// speed of the machine             );          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);      }  public void paint (Graphics g)  {     super.paint(g);     Graphics2D g2d = (Graphics2D) g;     g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);     g2d.fillOval(x, y, width, height); }  public static void main (String[] args)  {     // lx value          String lxValue =               JOptionPane.showInputDialog( "Enter lx" );     // ly value     String lyValue =               JOptionPane.showInputDialog( "Enter ly" );          String xValue =               JOptionPane.showInputDialog( "Enter x value" );     // ly value     String yValue =               JOptionPane.showInputDialog( "Enter y value" );        // convert String inputs to int values        int firstInput = Integer.parseInt( lxValue );        int secondInput = Integer.parseInt( lyValue );       int thirdInput = Integer.parseInt( xValue );        int forthInput = Integer.parseInt( yValue );               Cleaner cleaner = new Cleaner();                       frame.add(cleaner);       cleaner.lx = firstInput;       cleaner.ly = secondInput;       cleaner.x = thirdInput;       cleaner.y = forthInput;             }      } 

All help is appreciated!

How to draw the heap for an array in Java?

I have an assignment to draw the heap after an ArrayList and a LinkedList is created.

public static void main(String[] args) {      List list = new ArrayList();      list.add(0);      list.add(1);      list.add(1);      list.add(2); } 

and

public static void main(String[] args) {      List list = new LinkedList();     list.add(0);      list.add(1);      list.add(1);      list.add(2); } 

So far I have a tree set up for [0, 1, 1, 2] so that it just goes down like a tree from 0, 1 and 1, then 2. But I don’t know if that’s correct and if it’d be different for the ArrayList and LinkedList.

How do I approach towards an abstract production rule interpreter with this situation of converting XML to python or java class?

If I am asking in the wrong place, please forgive and direct me to a more suitable one

So I have a XML like this

<range>    unconstrained    <span>       <rttype>          String </range>  <range>    x type    <span>       <rttype>          int       <assert>          $   > 0 </range>  <range>    Simple class reference    <span>       <rttype>          SimpleClass </range>  <range>    Simple class set    <span>       <rttype>          ArrayList<SimpleClass> </range>  <class>   Simple class     <attribute>      x         <range>            x type   </attribute>    <attribute>      state   </attribute>    <action>      initializer      <guarantees>         x has been set to zero      </guarantees>      <pimaction>         .@a x @ = 0      </pimaction>   </action>    <action>      update x      <parameter>         new x         x type      <guarantees>         x has been set to new x      </guarantees>      <pimaction>         .@a x @ = @i new x @      </pimaction>   </action>    <state>      Exists   </state>    <state>      Doesn't exist   </state>    <event>      <<new>>   </event>    <event>      <<destroy>>   </event>    <event>      update   </event>    <transition>      Doesn't exist      <<new>>      Exists      <transitionaction>         initializer   </transition>    <transition>      Exists      <<destroy>>      Doesn't exist   </transition>    <transition>      Exists      update      Exists      <transitionaction>         update x   </transition> 

I have a Java compiler (let’s call this ToJavaCompiler) that will compile this into a Java class

And another Java compiler (let’s call this ToPythonCompiler) that will also compile this into a Python class.

class SimpleClass:      # State Enum Declaration     # see MMClass.ruleStateEnumDeclaration for implementation      SimpleClass_states = Enum("SimpleClass_states", "EXISTS DOESNTEXIST")      # Attribute instance variables     # see MMClass.ruleAttributeInstVarList for implementation      _x: int     _state: SimpleClass_states      # Class level attribute     # All class members accessor      SimpleClassSet: ClassVar[List[SimpleClass]] = []       # Constructor     # See MMClass.ruleConstructorOperation      # See constructEvent.ruleConstructorOperation     def __init__(self):         # requires         #    none         # guarantees         #    --> x has been set to zero and state == Exists         self._initializer()         self._state = SimpleClass.SimpleClass_states.EXISTS         SimpleClass.SimpleClassSet.append(self)      # Attribute getters      @property     def x(self) -> int:         # requires         #   none         # guarantees         #   returns the x         return self._x      @property     def state(self) -> SimpleClass_states:         # requires         #   none         # guarantees         #   returns the state         return self._state       # Pushed events      def destroy(self) -> None:         # requires         #    none         # guarantees         #   state was Exists --> state == Doesn't exist         if self._state == SimpleClass.SimpleClass_states.EXISTS:             self._state = SimpleClass.SimpleClass_states.DOESNTEXIST             SimpleClass.SimpleClassSet.remove(self)      def update(self, new_x: int) -> None:         # requires         #    none         # guarantees         #   state was Exists --> x has been set to new x         if self._state == SimpleClass.SimpleClass_states.EXISTS:             self._update_x(new_x)      # Private transition actions      def _initializer(self):         # requires         #   none         # guarantees         #   x has been set to zero         self._x = 0      def _update_x(self, new_x: int):         # requires         #   none         # guarantees         #   x has been set to new x         self._x = new_x 

THe thing is my production rule need access to instance variable data from the model object they are compiling.

For example to generate the instance variables declarations i need a production rule that’s written in Java code like this which require access to the underlying model itself at Context.model()

public void ruleAttributeInstVarList() {     // description     // this rule emits the set of (private) instance variable declarations, if any     //     // Class.#ATTRIBUTE_INST_VAR_LIST -->     // foreach anAttribute in class     // anAttribute.#DEFINE_INST_VAR     //     // requires     // none     // guarantees     // all attributes of this class have been declared as instance variable of the     // PIM Overlay run-time type     if (Context.model().isVerbose()) {         Context.codeOutput().indent();         Context.codeOutput().println("# Attribute instance variables");         Context.codeOutput().println("# see MMClass.ruleAttributeInstVarList for implementation");                  Context.codeOutput().println("");         if (!attributeSet.isEmpty()) {             for (Attribute anAttribute : attributeSet) {                 anAttribute.ruleDefineInstVarAsPrivate();             }         } else {             if (Context.model().isVerbose()) {                 Context.codeOutput().indent();                 Context.codeOutput().println("# none");             }         }         Context.codeOutput().indentLess();     } else {         for (Attribute anAttribute : attributeSet) {             anAttribute.ruleDefineInstVarAsPrivate();         }     }     Context.codeOutput().println("");     Context.codeOutput().println(""); } 

I wonder if there’s an easier way to add target languages or frameworks without creating separate codebases per target language.

For e.g. I now have a ToJavaCompiler and a ToPythonCompiler two separate codebases

So I am here asking if there’s a way I can create an abstract production rule interpreter that suits my needs. My aim is to ultimately produce model classes in the target language or framework (such as Django or Rails) with a single codebase that allows extensions for different target languages/frameworks

I am okay to move away from Java if there’s a better language that suits what I am trying to do.

Canvas VS JPanel (Java)

Everyone says all the time – "Be careful to combine Canvas with Swing components, because it is a heavyweight component and Swing is lightweight". How exactly will this harm me? Maybe in very specific cases that do not even come to my mind, but currently Canvas is the best way to develop games in Java if you use Swing in my opinion. And the fact is, Minecraft is also painted on AWT’s Canvas. Correct me if I’m wrong. But right now what gives me more control is Canvas and not JPanel.

Java Programming

Assume that you have been assigned a task to develop an application which will be handling teaching activities as the University. The application has four main entities namely administrator, lecturer, student and course. The application should be able to allow: a) Registration of classes b) Registration of modules c) Registration of lecturers d) Registration of students e) Assignment of modules into class f) Assignment of module to lecturer g) Assignment of student into class h) View all registered students, modules, classes i) View all students and their modules j) View lecturers and their modules The application should be developed by using Object Oriented programming in which encapsulation, inheritance, abstraction and polymorphism concepts MUST be observed and implemented by using Java

Establishing safe connection in Java

In my Java project I’m trying to create a 100% secure method of communication between the method and the client. I used to use this process:

Client: generates 4096-bit RSA keypair Client: sends public to server Client: generates 256-bit AES key Client: encrypts AES key using RSA and send Server: decrypts AES key from RSA Server & Client now communicate using AES only 

But I found out this isn’t safe as it can easily be ruined by a man-in-the-middle attack. I began researching TLS and found out about security certificates. My question is this: if the client generates the RSA keypair, signs it using the certificate, and sends it to the server, what stops a MITM from doing the same thing (assuming the certificate is publicly available, which I assume it would be because the server and the client would both need it).

When I use OpenSSL to generate a certificate it always provides an RSA key alongside it. Isn’t it safer to generate a new keypair for each connection, or do I actually use this particular key? What am I missing about the standard pattern for TLS?