Execution of one CLASS file ( a compiled program)
this is a ambiguse problem for me !!!!
i working with jsdk1.4.1 .
i can compile programs but can't perform them with "java" !!
this is error of it :
(( Exception in thread "main" java.lang.NoclassDefFoundError : file name ))
anyone can lead & help me !!!
Thank you for your responses .
F.Heidary
Set your classpath.
Similar Messages
-
Collect many workbook executions in one Excel file
My problem is to collect many workbook executions in only one excel file automatically, for example by broadcasting.
I explain the situation.
I have one (only) workbook to report the sales revenue by country. So by the input variable "country" I can have all the workbook reports needed.
By the broadcasting I can calculate and send them to the user.
But the user is one, the reports are many (30), and the mails are too many for him.
So he asked to have only one excel file with the requested reports over different sheets.
Anyone has a similar experience about?Hi Sergio,
Try this program for creation of more one than one sheets in one excel.
This program works 2 sheets.you can do how much you want.
REPORT zpck_download_to_excel .
INCLUDE ole2incl.
DATA: w_cell1 TYPE ole2_object,
w_cell2 TYPE ole2_object.
*--- Ole data Declarations
DATA: h_excel TYPE ole2_object, " Excel object
h_mapl TYPE ole2_object, " list of workbooks
h_map TYPE ole2_object, " workbook
h_zl TYPE ole2_object, " cell
h_f TYPE ole2_object, " font
gs_interior TYPE ole2_object, " Pattern
worksheet TYPE ole2_object,
h_cell TYPE ole2_object,
h_cell1 TYPE ole2_object,
range TYPE ole2_object,
h_sheet2 TYPE ole2_object,
h_sheet3 TYPE ole2_object,
gs_font TYPE ole2_object,
flg_stop(1) TYPE c.
Internal table Declaration
DATA : t_excel_t076m LIKE t076m OCCURS 0 WITH HEADER LINE,
t_excel_tedst LIKE tedst OCCURS 0 WITH HEADER LINE.
TYPES: data1(1500) TYPE c,
ty TYPE TABLE OF data1.
DATA: it TYPE ty WITH HEADER LINE,
it_2 TYPE ty WITH HEADER LINE.
DATA: rec TYPE sy-tfill,
deli(1) TYPE c,
l_amt(18) TYPE c.
DATA: BEGIN OF hex,
tab TYPE x,
END OF hex.
DATA: l_rc TYPE i.
FIELD-SYMBOLS: <fs> .
CONSTANTS cns_09(2) TYPE n VALUE 09.
ASSIGN deli TO <fs> TYPE 'X'.
hex-tab = cns_09.
<fs> = hex-tab.
DATA gv_sheet_name(20) TYPE c .
M A C R O Declaration
DEFINE ole_check_error.
if &1 ne 0.
message e002(zz) with &1.
exit.
endif.
END-OF-DEFINITION.
Fetching Data
SELECT * FROM t076m INTO TABLE t_excel_t076m.
SELECT * FROM tedst INTO TABLE t_excel_tedst.
LOOP AT t_excel_t076m.
CONCATENATE
t_excel_t076m-parart
t_excel_t076m-konto
t_excel_t076m-mwart
t_excel_t076m-mwsatz
t_excel_t076m-land1
t_excel_t076m-mwskz
INTO it
SEPARATED BY deli.
APPEND it.
CLEAR it.
ENDLOOP.
LOOP AT t_excel_tedst.
CONCATENATE
t_excel_tedst-rcvprt
t_excel_tedst-repid
t_excel_tedst-routidread
t_excel_tedst-routidwrit
INTO it_2
SEPARATED BY deli.
APPEND it_2.
CLEAR it_2.
ENDLOOP.
IF h_excel-header = space OR h_excel-handle = -1.
start Excel
CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
ENDIF.
*--- get list of workbooks, initially empty
CALL METHOD OF h_excel 'Workbooks' = h_mapl.
SET PROPERTY OF h_excel 'Visible' = 1.
add a new workbook
CALL METHOD OF h_mapl 'Add' = h_map.
First Sheet
Name of the T076
gv_sheet_name = 'T076M'.
GET PROPERTY OF h_excel 'ACTIVESHEET' = worksheet.
SET PROPERTY OF worksheet 'Name' = gv_sheet_name .
PERFORM formatting_data.
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
data = it[]
CHANGING
rc = l_rc
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
OTHERS = 4.
Get the First row and col
CALL METHOD OF h_excel 'Cells' = w_cell1
EXPORTING
#1 = 1
#2 = 1.
Get the 255 row and col
CALL METHOD OF h_excel 'Cells' = w_cell2
EXPORTING
#1 = 5000
#2 = 6.
Select the Data
CALL METHOD OF h_excel 'Range' = range
EXPORTING
#1 = w_cell1
#2 = w_cell2.
CALL METHOD OF range 'Select'.
CALL METHOD OF worksheet 'Paste'.
Second Sheet
Name of the Tedst
gv_sheet_name = 'TEDST'.
GET PROPERTY OF h_excel 'Sheets' = h_sheet2 .
CALL METHOD OF h_sheet2 'Add' = h_map.
SET PROPERTY OF h_map 'Name' = gv_sheet_name .
GET PROPERTY OF h_excel 'ACTIVESHEET' = worksheet.
PERFORM formatting_data.
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
data = it_2[]
CHANGING
rc = l_rc
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
OTHERS = 4.
Get the First row and col
CALL METHOD OF h_excel 'Cells' = w_cell1
EXPORTING
#1 = 1
#2 = 1.
Get the 255 row and col
CALL METHOD OF h_excel 'Cells' = w_cell2
EXPORTING
#1 = 255
#2 = 6.
Select the Data
CALL METHOD OF h_excel 'Range' = range
EXPORTING
#1 = w_cell1
#2 = w_cell2.
CALL METHOD OF range 'Select'.
CALL METHOD OF worksheet 'Paste'.
*--- disconnect from Excel
FREE OBJECT h_zl.
FREE OBJECT h_mapl.
FREE OBJECT h_map.
FREE OBJECT h_excel.
*& Form formatting_data
FORM formatting_data.
*--Formatting the area of additional data 1 and doing the BOLD
CALL METHOD OF h_excel 'Cells' = w_cell1
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
EXPORTING
#1 = 1
#2 = 50.
CALL METHOD OF h_excel 'Range' = h_cell
EXPORTING
#1 = w_cell1
#2 = w_cell2.
GET PROPERTY OF h_cell 'Font' = gs_font .
SET PROPERTY OF gs_font 'Bold' = 1 .
ENDFORM. " formatting_data
Hope it helps you.
Reward your points if it is helpful.
Thanks,
Chitra -
Java 6 upgrade -- ant replicating class files on compilation
On upgradation to java 6 , ant seems to replicated class files
which have already been compiled into jars (which i have mentioned in classpath).
This is the ant script
<javac srcdir="src" destdir="/WEB-INF/classes" classpath="${library.jar}" deprecation="on" debug="true">
<classpath refid="library.classpath"/>
<include name="com/test1/webapp/common/**/*.java"/>
</javac>
library.classpath contains path to library.jar
The above script works perfectly for java 5 but not for java 6.
The problem is that classes in the folder com/test1 are getting recompiled to WEB-INF/classes, when the classes were already in compiled to library.jar (which is in classpath).
Is there a solution to this problem?This is the code that I have written:
public class Board extends JApplet
JPanel p[][];
public void init()
try{
SwingUtilities.invokeAndWait(new Runnable()
public void run()
makeGUI(8,8);
}catch(InterruptedException e){e.printStackTrace();}
catch(InvocationTargetException e){e.printStackTrace();}
/* Board*/
private void makeGUI(int rows, int cols)
p = new JPanel[rows][cols];
Container contentPane = getContentPane();
contentPane.setLayout(new GridLayout(rows, cols));
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
p[i][j] = new JPanel();
contentPane.add(p[i][j]);
if (i % 2 == j % 2)
p[i][j].setBackground(Color.white);
else
p[i][j].setBackground(Color.darkGray);
In this which one is inner class? -
Do we have to separate java source files and class files after compiled..
Hi,
I really confussed with this:
I have compiled java source files into a package and tried to use but the classes can not be found. Should I separate class and source files after compiled with packages names. I hope you understand what i mean.
Thank you
So JagYou can choose to separate the source files or not. It sounds like your problem has to do with Classpath and packages.
If the file c:\base\compute\engine\mysourcefile.java starts with the statement "package engine;" then the fully qualified name of the class is is engine.mysourcefile. If the file c:\base\compute\client\mysourcefile.java starts with the statement "package client;" then its fully qualified name is client.mysourcefile.
In your source files, whenever you refer to a class from another class, the compiler needs the fully qualified class name. You can either import the class or use the fully qualified name. In order for the compiler to find the class, the c:\base\compute directory must be in the Classpath (assuming the package definitions from above).
Finally, to launch an application given the above, the command would be "java client.mysourcefile" assuming the main method is in client.mysourcefile. -
Setting JTree in one class file from another class file
Hello,
I'm new to java. I recently created a project in netbeans and here is one of the java files. I used the IDE to make a split pane, with a tree structure and panel in it.
* To change this template, choose Tools | Templates
* and open the template in the editor.
* AmplifierDesignGUI.java
* Created on Jun 20, 2010, 1:18:52 PM
package AmplifierDesign;
import java.util.logging.Level;
import java.util.logging.Logger;
* @author Bugz
public class AmplifierDesignGUI extends javax.swing.JFrame {
/** Creates new form AmplifierDesignGUI */
public AmplifierDesignGUI() {
initComponents();
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jSplitPane1 = new javax.swing.JSplitPane();
jScrollPane1 = new javax.swing.JScrollPane();
jTree1 = new javax.swing.JTree();
jPanel1 = new javax.swing.JPanel();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenu2 = new javax.swing.JMenu();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jScrollPane1.setViewportView(jTree1);
jSplitPane1.setLeftComponent(jScrollPane1);
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 475, Short.MAX_VALUE)
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 274, Short.MAX_VALUE)
jSplitPane1.setRightComponent(jPanel1);
jMenu1.setText("File");
jMenuBar1.add(jMenu1);
jMenu2.setText("Edit");
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(8, 8, 8)
.add(jSplitPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 571, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(32, Short.MAX_VALUE))
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(8, 8, 8)
.add(jSplitPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 278, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
pack();
}// </editor-fold>
* @param args the command line arguments
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new AmplifierDesignGUI().setVisible(true);
try {
new JTreeStructure().setVisible(true);
} catch (Exception ex) {
Logger.getLogger(AmplifierDesignGUI.class.getName()).log(Level.SEVERE, null, ex);
// Variables declaration - do not modify
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JTree jTree1;
// End of variables declaration
So once this was done I wanted to link the JTree to a mysql database. So I found a sample .java file on the net:
* To change this template, choose Tools | Templates
* and open the template in the editor.
package AmplifierDesign;
import java.awt.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.tree.*;
public class JTreeStructure extends JFrame {
Connection con = null;
Statement st = null;
ResultSet rs = null;
//public static void main(String args[]) throws Exception {
// new JTreeStructure();
public JTreeStructure() throws Exception {
super("Retrieving data from database ");
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:8889/";
String db = "icons";
ArrayList list = new ArrayList();
list.add("Laser Objects");
Class.forName(driver);
con = DriverManager.getConnection(url + db, "root", "root");
try {
String sql = "Select * from fiberComponents";
st = con.createStatement();
rs = st.executeQuery(sql);
while (rs.next()) {
Object value[] = {"Fiber Components",rs.getString(2) };
list.add(value);
} catch (Exception e) {
System.out.println(e);
rs.close();
st.close();
con.close();
Object hierarchy[] = list.toArray();
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container content = getContentPane();
DefaultMutableTreeNode root = processHierarchy(hierarchy);
JTree tree = new JTree(root);
content.add(new JScrollPane(tree), BorderLayout.CENTER);
setSize(275, 300);
setLocation(300, 100);
setVisible(true);
private DefaultMutableTreeNode processHierarchy(Object[] hierarchy) {
DefaultMutableTreeNode node = new DefaultMutableTreeNode(hierarchy[0]);
DefaultMutableTreeNode child;
for (int i = 1; i < hierarchy.length; i++) {
Object nodeSpecifier = hierarchy;
if (nodeSpecifier instanceof Object[]) // Ie node with children
child = processHierarchy((Object[]) nodeSpecifier);
} else {
child = new DefaultMutableTreeNode(nodeSpecifier); // Ie Leaf
node.add(child);
return (node);
The problem is when I run my program two windows open up. The original one with JTree1, and the panel and horizontal splitplane and another window with a new tree component that did get its objects from the database. My question is how do I "replace" the JTree1 with the new tree created from the second java file?
Or additionally, maybe I could set the data for JTree1 from within the second java file?zmoddynamics wrote:
....Please excuse my post as I am not sure what is meant by code tags?To use code tags, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.
Another way to do this is to manually place the tags into your code by placing the tag [code] above your pasted code and the tag [code] below your pasted code like so:
[code]
// your code goes here
// notice how the top and bottom tags are different
[/code]Luck. -
One class type compiles into many .class files
I have written a single large GUI file that is composed of a single class (FCTabGui class). When I run javac FCTabGui.java it generates around 190 classes with the same name (FCTabGui) but each one after the first is attached with $# at the end (ie FCTabGui$1.class, ..., FCTabGui$189.class) . I have never seen this before. Does anyone know why this is happening and how I can keep it to just one .class file instead of 190. Thanks.
JasonWhat I meant by "standard to jar up files for a GUI"
is that if there are lots of buttons that create
anonymous classes then you HAVE to jar up the files
because there is no alternative to it. One cannot
preserve the single .class file setup with a GUI,
unless its really small and has no action listeners.I suppose you could contort your code so that the single class not only creates all the widgets but also acts as the single action listener for every single button. This way you could avoid creating anonymous inner classes. But anyone who needs to maintain your code will grow to hate you.
One can double click on a jar file and it will start
running automatically, (assuming the JRE is
installed), right?You can do that, but it's not automatic. You have to explicitly list what class has the main() method to invoke when the jar is double clicked. If you're using a wizard to create the jar, this may be easily specified. Otherwise you can do it by creating a jar manifest file with a "Main-class:" attribute. -
Two class files with $ on compile
Hello friends, I have a simple java program, that consists of two classes, coded in the the same java file.
One of hte classes extends Thread.
When I compile the source file, I get one class file for the base class, and two for the other one - ClassName.class and ClassName$1.class.
Why is the second one created?The ClassName$1.class is a class file for an anonymous inner class. You create them with code likebutton.addActionListener(new ActionListener() {
actionPerformed(ActionEvent ae) {
System.out.println("button was pressed");
});This particular example is from the GUI world where event listeners are commonly created using anonymous inner classes. There's a separate file for it just because there's always exactly one class file for each class. -
How to compile and register a Java CFX tag with multiple class files?
All-
If this is the wrong forum for CFX questions, please let me
know.
I need to determine how to compile and register a Java CFX
tag that contains multiple class files. One class file implements
the CustomTag interface and the other class files implement various
supporting classes. All of the documentation that I have found
talks about using a single class file. I am assuming that a JAR
file will be involved, but I am not sure of the specifics.
Thanks in advance for your help.
-JoshYes, it will involve a jar. Use your java IDE (eclipse,
etcetera ..) to create a jar containing all of the classes. Check
your ide's documentation for how to create jar files. After you
have created the jar, place the jar in the CF class path so CF will
recognize it. For example the {cf_root}/WEB-INF/lib directory. CF
must be restarted before it will detect the new jar. After
restarting CF, register the CFX tag in the ColdFusion Administrator
using the name of the class that implements the CustomTag
interface.
Though it is worth noting you can also instantiate java
classes directly from ColdFusion (ie without using a CFX
tag). -
*Added* code to existing source file, compiled it, and class file shrunk
Another newbie here. Fortunately, my classpath is ok, so I'm able to compile a .java file.
I added one line of code (System.out.println) to write the value of a variable to a log. After compiling with javac, I noticed that the resulting [new] class file was smaller than the existing class file. I looked at each of the class files with Textpad. It's gibberish, but I quickly saw that a large block of code was missing in the new class file, even though the size of the source file had been increased.
There is a difference, however, between how the two class files were created. The existing class file was compiled (along with many others) by exporting an .EAR file from a development environment (WSAD) to the WebSphere Administrator Console. Conversely, I am now compiling the same source file with javac on my machine.
I suspect that this is the reason why I can add code to a .java file, compile it, and have the resulting class file actually lose code. Even if I am correct, I don't know what to do about it.
Does anyone have an idea?
Regards,
Daniel T.Thank you both for your replies. I've read many posts over the past few months, and I know how important it is to provide as much info as possible, when asking a question here. That said, I have another tasty tidbit...
After replacing the existing (larger) class file with the new (smaller) class file, my application now produces this:
"*Error 500: LinkageError while defining class*..." [name of class]
*"...(Unsupported major.minor version 50.0) This is often caused by having a class defined at multiple locations within the classloader hierarchy. Other potential causes include compiling against an older or newer version of the class that has an incompatible method signature. Dumping the current context classloader hierarchy: ==> indicates defining classloader ==>[0] com.ibm.ws.classloader.CompoundClassLoader@6bd156d5 Local ClassPath:"*
...[the entire classpath]...
Original exception--- java.lang.UnsupportedClassVersionError:
I'm guessing that my focus should mostly be on the 'Original exception', and maybe I need to revisit the JRE or JDK or JVM (these terms are somewhat nebulous to me, so please forgive me using them interchangeably) on my machine. For now, I'll just keep trying stuff. Thanks again for the replies!
Regards,
Daniel T. -
Why we can have only one public class in one source file
why we can have only one public class in one source file
When the java compiler is run it looks for classes referenced by the classes you are directly compiling. When looking for these referenced classes it looks for source as well as class files and compiles them automatically if the coresponding class files are missing, or older than the source.
In order to do this it must be able to work out the source file name for any given class which might be referenced from another (the rule also applies to package level access). -
How do I dynamically load a SWF that was compiled from an Fla with a linked external class file
I am dynamically loading external SWFs in a Main Fla in response to clicks on a menu.
The loading code is standard and works fine for all of the SWFs except one. When I try to load it I get the following error:
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
I am certain that the URL to the problem SWF is correct. The SWF itself doesn't load any other SWFs or images.
The problem SWF is linked to an external class file and compiled with it.
i.e. in the properties panel of the main timeline of the problem SWF's Fla I have entered the path to the external class.
1. there is no problem compiling this SWF with the class (it works fine by itself)
2. if I remove the external class from the properties panel and don't use it the resulting SWF imports without a problem into the Main Fla mentioned before
So the problem seems to be the fact that the external class is linked in the properties panel. Is this a path problem?
Would appreciate any suggestions,
Thanks!despite what you say, that loaded swf most likely is loading something and that's the cause of the error.
you could test that by putting the main swf's embedding html file in the same directory with problematic swf. if the problem is as explained above, you'll have no problem when the main html is in the same directory with the loaded swf. -
Decompile JAR , Update .Class file , Compile?
Is it possible to decompile a excutable JAR file, update the .class file and compile it again?
I'm using DJ Decompile software.
Need your expertise.. =PWell, you wouldn't decompile the jar. You'd basically just unpack it, and then you'd decompile the classes inside it, and then you'd update the .java file, and then recompile the source code files and repackage it into a new jar.
But otherwise, yes.
There may be a variety of better options though. For example, maybe you could create a single new class that replaces or wraps a single class in the jar, and then create a new manifest file with the Main-Class attribute pointing to your new class. Or with any luck you could get the original source code. Etc. -
Time estimation of a class file without execution
Can any body help me....
I have to find the execution time of class files without execution.
can I do it with java...!!!!!!!!!!Presumably this is a class assignment and not a work assignment. If it is for work then either ask for justification for this stupidity or start playing games and looking for another job.
Use javap and count the byte codes. Each byte code has a size so give a execution time of n X size. Each branch has a execution time of n X size + 1 (since it take longer.) Each method call is n X size + 2 (a goto and a return.)
'n' in the above is an arbritrary constant.
Each method is the sum of its contents. If you have a loop that calls a method you have to estimate the average loops and use that multiplied by the method count.
For system methods you will just have to list them and give each a unknown time, since presumably you aren't analyzing everything. -
Class File Compilation Version
Anyone knows how I can see in which version of jdk a class file is compiled?
The first 4 bytes in the class file are the magic number, ie. 0xCAFEBABE
The next 2 are the minor number, next 2 are the major number.
I've a lookup table up to version 1.2 but not beyond that.
So, assuming these are major & minor number pair ranges...
( 0, 0 ) - ( 44, 65535 ) = Unknown JDK, less than 1.0.2
( 45, 0 ) - ( 45, 3 ) = Sun JDK 1.0.2
( 45, 3 ) - ( 45, 65535 ) = Sun JDK 1.1.X
( 45, 0 ) - ( 46, 0 ) = Sun JDK 1.2
( 46, 0 ) - ( 65535, 65535 ) = Sun JDK 1.2 or greater
regards,
Owen -
How do I make a batch file if the .class file uses a foreign package?
I am trying to make an MS-DOS batch file using the bytecode file from the Java source file, called AddFields.java. This program uses the package BreezySwing; which is not standard with the JDK. I had to download it seperately. I will come back to this batch file later.
But first, in order to prove the concept, I created a Java file called Soap.java in JCreator. It is a very simple GUI program that uses the javax.swing package; which does come with the JDK. The JDK is currently stored in the following directory: C:\Program Files\Java\jdk1.6.0_07. I have the PATH environment variable set to the 'bin' folder of the JDK. I believe that it is important that this variable stay this way because C:\Program Files\Java\jdk1.6.0_07\bin is where the file 'java.exe' and 'javac.exe' are stored. Here is my batch file so far for Soap:
@echo off
cd \acorn
set path=C:\Program Files\Java\jdk1.6.0_07\bin
set classpath=.
java Soap
pause
Before I ran this file, I compiled Soap.java in my IDE and then ran it successfully. Then I moved the .class file to the directory C:\acorn. I put NOTHING ELSE in this folder. then I told the computer where to find the file 'java.exe' which I know is needed for execution of the .class file. I put the above text in Notepad and then saved it as Soap.bat onto my desktop. When I double click on it, the command prompt comes up in a little green box for a few seconds, and then the GUI opens and says "It Works!". Now that I know the concept of batch files, I tried creating another one that used the BreezySwing package.
After I installed my JDK, I installed BreezySwing and TerminalIO which are two foreign packages that make building code much easier. I downloaded the .zip file from Lambert and Osborne called BreezySwingAndTerminalIO.zip. I extracted the files to the 'bin' folder of my JDK. Once I did this, and set the PATH environment variable to the 'bin' folder of my JDK, all BreezySwing and TerminalIO programs that I made worked. Now I wanted to make a batch file from the program AddFields.java. It is a GUI program that imports two packages, the traditional GUI javax.swing package and the foreign package BreezySwing. The user enters two numbers in two DoubleField objects and then selects one of four buttons; one for each arithmetic operation (add, subtract, multiply, or divide). Then the program displays the solution in a third DoubleField object. This program both compiles and runs successfully in JCreator. So, next I moved the .class file from the MyProjects folder that JCreator uses to C:\acorn. I put nothing else in this folder. The file Soap.class was still in there, but I did not think it would matter. Then I created the batch file:
@echo off
cd \acorn
set path=C:\Program Files\Java\jdk1.6.0_07\bin
set classpath=.
java AddFields
pause
As you can see, it is exactly the same as the one for Soap. I made this file in Notepad and called it AddFields.bat. Upon double clicking on the file, I got this error message from command prompt:
Exception in thread "main" java.lang.NoClassDefFoundError: BreezySwing/GBFrame
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Caused by: java.lang.ClassNotFoundException: BreezySwing.GBFrame
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 12 more
Press any key to continue . . .
I know that most of this makes no sense; but that it only means that it cannot find the class BreezySwing or GBFrame (which AddFields extends). Notice, however that it does not give an error for javax.swing. If I change the "set path..." command to anything other than the 'bin' folder of my JDK, I get this error:
'java' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .
I know this means that the computer cannot find the file 'java.exe' which I believe holds all of the java.x.y.z style packages (native packages); but not BreezySwing or any other foreign packages. Remember, I do not get this error for any of the native Java packages. I decided to compare the java.x.y.z packages with BreezySwing:
I see that all of the native packages are not actually visible in the JDK's bin folder. I think that they are all stored in one of the .exe files in there because there are no .class files in the JDK's bin folder.
However, BreezySwing is different, there is no such file called "BreezySwing.exe"; there are just about 20 .class files all with names like "GBFrame.class", and "GBActionListener.class". As a last effort, I moved all of these .class files directly into the bin folder (they were originally in a seperate folder called BreezySwingAndTerminalIO). This did nothing; even with all of the files in the same folder as java.exe.
So my question is: What do I need to do to get the BreezySwing package recognized on my computer? Is there possibly a download for a file called "BreezySwing.exe" somewhere that would be similar to "java.exe" and contain all of the BreezySwing packages?There is a lot of detail in your posts. I won't properly quote everything you put (too laborious). Instead I'll just put your words inside quotes (").
"..there are some things about the interface that I do not like."
Like +what?+ This is not a help desk, and I would appreciate you participating in this discussion by providing details of what it is about the 'interface' of webstart that you 'do not like'. They are probably misunderstandings on your part.
"Some of the .jar files I made were so dangerously corrupt, that I had to restart my computer before I could delete them."
Corrupt?! I have never once had the Java tools produce a corrupt Jar. OTOH, the 'cannot delete' problem might relate to the JRE gaining a file lock on the archive at run-time. If the file lock persisted after ending the app., it suggests that the JRE was not properly shut down. This is a bug in the code and should be fixed. Deploying as .class files will only 'hide' the problem (from casual inspection - though the Task Manager should show the orphaned 'java' process).
"I then turned to batch files for their simple structure and portability (I managed to successfully transport a java.util containing batch file from my computer to another). This was what I did:
- I created a folder called Task
- Then I copied three things into this folder: 1. The file "java.exe" from my JDK. 2. The program's .class file (Count.class). and 3. The original batch file.
- Then I moved the folder from a removable disk to the second computer's C drive (C:\Task).
- Last, I changed the code in the batch file...:"
That is the +funniest+ thing I've heard on the forums in the last 72 hours. You say that is easy?! Some points.
- editing batch files is not scalable to 100+ machines, let alone 10000+.
- The fact that Java worked on the target machine was because it was +already installed.+ Dragging the 'java.exe' onto a Windows PC which has no Java will not magically make it 'Java enabled'.
And speaking of Java on the client machine. Webstart has in-built mechanisms to ensure that the end user has the minimum required Java version to run the app. - we can also use the [deployJava.js|http://java.sun.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html#deplToolkit] on the original web page, to check for minimum Java before it puts the link to download/install the app. - if the user does not have the required Java, the script should guide them through installing it.
Those nice features in deployJava.js are available to applets and apps. launched using webstart, but they are not available for (plain) Jar's or loose class files. So if 'ensuring the user has Java' is one of the requirements for your launch, you are barking up the wrong tree by deploying loose class files.
Note also that if you abandon webstart, but have your app. set up to work from a Jar, the installation process would be similar to above (though it would not need a .bat file, or editing it). This basic strategy is one way that I provide [Appleteer (as a downloadable ZIP archive)|http://pscode.org/appleteer/#download]. Though I side-step your part 1 by putting the stuff into a Jar with the path Appleteer/ - when the user expands the ZIP, the parts of the app. are already in the Appleteer directory.
Appleteer is also provided as a webstart launched application (and as an applet). Either of those are 'easier' to use than the downloadable ZIP, but I thought I would provide it in case the end user wants to save it to disk and transport the app. to a machine with no internet connection, but with Java (why they would be testing applets on a PC with no internet connection, I am not sure - but the option is there).
"I know that .jar and .exe files are out because I always get errors and I do not like their interfaces. "
What on earth are you talking about? Once the app. is on-screen, the end user would not be able to distinguish between
1) A Jar launched using a manifest.
2) A Jar launched using webstart.
3) Loose class files.
Your fixation on .bat files sounds much like the adage that 'If the only tool you have is a hammer, every job starts to look like a nail'.
Get over them, will you? +Using .bat files is not a practical way to provide a Java app. to the end user+ (and launching an app. from a .bat looks quite crappy and 'second hand' to +this+ user).
Edit 1:
The instructions for running Appleteer as a Jar are further up the page, in the [Running Appleteer: Application|http://pscode.org/appleteer/#application] section.
Edited by: AndrewThompson64 on May 19, 2009 12:06 PM
Maybe you are looking for
-
Something is wrong with Parallel Gateways
Hello Oracle BPM Comunity, I am modeling and implementing bpmn process using Oracle BPM Suite 11.1.1.5. I have a process that, after the start event, splits the flow using a parallel gateway. The process splits in three ways, each one doing diferent
-
Need to obtain updateable ResultSet via call to PL/SQL function
I'm using JDBC and the Oracle JDBC driver to call a PL/SQL function that returns a SYS_REFCURSOR. I do this via a CallableStatement object and then cast the output parameter to a ResultSet object. However, I want this ResultSet object I end up with t
-
Root.sh failed:Raw devices for OEL 5.3 and 10.2.0.4 RAC
Hi We have OEL 5.3 and Oracle RAC 10.2.0.4 While installing clusterware and running root.sh we are getting the error Failed to upgrade the cluster registry. Further the ocrconfig.log are as below: ocrconfig_20527.log Oracle Database 10g CRS Release 1
-
Unable to update app or download
after updating to ios 8.2 i cant download or updates any app it keeps saying that i have to verify my card and my payment is declined and i tried using other payment method it still doesnt work please help me resolve P.s my card is working fine i pur
-
Duplicates and Trouble Keeeping Music Updated and Backed Up
Hello all. In my attempt to organize my music and back it up since I have over 20,000 songs, when I transfer music to itunes I have hundreds of duplicates. Does anyone know the BEST way to organize music in separate hard drives to one library without