Java compiling question

Hi . I have one class file for an IRC client , the compilation works fine...
javac -O <filename>.java
jar cvf <filename>.jar <filename>.class
jarsigner -keystore suresh.store <filename>.jar sureshcert
But now I want to compile it so it would work with Microsoft VM too on my web browser . What tools should I use or what are the correct commands on compilation (I'm using Java 2 SDK 1.4.2_05)?

Hi,
This forum is exclusively for the Sun Java Studio Creator related discussions. Could you please post your question in the appropriate forum.
http://forum.java.sun.com/forum.jspa?forumID=31
Thanks,
RK.

Similar Messages

  • Java compile and run time questions

    Hello, I have two generic question about java compile and run:
    1. When I used javac to compile my project, it complained some classes can't be found. I added the jar file which contains these needed classes to the jre/lib/ext/ directory. The compiler no longer complains. But I'm confused. I thought the jar files in jre/lib/ext/ only used for java run time, not the compile time. Can someone help me to explain this?
    2. If I need certain user defined jar file in the classpath to compile my application, does that imply that I have to have that jar file if I want to run my project?
    Thanks in advance.

    1. lib/ext is used for generally finding classes, it doesn't matter whether you are compiling or running.
    2. Yes, you will.

  • Java Programming Question

    Hi,Everybody:
    I have a question about Java programming. If I want to write a java class code called if.java like below, how should I do to make it pass the java compiler and make it work. I know the words "if" and "for" are reserved words. I just try to figure it out that is it possible??? Do I need to create my own java compiler or recompiler?
    public class if
    public if() { }
    public static for test()
    return new for();
    public class for
    public for() { System.out.println("for class constructor"); }
    }

    I don't think you can bypass the compiler's rejection of this. There is little point to naming the classes after keywords. Not sure if it's case sensitive though, so maybe "If" or "For"? Otherwise, try "if_" or "for_"

  • Java compiler validation

    I've developed a java compiler in java that will be used in a tool to teach java programming. I'd like to test the compiler with an independent set of programs.
    Anyone know of a free/inexpensive compiler validation suite of programs?
    Many thanks.
    Lindsey Ford

    Hey Keith,
    You may want to post this question on the jboss community forum. No idea what's going on here...
    Bob

  • Java Compilation

    Hi ,
    I want to know how the JAVAC and JAVA command works internally. And also the JVM and JDK architecture to understand the java compilation and execution process. Can anybody help me out .
    Thanks
    Raghav

    raghav1212 wrote:
    Hi ,
    I want to know how the JAVAC and JAVA command works internally. And also the JVM and JDK architecture to understand the java compilation and execution process. Can anybody help me out .Well time to study generic compiler theory then. Its a fun fun world of abstract syntax trees, lexical analysis, etc. etc. Your question is not Java programming related in any case and certainly not something to pose in a forum - perhaps you can find a good book on compiler theory. Its very complex material, I warn you.

  • Example code for java compiler with a simple GUI

    There is no question here (though discussion of the code is welcome).
    /* Update 1 */
    Now available as a stand alone or webstart app.! The STBC (see the web page*) has its own web page and has been improved to allow the user to browse to a tools.jar if one is not found on the runtime classpath, or in the JRE running the code.
    * See [http://pscode.org/stbc/].
    /* End: Update 1 */
    This simple example of using the JavaCompiler made available in Java 1.6 might be of use to check that your SSCCE is actually what it claims to be!
    If an SSCCE claims to display a runtime problem, it should compile cleanly when pasted into the text area above the Compile button. For a compilation problem, the code should show the same output errors seen in your own editor (at least until the last line of the output in the text area).
    import java.awt.BorderLayout;
    import java.awt.Font;
    import java.awt.EventQueue;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JLabel;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.JButton;
    import javax.swing.SwingWorker;
    import javax.swing.border.EmptyBorder;
    import java.util.ArrayList;
    import java.net.URI;
    import java.io.ByteArrayOutputStream;
    import java.io.OutputStreamWriter;
    import javax.tools.ToolProvider;
    import javax.tools.JavaCompiler;
    import javax.tools.SimpleJavaFileObject;
    /** A simple Java compiler with a GUI.  Java 1.6+.
    @author Andrew Thompson
    @version 2008-06-13
    public class GuiCompiler extends JPanel {
      /** Instance of the compiler used for all compilations. */
      JavaCompiler compiler;
      /** The name of the public class.  For 'HelloWorld.java',
      this would be 'HelloWorld'. */
      JTextField name;
      /** The source code to be compiled. */
      JTextArea sourceCode;
      /** Errors and messages from the compiler. */
      JTextArea output;
      JButton compile;
      static int pad = 5;
      GuiCompiler() {
        super( new BorderLayout(pad,pad) );
        setBorder( new EmptyBorder(7,4,7,4) );
      /** A worker to perform each compilation. Disables
      the GUI input elements during the work. */
      class SourceCompilation extends SwingWorker<String, Object> {
        @Override
        public String doInBackground() {
          return compileCode();
        @Override
        protected void done() {
          try {
            enableComponents(true);
          } catch (Exception ignore) {
      /** Construct the GUI. */
      public void initGui() {
        JPanel input = new JPanel( new BorderLayout(pad,pad) );
        Font outputFont = new Font("Monospaced",Font.PLAIN,12);
        sourceCode = new JTextArea("Paste code here..", 15, 60);
        sourceCode.setFont( outputFont );
        input.add( new JScrollPane( sourceCode ),
          BorderLayout.CENTER );
        sourceCode.select(0,sourceCode.getText().length());
        JPanel namePanel = new JPanel(new BorderLayout(pad,pad));
        name = new JTextField(15);
        name.setToolTipText("Name of the public class");
        namePanel.add( name, BorderLayout.CENTER );
        namePanel.add( new JLabel("Class name"), BorderLayout.WEST );
        input.add( namePanel, BorderLayout.NORTH );
        compile = new JButton( "Compile" );
        compile.addActionListener( new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              (new SourceCompilation()).execute();
        input.add( compile, BorderLayout.SOUTH );
        this.add( input, BorderLayout.CENTER );
        output = new JTextArea("", 5, 40);
        output.setFont( outputFont );
        output.setEditable(false);
        this.add( new JScrollPane( output ), BorderLayout.SOUTH );
      /** Compile the code in the source input area. */
      public String compileCode() {
        output.setText( "Compiling.." );
        enableComponents(false);
        String compResult = null;
        if (compiler==null) {
          compiler = ToolProvider.getSystemJavaCompiler();
        if ( compiler!=null ) {
          String code = sourceCode.getText();
          String sourceName = name.getText().trim();
          if ( sourceName.toLowerCase().endsWith(".java") ) {
            sourceName = sourceName.substring(
              0,sourceName.length()-5 );
          JavaSourceFromString javaString = new JavaSourceFromString(
            sourceName,
            code);
          ArrayList<JavaSourceFromString> al =
            new ArrayList<JavaSourceFromString>();
          al.add( javaString );
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          OutputStreamWriter osw = new OutputStreamWriter( baos );
          JavaCompiler.CompilationTask task = compiler.getTask(
            osw,
            null,
            null,
            null,
            null,
            al);
          boolean success = task.call();
          output.setText( baos.toString().replaceAll("\t", "  ") );
          compResult = "Compiled without errors: " + success;
          output.append( compResult );
          output.setCaretPosition(0);
        } else {
          output.setText( "No compilation possible - sorry!" );
          JOptionPane.showMessageDialog(this,
            "No compiler is available to this runtime!",
            "Compiler not found",
            JOptionPane.ERROR_MESSAGE
          System.exit(-1);
        return compResult;
      /** Set the main GUI input components enabled
      according to the enable flag. */
      public void enableComponents(boolean enable) {
        compile.setEnabled(enable);
        name.setEnabled(enable);
        sourceCode.setEnabled(enable);
      public static void main(String[] args) throws Exception {
        Runnable r = new Runnable() {
          public void run() {
            JFrame f = new JFrame("SSCCE text based compiler");
            f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            GuiCompiler compilerPane = new GuiCompiler();
            compilerPane.initGui();
            f.getContentPane().add(compilerPane);
            f.pack();
            f.setMinimumSize( f.getSize() );
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        EventQueue.invokeLater(r);
    * A file object used to represent source coming from a string.
    * This example is from the JavaDocs for JavaCompiler.
    class JavaSourceFromString extends SimpleJavaFileObject {
      * The source code of this "file".
      final String code;
      * Constructs a new JavaSourceFromString.
      * @param name the name of the compilation unit represented
        by this file object
      * @param code the source code for the compilation unit
        represented by this file object
      JavaSourceFromString(String name, String code) {
        super(URI.create(
          "string:///" +
          name.replace('.','/') +
          Kind.SOURCE.extension),
          Kind.SOURCE);
        this.code = code;
      @Override
      public CharSequence getCharContent(boolean ignoreEncodingErrors) {
        return code;
    }Edit 1:
    Added..
            f.setMinimumSize( f.getSize() );Edited by: AndrewThompson64 on Jun 13, 2008 12:24 PM
    Edited by: AndrewThompson64 on Jun 23, 2008 5:54 AM

    kevjava wrote: Some things that I think would be useful:
    Suggestions reordered to suit my reply..
    kevjava wrote: 2. Line numbering, and/or a line counter so you can see how much scrolling you're going to be imposing on the forum readers.
    Good idea, and since the line count is only a handful of lines of code to implement, I took that option. See the [line count|http://pscode.org/stbc/help.html#linecount] section of the (new) [STBC Help|http://pscode.org/stbc/help.html] page for more details. (Insert plaintiff whining about the arbitrary limits set - here).
    I considered adding line length checking, but the [Text Width Checker|http://pscode.org/twc/] ('sold separately') already has that covered, and I would prefer to keep this tool more specific to compilation, which leads me to..
    kevjava wrote: 1. A button to run the code, to see that it demonstrates the problem that you wish for the forum to solve...
    Interesting idea, but I think that is better suited to a more full blown (but still relatively simple) GUId compiler. I am not fully decided that running a class is unsuited to STBC, but I am more likely to implement a clickable list of compilation errors, than a 'run' button.
    On the other hand I am thinking the clickable error list is also better suited to an altogether more abled compiler, so don't hold your breath to see either in the STBC.
    You might note I have not bothered to update the screenshots to show the line count label. That is because I am still considering error lists and running code, and open to further suggestion (not because I am just slack!). If the screenshots update to include the line count but nothing else, take that as a sign. ;-)
    Thanks for your ideas. The line count alone is worth a few Dukes.

  • Java compiler Switching

    Hi All,
    My question is about the compiler. I was just wondering if there was any code snippets or something that could help me figure out if there is a way to
    have the java compiler skipp some code given a variable.
    My problem is that I need to have versions and Im using classes with annotations that map to the db. the problem is if there is a version that doesn't have the same db as the previous I have to manually comment the annotation out..
    So any helps suggestions pointers?

    jbayuga wrote:
    Hi All,
    My question is about the compiler. I was just wondering if there was any code snippets or something that could help me figure out if there is a way to
    have the java compiler skipp some code given a variable.
    My problem is that I need to have versions and Im using classes with annotations that map to the db. the problem is if there is a version that doesn't have the same db as the previous I have to manually comment the annotation out..
    So any helps suggestions pointers?I wouldn't say this is a compiler issue more than a compiliing issue.
    Depending on what you are using to compile this (be it Ant or doing it by hand or what have you, you should be able ti setup what you want )
    I'm not to sure how far you are into java, but have you thought about something as simple as putting in an if/else statement around your annotations to allow them to appear or not depending on the value of variable that could come from the commandline or a configuration file.
    Also depending on weather or not you are in the development stage or the testing phase it might be easier to keep a compiled version of each around.
    Hope this helps.

  • Sigh. This is wearing me out. compiler question

    I am not really a newbie to java technology but I seem to have a compiler question. My old compiler use to compile my codes. But a compiler I downloaded from your site dosent seem to work. Now there is a possibility that I downloaded a older version but I need someone to check this.
    Problem? My compiler will not comply with the websites. It seems that when I go to test my applet on a website it says not found. Now bear in mind I am testing on my hard drive but they are both in the same folder (Applet .class, .html file) Heres something that may be the deciding factor. My compiler version is 1.1.8
    See any problem that I can fix in this?

    public class Anotherapplet extends Applet {
    public void paint(Graphics g) {
    g.drawString("Hello world!", 50, 25);
    More problems. It says that "Anotherapplet" should not be defined in "filename.java"
    What am I doing wrong now?

  • What Java compiler for Java Card development ?

    What Java compiler and options should be used for Java Card development with the goal of generating correct, and (secondarily) small or/and fast code after conversion to Java Card bytecode using converter ?
    In particular
    - Is use of JDK 7 approved by Oracle for Java Card development? That would solve security problems associated with (the web components of the JRE of) some earlier JDK, including the latest JDK6. The JCDK 3.0.4 release notes states "+the commercial version of Java Development Kit (JDK software) version 6 Update 10 (JDK 6 Update 10) or later is required+, but that does not answer that question.
    - Anyone had _bad_ experience (like incorrect or disastrous code) with the Java compiler bundled with Eclipse ? I have seen at least one case where org.eclipse.jdt.core_3.7.3.v20120119-1537.jar produced slightly more compact code than javac.
    - Anyone had _bad_ experience with javac in jdk1.3 ? In an applet involving a "finally" clause, I've seen it generating more compact code than later javac (which in my test triplicated the code for the finally clause).

    What Java compiler and options should be used for Java Card development with the goal of generating correct, and (secondarily) small or/and fast code after conversion to Java Card bytecode using converter ?-target -source may be required to generate compatible byte code. Depending on the CAP file converter being used debug information may also help. Remember that Java Card is a subset of the Java language (also there are short opcodes that Java doesn't have etc) so a lot of the work for optimisation is done by the converter or the JCRE. You can look at the JCA code generated to determine what works best for your applets. There are also some ways of stripping out dead code etc from JCA files (return statements after a throw etc) to reduce your code size. Most of the speed optimisations come from your code (avoiding context switches and unnecessary security/access checks).
    The compactness of your Java Card binary may not be directly related to the size of your compiled Java code. It can depend on the converter you use and any optimisaitons the JCRE might try to do when the code is loaded.
    - Is use of JDK 7 approved by Oracle for Java Card development? That would solve security problems associated with (the web components of the JRE of) some earlier JDK, including the latest JDK6. Java Card does not use any of the libraries from the JDK/JRE. All of the libraries are provided by the JCRE on the smartcard.
    The JCDK 3.0.4 release notes states "+the commercial version of Java Development Kit (JDK software) version 6 Update 10 (JDK 6 Update 10) or later is required+, but that does not answer that question.Anything above JDK6u10 is supported. If you use Java 7 you may need to add a -source and -target flag when compiling.
    - Anyone had _bad_ experience (like incorrect or disastrous code) with the Java compiler bundled with Eclipse ? I have seen at least one case where org.eclipse.jdt.core_3.7.3.v20120119-1537.jar produced slightly more compact code than javac.We generally use the Eclipse compiler as we find that we get more deterministic builds. When CAP files are sent for security review it is helpful to have the reviewer able to generate a CAP file that matches the one you sent to confirm the binary is what you say it is.
    - Anyone had _bad_ experience with javac in jdk1.3 ? In an applet involving a "finally" clause, I've seen it generating more compact code than later javac (which in my test triplicated the code for the finally clause).We do not use anything less than Java 6 for compilation.
    - Shane

  • Is java compiler that weak ???

    Hello buddies
    i have a question that why do we have to put an f
    like
    Float fNew = 10.12f ;
    why does not java compiler treat it the same way like other like
    int nNew = 10 ;
    if we dont put an f it gives a type cast error and and it treats it like a double.
    is java compiler that weak that we have to tell to compiler that its a float no.

    thats wht i am asking that compiler is week so we have
    to tell compiler that its a float .....
    cause in c we dont have to instruct compiler that its
    a float
    i know thats written in specs but it shoudnt be like
    .... this i wanted to ask does any one
    KNOW THAT WHY THIS IS THE REASON THAT WE HAVE TO PUT F
    WITH FLOATS ???Actually I've had some C compilers complain if you don't use the f for the float.
    For real numbers, the default is double, integers, the default is int. I don't think the compiler is "weak". If the defaults were float and long, then we'd have to specify something to make them doubles or ints.
    What makes 10.12 a float or a double? It can be both so you have to tell it not to treat it as a double (the default). The warning/error is pretty much saying "do you really want me to cripple the precision of this number?"

  • Run time java compiler

    Last year I researched oracle spatial technology and created prototype using oracle 9i, standalone oc4j. In order to start oc4j, i had to download java 1.4.2 from sun site. everything worked fine.
    Now I am expanding on the prototype on different machine but am using oracle 10g. I followed the same steps (installed 10g, oc4j, downloaded j2se 1.4.2 and installed). When I start oc4j by following command
    java -jar oc4j.jar, I get
    error message stating Error loading package at file:/E:/oracle_downloads/oc4j/j2ee/home/applications/admin_ejb.jar, javac.exe no
    t found under F:\oracle\product\10.1.0\db_1\jre\1.4.2, please use a valid jdk or
    specify the location of your java compiler in server.xml using the <java-compil
    er .../> tag.
    I am not sure how do I specify location of java compiler in server.xml file sysntactically. I do not not recall this step with oracle 9i.
    I edited server.xml and http-wev-site.xml as per instructions in my spatial class for mapviewer application but I need help on how to enter the location of java compiler file in server.xml file.
    Thank you

    You cannot use the JRE java to start oc4j. Must install a complete 1.4.2 J2SDK (not JRE) then use the java binary under its bin directory to start oc4j (not the one under jre/bin directory).
    lj

  • How to run a java program without Java Compiler

    I have a small project and I want share it with my friends but my friend'pc have not
    Java compiler.
    for example, I writen a application like YM, then 2cp can sent,receive messege. My cumputer run as Server, and my frien PC run as client.
    How can my friend run it? or how to create an icon in dektop tu run a java program..??..
    (sorry about my English but U still understand what i mean (:-:)) )

    To run a program you don't need a Java compiler. Just the Java Runtime Engine. That can be downloaded from the Sun website and comes with an installer.
    You could then turn your application into an executable jar file and start it somehow like jar myYM.
    There is also software that packs a Java program into an executable file. I've never used that but one that comes to my mind is JexePack. It's for free if you can live with a copyright message popping up every time you start the program.
    http://www.duckware.com/jexepack/index.html

  • Javax.sound missing with Fedora Core 3 linux's java compiler?

    I'm running Fedora core 3, and I did a complete install(selected all the packeges). I have the java compiler that FC3 installed. I can compile most things, but I seem to be missing the sound package/folder.
    This leads to an error when I try to import the sound libraries.
    //start code
    //simple non-working example
    import javax.sound.*;
    class sounds
    //end code
    results in the error "The import javax.sound cannot be resolved"
    I am trying to run a code snippet from javaAlmanac, and of course it won't work. Today, a friend of mine had the exact same problem on a windows machine using JDK 1.5.
    I'm going to test this code out on a windows machine also.
    Are there issues with the FC3 java compiler?
    Has anyone else run into and solved this issue?
    I'm considering copying the sound folder from some other Java installation, anyone try this?
    Thanks,

    I'm pretty new at this myself. I've also installed Fedora Core 3 on an AMD 64. When I do the same uname - a I get:
    Linux localhost.localdomain 2.6.9-1.667 #1 Tue Nov 2 14:50:10 EST 2004 x86_64 x8 6_64 x86_64 GNU/Linux
    Maybe you didn't install as 64 bit ?
    I've also successfully installed Jave Runtime Environment. java -version gets me:
    java version "1.4.2_08"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
    Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
    I'd suggest installing 32 bit. I can't tell the difference when I run programmes that use 64 or 32 bits - it will be just as good.
    Eurostar

  • Java Compiler API Status?

    Does anyone know what the current status of JSR 199: Java Compiler API is?
    (http://www.jcp.org/en/jsr/detail?id=199)
    To me it seems the inclusion in JDK 1.5 was silently dropped. I have not found the smallest bit of information, though.

    JSR199 is in suspended animation. For Tiger, we're
    merely documenting the com.sun.tools.javac.Main entry
    point.Hi,
    where could this documentation be found?
    Regards
    Richard

  • Oracle Java Compiler 11g - JVM ERROR

    Hi Jdev Team,
    I have an issue to report,
    Sometimes when run a project and navigate through the pages, i get the following error message:
    Oracle Java Compiler 11g
    Unable to create an instance of the Java Virtual Machine
    Located at path:
    H:\jdevstudio1111\jdk\jre\bin\client\jvm.dll
    The only way to solve this is delete the settings of the Jdev and the Jdev from the PC, and install again, with the associated waste of time as consecuence. Please you can give a light to resolve this issue? Thanks
    Well i correct what i just said.
    The problem doesn´t fix, with the erase of the jdev program folder or settings folder in windows user docs and settings. What else i can do!?, out of ideas in here.
    Regards,
    Leo
    Message was edited by:
    LCJ

    Solution (workaround):
    Re: ADF table and filtering
    Pedja

Maybe you are looking for

  • IDOC to post with clearing (F-28 / F-53)

    Hello all, I'm wondering if anyone knows of an IDOC type that can post an FI document with clearing.  Specifically, we are looking to clear AR and AP items with FI documents generated similar to the F-28 and F-53 transactions. I've found the ACC_DOCU

  • OIM 11gR2 - Self Registration Locale and Timezone

    Hi, I would like to prepopulate locale (usr_locale) and timezone (usr_timezone) when a user registers using self registration. I created a PrePopulationAdapter, updated SelfCreateUserDataset.xml in MDS, registered the plugin containing the adapter, r

  • Problem with step Acquision and subsequnet consolidation

    Hi Gurus, I am trying to do step acquision, problem is as follows. A Ltd having % of holding @ first consolidation in BLtd 60%. I have executed COI and posted elimination entries with 60% In the next consolidation period I have increased my % of hold

  • Access connection can only connect at 54Mbps

    I'm running Access Connection 5.50. My W500 has Intel Wifi link  5300 AGN with PAN (driver 13.0.0.107). Going through AC, I can only get 54Mbps connecting to a TP-Link WR841N AP (BGN) but using Windows Wireless Services, I get 130Mbps. I have another

  • Uttsc assertion failed

    Dear all, I'm running Solaris 10.4, SRSS 4.0 and Sun Ray Connector 1.1; until I tried using the Sun Ray Connector, everything was working very well and I was very happy with it all. If I run: $ /opt/SUNWuttsc/bin/uttsc <a windows server> I have the f