Results 1 to 12 of 12

Thread: Java-jnlp

  1. #1
    mrarefi is offline Member
    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    Default Java-jnlp

    Dear Friends

    How I can import package javax.jnlp.* ??
    I do not know what should I do exacly

    Thanks for your help already

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,397
    Rep Power
    25

    Default Re: Java-jnlp

    Where is that package defined?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    mrarefi is offline Member
    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    Default Re: Java-jnlp

    here I have problem there is red underlinem

    import java.applet.*;
    import java.awt.BorderLayout;
    import java.awt.Graphics;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.jnlp.FileContents;
    import javax.jnlp.FileOpenService;
    import javax.swing.ImageIcon;
    import javax.swing.JApplet;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JTextField;



    public class LoadImage extends JApplet

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,397
    Rep Power
    25

    Default Re: Java-jnlp

    Where is that package defined? What you posted is NOT a definition for the package.
    Why do you think the package exists?
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    mrarefi is offline Member
    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    Default Re: Java-jnlp

    how can I define this package to my program?

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,397
    Rep Power
    25

    Default Re: Java-jnlp

    Search on the internet for the package, download the jar file that contains that package, add that jar file to the classpath for your compiler.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    mrarefi is offline Member
    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    Default Re: Java-jnlp

    how can I add the package to my compiler this is my problem

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,397
    Rep Power
    25

    Default Re: Java-jnlp

    If you have the jar file you can use the javac -cp option to add it to the compiler's classpath. Here is a sample commandline I use to execute javac with the -cp option:
    javac.exe -Xlint -cp ..\.;javaws.jar FileHandler.java
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    mrarefi is offline Member
    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    Default Re: Java-jnlp

    This is my code
    I could not add it
    Java Code:
    package applet;
    
    import java.applet.*;
    import java.awt.BorderLayout;
    import java.awt.Graphics;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.jnlp.FileContents;
    import javax.jnlp.FileOpenService;
    import javax.jnlp.ServiceManager;
    import javax.swing.ImageIcon;
    import javax.swing.JApplet;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    
    
    
    public class LoadImage extends JApplet {
    	
    	private ImageIcon image;
    	private JPanel scaleJPanel;
    	private JLabel percentJLabel;
    	private JTextField scaleInputJTextField;
    	private JButton scaleChangJButton;
    	private double scaleValue = 1.0;
    	
    	public void init ()
    	{
    		scaleJPanel = new JPanel();
    		percentJLabel = new JLabel("Scale persent");
    		scaleInputJTextField = new JTextField("100");
    		scaleChangJButton = new JButton("set Scale");
    		
    		
    		scaleJPanel.add(percentJLabel);
    		scaleJPanel.add(scaleInputJTextField);
    		scaleJPanel.add(scaleChangJButton);
    		add(scaleJPanel, BorderLayout.NORTH);
    		
    		scaleChangJButton.addActionListener(new ActionListener() {
    			
    			@Override
    			public void actionPerformed(ActionEvent arg0) {
    				
    				scaleValue = Double.parseDouble(scaleInputJTextField.getText())/100.0;
    				repaint();
    				
    				
    			}
    		});
    		
    		try {
    			
    			FileOpenService fileOpenService =
    					(FileOpenService) ServiceManager.lookup(
    					"javax.jnlp.FileOpenService" );
    			FileContents contents =
    					fileOpenService.openFileDialog( null, null );
    			byte[] imageData = new byte[ (int) contents.getLength() ];
    			contents.getInputStream().read( imageData ); // read image bytes
    			image = new ImageIcon( imageData );
    			
    			add( new DrawJPanel(), BorderLayout.CENTER );
    		
    		    }
    		catch (Exception e)
    		{
    			e.printStackTrace();
    		}
    	}
    	
    	private class DrawJPanel extends JPanel
    	{
    		
    		public void paintComponent( Graphics g )
    		{
    			
    			super.paintComponent(g);
    			
    			double spareWidth = getWidth() - scaleValue * image.getIconWidth();
    			double spareHeight = getHeight() - scaleValue * image.getIconHeight();
    			
    			g.drawImage(image.getImage(),
    					(int) ( spareWidth ) / 2, (int) ( spareHeight ) / 2,
    					(int) ( image.getIconWidth() * scaleValue ),
    					(int) ( image.getIconHeight() * scaleValue ), this );
    		}
    		
    	}
    
    }

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,397
    Rep Power
    25

    Default Re: Java-jnlp

    I could not add it
    What is the "it" you are talking about?

    Post the commandline you are using to compile the program.
    Also copy the full text of any error messages and paste them here.
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    mrarefi is offline Member
    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0

    Default Re: Java-jnlp

    this is the error

    java.lang.Error: Unresolved compilation problems:
    The import javax.jnlp cannot be resolved
    The import javax.jnlp cannot be resolved
    FileOpenService cannot be resolved to a type
    FileOpenService cannot be resolved to a type
    ServiceManager cannot be resolved
    FileContents cannot be resolved to a type

    at applet.LoadImage.<init>(LoadImage.java:8)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at sun.applet.AppletPanel.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(Unknown Source)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,397
    Rep Power
    25

    Default Re: Java-jnlp

    The compiler can not find the definition for the package named in the error message.
    You must find the jar file that contains that package and put it on the classpath for the compiler.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. JNLP for using Java web start
    By wanda in forum New To Java
    Replies: 15
    Last Post: 02-26-2013, 10:37 AM
  2. JNLP(Java Network Launching Protocol)
    By mitra in forum Networking
    Replies: 0
    Last Post: 07-28-2011, 01:48 PM
  3. Jnlp
    By tecno40 in forum Java Applets
    Replies: 1
    Last Post: 11-29-2010, 03:37 AM
  4. Replies: 0
    Last Post: 04-28-2010, 03:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •