|
_Comet_Keeper_ wrote: IBM refers to EMF, but I can't find a simple tutorial to simply open XMI file and retrive objects.
Take a look at the samples in this article[^]
led mike
|
|
|
|
|
Hi , I'm an electronic man with 5+ years experience and I have some knowledge of C and C++ I have written quite big projects with C++ for windows(multi thread, kernel programming,...) and also in C I have written many programs for different microcontrollers. My knowledge about Java and .Net is zilch. Now I feel the need to learn a new language that just like C can be both helpful in firmware development and also in software development. I have heard that Java is platform independent and can be run on any device using a virtual machine and I've heard microsoft has tried to copycat Java and ended up to something that it calls it .Net So I want to learn something that 5 years later I do not regret wasting time to learn it. I do not want to learn something that is living its last days. as I said one of my main purposes is to be able to program new fast big microcontrollers they can run Linux programs, Java Programs and make people doubt if they need desktop computers anymore.
now please put your Java patriotism aside and give me a piece of professional advice that with regard to my experiments in C and my need to program new emerging embedded devices what will be the best choice to learn Java, Linux, .Net, C# or something else... It will be appreciated if you can give some solid rock reasons about your recommendation.
Thanks
|
|
|
|
|
maybe you'd want to read this[^] thread ?!
I've already argued on the matter, and this site is mainly populated with microsofties, so it's hard to make a voice for java out there... but feel free to argue if you want to.
|
|
|
|
|
Oh!
Sorry I had to search before posting
Your posts in that thread was informative, thank you.
I had no doubt that Java is a great Language, millions of people use Java applications in their mobile and other embedded stuff.
As a matter of fact speed and power of microcontroller are increasing so fast that many of them can run OS and big applications, for example a microcontroller that I'm playing with it for awhile(ARM9) has 200 MIPS power @ 200MHz @ 32bit. dose anybody remember 80286@16Mhz running Windows 3.1
Now there are two thing that I seriously considering as my next learning project
1- Linux
2- Java
many embedded devices can run small versions of linux, its programming shouldn't be very different from C++ in fact there is C++ for linux I only have to become familiar with this OS and APIs
about Java I honestly have no idea how hard would be to develop a big graphical program comparing it to development time in C++.
regards,
|
|
|
|
|
Java is standard language .... runs on any platform therefore its code is same for windows, linux, mac, etc.
This is the best feature of Java.
so if u wanna java u learn java i dont think there is downside for it else its first time compilations for its code
BlaCk WolViX
|
|
|
|
|
Hi , One thing about Java is almost all programs that I've seen written in Java are small programs. I hadn't seen a major program like a powerful spread sheet / word processor program (like microsoft word or microsoft excel) written in Java. Maybe I haven't seen it maybe there are reasons programmers prefer other languages for major programs, I don't know. maybe someone here can explain about it.
Best wishes
|
|
|
|
|
if you know Eclipse (I mean, if you know it well), you might have found that it's a quite big one... and it's Java !
I've myself worked on a project which was all J2EE based, but I can't say much as this is not a software people can find anywhere. it was an application (in fact, a set of many applications interconnected) which was to manage the whole trains in France. there were GUI ones, for end users to park the trains in the station, and such tasks ; there were non graphical ones as well for the integration streams parts too...
|
|
|
|
|
Hi , Thanks for enlightening. I don't know Eclipse. But what you said about the application you worked on was quite interesting for me because that sounds that specific application runs on different platforms. That was very important for me because many of my applications also have to interconnect different platforms. For example one of my big headaches always is how to write a firmware that is running on a MicroController(MCU) and the computer GUI that connects to it with the same scaffold. Let me explain, For example in a firmware application I have to calculate value of a parameter measured with an analog to digital converter(ADC) and display it to the user on device LCD and also I have to send the value of this variable to the computer for display on computer screen and storage and further data processing. There are many identical operations that have to be done both in MCU and computer. Also I struggle to write variables and functions that do the same work with the same name so at the time of Debug or Upgrading of the software/firmware I do not get confused with different variable names that actually do the same thing or with different programming style for the same purpose. It is not easy at all. I don't know what kind of life I would have with Java. Maybe If I can develop my software and firmware with the same IDE it makes my life a lot more easier. By the way is Eclipse open source or I have to buy it? and is J2EE version 2 of Java? If I want to begin Java where should I begin? Can you recommend good books or Online Resources?
thanks
|
|
|
|
|
Electronic75 wrote: By the way is Eclipse open source or I have to buy it?
Eclipse 3.4[^] (Free and Open source)
Electronic75 wrote: is J2EE version 2 of Java?
J2EE means 2 things : J2 for Java 2, EE for Enterprie Edition (by oposition to SE - Standard Edition).
Electronic75 wrote: If I want to begin Java where should I begin?
Eclipse is an excelent IDE, but if you don't know Java yet, a book should be a best answer. unfortunately, I have to online resources for that ; I used to read paper books only when I'm learning new programming languages.
|
|
|
|
|
i do not know how to do it....
please help me
task: Cattle Weighing Calculator
One job that a typical farmer needs to do from time to time is to record the individual weights of all his cattle. To do this, he records the number on the ear tag of each animal, along with its weight, which is output by a weighing platform in the cattle yards.
Your task is to program an application that will allow a farmer to record the cattle weight data, and then allow him to get certain kinds of useful information from the recorded data.
Your program should consist of a single form and two separate classes, Form.cs which provides the form functionality, and Queue.cs which provides a dynamic (linked list based) implementation for queues.
The data will be stored in a queue, where each node contains separate data fields for both tag number and weight, and a reference to the next item in the queue.
To begin with, your application should have a form including
a rich textbox, for output only
a textbox, labelled Tag Number, for input of animal ear tag numbers
a textbox, labeled Weight, for input of corresponding animal weights
a button Record
a button Print
When a number is entered into each of the textboxes and the Record button is clicked your program should
(i) Check that there is valid data in textbox; if not, display a suitable message, otherwise
(ii) Call the queue method enqueue to insert the appropriate record into the data queue.
When the Print button is clicked your program should
(i) Check that the data queue is not empty; if it is empty display a suitable message, otherwise
(ii) Call the queue method printQueue to print out to the rich textbox a list of the
(tag number, weight) pairs stored in the data queue.
You should get a first version of the program working that supports this part of the application.
must be written in C#.
|
|
|
|
|
Hi, I am very new to Java and Eclipse and want to create an array of objects and use the objects methods? I have put together the following code:
public class aub {
private int iNumber;
public void setNumber(int iNewValue){
iNumber = iNewValue;
}
public int getNumber(){
return iNumber;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
aub[] ExObj = new aub[10];
for (int i=0;i<10;i++){
ExObj[i].setNumber(i);
}
//ExObj[0].setNumber(8);
System.out.println(ExObj[0].getNumber());
System.out.println(" End of program " );
}
}
When I run the code in Eclipse I get the following error:
Exception in thread "main" java.lang.NullPointerException
at aub.main(aub.java:20)
which is the for loop object method line. I want to use methods to assign values to the objects properties.
Please help|
|
|
|
|
|
you can initialize the array before using it.
public static void main(String[] args) {
aub[] ExObj = new aub[10];
for (int i=0;i<10;i++){
ExObj[i]=new testclass();
ExObj[i].setNumber(i);
}
System.out.println(ExObj[0].getNumber());
System.out.println(" End of program " );
}
}
|
|
|
|
|
Member 3363498 wrote: Exception in thread "main" java.lang.NullPointerException
at aub.main(aub.java:20)
That was pretty clear, wasn't it ?
A NullPointerException means you are dereferencing a pointer which contains null rather than a valid address. Basically, it means that the Reference has not been initialised, or that no object is created.
As already suggested, you then have to create a new aub instance in each cell of your array, because creating an array doesn't create the objects itself. It only reserve the space for the pointers to point to a laterly allocated instance of the aub class.
|
|
|
|
|
The problem is you have not assign the real instance of sub into that array.aub[] ExObj = new aub[10]; is just declared an array which have the capacity to store 10 aub instances, so you should write like this:
for (int i = 0; i < 10; i++){
ExObj[i] = new sub();
}
for (int i = 0; i < 10; i++){
ExObj[i].setNumber(i);
}
or:
for (int i = 0; i < 10; i++){
ExObj[i] = new sub();
ExObj[i].setNumber(i);
}
|
|
|
|
|
Respected Members,
I am in final year of engineering. We are suppose to create a project this year. I gave it a lot of thought but am short of ideas. Can anyone please help me out. Topics like Smart building, Mobile Messenger, and couple of other were rejected by my professor. The project should be big and should be completed within 7-8 months. Technology i am interested in is Java, .Net, XML and then others. Please help me.
Thank you.
kashyap
|
|
|
|
|
Hi,
I have encountered an infinite loop in the following example.
I just want to update the mathine's "tag".
when the "tag" is ture ,then put out message "aaaaaaaaaaaaaaaaaaaaaaa".
But infinite loop occurs even though no-loop is used.
is there anyone can help me? thanks!
package com.sample
rule "Test for type1 machine"
no-loop true
salience 100
when
machine1 : Machine($t:type , type == "Type1" , functions == "func1",code == "c001")
machine2 : Machine($f:functions,type == $t,functions=="func2",code=="c002")
machine3 : Machine(type == "Type2" ,functions==$f , code=="c003")
then
System.out.println("match");
machine1.setTag(true);
machine2.setTag(true);
machine3.setTag(true);
System.out.println(machine1.getName()+" "+machine1.getTag());
System.out.println(machine2.getName()+" "+machine2.getTag());
System.out.println(machine3.getName()+" "+machine3.getTag());
update(machine1);
//update(machine2);
// update(machine3);
end
rule "Test modify"
no-loop true
salience 90
when
machine6 : Machine(tag == true)
then
System.out.println(machine6.getName()+"aaaaaaaaaaaaaaaa");
end
public static final void main(String[] args) {
try {
//load up the rulebase
RuleBase ruleBase = readRule();
// RuleBase ruleBase =getRuleBase();
WorkingMemory workingMemory = ruleBase.newStatefulSession();
//go !
Machine machine1=new Machine("Type1","func1","machine1","c001");
Machine machine2=new Machine("Type1","func2","machine2","c002");
Machine machine3=new Machine("Type2","func2","machine3","c003");
Machine machine4=new Machine("Type2","func2","machine4","c003");
Machine machine5=new Machine("Type1","func1","machine5","c001");
workingMemory.insert( machine1 );
workingMemory.insert( machine2 );
workingMemory.insert( machine3 );
workingMemory.insert( machine4 );
workingMemory.insert( machine5 );
workingMemory.fireAllRules();
}
|
|
|
|
|
Doesn't look like any "Java" I've ever seen. Maybe C#??? Try their forums
John P.
|
|
|
|
|
which programming language this code is for? :S
regards
BlaCk WolViX
|
|
|
|
|
Hi, earlier today, I posted a question here, and then found that is was due to a bug in Java SE 6, but in fact it already existed in 1.5, 1.4, and maybe further back. It is supposed to be fixed since 1.4, but obviously is not.
This is related to JTextArea (but in fact seems to be wider than that, maybe other subclasses of the JComponent family). JTextArea doesn't compute its prefered size as it should. It can just provide any huge size when it holds only a few characters. I ran into that while using JTextArea as a cell String renderer for JTable . I have a routine that resizes dynamically each row of JTable , based on the tallest cell of the row. Each cell has the capacity to wrap its content (this is in fact the first reason for me to use a renderer in place of the default JTable renderer). With this bug, it worked really weirdly when the columns were resized, or when the content of the cells changed.
After realizing it was a bug, I remove my post here, but since it really gave me a hard time , I think it may help someone else to describe the problem and the solution, with the opportunity to run a small demo. Copy the code into your IDE, run it, the rows won't resize their height when you resize the columns or the window. Uncomment the two lines at the end of the code and it will work. The workaround is provided by Sun here: bug 4446522[^]
package test;
import java.awt.Component;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.TableColumnModelEvent;
import javax.swing.event.TableColumnModelListener;
import javax.swing.table.TableCellRenderer;
@SuppressWarnings("serial")
public class Test extends JFrame implements TableColumnModelListener {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {public void run() {
new Test().setVisible(true);
}});
}
private static final int ROWS = 5, COLS = 4;
private final JTable table = new JTable(ROWS, COLS);
public Test() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(600, 400);
add(new JScrollPane(table));
table.getTableHeader().getColumnModel().addColumnModelListener(this);
table.setFillsViewportHeight(true);
table.setRowHeight(27);
table.setDefaultRenderer(Object.class, new StringRenderer());
String template = "Aenean ut orci vel massa suscipit pulvinar. Nulla sollicitudin. "
+ "Fusce varius, ligula non tempus aliquam, nunc turpis ullamcorper "
+ "nibh, in tempus sapien eros vitae ligula. Pellentesque rhoncus "
+ "nunc et augue. Integer id felis. Curabitur aliquet pellentesque "
+ "diam. Integer quis metus vitae elit lobortis egestas. Lorem ipsum "
+ "dolor sit amet, consectetuer adipiscing elit";
int tempLen = template.length();
for (int row = 0; row < ROWS; ++row) {
for (int col = 0; col < COLS; ++col) {
Random random = new Random();
table.setValueAt(template.substring(random.nextInt(tempLen)),
row, col);
}
}
}
@Override
public void columnMarginChanged(ChangeEvent e) {
for (int row = 0; row < table.getRowCount(); ++row) {
adjustRowHeight(table, row);
}
}
@Override
public void columnAdded(TableColumnModelEvent e) {}
@Override
public void columnRemoved(TableColumnModelEvent e) {}
@Override
public void columnMoved(TableColumnModelEvent e) {}
@Override
public void columnSelectionChanged(ListSelectionEvent e) {}
private void adjustRowHeight(JTable table, int rowIndex) {
int tallestCellHeight = 0;
for (int columnIndex = 0; columnIndex < table.getColumnCount(); ++columnIndex) {
TableCellRenderer cellRenderer = table.getCellRenderer(rowIndex, columnIndex);
Component cellContent = table.prepareRenderer(cellRenderer, rowIndex, columnIndex);
int cellHeight = cellContent.getPreferredSize().height;
tallestCellHeight = Math.max(tallestCellHeight, cellHeight);
}
if (tallestCellHeight != table.getRowHeight(rowIndex)) {
table.setRowHeight(rowIndex, tallestCellHeight);
}
}
@SuppressWarnings("serial")
private class StringRenderer extends JTextArea implements TableCellRenderer {
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row,
int column) {
setLineWrap(true); setWrapStyleWord(true);
setText((String) value);
return this;
}
}
}
So the workaround is made of these lines:
setSize(table.getColumnModel().getColumn(column).getWidth(), 0);<br />
getUI().getRootView(this).setSize(getWidth(), 0f);
Regards.
modified on Tuesday, August 5, 2008 7:58 PM (code correction)
|
|
|
|
|
How to create a scroll banner which displays two messages scroling in opposite direction across the applet’s Window.
Can anyone help me?
With Regards,
Suman
|
|
|
|
|
Not sure if this will work, but maybe it will give you a palce to start.
try using methods setAlignmentX() and setAlignmentY(). Increment them in the direction you want your text banner object to move.
John P.
|
|
|
|
|
Does anyone have any walkthrough's for creating your own IP discovery protocol? Basically to write my own ARP protocol. I would like to send a MAC address broadcast to the nodes in the local subnet and read through the responses they give me which contain their IP address. (Preferably without any requirement for special software on the listeners end).
|
|
|
|
|
All you have to do is run the application and send me a screen shot of the application running.
You can download the application from the following web page, it is called "Ripserver Finder"
http://www.ripfactory.com/ripserverdownloads.html
This is an application that I have created to detect a particular device on a LAN by searching for a preset hostname.
Any help with this is greatly appreciated.
My Email address: micealg@yahoo.co.uk
- M
When the game is over the Pawn and the King go into the same box.
|
|
|
|
|
I'm beginning with java and I'm using NetBeans IDE 6.1 to edit, build and run my first sourcefiles and projects.
The problems is when I need to enter data to my program. For example, look at the following code:
package formattedprint;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter an integer number:\n");
int intNum = in.nextInt();
System.out.println("Enter a string:\n");
String string = in.nextLine();
System.out.println("------------------------------");
System.out.printf("Integer number: %d%n", intNum);
System.out.printf("Cadena: %s%n", string);
System.out.println("------------------------------");
}
}
When I run this code, there is not an input window. Only I can enter data in the "output window", and it seems to work in a bad way:
When the program ask for the integer number and I enter 1 (for example), the program finish without ask for the string.
This is the output window:
init:
deps-jar:
Compiling 1 source file to /home/adrian/NetBeansProjects/FormattedPrint/build/classes
compile:
run:
Enter an integer number:
Enter a string:
------------------------------
Integer number: 1
Cadena:
------------------------------
1
BUILD SUCCESSFUL (total time: 6 seconds)
I think, I'm doing something wrong. (May be I should open an input window, but I didn't find it.)
Please, can somebody help me?
[Adrián Córdoba]
|
|
|
|
|
Hi,
yep that was kinda weird or was just done for file reading. :S
btw i dunno why are you using printf if you have the easier methods which are println and print :P
however its ur decision but i find this is working XD
anyways you can use this code:
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter an integer number:\n");
int intNum = in.nextInt();
System.out.println("Enter a string:\n");
//This will only read the first string aka the first name if u wish
String string1 = in.next();
//This is for the last name if you wish
String string2 = in.next();
System.out.println("------------------------------");
System.out.println("Integer number: " + intNum);
System.out.println("Cadena: " + string1 + " " + string2);
System.out.println("------------------------------");
}
}
The output:
init:
deps-jar:
compile:
run:
Enter an integer number:
1
Enter a string:
Jassim Makki
------------------------------
Integer number: 1
Cadena: Jassim Makki
------------------------------
BUILD SUCCESSFUL (total time: 6 seconds)
BlaCk WolViX
|
|
|
|
|